aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-class-mtd17
-rw-r--r--Documentation/DocBook/media/v4l/controls.xml2
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml7
-rw-r--r--Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt2
-rw-r--r--Documentation/kdump/kdump.txt2
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig22
-rw-r--r--arch/arm/Kconfig.debug9
-rw-r--r--arch/arm/Makefile3
-rw-r--r--arch/arm/boot/compressed/atags_to_fdt.c62
-rw-r--r--arch/arm/boot/dts/spear13xx.dtsi11
-rw-r--r--arch/arm/boot/dts/spear320-evb.dts6
-rw-r--r--arch/arm/boot/dts/spear600.dtsi1
-rw-r--r--arch/arm/configs/omap2plus_defconfig1
-rw-r--r--arch/arm/include/asm/arch_timer.h3
-rw-r--r--arch/arm/include/asm/delay.h32
-rw-r--r--arch/arm/include/asm/locks.h274
-rw-r--r--arch/arm/include/asm/memory.h2
-rw-r--r--arch/arm/include/asm/perf_event.h17
-rw-r--r--arch/arm/include/asm/pmu.h3
-rw-r--r--arch/arm/include/asm/spinlock.h76
-rw-r--r--arch/arm/include/asm/spinlock_types.h17
-rw-r--r--arch/arm/include/asm/timex.h10
-rw-r--r--arch/arm/include/asm/uaccess.h27
-rw-r--r--arch/arm/include/asm/word-at-a-time.h96
-rw-r--r--arch/arm/kernel/arch_timer.c13
-rw-r--r--arch/arm/kernel/armksyms.c7
-rw-r--r--arch/arm/kernel/entry-common.S20
-rw-r--r--arch/arm/kernel/head.S59
-rw-r--r--arch/arm/kernel/perf_event.c15
-rw-r--r--arch/arm/kernel/perf_event_v6.c2
-rw-r--r--arch/arm/kernel/perf_event_v7.c5
-rw-r--r--arch/arm/kernel/perf_event_xscale.c2
-rw-r--r--arch/arm/kernel/ptrace.c34
-rw-r--r--arch/arm/kernel/topology.c239
-rw-r--r--arch/arm/kernel/traps.c78
-rw-r--r--arch/arm/lib/Makefile3
-rw-r--r--arch/arm/lib/delay-loop.S (renamed from arch/arm/lib/delay.S)20
-rw-r--r--arch/arm/lib/delay.c71
-rw-r--r--arch/arm/lib/strncpy_from_user.S43
-rw-r--r--arch/arm/lib/strnlen_user.S40
-rw-r--r--arch/arm/mach-exynos/pm_domains.c13
-rw-r--r--arch/arm/mach-msm/platsmp.c2
-rw-r--r--arch/arm/mach-omap2/clockdomain.h4
-rw-r--r--arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c1
-rw-r--r--arch/arm/mach-omap2/clockdomains44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/omap-smp.c2
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c32
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ost.h22
-rw-r--r--arch/arm/mach-pxa/reset.c7
-rw-r--r--arch/arm/mach-pxa/time.c52
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2440.c2
-rw-r--r--arch/arm/mach-sa1100/assabet.c2
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c1
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1110.c1
-rw-r--r--arch/arm/mach-sa1100/include/mach/SA-1100.h16
-rw-r--r--arch/arm/mach-sa1100/include/mach/gpio.h1
-rw-r--r--arch/arm/mach-sa1100/include/mach/hardware.h6
-rw-r--r--arch/arm/mach-sa1100/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-sa1100/irq.c1
-rw-r--r--arch/arm/mach-sa1100/jornada720_ssp.c1
-rw-r--r--arch/arm/mach-sa1100/leds-cerf.c1
-rw-r--r--arch/arm/mach-sa1100/leds-lart.c1
-rw-r--r--arch/arm/mach-sa1100/pm.c1
-rw-r--r--arch/arm/mach-sa1100/sleep.S8
-rw-r--r--arch/arm/mach-sa1100/time.c48
-rw-r--r--arch/arm/mach-shmobile/platsmp.c5
-rw-r--r--arch/arm/mach-spear3xx/spear3xx.c2
-rw-r--r--arch/arm/mach-spear6xx/spear6xx.c2
-rw-r--r--arch/arm/mach-ux500/board-mop500.c12
-rw-r--r--arch/arm/mach-ux500/timer.c2
-rw-r--r--arch/arm/mm/context.c35
-rw-r--r--arch/arm/mm/dma-mapping.c6
-rw-r--r--arch/arm/mm/init.c2
-rw-r--r--arch/arm/mm/ioremap.c2
-rw-r--r--arch/arm/mm/mmu.c8
-rw-r--r--arch/arm/mm/proc-v6.S6
-rw-r--r--arch/arm/mm/proc-v7-2level.S5
-rw-r--r--arch/arm/oprofile/common.c45
-rw-r--r--arch/arm/plat-samsung/adc.c8
-rw-r--r--arch/arm/plat-samsung/devs.c3
-rw-r--r--arch/arm/plat-samsung/s5p-clock.c1
-rw-r--r--arch/arm/plat-versatile/platsmp.c2
-rw-r--r--arch/h8300/include/asm/pgtable.h3
-rw-r--r--arch/h8300/include/asm/uaccess.h3
-rw-r--r--arch/h8300/kernel/signal.c2
-rw-r--r--arch/h8300/kernel/time.c1
-rw-r--r--arch/m32r/boot/compressed/Makefile6
-rw-r--r--arch/m32r/boot/compressed/misc.c12
-rw-r--r--arch/m32r/include/asm/ptrace.h3
-rw-r--r--arch/m32r/kernel/ptrace.c7
-rw-r--r--arch/m32r/kernel/signal.c2
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/bcm47xx/Kconfig1
-rw-r--r--arch/mips/bcm63xx/dev-pcmcia.c4
-rw-r--r--arch/mips/cavium-octeon/Kconfig4
-rw-r--r--arch/mips/cavium-octeon/smp.c2
-rw-r--r--arch/mips/include/asm/bitops.h1
-rw-r--r--arch/mips/include/asm/cmpxchg.h1
-rw-r--r--arch/mips/include/asm/cpu.h7
-rw-r--r--arch/mips/include/asm/gic.h15
-rw-r--r--arch/mips/include/asm/inst.h4
-rw-r--r--arch/mips/include/asm/io.h1
-rw-r--r--arch/mips/include/asm/irq.h1
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h2
-rw-r--r--arch/mips/include/asm/mips-boards/maltaint.h10
-rw-r--r--arch/mips/include/asm/mipsmtregs.h2
-rw-r--r--arch/mips/include/asm/switch_to.h6
-rw-r--r--arch/mips/include/asm/thread_info.h4
-rw-r--r--arch/mips/kernel/cpu-probe.c11
-rw-r--r--arch/mips/kernel/mips_ksyms.c8
-rw-r--r--arch/mips/kernel/octeon_switch.S2
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c5
-rw-r--r--arch/mips/kernel/r2300_switch.S15
-rw-r--r--arch/mips/kernel/r4k_switch.S12
-rw-r--r--arch/mips/kernel/smp-bmips.c15
-rw-r--r--arch/mips/kernel/smp.c12
-rw-r--r--arch/mips/kernel/smtc.c13
-rw-r--r--arch/mips/kernel/sync-r4k.c5
-rw-r--r--arch/mips/kernel/traps.c7
-rw-r--r--arch/mips/kernel/vmlinux.lds.S3
-rw-r--r--arch/mips/mm/Makefile4
-rw-r--r--arch/mips/mm/c-r4k.c5
-rw-r--r--arch/mips/mm/page-funcs.S50
-rw-r--r--arch/mips/mm/page.c67
-rw-r--r--arch/mips/mm/tlbex.c2
-rw-r--r--arch/mips/mti-malta/malta-pci.c7
-rw-r--r--arch/mips/mti-malta/malta-setup.c2
-rw-r--r--arch/mips/netlogic/xlp/setup.c8
-rw-r--r--arch/mips/oprofile/common.c1
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c4
-rw-r--r--arch/mips/pci/fixup-fuloong2e.c12
-rw-r--r--arch/mips/pci/fixup-lemote2f.c12
-rw-r--r--arch/mips/pci/fixup-malta.c6
-rw-r--r--arch/mips/pci/fixup-mpc30x.c4
-rw-r--r--arch/mips/pci/fixup-sb1250.c6
-rw-r--r--arch/mips/pci/ops-tx4927.c2
-rw-r--r--arch/mips/pci/pci-ip27.c2
-rw-r--r--arch/mips/pci/pci-lantiq.c4
-rw-r--r--arch/mips/pci/pci-xlr.c61
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c2
-rw-r--r--arch/mips/powertv/asic/asic-calliope.c2
-rw-r--r--arch/mips/powertv/asic/asic-cronus.c2
-rw-r--r--arch/mips/powertv/asic/asic-gaia.c2
-rw-r--r--arch/mips/powertv/asic/asic-zeus.c2
-rw-r--r--arch/mips/txx9/generic/pci.c2
-rw-r--r--arch/mn10300/include/asm/ptrace.h3
-rw-r--r--arch/mn10300/include/asm/thread_info.h2
-rw-r--r--arch/mn10300/include/asm/timex.h11
-rw-r--r--arch/mn10300/kernel/cevt-mn10300.c10
-rw-r--r--arch/mn10300/kernel/internal.h2
-rw-r--r--arch/mn10300/kernel/irq.c4
-rw-r--r--arch/mn10300/kernel/signal.c5
-rw-r--r--arch/mn10300/kernel/traps.c1
-rw-r--r--arch/mn10300/mm/dma-alloc.c1
-rw-r--r--arch/mn10300/unit-asb2303/include/unit/timex.h4
-rw-r--r--arch/mn10300/unit-asb2303/smc91111.c1
-rw-r--r--arch/mn10300/unit-asb2305/include/unit/timex.h4
-rw-r--r--arch/mn10300/unit-asb2305/unit-init.c1
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/timex.h4
-rw-r--r--arch/powerpc/include/asm/hw_irq.h6
-rw-r--r--arch/powerpc/kernel/irq.c48
-rw-r--r--arch/powerpc/kvm/book3s_pr_papr.c1
-rw-r--r--arch/powerpc/mm/numa.c2
-rw-r--r--arch/powerpc/platforms/cell/pervasive.c11
-rw-r--r--arch/powerpc/platforms/pseries/processor_idle.c17
-rw-r--r--arch/sh/include/asm/io_noioport.h17
-rw-r--r--arch/sh/kernel/cpu/sh3/serial-sh7720.c2
-rw-r--r--arch/tile/kernel/backtrace.c9
-rw-r--r--arch/um/drivers/mconsole_kern.c1
-rw-r--r--arch/x86/kernel/vsyscall_64.c39
-rw-r--r--arch/xtensa/kernel/process.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c22
-rw-r--r--drivers/acpi/acpica/nspredef.c2
-rw-r--r--drivers/acpi/processor_core.c6
-rw-r--r--drivers/amba/bus.c2
-rw-r--r--drivers/base/dd.c2
-rw-r--r--drivers/block/loop.c8
-rw-r--r--drivers/block/rbd.c4
-rw-r--r--drivers/clk/spear/spear1310_clock.c312
-rw-r--r--drivers/clk/spear/spear1340_clock.c279
-rw-r--r--drivers/clk/spear/spear3xx_clock.c180
-rw-r--r--drivers/clk/spear/spear6xx_clock.c122
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/devres.c1
-rw-r--r--drivers/gpio/gpio-mxc.c10
-rw-r--r--drivers/gpio/gpio-omap.c14
-rw-r--r--drivers/gpio/gpio-sta2x11.c5
-rw-r--r--drivers/gpio/gpio-tps65910.c3
-rw-r--r--drivers/gpio/gpio-wm8994.c5
-rw-r--r--drivers/gpu/drm/gma500/cdv_device.c35
-rw-r--r--drivers/gpu/drm/gma500/opregion.c8
-rw-r--r--drivers/gpu/drm/gma500/opregion.h5
-rw-r--r--drivers/gpu/drm/gma500/psb_device.c12
-rw-r--r--drivers/gpu/drm/gma500/psb_drv.c1
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-apple.c6
-rw-r--r--drivers/hid/hid-core.c7
-rw-r--r--drivers/hid/hid-ids.h12
-rw-r--r--drivers/hid/hid-input.c3
-rw-r--r--drivers/hid/hid-multitouch.c5
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hwmon/it87.c2
-rw-r--r--drivers/hwspinlock/hwspinlock_core.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c12
-rw-r--r--drivers/input/joystick/xpad.c6
-rw-r--r--drivers/input/mouse/bcm5974.c20
-rw-r--r--drivers/input/touchscreen/jornada720_ts.c1
-rw-r--r--drivers/iommu/amd_iommu.c11
-rw-r--r--drivers/iommu/amd_iommu_init.c6
-rw-r--r--drivers/iommu/amd_iommu_types.h2
-rw-r--r--drivers/iommu/tegra-smmu.c4
-rw-r--r--drivers/isdn/mISDN/stack.c4
-rw-r--r--drivers/md/dm-raid1.c3
-rw-r--r--drivers/md/dm-region-hash.c5
-rw-r--r--drivers/md/dm-thin.c6
-rw-r--r--drivers/md/md.c37
-rw-r--r--drivers/md/raid1.c13
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c1
-rw-r--r--drivers/media/rc/winbond-cir.c4
-rw-r--r--drivers/media/video/cx231xx/cx231xx-audio.c4
-rw-r--r--drivers/media/video/cx231xx/cx231xx-vbi.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c89
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c6
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c9
-rw-r--r--drivers/media/video/cx23885/cx23885.h1
-rw-r--r--drivers/media/video/cx25821/cx25821-core.c3
-rw-r--r--drivers/media/video/cx25821/cx25821.h2
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c76
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c2
-rw-r--r--drivers/media/video/gspca/sn9c20x.c13
-rw-r--r--drivers/media/video/mx2_camera.c27
-rw-r--r--drivers/media/video/omap3isp/isppreview.c6
-rw-r--r--drivers/media/video/pms.c1
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c69
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c19
-rw-r--r--drivers/media/video/s5p-fimc/fimc-lite.c73
-rw-r--r--drivers/media/video/s5p-fimc/fimc-mdevice.c48
-rw-r--r--drivers/media/video/s5p-fimc/fimc-mdevice.h2
-rw-r--r--drivers/media/video/s5p-mfc/s5p_mfc_dec.c1
-rw-r--r--drivers/media/video/s5p-mfc/s5p_mfc_enc.c1
-rw-r--r--drivers/media/video/smiapp/smiapp-core.c1
-rw-r--r--drivers/media/video/v4l2-dev.c1
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/ab5500-core.h87
-rw-r--r--drivers/mfd/mc13xxx-spi.c67
-rw-r--r--drivers/mfd/omap-usb-host.c48
-rw-r--r--drivers/mfd/palmas.c13
-rw-r--r--drivers/misc/mei/main.c2
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c4
-rw-r--r--drivers/mmc/core/cd-gpio.c4
-rw-r--r--drivers/mmc/core/mmc.c18
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c10
-rw-r--r--drivers/mtd/nand/mxc_nand.c37
-rw-r--r--drivers/mtd/nand/nandsim.c12
-rw-r--r--drivers/net/bonding/bond_debugfs.c2
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c1
-rw-r--r--drivers/net/ethernet/broadcom/b44.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c6
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c10
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c7
-rw-r--r--drivers/net/ethernet/intel/e1000e/82571.c3
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c42
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c15
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/ring_mode.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c3
-rw-r--r--drivers/net/irda/pxaficp_ir.c12
-rw-r--r--drivers/net/phy/mdio-mux.c10
-rw-r--r--drivers/net/usb/qmi_wwan.c18
-rw-r--r--drivers/net/wireless/b43legacy/dma.c2
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c4
-rw-r--r--drivers/net/wireless/iwlegacy/common.c14
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c2
-rw-r--r--drivers/of/base.c30
-rw-r--r--drivers/of/platform.c7
-rw-r--r--drivers/pci/pci-driver.c12
-rw-r--r--drivers/pci/pci.c5
-rw-r--r--drivers/pci/quirks.c26
-rw-r--r--drivers/pcmcia/sa1100_shannon.c1
-rw-r--r--drivers/pinctrl/pinctrl-imx.c2
-rw-r--r--drivers/pinctrl/pinctrl-imx6q.c2
-rw-r--r--drivers/platform/x86/ideapad-laptop.c6
-rw-r--r--drivers/platform/x86/intel_ips.c22
-rw-r--r--drivers/platform/x86/sony-laptop.c136
-rw-r--r--drivers/regulator/core.c10
-rw-r--r--drivers/remoteproc/Kconfig2
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c57
-rw-r--r--drivers/rtc/rtc-ab8500.c10
-rw-r--r--drivers/rtc/rtc-mxc.c5
-rw-r--r--drivers/rtc/rtc-spear.c2
-rw-r--r--drivers/rtc/rtc-twl.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_task.c2
-rw-r--r--drivers/scsi/bnx2i/bnx2i.h1
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c3
-rw-r--r--drivers/scsi/bnx2i/bnx2i_iscsi.c10
-rw-r--r--drivers/scsi/libsas/sas_ata.c12
-rw-r--r--drivers/scsi/scsi_wait_scan.c5
-rw-r--r--drivers/target/target_core_cdb.c2
-rw-r--r--drivers/target/target_core_pr.c7
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c2
-rw-r--r--drivers/tty/hvc/hvc_opal.c2
-rw-r--r--drivers/tty/serial/amba-pl011.c2
-rw-r--r--drivers/usb/class/cdc-wdm.c2
-rw-r--r--drivers/usb/core/hub.c18
-rw-r--r--drivers/usb/host/ehci-omap.c18
-rw-r--r--drivers/usb/host/xhci-hub.c44
-rw-r--r--drivers/usb/host/xhci-ring.c11
-rw-r--r--drivers/usb/host/xhci.h6
-rw-r--r--drivers/usb/serial/metro-usb.c8
-rw-r--r--drivers/usb/serial/option.c26
-rw-r--r--drivers/video/omap2/dss/core.c43
-rw-r--r--drivers/video/omap2/dss/dispc.c2
-rw-r--r--drivers/video/omap2/dss/dsi.c2
-rw-r--r--drivers/video/omap2/dss/dss.c2
-rw-r--r--drivers/video/omap2/dss/hdmi.c2
-rw-r--r--drivers/video/omap2/dss/rfbi.c2
-rw-r--r--drivers/video/omap2/dss/venc.c2
-rw-r--r--drivers/virtio/virtio_balloon.c24
-rw-r--r--drivers/watchdog/sa1100_wdt.c14
-rw-r--r--fs/buffer.c22
-rw-r--r--fs/cifs/cifssmb.c30
-rw-r--r--fs/cifs/connect.c18
-rw-r--r--fs/cifs/readdir.c7
-rw-r--r--fs/cifs/transport.c26
-rw-r--r--fs/eventpoll.c2
-rw-r--r--fs/exofs/ore.c8
-rw-r--r--fs/exofs/ore_raid.c91
-rw-r--r--fs/ext4/ioctl.c1
-rw-r--r--fs/fat/inode.c13
-rw-r--r--fs/fifo.c9
-rw-r--r--fs/locks.c2
-rw-r--r--fs/nfs/direct.c6
-rw-r--r--fs/nfs/objlayout/objio_osd.c25
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/ramfs/file-nommu.c1
-rw-r--r--fs/ubifs/sb.c8
-rw-r--r--fs/xfs/xfs_alloc.c19
-rw-r--r--fs/xfs/xfs_buf.c53
-rw-r--r--fs/xfs/xfs_buf.h1
-rw-r--r--fs/xfs/xfs_buf_item.c2
-rw-r--r--include/asm-generic/dma-contiguous.h2
-rw-r--r--include/asm-generic/sizes.h49
-rw-r--r--include/linux/bootmem.h5
-rw-r--r--include/linux/capability.h6
-rw-r--r--include/linux/ceph/messenger.h12
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/eventpoll.h2
-rw-r--r--include/linux/gpio.h4
-rw-r--r--include/linux/hrtimer.h10
-rw-r--r--include/linux/kernel.h1
-rw-r--r--include/linux/kmsg_dump.h16
-rw-r--r--include/linux/memblock.h4
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/rcupdate.h1
-rw-r--r--include/linux/rcutiny.h6
-rw-r--r--include/linux/rpmsg.h6
-rw-r--r--include/linux/sched.h18
-rw-r--r--include/linux/sizes.h47
-rw-r--r--include/net/ip_vs.h2
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h2
-rw-r--r--include/scsi/libsas.h6
-rw-r--r--include/scsi/scsi_cmnd.h8
-rw-r--r--init/Kconfig2
-rw-r--r--kernel/cgroup.c23
-rw-r--r--kernel/debug/kdb/kdb_main.c91
-rw-r--r--kernel/debug/kdb/kdb_private.h1
-rw-r--r--kernel/fork.c11
-rw-r--r--kernel/hrtimer.c53
-rw-r--r--kernel/power/hibernate.c8
-rw-r--r--kernel/power/user.c2
-rw-r--r--kernel/printk.c285
-rw-r--r--kernel/rcutree.c1
-rw-r--r--kernel/rcutree.h1
-rw-r--r--kernel/rcutree_plugin.h14
-rw-r--r--kernel/sched/core.c276
-rw-r--r--kernel/sched/idle_task.c1
-rw-r--r--kernel/sched/sched.h2
-rw-r--r--kernel/sys.c16
-rw-r--r--kernel/time/ntp.c8
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/time/timekeeping.c64
-rw-r--r--kernel/trace/ring_buffer.c6
-rw-r--r--lib/dma-debug.c4
-rw-r--r--mm/bootmem.c6
-rw-r--r--mm/compaction.c5
-rw-r--r--mm/memblock.c51
-rw-r--r--mm/memory_hotplug.c2
-rw-r--r--mm/nobootmem.c40
-rw-r--r--mm/page_alloc.c7
-rw-r--r--mm/shmem.c193
-rw-r--r--mm/sparse.c20
-rw-r--r--mm/vmscan.c12
-rw-r--r--net/8021q/vlan.c3
-rw-r--r--net/ax25/af_ax25.c1
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c15
-rw-r--r--net/batman-adv/bridge_loop_avoidance.h5
-rw-r--r--net/batman-adv/soft-interface.c6
-rw-r--r--net/caif/caif_dev.c2
-rw-r--r--net/ceph/messenger.c12
-rw-r--r--net/core/dev.c11
-rw-r--r--net/core/net_namespace.c4
-rw-r--r--net/core/netprio_cgroup.c78
-rw-r--r--net/core/skbuff.c2
-rw-r--r--net/ieee802154/dgram.c12
-rw-r--r--net/ipv4/cipso_ipv4.c6
-rw-r--r--net/mac80211/mlme.c6
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c5
-rw-r--r--net/netfilter/xt_set.c4
-rw-r--r--net/nfc/llcp/sock.c2
-rw-r--r--net/rxrpc/ar-peer.c2
-rw-r--r--net/sched/sch_netem.c42
-rw-r--r--net/sched/sch_sfb.c2
-rw-r--r--net/sctp/input.c7
-rw-r--r--net/sctp/socket.c12
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--security/selinux/include/classmap.h4
-rw-r--r--sound/usb/endpoint.c73
-rw-r--r--sound/usb/pcm.c61
-rw-r--r--tools/perf/util/map.c29
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/trace-event-parse.c3
-rw-r--r--virt/kvm/assigned-dev.c15
429 files changed, 4356 insertions, 3033 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-mtd b/Documentation/ABI/testing/sysfs-class-mtd
index db1ad7e34fc..938ef71e203 100644
--- a/Documentation/ABI/testing/sysfs-class-mtd
+++ b/Documentation/ABI/testing/sysfs-class-mtd
@@ -142,13 +142,14 @@ KernelVersion: 3.4
142Contact: linux-mtd@lists.infradead.org 142Contact: linux-mtd@lists.infradead.org
143Description: 143Description:
144 This allows the user to examine and adjust the criteria by which 144 This allows the user to examine and adjust the criteria by which
145 mtd returns -EUCLEAN from mtd_read(). If the maximum number of 145 mtd returns -EUCLEAN from mtd_read() and mtd_read_oob(). If the
146 bit errors that were corrected on any single region comprising 146 maximum number of bit errors that were corrected on any single
147 an ecc step (as reported by the driver) equals or exceeds this 147 region comprising an ecc step (as reported by the driver) equals
148 value, -EUCLEAN is returned. Otherwise, absent an error, 0 is 148 or exceeds this value, -EUCLEAN is returned. Otherwise, absent
149 returned. Higher layers (e.g., UBI) use this return code as an 149 an error, 0 is returned. Higher layers (e.g., UBI) use this
150 indication that an erase block may be degrading and should be 150 return code as an indication that an erase block may be
151 scrutinized as a candidate for being marked as bad. 151 degrading and should be scrutinized as a candidate for being
152 marked as bad.
152 153
153 The initial value may be specified by the flash device driver. 154 The initial value may be specified by the flash device driver.
154 If not, then the default value is ecc_strength. 155 If not, then the default value is ecc_strength.
@@ -167,7 +168,7 @@ Description:
167 block degradation, but high enough to avoid the consequences of 168 block degradation, but high enough to avoid the consequences of
168 a persistent return value of -EUCLEAN on devices where sticky 169 a persistent return value of -EUCLEAN on devices where sticky
169 bitflips occur. Note that if bitflip_threshold exceeds 170 bitflips occur. Note that if bitflip_threshold exceeds
170 ecc_strength, -EUCLEAN is never returned by mtd_read(). 171 ecc_strength, -EUCLEAN is never returned by the read operations.
171 Conversely, if bitflip_threshold is zero, -EUCLEAN is always 172 Conversely, if bitflip_threshold is zero, -EUCLEAN is always
172 returned, absent a hard error. 173 returned, absent a hard error.
173 174
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index 676bc46f9c5..cda0dfb6769 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3988,7 +3988,7 @@ interface and may change in the future.</para>
3988 from RGB to Y'CbCr color space. 3988 from RGB to Y'CbCr color space.
3989 </entry> 3989 </entry>
3990 </row> 3990 </row>
3991 <row id = "v4l2-jpeg-chroma-subsampling"> 3991 <row>
3992 <entrytbl spanname="descr" cols="2"> 3992 <entrytbl spanname="descr" cols="2">
3993 <tbody valign="top"> 3993 <tbody valign="top">
3994 <row> 3994 <row>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index e3d5afcdafb..0a4b90fcf2d 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -284,13 +284,6 @@ These controls are described in <xref
284 processing controls. These controls are described in <xref 284 processing controls. These controls are described in <xref
285 linkend="image-process-controls" />.</entry> 285 linkend="image-process-controls" />.</entry>
286 </row> 286 </row>
287 <row>
288 <entry><constant>V4L2_CTRL_CLASS_JPEG</constant></entry>
289 <entry>0x9d0000</entry>
290 <entry>The class containing JPEG compression controls.
291These controls are described in <xref
292 linkend="jpeg-controls" />.</entry>
293 </row>
294 </tbody> 287 </tbody>
295 </tgroup> 288 </tgroup>
296 </table> 289 </table>
diff --git a/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt
index 82b43f91585..a4119f6422d 100644
--- a/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt
@@ -1626,3 +1626,5 @@ MX6Q_PAD_SD2_DAT3__PCIE_CTRL_MUX_11 1587
1626MX6Q_PAD_SD2_DAT3__GPIO_1_12 1588 1626MX6Q_PAD_SD2_DAT3__GPIO_1_12 1588
1627MX6Q_PAD_SD2_DAT3__SJC_DONE 1589 1627MX6Q_PAD_SD2_DAT3__SJC_DONE 1589
1628MX6Q_PAD_SD2_DAT3__ANATOP_TESTO_3 1590 1628MX6Q_PAD_SD2_DAT3__ANATOP_TESTO_3 1590
1629MX6Q_PAD_ENET_RX_ER__ANATOP_USBOTG_ID 1591
1630MX6Q_PAD_GPIO_1__ANATOP_USBOTG_ID 1592
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
index 506c7390c2b..13f1aa09b93 100644
--- a/Documentation/kdump/kdump.txt
+++ b/Documentation/kdump/kdump.txt
@@ -86,7 +86,7 @@ There is also a gitweb interface available at
86http://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git 86http://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git
87 87
88More information about kexec-tools can be found at 88More information about kexec-tools can be found at
89http://www.kernel.org/pub/linux/utils/kernel/kexec/README.html 89http://horms.net/projects/kexec/
90 90
913) Unpack the tarball with the tar command, as follows: 913) Unpack the tarball with the tar command, as follows:
92 92
diff --git a/MAINTAINERS b/MAINTAINERS
index 03df1d15ebf..fe643e7b9df 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3433,13 +3433,14 @@ S: Supported
3433F: drivers/idle/i7300_idle.c 3433F: drivers/idle/i7300_idle.c
3434 3434
3435IEEE 802.15.4 SUBSYSTEM 3435IEEE 802.15.4 SUBSYSTEM
3436M: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
3436M: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 3437M: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
3437M: Sergey Lapin <slapin@ossfans.org>
3438L: linux-zigbee-devel@lists.sourceforge.net (moderated for non-subscribers) 3438L: linux-zigbee-devel@lists.sourceforge.net (moderated for non-subscribers)
3439W: http://apps.sourceforge.net/trac/linux-zigbee 3439W: http://apps.sourceforge.net/trac/linux-zigbee
3440T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git 3440T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git
3441S: Maintained 3441S: Maintained
3442F: net/ieee802154/ 3442F: net/ieee802154/
3443F: net/mac802154/
3443F: drivers/ieee802154/ 3444F: drivers/ieee802154/
3444 3445
3445IIO SUBSYSTEM AND DRIVERS 3446IIO SUBSYSTEM AND DRIVERS
@@ -4857,6 +4858,7 @@ M: Kevin Hilman <khilman@ti.com>
4857L: linux-omap@vger.kernel.org 4858L: linux-omap@vger.kernel.org
4858S: Maintained 4859S: Maintained
4859F: arch/arm/*omap*/*pm* 4860F: arch/arm/*omap*/*pm*
4861F: drivers/cpufreq/omap-cpufreq.c
4860 4862
4861OMAP POWERDOMAIN/CLOCKDOMAIN SOC ADAPTATION LAYER SUPPORT 4863OMAP POWERDOMAIN/CLOCKDOMAIN SOC ADAPTATION LAYER SUPPORT
4862M: Rajendra Nayak <rnayak@ti.com> 4864M: Rajendra Nayak <rnayak@ti.com>
@@ -5563,7 +5565,7 @@ F: Documentation/networking/LICENSE.qla3xxx
5563F: drivers/net/ethernet/qlogic/qla3xxx.* 5565F: drivers/net/ethernet/qlogic/qla3xxx.*
5564 5566
5565QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER 5567QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER
5566M: Anirban Chakraborty <anirban.chakraborty@qlogic.com> 5568M: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
5567M: Sony Chacko <sony.chacko@qlogic.com> 5569M: Sony Chacko <sony.chacko@qlogic.com>
5568M: linux-driver@qlogic.com 5570M: linux-driver@qlogic.com
5569L: netdev@vger.kernel.org 5571L: netdev@vger.kernel.org
@@ -5571,7 +5573,6 @@ S: Supported
5571F: drivers/net/ethernet/qlogic/qlcnic/ 5573F: drivers/net/ethernet/qlogic/qlcnic/
5572 5574
5573QLOGIC QLGE 10Gb ETHERNET DRIVER 5575QLOGIC QLGE 10Gb ETHERNET DRIVER
5574M: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
5575M: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com> 5576M: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
5576M: Ron Mercer <ron.mercer@qlogic.com> 5577M: Ron Mercer <ron.mercer@qlogic.com>
5577M: linux-driver@qlogic.com 5578M: linux-driver@qlogic.com
@@ -5909,7 +5910,7 @@ M: Ingo Molnar <mingo@redhat.com>
5909M: Peter Zijlstra <peterz@infradead.org> 5910M: Peter Zijlstra <peterz@infradead.org>
5910T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core 5911T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core
5911S: Maintained 5912S: Maintained
5912F: kernel/sched* 5913F: kernel/sched/
5913F: include/linux/sched.h 5914F: include/linux/sched.h
5914 5915
5915SCORE ARCHITECTURE 5916SCORE ARCHITECTURE
diff --git a/Makefile b/Makefile
index bf02707a5e9..4bb09e1b123 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 5 2PATCHLEVEL = 5
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc6 4EXTRAVERSION =
5NAME = Saber-toothed Squirrel 5NAME = Saber-toothed Squirrel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a91009c6187..8928b21a2db 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -45,6 +45,9 @@ config ARM
45 select GENERIC_SMP_IDLE_THREAD 45 select GENERIC_SMP_IDLE_THREAD
46 select KTIME_SCALAR 46 select KTIME_SCALAR
47 select GENERIC_CLOCKEVENTS_BROADCAST if SMP 47 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
48 select GENERIC_STRNCPY_FROM_USER
49 select GENERIC_STRNLEN_USER
50 select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN
48 help 51 help
49 The ARM series is a line of low-power-consumption RISC chip designs 52 The ARM series is a line of low-power-consumption RISC chip designs
50 licensed by ARM Ltd and targeted at embedded applications and 53 licensed by ARM Ltd and targeted at embedded applications and
@@ -1961,6 +1964,25 @@ config ARM_ATAG_DTB_COMPAT
1961 bootloaders, this option allows zImage to extract the information 1964 bootloaders, this option allows zImage to extract the information
1962 from the ATAG list and store it at run time into the appended DTB. 1965 from the ATAG list and store it at run time into the appended DTB.
1963 1966
1967choice
1968 prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
1969 default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
1970
1971config ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
1972 bool "Use bootloader kernel arguments if available"
1973 help
1974 Uses the command-line options passed by the boot loader instead of
1975 the device tree bootargs property. If the boot loader doesn't provide
1976 any, the device tree bootargs property will be used.
1977
1978config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
1979 bool "Extend with bootloader kernel arguments"
1980 help
1981 The command-line arguments provided by the boot loader will be
1982 appended to the the device tree bootargs property.
1983
1984endchoice
1985
1964config CMDLINE 1986config CMDLINE
1965 string "Default kernel command string" 1987 string "Default kernel command string"
1966 default "" 1988 default ""
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 01a13414121..521e15bc640 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -369,4 +369,13 @@ config ARM_KPROBES_TEST
369 help 369 help
370 Perform tests of kprobes API and instruction set simulation. 370 Perform tests of kprobes API and instruction set simulation.
371 371
372config PID_IN_CONTEXTIDR
373 bool "Write the current PID to the CONTEXTIDR register"
374 depends on CPU_COPY_V6
375 help
376 Enabling this option causes the kernel to write the current PID to
377 the PROCID field of the CONTEXTIDR register, at the expense of some
378 additional instructions during context switch. Say Y here only if you
379 are planning to use hardware trace tools with this kernel.
380
372endmenu 381endmenu
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 0298b00fe24..f8ebf1e9702 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -10,6 +10,9 @@
10# 10#
11# Copyright (C) 1995-2001 by Russell King 11# Copyright (C) 1995-2001 by Russell King
12 12
13# Ensure linker flags are correct
14LDFLAGS :=
15
13LDFLAGS_vmlinux :=-p --no-undefined -X 16LDFLAGS_vmlinux :=-p --no-undefined -X
14ifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 17ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
15LDFLAGS_vmlinux += --be8 18LDFLAGS_vmlinux += --be8
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 797f04bedb4..aabc02a6848 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -1,6 +1,12 @@
1#include <asm/setup.h> 1#include <asm/setup.h>
2#include <libfdt.h> 2#include <libfdt.h>
3 3
4#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)
5#define do_extend_cmdline 1
6#else
7#define do_extend_cmdline 0
8#endif
9
4static int node_offset(void *fdt, const char *node_path) 10static int node_offset(void *fdt, const char *node_path)
5{ 11{
6 int offset = fdt_path_offset(fdt, node_path); 12 int offset = fdt_path_offset(fdt, node_path);
@@ -36,6 +42,48 @@ static int setprop_cell(void *fdt, const char *node_path,
36 return fdt_setprop_cell(fdt, offset, property, val); 42 return fdt_setprop_cell(fdt, offset, property, val);
37} 43}
38 44
45static const void *getprop(const void *fdt, const char *node_path,
46 const char *property, int *len)
47{
48 int offset = fdt_path_offset(fdt, node_path);
49
50 if (offset == -FDT_ERR_NOTFOUND)
51 return NULL;
52
53 return fdt_getprop(fdt, offset, property, len);
54}
55
56static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
57{
58 char cmdline[COMMAND_LINE_SIZE];
59 const char *fdt_bootargs;
60 char *ptr = cmdline;
61 int len = 0;
62
63 /* copy the fdt command line into the buffer */
64 fdt_bootargs = getprop(fdt, "/chosen", "bootargs", &len);
65 if (fdt_bootargs)
66 if (len < COMMAND_LINE_SIZE) {
67 memcpy(ptr, fdt_bootargs, len);
68 /* len is the length of the string
69 * including the NULL terminator */
70 ptr += len - 1;
71 }
72
73 /* and append the ATAG_CMDLINE */
74 if (fdt_cmdline) {
75 len = strlen(fdt_cmdline);
76 if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
77 *ptr++ = ' ';
78 memcpy(ptr, fdt_cmdline, len);
79 ptr += len;
80 }
81 }
82 *ptr = '\0';
83
84 setprop_string(fdt, "/chosen", "bootargs", cmdline);
85}
86
39/* 87/*
40 * Convert and fold provided ATAGs into the provided FDT. 88 * Convert and fold provided ATAGs into the provided FDT.
41 * 89 *
@@ -72,8 +120,18 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
72 120
73 for_each_tag(atag, atag_list) { 121 for_each_tag(atag, atag_list) {
74 if (atag->hdr.tag == ATAG_CMDLINE) { 122 if (atag->hdr.tag == ATAG_CMDLINE) {
75 setprop_string(fdt, "/chosen", "bootargs", 123 /* Append the ATAGS command line to the device tree
76 atag->u.cmdline.cmdline); 124 * command line.
125 * NB: This means that if the same parameter is set in
126 * the device tree and in the tags, the one from the
127 * tags will be chosen.
128 */
129 if (do_extend_cmdline)
130 merge_fdt_bootargs(fdt,
131 atag->u.cmdline.cmdline);
132 else
133 setprop_string(fdt, "/chosen", "bootargs",
134 atag->u.cmdline.cmdline);
77 } else if (atag->hdr.tag == ATAG_MEM) { 135 } else if (atag->hdr.tag == ATAG_MEM) {
78 if (memcount >= sizeof(mem_reg_property)/4) 136 if (memcount >= sizeof(mem_reg_property)/4)
79 continue; 137 continue;
diff --git a/arch/arm/boot/dts/spear13xx.dtsi b/arch/arm/boot/dts/spear13xx.dtsi
index 10dcec7e732..f7b84aced65 100644
--- a/arch/arm/boot/dts/spear13xx.dtsi
+++ b/arch/arm/boot/dts/spear13xx.dtsi
@@ -43,8 +43,8 @@
43 43
44 pmu { 44 pmu {
45 compatible = "arm,cortex-a9-pmu"; 45 compatible = "arm,cortex-a9-pmu";
46 interrupts = <0 8 0x04 46 interrupts = <0 6 0x04
47 0 9 0x04>; 47 0 7 0x04>;
48 }; 48 };
49 49
50 L2: l2-cache { 50 L2: l2-cache {
@@ -119,8 +119,8 @@
119 gmac0: eth@e2000000 { 119 gmac0: eth@e2000000 {
120 compatible = "st,spear600-gmac"; 120 compatible = "st,spear600-gmac";
121 reg = <0xe2000000 0x8000>; 121 reg = <0xe2000000 0x8000>;
122 interrupts = <0 23 0x4 122 interrupts = <0 33 0x4
123 0 24 0x4>; 123 0 34 0x4>;
124 interrupt-names = "macirq", "eth_wake_irq"; 124 interrupt-names = "macirq", "eth_wake_irq";
125 status = "disabled"; 125 status = "disabled";
126 }; 126 };
@@ -202,6 +202,7 @@
202 kbd@e0300000 { 202 kbd@e0300000 {
203 compatible = "st,spear300-kbd"; 203 compatible = "st,spear300-kbd";
204 reg = <0xe0300000 0x1000>; 204 reg = <0xe0300000 0x1000>;
205 interrupts = <0 52 0x4>;
205 status = "disabled"; 206 status = "disabled";
206 }; 207 };
207 208
@@ -224,7 +225,7 @@
224 serial@e0000000 { 225 serial@e0000000 {
225 compatible = "arm,pl011", "arm,primecell"; 226 compatible = "arm,pl011", "arm,primecell";
226 reg = <0xe0000000 0x1000>; 227 reg = <0xe0000000 0x1000>;
227 interrupts = <0 36 0x4>; 228 interrupts = <0 35 0x4>;
228 status = "disabled"; 229 status = "disabled";
229 }; 230 };
230 231
diff --git a/arch/arm/boot/dts/spear320-evb.dts b/arch/arm/boot/dts/spear320-evb.dts
index c13fd1f3b09..e4e912f9502 100644
--- a/arch/arm/boot/dts/spear320-evb.dts
+++ b/arch/arm/boot/dts/spear320-evb.dts
@@ -15,8 +15,8 @@
15/include/ "spear320.dtsi" 15/include/ "spear320.dtsi"
16 16
17/ { 17/ {
18 model = "ST SPEAr300 Evaluation Board"; 18 model = "ST SPEAr320 Evaluation Board";
19 compatible = "st,spear300-evb", "st,spear300"; 19 compatible = "st,spear320-evb", "st,spear320";
20 #address-cells = <1>; 20 #address-cells = <1>;
21 #size-cells = <1>; 21 #size-cells = <1>;
22 22
@@ -26,7 +26,7 @@
26 26
27 ahb { 27 ahb {
28 pinmux@b3000000 { 28 pinmux@b3000000 {
29 st,pinmux-mode = <3>; 29 st,pinmux-mode = <4>;
30 pinctrl-names = "default"; 30 pinctrl-names = "default";
31 pinctrl-0 = <&state_default>; 31 pinctrl-0 = <&state_default>;
32 32
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
index 089f0a42c50..a3c36e47d7e 100644
--- a/arch/arm/boot/dts/spear600.dtsi
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -181,6 +181,7 @@
181 timer@f0000000 { 181 timer@f0000000 {
182 compatible = "st,spear-timer"; 182 compatible = "st,spear-timer";
183 reg = <0xf0000000 0x400>; 183 reg = <0xf0000000 0x400>;
184 interrupt-parent = <&vic0>;
184 interrupts = <16>; 185 interrupts = <16>;
185 }; 186 };
186 }; 187 };
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 9854ff4279e..11828e63253 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -176,7 +176,6 @@ CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
176CONFIG_USB_DEVICEFS=y 176CONFIG_USB_DEVICEFS=y
177CONFIG_USB_SUSPEND=y 177CONFIG_USB_SUSPEND=y
178CONFIG_USB_MON=y 178CONFIG_USB_MON=y
179CONFIG_USB_EHCI_HCD=y
180CONFIG_USB_WDM=y 179CONFIG_USB_WDM=y
181CONFIG_USB_STORAGE=y 180CONFIG_USB_STORAGE=y
182CONFIG_USB_LIBUSUAL=y 181CONFIG_USB_LIBUSUAL=y
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index ed2e95d46e2..62e75475e57 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -1,7 +1,10 @@
1#ifndef __ASMARM_ARCH_TIMER_H 1#ifndef __ASMARM_ARCH_TIMER_H
2#define __ASMARM_ARCH_TIMER_H 2#define __ASMARM_ARCH_TIMER_H
3 3
4#include <asm/errno.h>
5
4#ifdef CONFIG_ARM_ARCH_TIMER 6#ifdef CONFIG_ARM_ARCH_TIMER
7#define ARCH_HAS_READ_CURRENT_TIMER
5int arch_timer_of_register(void); 8int arch_timer_of_register(void);
6int arch_timer_sched_clock_init(void); 9int arch_timer_sched_clock_init(void);
7#else 10#else
diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
index b2deda18154..dc6145120de 100644
--- a/arch/arm/include/asm/delay.h
+++ b/arch/arm/include/asm/delay.h
@@ -6,9 +6,22 @@
6#ifndef __ASM_ARM_DELAY_H 6#ifndef __ASM_ARM_DELAY_H
7#define __ASM_ARM_DELAY_H 7#define __ASM_ARM_DELAY_H
8 8
9#include <asm/memory.h>
9#include <asm/param.h> /* HZ */ 10#include <asm/param.h> /* HZ */
10 11
11extern void __delay(int loops); 12#define MAX_UDELAY_MS 2
13#define UDELAY_MULT ((UL(2199023) * HZ) >> 11)
14#define UDELAY_SHIFT 30
15
16#ifndef __ASSEMBLY__
17
18extern struct arm_delay_ops {
19 void (*delay)(unsigned long);
20 void (*const_udelay)(unsigned long);
21 void (*udelay)(unsigned long);
22} arm_delay_ops;
23
24#define __delay(n) arm_delay_ops.delay(n)
12 25
13/* 26/*
14 * This function intentionally does not exist; if you see references to 27 * This function intentionally does not exist; if you see references to
@@ -23,22 +36,27 @@ extern void __bad_udelay(void);
23 * division by multiplication: you don't have to worry about 36 * division by multiplication: you don't have to worry about
24 * loss of precision. 37 * loss of precision.
25 * 38 *
26 * Use only for very small delays ( < 1 msec). Should probably use a 39 * Use only for very small delays ( < 2 msec). Should probably use a
27 * lookup table, really, as the multiplications take much too long with 40 * lookup table, really, as the multiplications take much too long with
28 * short delays. This is a "reasonable" implementation, though (and the 41 * short delays. This is a "reasonable" implementation, though (and the
29 * first constant multiplications gets optimized away if the delay is 42 * first constant multiplications gets optimized away if the delay is
30 * a constant) 43 * a constant)
31 */ 44 */
32extern void __udelay(unsigned long usecs); 45#define __udelay(n) arm_delay_ops.udelay(n)
33extern void __const_udelay(unsigned long); 46#define __const_udelay(n) arm_delay_ops.const_udelay(n)
34
35#define MAX_UDELAY_MS 2
36 47
37#define udelay(n) \ 48#define udelay(n) \
38 (__builtin_constant_p(n) ? \ 49 (__builtin_constant_p(n) ? \
39 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \ 50 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
40 __const_udelay((n) * ((2199023U*HZ)>>11))) : \ 51 __const_udelay((n) * UDELAY_MULT)) : \
41 __udelay(n)) 52 __udelay(n))
42 53
54/* Loop-based definitions for assembly code. */
55extern void __loop_delay(unsigned long loops);
56extern void __loop_udelay(unsigned long usecs);
57extern void __loop_const_udelay(unsigned long);
58
59#endif /* __ASSEMBLY__ */
60
43#endif /* defined(_ARM_DELAY_H) */ 61#endif /* defined(_ARM_DELAY_H) */
44 62
diff --git a/arch/arm/include/asm/locks.h b/arch/arm/include/asm/locks.h
deleted file mode 100644
index ef4c897772d..00000000000
--- a/arch/arm/include/asm/locks.h
+++ /dev/null
@@ -1,274 +0,0 @@
1/*
2 * arch/arm/include/asm/locks.h
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Interrupt safe locking assembler.
11 */
12#ifndef __ASM_PROC_LOCKS_H
13#define __ASM_PROC_LOCKS_H
14
15#if __LINUX_ARM_ARCH__ >= 6
16
17#define __down_op(ptr,fail) \
18 ({ \
19 __asm__ __volatile__( \
20 "@ down_op\n" \
21"1: ldrex lr, [%0]\n" \
22" sub lr, lr, %1\n" \
23" strex ip, lr, [%0]\n" \
24" teq ip, #0\n" \
25" bne 1b\n" \
26" teq lr, #0\n" \
27" movmi ip, %0\n" \
28" blmi " #fail \
29 : \
30 : "r" (ptr), "I" (1) \
31 : "ip", "lr", "cc"); \
32 smp_mb(); \
33 })
34
35#define __down_op_ret(ptr,fail) \
36 ({ \
37 unsigned int ret; \
38 __asm__ __volatile__( \
39 "@ down_op_ret\n" \
40"1: ldrex lr, [%1]\n" \
41" sub lr, lr, %2\n" \
42" strex ip, lr, [%1]\n" \
43" teq ip, #0\n" \
44" bne 1b\n" \
45" teq lr, #0\n" \
46" movmi ip, %1\n" \
47" movpl ip, #0\n" \
48" blmi " #fail "\n" \
49" mov %0, ip" \
50 : "=&r" (ret) \
51 : "r" (ptr), "I" (1) \
52 : "ip", "lr", "cc"); \
53 smp_mb(); \
54 ret; \
55 })
56
57#define __up_op(ptr,wake) \
58 ({ \
59 smp_mb(); \
60 __asm__ __volatile__( \
61 "@ up_op\n" \
62"1: ldrex lr, [%0]\n" \
63" add lr, lr, %1\n" \
64" strex ip, lr, [%0]\n" \
65" teq ip, #0\n" \
66" bne 1b\n" \
67" cmp lr, #0\n" \
68" movle ip, %0\n" \
69" blle " #wake \
70 : \
71 : "r" (ptr), "I" (1) \
72 : "ip", "lr", "cc"); \
73 })
74
75/*
76 * The value 0x01000000 supports up to 128 processors and
77 * lots of processes. BIAS must be chosen such that sub'ing
78 * BIAS once per CPU will result in the long remaining
79 * negative.
80 */
81#define RW_LOCK_BIAS 0x01000000
82#define RW_LOCK_BIAS_STR "0x01000000"
83
84#define __down_op_write(ptr,fail) \
85 ({ \
86 __asm__ __volatile__( \
87 "@ down_op_write\n" \
88"1: ldrex lr, [%0]\n" \
89" sub lr, lr, %1\n" \
90" strex ip, lr, [%0]\n" \
91" teq ip, #0\n" \
92" bne 1b\n" \
93" teq lr, #0\n" \
94" movne ip, %0\n" \
95" blne " #fail \
96 : \
97 : "r" (ptr), "I" (RW_LOCK_BIAS) \
98 : "ip", "lr", "cc"); \
99 smp_mb(); \
100 })
101
102#define __up_op_write(ptr,wake) \
103 ({ \
104 smp_mb(); \
105 __asm__ __volatile__( \
106 "@ up_op_write\n" \
107"1: ldrex lr, [%0]\n" \
108" adds lr, lr, %1\n" \
109" strex ip, lr, [%0]\n" \
110" teq ip, #0\n" \
111" bne 1b\n" \
112" movcs ip, %0\n" \
113" blcs " #wake \
114 : \
115 : "r" (ptr), "I" (RW_LOCK_BIAS) \
116 : "ip", "lr", "cc"); \
117 })
118
119#define __down_op_read(ptr,fail) \
120 __down_op(ptr, fail)
121
122#define __up_op_read(ptr,wake) \
123 ({ \
124 smp_mb(); \
125 __asm__ __volatile__( \
126 "@ up_op_read\n" \
127"1: ldrex lr, [%0]\n" \
128" add lr, lr, %1\n" \
129" strex ip, lr, [%0]\n" \
130" teq ip, #0\n" \
131" bne 1b\n" \
132" teq lr, #0\n" \
133" moveq ip, %0\n" \
134" bleq " #wake \
135 : \
136 : "r" (ptr), "I" (1) \
137 : "ip", "lr", "cc"); \
138 })
139
140#else
141
142#define __down_op(ptr,fail) \
143 ({ \
144 __asm__ __volatile__( \
145 "@ down_op\n" \
146" mrs ip, cpsr\n" \
147" orr lr, ip, #128\n" \
148" msr cpsr_c, lr\n" \
149" ldr lr, [%0]\n" \
150" subs lr, lr, %1\n" \
151" str lr, [%0]\n" \
152" msr cpsr_c, ip\n" \
153" movmi ip, %0\n" \
154" blmi " #fail \
155 : \
156 : "r" (ptr), "I" (1) \
157 : "ip", "lr", "cc"); \
158 smp_mb(); \
159 })
160
161#define __down_op_ret(ptr,fail) \
162 ({ \
163 unsigned int ret; \
164 __asm__ __volatile__( \
165 "@ down_op_ret\n" \
166" mrs ip, cpsr\n" \
167" orr lr, ip, #128\n" \
168" msr cpsr_c, lr\n" \
169" ldr lr, [%1]\n" \
170" subs lr, lr, %2\n" \
171" str lr, [%1]\n" \
172" msr cpsr_c, ip\n" \
173" movmi ip, %1\n" \
174" movpl ip, #0\n" \
175" blmi " #fail "\n" \
176" mov %0, ip" \
177 : "=&r" (ret) \
178 : "r" (ptr), "I" (1) \
179 : "ip", "lr", "cc"); \
180 smp_mb(); \
181 ret; \
182 })
183
184#define __up_op(ptr,wake) \
185 ({ \
186 smp_mb(); \
187 __asm__ __volatile__( \
188 "@ up_op\n" \
189" mrs ip, cpsr\n" \
190" orr lr, ip, #128\n" \
191" msr cpsr_c, lr\n" \
192" ldr lr, [%0]\n" \
193" adds lr, lr, %1\n" \
194" str lr, [%0]\n" \
195" msr cpsr_c, ip\n" \
196" movle ip, %0\n" \
197" blle " #wake \
198 : \
199 : "r" (ptr), "I" (1) \
200 : "ip", "lr", "cc"); \
201 })
202
203/*
204 * The value 0x01000000 supports up to 128 processors and
205 * lots of processes. BIAS must be chosen such that sub'ing
206 * BIAS once per CPU will result in the long remaining
207 * negative.
208 */
209#define RW_LOCK_BIAS 0x01000000
210#define RW_LOCK_BIAS_STR "0x01000000"
211
212#define __down_op_write(ptr,fail) \
213 ({ \
214 __asm__ __volatile__( \
215 "@ down_op_write\n" \
216" mrs ip, cpsr\n" \
217" orr lr, ip, #128\n" \
218" msr cpsr_c, lr\n" \
219" ldr lr, [%0]\n" \
220" subs lr, lr, %1\n" \
221" str lr, [%0]\n" \
222" msr cpsr_c, ip\n" \
223" movne ip, %0\n" \
224" blne " #fail \
225 : \
226 : "r" (ptr), "I" (RW_LOCK_BIAS) \
227 : "ip", "lr", "cc"); \
228 smp_mb(); \
229 })
230
231#define __up_op_write(ptr,wake) \
232 ({ \
233 __asm__ __volatile__( \
234 "@ up_op_write\n" \
235" mrs ip, cpsr\n" \
236" orr lr, ip, #128\n" \
237" msr cpsr_c, lr\n" \
238" ldr lr, [%0]\n" \
239" adds lr, lr, %1\n" \
240" str lr, [%0]\n" \
241" msr cpsr_c, ip\n" \
242" movcs ip, %0\n" \
243" blcs " #wake \
244 : \
245 : "r" (ptr), "I" (RW_LOCK_BIAS) \
246 : "ip", "lr", "cc"); \
247 smp_mb(); \
248 })
249
250#define __down_op_read(ptr,fail) \
251 __down_op(ptr, fail)
252
253#define __up_op_read(ptr,wake) \
254 ({ \
255 smp_mb(); \
256 __asm__ __volatile__( \
257 "@ up_op_read\n" \
258" mrs ip, cpsr\n" \
259" orr lr, ip, #128\n" \
260" msr cpsr_c, lr\n" \
261" ldr lr, [%0]\n" \
262" adds lr, lr, %1\n" \
263" str lr, [%0]\n" \
264" msr cpsr_c, ip\n" \
265" moveq ip, %0\n" \
266" bleq " #wake \
267 : \
268 : "r" (ptr), "I" (1) \
269 : "ip", "lr", "cc"); \
270 })
271
272#endif
273
274#endif
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index fcb575747e5..e965f1b560f 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -16,7 +16,7 @@
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/const.h> 17#include <linux/const.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <asm/sizes.h> 19#include <linux/sizes.h>
20 20
21#ifdef CONFIG_NEED_MACH_MEMORY_H 21#ifdef CONFIG_NEED_MACH_MEMORY_H
22#include <mach/memory.h> 22#include <mach/memory.h>
diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h
index 00cbe10a50e..e074948d814 100644
--- a/arch/arm/include/asm/perf_event.h
+++ b/arch/arm/include/asm/perf_event.h
@@ -12,21 +12,6 @@
12#ifndef __ARM_PERF_EVENT_H__ 12#ifndef __ARM_PERF_EVENT_H__
13#define __ARM_PERF_EVENT_H__ 13#define __ARM_PERF_EVENT_H__
14 14
15/* ARM perf PMU IDs for use by internal perf clients. */ 15/* Nothing to see here... */
16enum arm_perf_pmu_ids {
17 ARM_PERF_PMU_ID_XSCALE1 = 0,
18 ARM_PERF_PMU_ID_XSCALE2,
19 ARM_PERF_PMU_ID_V6,
20 ARM_PERF_PMU_ID_V6MP,
21 ARM_PERF_PMU_ID_CA8,
22 ARM_PERF_PMU_ID_CA9,
23 ARM_PERF_PMU_ID_CA5,
24 ARM_PERF_PMU_ID_CA15,
25 ARM_PERF_PMU_ID_CA7,
26 ARM_NUM_PMU_IDS,
27};
28
29extern enum arm_perf_pmu_ids
30armpmu_get_pmu_id(void);
31 16
32#endif /* __ARM_PERF_EVENT_H__ */ 17#endif /* __ARM_PERF_EVENT_H__ */
diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h
index 90114faa9f3..4432305f4a2 100644
--- a/arch/arm/include/asm/pmu.h
+++ b/arch/arm/include/asm/pmu.h
@@ -103,10 +103,9 @@ struct pmu_hw_events {
103 103
104struct arm_pmu { 104struct arm_pmu {
105 struct pmu pmu; 105 struct pmu pmu;
106 enum arm_perf_pmu_ids id;
107 enum arm_pmu_type type; 106 enum arm_pmu_type type;
108 cpumask_t active_irqs; 107 cpumask_t active_irqs;
109 const char *name; 108 char *name;
110 irqreturn_t (*handle_irq)(int irq_num, void *dev); 109 irqreturn_t (*handle_irq)(int irq_num, void *dev);
111 void (*enable)(struct hw_perf_event *evt, int idx); 110 void (*enable)(struct hw_perf_event *evt, int idx);
112 void (*disable)(struct hw_perf_event *evt, int idx); 111 void (*disable)(struct hw_perf_event *evt, int idx);
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index 65fa3c88095..b4ca707d0a6 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -59,18 +59,13 @@ static inline void dsb_sev(void)
59} 59}
60 60
61/* 61/*
62 * ARMv6 Spin-locking. 62 * ARMv6 ticket-based spin-locking.
63 * 63 *
64 * We exclusively read the old value. If it is zero, we may have 64 * A memory barrier is required after we get a lock, and before we
65 * won the lock, so we try exclusively storing it. A memory barrier 65 * release it, because V6 CPUs are assumed to have weakly ordered
66 * is required after we get a lock, and before we release it, because 66 * memory.
67 * V6 CPUs are assumed to have weakly ordered memory.
68 *
69 * Unlocked value: 0
70 * Locked value: 1
71 */ 67 */
72 68
73#define arch_spin_is_locked(x) ((x)->lock != 0)
74#define arch_spin_unlock_wait(lock) \ 69#define arch_spin_unlock_wait(lock) \
75 do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) 70 do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
76 71
@@ -79,31 +74,39 @@ static inline void dsb_sev(void)
79static inline void arch_spin_lock(arch_spinlock_t *lock) 74static inline void arch_spin_lock(arch_spinlock_t *lock)
80{ 75{
81 unsigned long tmp; 76 unsigned long tmp;
77 u32 newval;
78 arch_spinlock_t lockval;
82 79
83 __asm__ __volatile__( 80 __asm__ __volatile__(
84"1: ldrex %0, [%1]\n" 81"1: ldrex %0, [%3]\n"
85" teq %0, #0\n" 82" add %1, %0, %4\n"
86 WFE("ne") 83" strex %2, %1, [%3]\n"
87" strexeq %0, %2, [%1]\n" 84" teq %2, #0\n"
88" teqeq %0, #0\n"
89" bne 1b" 85" bne 1b"
90 : "=&r" (tmp) 86 : "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
91 : "r" (&lock->lock), "r" (1) 87 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
92 : "cc"); 88 : "cc");
93 89
90 while (lockval.tickets.next != lockval.tickets.owner) {
91 wfe();
92 lockval.tickets.owner = ACCESS_ONCE(lock->tickets.owner);
93 }
94
94 smp_mb(); 95 smp_mb();
95} 96}
96 97
97static inline int arch_spin_trylock(arch_spinlock_t *lock) 98static inline int arch_spin_trylock(arch_spinlock_t *lock)
98{ 99{
99 unsigned long tmp; 100 unsigned long tmp;
101 u32 slock;
100 102
101 __asm__ __volatile__( 103 __asm__ __volatile__(
102" ldrex %0, [%1]\n" 104" ldrex %0, [%2]\n"
103" teq %0, #0\n" 105" subs %1, %0, %0, ror #16\n"
104" strexeq %0, %2, [%1]" 106" addeq %0, %0, %3\n"
105 : "=&r" (tmp) 107" strexeq %1, %0, [%2]"
106 : "r" (&lock->lock), "r" (1) 108 : "=&r" (slock), "=&r" (tmp)
109 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
107 : "cc"); 110 : "cc");
108 111
109 if (tmp == 0) { 112 if (tmp == 0) {
@@ -116,17 +119,38 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
116 119
117static inline void arch_spin_unlock(arch_spinlock_t *lock) 120static inline void arch_spin_unlock(arch_spinlock_t *lock)
118{ 121{
122 unsigned long tmp;
123 u32 slock;
124
119 smp_mb(); 125 smp_mb();
120 126
121 __asm__ __volatile__( 127 __asm__ __volatile__(
122" str %1, [%0]\n" 128" mov %1, #1\n"
123 : 129"1: ldrex %0, [%2]\n"
124 : "r" (&lock->lock), "r" (0) 130" uadd16 %0, %0, %1\n"
131" strex %1, %0, [%2]\n"
132" teq %1, #0\n"
133" bne 1b"
134 : "=&r" (slock), "=&r" (tmp)
135 : "r" (&lock->slock)
125 : "cc"); 136 : "cc");
126 137
127 dsb_sev(); 138 dsb_sev();
128} 139}
129 140
141static inline int arch_spin_is_locked(arch_spinlock_t *lock)
142{
143 struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
144 return tickets.owner != tickets.next;
145}
146
147static inline int arch_spin_is_contended(arch_spinlock_t *lock)
148{
149 struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
150 return (tickets.next - tickets.owner) > 1;
151}
152#define arch_spin_is_contended arch_spin_is_contended
153
130/* 154/*
131 * RWLOCKS 155 * RWLOCKS
132 * 156 *
@@ -158,7 +182,7 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
158 unsigned long tmp; 182 unsigned long tmp;
159 183
160 __asm__ __volatile__( 184 __asm__ __volatile__(
161"1: ldrex %0, [%1]\n" 185" ldrex %0, [%1]\n"
162" teq %0, #0\n" 186" teq %0, #0\n"
163" strexeq %0, %2, [%1]" 187" strexeq %0, %2, [%1]"
164 : "=&r" (tmp) 188 : "=&r" (tmp)
@@ -244,7 +268,7 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
244 unsigned long tmp, tmp2 = 1; 268 unsigned long tmp, tmp2 = 1;
245 269
246 __asm__ __volatile__( 270 __asm__ __volatile__(
247"1: ldrex %0, [%2]\n" 271" ldrex %0, [%2]\n"
248" adds %0, %0, #1\n" 272" adds %0, %0, #1\n"
249" strexpl %1, %0, [%2]\n" 273" strexpl %1, %0, [%2]\n"
250 : "=&r" (tmp), "+r" (tmp2) 274 : "=&r" (tmp), "+r" (tmp2)
diff --git a/arch/arm/include/asm/spinlock_types.h b/arch/arm/include/asm/spinlock_types.h
index d14d197ae04..b262d2f8b47 100644
--- a/arch/arm/include/asm/spinlock_types.h
+++ b/arch/arm/include/asm/spinlock_types.h
@@ -5,11 +5,24 @@
5# error "please don't include this file directly" 5# error "please don't include this file directly"
6#endif 6#endif
7 7
8#define TICKET_SHIFT 16
9
8typedef struct { 10typedef struct {
9 volatile unsigned int lock; 11 union {
12 u32 slock;
13 struct __raw_tickets {
14#ifdef __ARMEB__
15 u16 next;
16 u16 owner;
17#else
18 u16 owner;
19 u16 next;
20#endif
21 } tickets;
22 };
10} arch_spinlock_t; 23} arch_spinlock_t;
11 24
12#define __ARCH_SPIN_LOCK_UNLOCKED { 0 } 25#define __ARCH_SPIN_LOCK_UNLOCKED { { 0 } }
13 26
14typedef struct { 27typedef struct {
15 volatile unsigned int lock; 28 volatile unsigned int lock;
diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 3be8de3adab..ce119442277 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -12,13 +12,15 @@
12#ifndef _ASMARM_TIMEX_H 12#ifndef _ASMARM_TIMEX_H
13#define _ASMARM_TIMEX_H 13#define _ASMARM_TIMEX_H
14 14
15#include <asm/arch_timer.h>
15#include <mach/timex.h> 16#include <mach/timex.h>
16 17
17typedef unsigned long cycles_t; 18typedef unsigned long cycles_t;
18 19
19static inline cycles_t get_cycles (void) 20#ifdef ARCH_HAS_READ_CURRENT_TIMER
20{ 21#define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; })
21 return 0; 22#else
22} 23#define get_cycles() (0)
24#endif
23 25
24#endif 26#endif
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 71f6536d17a..479a6352e0b 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -189,6 +189,9 @@ static inline void set_fs(mm_segment_t fs)
189 189
190#define access_ok(type,addr,size) (__range_ok(addr,size) == 0) 190#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
191 191
192#define user_addr_max() \
193 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
194
192/* 195/*
193 * The "__xxx" versions of the user access functions do not verify the 196 * The "__xxx" versions of the user access functions do not verify the
194 * address space - it must have been done previously with a separate 197 * address space - it must have been done previously with a separate
@@ -398,9 +401,6 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
398#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0) 401#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0)
399#endif 402#endif
400 403
401extern unsigned long __must_check __strncpy_from_user(char *to, const char __user *from, unsigned long count);
402extern unsigned long __must_check __strnlen_user(const char __user *s, long n);
403
404static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n) 404static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
405{ 405{
406 if (access_ok(VERIFY_READ, from, n)) 406 if (access_ok(VERIFY_READ, from, n))
@@ -427,24 +427,9 @@ static inline unsigned long __must_check clear_user(void __user *to, unsigned lo
427 return n; 427 return n;
428} 428}
429 429
430static inline long __must_check strncpy_from_user(char *dst, const char __user *src, long count) 430extern long strncpy_from_user(char *dest, const char __user *src, long count);
431{
432 long res = -EFAULT;
433 if (access_ok(VERIFY_READ, src, 1))
434 res = __strncpy_from_user(dst, src, count);
435 return res;
436}
437
438#define strlen_user(s) strnlen_user(s, ~0UL >> 1)
439 431
440static inline long __must_check strnlen_user(const char __user *s, long n) 432extern __must_check long strlen_user(const char __user *str);
441{ 433extern __must_check long strnlen_user(const char __user *str, long n);
442 unsigned long res = 0;
443
444 if (__addr_ok(s))
445 res = __strnlen_user(s, n);
446
447 return res;
448}
449 434
450#endif /* _ASMARM_UACCESS_H */ 435#endif /* _ASMARM_UACCESS_H */
diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/word-at-a-time.h
new file mode 100644
index 00000000000..4d52f92967a
--- /dev/null
+++ b/arch/arm/include/asm/word-at-a-time.h
@@ -0,0 +1,96 @@
1#ifndef __ASM_ARM_WORD_AT_A_TIME_H
2#define __ASM_ARM_WORD_AT_A_TIME_H
3
4#ifndef __ARMEB__
5
6/*
7 * Little-endian word-at-a-time zero byte handling.
8 * Heavily based on the x86 algorithm.
9 */
10#include <linux/kernel.h>
11
12struct word_at_a_time {
13 const unsigned long one_bits, high_bits;
14};
15
16#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
17
18static inline unsigned long has_zero(unsigned long a, unsigned long *bits,
19 const struct word_at_a_time *c)
20{
21 unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
22 *bits = mask;
23 return mask;
24}
25
26#define prep_zero_mask(a, bits, c) (bits)
27
28static inline unsigned long create_zero_mask(unsigned long bits)
29{
30 bits = (bits - 1) & ~bits;
31 return bits >> 7;
32}
33
34static inline unsigned long find_zero(unsigned long mask)
35{
36 unsigned long ret;
37
38#if __LINUX_ARM_ARCH__ >= 5
39 /* We have clz available. */
40 ret = fls(mask) >> 3;
41#else
42 /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
43 ret = (0x0ff0001 + mask) >> 23;
44 /* Fix the 1 for 00 case */
45 ret &= mask;
46#endif
47
48 return ret;
49}
50
51#ifdef CONFIG_DCACHE_WORD_ACCESS
52
53#define zero_bytemask(mask) (mask)
54
55/*
56 * Load an unaligned word from kernel space.
57 *
58 * In the (very unlikely) case of the word being a page-crosser
59 * and the next page not being mapped, take the exception and
60 * return zeroes in the non-existing part.
61 */
62static inline unsigned long load_unaligned_zeropad(const void *addr)
63{
64 unsigned long ret, offset;
65
66 /* Load word from unaligned pointer addr */
67 asm(
68 "1: ldr %0, [%2]\n"
69 "2:\n"
70 " .pushsection .fixup,\"ax\"\n"
71 " .align 2\n"
72 "3: and %1, %2, #0x3\n"
73 " bic %2, %2, #0x3\n"
74 " ldr %0, [%2]\n"
75 " lsl %1, %1, #0x3\n"
76 " lsr %0, %0, %1\n"
77 " b 2b\n"
78 " .popsection\n"
79 " .pushsection __ex_table,\"a\"\n"
80 " .align 3\n"
81 " .long 1b, 3b\n"
82 " .popsection"
83 : "=&r" (ret), "=&r" (offset)
84 : "r" (addr), "Qo" (*(unsigned long *)addr));
85
86 return ret;
87}
88
89
90#endif /* DCACHE_WORD_ACCESS */
91
92#else /* __ARMEB__ */
93#include <asm-generic/word-at-a-time.h>
94#endif
95
96#endif /* __ASM_ARM_WORD_AT_A_TIME_H */
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index dd58035621f..cf258807160 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -32,6 +32,8 @@ static int arch_timer_ppi2;
32 32
33static struct clock_event_device __percpu **arch_timer_evt; 33static struct clock_event_device __percpu **arch_timer_evt;
34 34
35extern void init_current_timer_delay(unsigned long freq);
36
35/* 37/*
36 * Architected system timer support. 38 * Architected system timer support.
37 */ 39 */
@@ -137,7 +139,7 @@ static int __cpuinit arch_timer_setup(struct clock_event_device *clk)
137 /* Be safe... */ 139 /* Be safe... */
138 arch_timer_disable(); 140 arch_timer_disable();
139 141
140 clk->features = CLOCK_EVT_FEAT_ONESHOT; 142 clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP;
141 clk->name = "arch_sys_timer"; 143 clk->name = "arch_sys_timer";
142 clk->rating = 450; 144 clk->rating = 450;
143 clk->set_mode = arch_timer_set_mode; 145 clk->set_mode = arch_timer_set_mode;
@@ -223,6 +225,14 @@ static cycle_t arch_counter_read(struct clocksource *cs)
223 return arch_counter_get_cntpct(); 225 return arch_counter_get_cntpct();
224} 226}
225 227
228int read_current_timer(unsigned long *timer_val)
229{
230 if (!arch_timer_rate)
231 return -ENXIO;
232 *timer_val = arch_counter_get_cntpct();
233 return 0;
234}
235
226static struct clocksource clocksource_counter = { 236static struct clocksource clocksource_counter = {
227 .name = "arch_sys_counter", 237 .name = "arch_sys_counter",
228 .rating = 400, 238 .rating = 400,
@@ -296,6 +306,7 @@ static int __init arch_timer_register(void)
296 if (err) 306 if (err)
297 goto out_free_irq; 307 goto out_free_irq;
298 308
309 init_current_timer_delay(arch_timer_rate);
299 return 0; 310 return 0;
300 311
301out_free_irq: 312out_free_irq:
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index b57c75e0b01..60d3b738d42 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -49,8 +49,7 @@ extern void __aeabi_ulcmp(void);
49extern void fpundefinstr(void); 49extern void fpundefinstr(void);
50 50
51 /* platform dependent support */ 51 /* platform dependent support */
52EXPORT_SYMBOL(__udelay); 52EXPORT_SYMBOL(arm_delay_ops);
53EXPORT_SYMBOL(__const_udelay);
54 53
55 /* networking */ 54 /* networking */
56EXPORT_SYMBOL(csum_partial); 55EXPORT_SYMBOL(csum_partial);
@@ -87,10 +86,6 @@ EXPORT_SYMBOL(memmove);
87EXPORT_SYMBOL(memchr); 86EXPORT_SYMBOL(memchr);
88EXPORT_SYMBOL(__memzero); 87EXPORT_SYMBOL(__memzero);
89 88
90 /* user mem (segment) */
91EXPORT_SYMBOL(__strnlen_user);
92EXPORT_SYMBOL(__strncpy_from_user);
93
94#ifdef CONFIG_MMU 89#ifdef CONFIG_MMU
95EXPORT_SYMBOL(copy_page); 90EXPORT_SYMBOL(copy_page);
96 91
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 4afed88d250..49d9f930524 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -95,13 +95,7 @@ ENDPROC(ret_to_user)
95ENTRY(ret_from_fork) 95ENTRY(ret_from_fork)
96 bl schedule_tail 96 bl schedule_tail
97 get_thread_info tsk 97 get_thread_info tsk
98 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
99 mov why, #1 98 mov why, #1
100 tst r1, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
101 beq ret_slow_syscall
102 mov r1, sp
103 mov r0, #1 @ trace exit [IP = 1]
104 bl syscall_trace
105 b ret_slow_syscall 99 b ret_slow_syscall
106ENDPROC(ret_from_fork) 100ENDPROC(ret_from_fork)
107 101
@@ -448,10 +442,9 @@ ENDPROC(vector_swi)
448 * context switches, and waiting for our parent to respond. 442 * context switches, and waiting for our parent to respond.
449 */ 443 */
450__sys_trace: 444__sys_trace:
451 mov r2, scno 445 mov r1, scno
452 add r1, sp, #S_OFF 446 add r0, sp, #S_OFF
453 mov r0, #0 @ trace entry [IP = 0] 447 bl syscall_trace_enter
454 bl syscall_trace
455 448
456 adr lr, BSYM(__sys_trace_return) @ return address 449 adr lr, BSYM(__sys_trace_return) @ return address
457 mov scno, r0 @ syscall number (possibly new) 450 mov scno, r0 @ syscall number (possibly new)
@@ -463,10 +456,9 @@ __sys_trace:
463 456
464__sys_trace_return: 457__sys_trace_return:
465 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 458 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
466 mov r2, scno 459 mov r1, scno
467 mov r1, sp 460 mov r0, sp
468 mov r0, #1 @ trace exit [IP = 1] 461 bl syscall_trace_exit
469 bl syscall_trace
470 b ret_slow_syscall 462 b ret_slow_syscall
471 463
472 .align 5 464 .align 5
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 835898e7d70..3db960e20cb 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -55,14 +55,6 @@
55 add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE 55 add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
56 .endm 56 .endm
57 57
58#ifdef CONFIG_XIP_KERNEL
59#define KERNEL_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
60#define KERNEL_END _edata_loc
61#else
62#define KERNEL_START KERNEL_RAM_VADDR
63#define KERNEL_END _end
64#endif
65
66/* 58/*
67 * Kernel startup entry point. 59 * Kernel startup entry point.
68 * --------------------------- 60 * ---------------------------
@@ -218,51 +210,46 @@ __create_page_tables:
218 blo 1b 210 blo 1b
219 211
220 /* 212 /*
221 * Now setup the pagetables for our kernel direct 213 * Map our RAM from the start to the end of the kernel .bss section.
222 * mapped region.
223 */ 214 */
224 mov r3, pc 215 add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
225 mov r3, r3, lsr #SECTION_SHIFT 216 ldr r6, =(_end - 1)
226 orr r3, r7, r3, lsl #SECTION_SHIFT 217 orr r3, r8, r7
227 add r0, r4, #(KERNEL_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
228 str r3, [r0, #((KERNEL_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
229 ldr r6, =(KERNEL_END - 1)
230 add r0, r0, #1 << PMD_ORDER
231 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) 218 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
2321: cmp r0, r6 2191: str r3, [r0], #1 << PMD_ORDER
233 add r3, r3, #1 << SECTION_SHIFT 220 add r3, r3, #1 << SECTION_SHIFT
234 strls r3, [r0], #1 << PMD_ORDER 221 cmp r0, r6
235 bls 1b 222 bls 1b
236 223
237#ifdef CONFIG_XIP_KERNEL 224#ifdef CONFIG_XIP_KERNEL
238 /* 225 /*
239 * Map some ram to cover our .data and .bss areas. 226 * Map the kernel image separately as it is not located in RAM.
240 */ 227 */
241 add r3, r8, #TEXT_OFFSET 228#define XIP_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
242 orr r3, r3, r7 229 mov r3, pc
243 add r0, r4, #(KERNEL_RAM_VADDR & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER) 230 mov r3, r3, lsr #SECTION_SHIFT
244 str r3, [r0, #(KERNEL_RAM_VADDR & 0x00f00000) >> (SECTION_SHIFT - PMD_ORDER)]! 231 orr r3, r7, r3, lsl #SECTION_SHIFT
245 ldr r6, =(_end - 1) 232 add r0, r4, #(XIP_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
246 add r0, r0, #4 233 str r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
234 ldr r6, =(_edata_loc - 1)
235 add r0, r0, #1 << PMD_ORDER
247 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) 236 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
2481: cmp r0, r6 2371: cmp r0, r6
249 add r3, r3, #1 << 20 238 add r3, r3, #1 << SECTION_SHIFT
250 strls r3, [r0], #4 239 strls r3, [r0], #1 << PMD_ORDER
251 bls 1b 240 bls 1b
252#endif 241#endif
253 242
254 /* 243 /*
255 * Then map boot params address in r2 or the first 1MB (2MB with LPAE) 244 * Then map boot params address in r2 if specified.
256 * of ram if boot params address is not specified.
257 */ 245 */
258 mov r0, r2, lsr #SECTION_SHIFT 246 mov r0, r2, lsr #SECTION_SHIFT
259 movs r0, r0, lsl #SECTION_SHIFT 247 movs r0, r0, lsl #SECTION_SHIFT
260 moveq r0, r8 248 subne r3, r0, r8
261 sub r3, r0, r8 249 addne r3, r3, #PAGE_OFFSET
262 add r3, r3, #PAGE_OFFSET 250 addne r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER)
263 add r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER) 251 orrne r6, r7, r0
264 orr r6, r7, r0 252 strne r6, [r3]
265 str r6, [r3]
266 253
267#ifdef CONFIG_DEBUG_LL 254#ifdef CONFIG_DEBUG_LL
268#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING) 255#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index a02eada3aa5..ab243b87118 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -47,17 +47,14 @@ static DEFINE_PER_CPU(struct pmu_hw_events, cpu_hw_events);
47/* Set at runtime when we know what CPU type we are. */ 47/* Set at runtime when we know what CPU type we are. */
48static struct arm_pmu *cpu_pmu; 48static struct arm_pmu *cpu_pmu;
49 49
50enum arm_perf_pmu_ids 50const char *perf_pmu_name(void)
51armpmu_get_pmu_id(void)
52{ 51{
53 int id = -ENODEV; 52 if (!cpu_pmu)
54 53 return NULL;
55 if (cpu_pmu != NULL)
56 id = cpu_pmu->id;
57 54
58 return id; 55 return cpu_pmu->pmu.name;
59} 56}
60EXPORT_SYMBOL_GPL(armpmu_get_pmu_id); 57EXPORT_SYMBOL_GPL(perf_pmu_name);
61 58
62int perf_num_counters(void) 59int perf_num_counters(void)
63{ 60{
@@ -760,7 +757,7 @@ init_hw_perf_events(void)
760 cpu_pmu->name, cpu_pmu->num_events); 757 cpu_pmu->name, cpu_pmu->num_events);
761 cpu_pmu_init(cpu_pmu); 758 cpu_pmu_init(cpu_pmu);
762 register_cpu_notifier(&pmu_cpu_notifier); 759 register_cpu_notifier(&pmu_cpu_notifier);
763 armpmu_register(cpu_pmu, "cpu", PERF_TYPE_RAW); 760 armpmu_register(cpu_pmu, cpu_pmu->name, PERF_TYPE_RAW);
764 } else { 761 } else {
765 pr_info("no hardware support available\n"); 762 pr_info("no hardware support available\n");
766 } 763 }
diff --git a/arch/arm/kernel/perf_event_v6.c b/arch/arm/kernel/perf_event_v6.c
index ab627a740fa..c90fcb2b696 100644
--- a/arch/arm/kernel/perf_event_v6.c
+++ b/arch/arm/kernel/perf_event_v6.c
@@ -650,7 +650,6 @@ static int armv6_map_event(struct perf_event *event)
650} 650}
651 651
652static struct arm_pmu armv6pmu = { 652static struct arm_pmu armv6pmu = {
653 .id = ARM_PERF_PMU_ID_V6,
654 .name = "v6", 653 .name = "v6",
655 .handle_irq = armv6pmu_handle_irq, 654 .handle_irq = armv6pmu_handle_irq,
656 .enable = armv6pmu_enable_event, 655 .enable = armv6pmu_enable_event,
@@ -685,7 +684,6 @@ static int armv6mpcore_map_event(struct perf_event *event)
685} 684}
686 685
687static struct arm_pmu armv6mpcore_pmu = { 686static struct arm_pmu armv6mpcore_pmu = {
688 .id = ARM_PERF_PMU_ID_V6MP,
689 .name = "v6mpcore", 687 .name = "v6mpcore",
690 .handle_irq = armv6pmu_handle_irq, 688 .handle_irq = armv6pmu_handle_irq,
691 .enable = armv6pmu_enable_event, 689 .enable = armv6pmu_enable_event,
diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index d3c53606816..f04070bd218 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -1258,7 +1258,6 @@ static u32 __init armv7_read_num_pmnc_events(void)
1258 1258
1259static struct arm_pmu *__init armv7_a8_pmu_init(void) 1259static struct arm_pmu *__init armv7_a8_pmu_init(void)
1260{ 1260{
1261 armv7pmu.id = ARM_PERF_PMU_ID_CA8;
1262 armv7pmu.name = "ARMv7 Cortex-A8"; 1261 armv7pmu.name = "ARMv7 Cortex-A8";
1263 armv7pmu.map_event = armv7_a8_map_event; 1262 armv7pmu.map_event = armv7_a8_map_event;
1264 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1263 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1267,7 +1266,6 @@ static struct arm_pmu *__init armv7_a8_pmu_init(void)
1267 1266
1268static struct arm_pmu *__init armv7_a9_pmu_init(void) 1267static struct arm_pmu *__init armv7_a9_pmu_init(void)
1269{ 1268{
1270 armv7pmu.id = ARM_PERF_PMU_ID_CA9;
1271 armv7pmu.name = "ARMv7 Cortex-A9"; 1269 armv7pmu.name = "ARMv7 Cortex-A9";
1272 armv7pmu.map_event = armv7_a9_map_event; 1270 armv7pmu.map_event = armv7_a9_map_event;
1273 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1271 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1276,7 +1274,6 @@ static struct arm_pmu *__init armv7_a9_pmu_init(void)
1276 1274
1277static struct arm_pmu *__init armv7_a5_pmu_init(void) 1275static struct arm_pmu *__init armv7_a5_pmu_init(void)
1278{ 1276{
1279 armv7pmu.id = ARM_PERF_PMU_ID_CA5;
1280 armv7pmu.name = "ARMv7 Cortex-A5"; 1277 armv7pmu.name = "ARMv7 Cortex-A5";
1281 armv7pmu.map_event = armv7_a5_map_event; 1278 armv7pmu.map_event = armv7_a5_map_event;
1282 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1279 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1285,7 +1282,6 @@ static struct arm_pmu *__init armv7_a5_pmu_init(void)
1285 1282
1286static struct arm_pmu *__init armv7_a15_pmu_init(void) 1283static struct arm_pmu *__init armv7_a15_pmu_init(void)
1287{ 1284{
1288 armv7pmu.id = ARM_PERF_PMU_ID_CA15;
1289 armv7pmu.name = "ARMv7 Cortex-A15"; 1285 armv7pmu.name = "ARMv7 Cortex-A15";
1290 armv7pmu.map_event = armv7_a15_map_event; 1286 armv7pmu.map_event = armv7_a15_map_event;
1291 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1287 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1295,7 +1291,6 @@ static struct arm_pmu *__init armv7_a15_pmu_init(void)
1295 1291
1296static struct arm_pmu *__init armv7_a7_pmu_init(void) 1292static struct arm_pmu *__init armv7_a7_pmu_init(void)
1297{ 1293{
1298 armv7pmu.id = ARM_PERF_PMU_ID_CA7;
1299 armv7pmu.name = "ARMv7 Cortex-A7"; 1294 armv7pmu.name = "ARMv7 Cortex-A7";
1300 armv7pmu.map_event = armv7_a7_map_event; 1295 armv7pmu.map_event = armv7_a7_map_event;
1301 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1296 armv7pmu.num_events = armv7_read_num_pmnc_events();
diff --git a/arch/arm/kernel/perf_event_xscale.c b/arch/arm/kernel/perf_event_xscale.c
index e34e7254e65..f759fe0bab6 100644
--- a/arch/arm/kernel/perf_event_xscale.c
+++ b/arch/arm/kernel/perf_event_xscale.c
@@ -435,7 +435,6 @@ static int xscale_map_event(struct perf_event *event)
435} 435}
436 436
437static struct arm_pmu xscale1pmu = { 437static struct arm_pmu xscale1pmu = {
438 .id = ARM_PERF_PMU_ID_XSCALE1,
439 .name = "xscale1", 438 .name = "xscale1",
440 .handle_irq = xscale1pmu_handle_irq, 439 .handle_irq = xscale1pmu_handle_irq,
441 .enable = xscale1pmu_enable_event, 440 .enable = xscale1pmu_enable_event,
@@ -803,7 +802,6 @@ xscale2pmu_write_counter(int counter, u32 val)
803} 802}
804 803
805static struct arm_pmu xscale2pmu = { 804static struct arm_pmu xscale2pmu = {
806 .id = ARM_PERF_PMU_ID_XSCALE2,
807 .name = "xscale2", 805 .name = "xscale2",
808 .handle_irq = xscale2pmu_handle_irq, 806 .handle_irq = xscale2pmu_handle_irq,
809 .enable = xscale2pmu_enable_event, 807 .enable = xscale2pmu_enable_event,
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 14e38261cd3..dab711e6e1c 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -907,16 +907,16 @@ long arch_ptrace(struct task_struct *child, long request,
907 return ret; 907 return ret;
908} 908}
909 909
910asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) 910enum ptrace_syscall_dir {
911 PTRACE_SYSCALL_ENTER = 0,
912 PTRACE_SYSCALL_EXIT,
913};
914
915static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
916 enum ptrace_syscall_dir dir)
911{ 917{
912 unsigned long ip; 918 unsigned long ip;
913 919
914 if (why)
915 audit_syscall_exit(regs);
916 else
917 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0,
918 regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
919
920 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 920 if (!test_thread_flag(TIF_SYSCALL_TRACE))
921 return scno; 921 return scno;
922 922
@@ -927,14 +927,28 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
927 * IP = 0 -> entry, =1 -> exit 927 * IP = 0 -> entry, =1 -> exit
928 */ 928 */
929 ip = regs->ARM_ip; 929 ip = regs->ARM_ip;
930 regs->ARM_ip = why; 930 regs->ARM_ip = dir;
931 931
932 if (why) 932 if (dir == PTRACE_SYSCALL_EXIT)
933 tracehook_report_syscall_exit(regs, 0); 933 tracehook_report_syscall_exit(regs, 0);
934 else if (tracehook_report_syscall_entry(regs)) 934 else if (tracehook_report_syscall_entry(regs))
935 current_thread_info()->syscall = -1; 935 current_thread_info()->syscall = -1;
936 936
937 regs->ARM_ip = ip; 937 regs->ARM_ip = ip;
938
939 return current_thread_info()->syscall; 938 return current_thread_info()->syscall;
940} 939}
940
941asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
942{
943 int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER);
944 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1,
945 regs->ARM_r2, regs->ARM_r3);
946 return ret;
947}
948
949asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno)
950{
951 int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT);
952 audit_syscall_exit(regs);
953 return ret;
954}
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 8200deaa14f..198b08456e9 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -17,11 +17,190 @@
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18#include <linux/node.h> 18#include <linux/node.h>
19#include <linux/nodemask.h> 19#include <linux/nodemask.h>
20#include <linux/of.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/slab.h>
21 23
22#include <asm/cputype.h> 24#include <asm/cputype.h>
23#include <asm/topology.h> 25#include <asm/topology.h>
24 26
27/*
28 * cpu power scale management
29 */
30
31/*
32 * cpu power table
33 * This per cpu data structure describes the relative capacity of each core.
34 * On a heteregenous system, cores don't have the same computation capacity
35 * and we reflect that difference in the cpu_power field so the scheduler can
36 * take this difference into account during load balance. A per cpu structure
37 * is preferred because each CPU updates its own cpu_power field during the
38 * load balance except for idle cores. One idle core is selected to run the
39 * rebalance_domains for all idle cores and the cpu_power can be updated
40 * during this sequence.
41 */
42static DEFINE_PER_CPU(unsigned long, cpu_scale);
43
44unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu)
45{
46 return per_cpu(cpu_scale, cpu);
47}
48
49static void set_power_scale(unsigned int cpu, unsigned long power)
50{
51 per_cpu(cpu_scale, cpu) = power;
52}
53
54#ifdef CONFIG_OF
55struct cpu_efficiency {
56 const char *compatible;
57 unsigned long efficiency;
58};
59
60/*
61 * Table of relative efficiency of each processors
62 * The efficiency value must fit in 20bit and the final
63 * cpu_scale value must be in the range
64 * 0 < cpu_scale < 3*SCHED_POWER_SCALE/2
65 * in order to return at most 1 when DIV_ROUND_CLOSEST
66 * is used to compute the capacity of a CPU.
67 * Processors that are not defined in the table,
68 * use the default SCHED_POWER_SCALE value for cpu_scale.
69 */
70struct cpu_efficiency table_efficiency[] = {
71 {"arm,cortex-a15", 3891},
72 {"arm,cortex-a7", 2048},
73 {NULL, },
74};
75
76struct cpu_capacity {
77 unsigned long hwid;
78 unsigned long capacity;
79};
80
81struct cpu_capacity *cpu_capacity;
82
83unsigned long middle_capacity = 1;
84
85/*
86 * Iterate all CPUs' descriptor in DT and compute the efficiency
87 * (as per table_efficiency). Also calculate a middle efficiency
88 * as close as possible to (max{eff_i} - min{eff_i}) / 2
89 * This is later used to scale the cpu_power field such that an
90 * 'average' CPU is of middle power. Also see the comments near
91 * table_efficiency[] and update_cpu_power().
92 */
93static void __init parse_dt_topology(void)
94{
95 struct cpu_efficiency *cpu_eff;
96 struct device_node *cn = NULL;
97 unsigned long min_capacity = (unsigned long)(-1);
98 unsigned long max_capacity = 0;
99 unsigned long capacity = 0;
100 int alloc_size, cpu = 0;
101
102 alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);
103 cpu_capacity = (struct cpu_capacity *)kzalloc(alloc_size, GFP_NOWAIT);
104
105 while ((cn = of_find_node_by_type(cn, "cpu"))) {
106 const u32 *rate, *reg;
107 int len;
108
109 if (cpu >= num_possible_cpus())
110 break;
111
112 for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
113 if (of_device_is_compatible(cn, cpu_eff->compatible))
114 break;
115
116 if (cpu_eff->compatible == NULL)
117 continue;
118
119 rate = of_get_property(cn, "clock-frequency", &len);
120 if (!rate || len != 4) {
121 pr_err("%s missing clock-frequency property\n",
122 cn->full_name);
123 continue;
124 }
125
126 reg = of_get_property(cn, "reg", &len);
127 if (!reg || len != 4) {
128 pr_err("%s missing reg property\n", cn->full_name);
129 continue;
130 }
131
132 capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
133
134 /* Save min capacity of the system */
135 if (capacity < min_capacity)
136 min_capacity = capacity;
137
138 /* Save max capacity of the system */
139 if (capacity > max_capacity)
140 max_capacity = capacity;
141
142 cpu_capacity[cpu].capacity = capacity;
143 cpu_capacity[cpu++].hwid = be32_to_cpup(reg);
144 }
145
146 if (cpu < num_possible_cpus())
147 cpu_capacity[cpu].hwid = (unsigned long)(-1);
148
149 /* If min and max capacities are equals, we bypass the update of the
150 * cpu_scale because all CPUs have the same capacity. Otherwise, we
151 * compute a middle_capacity factor that will ensure that the capacity
152 * of an 'average' CPU of the system will be as close as possible to
153 * SCHED_POWER_SCALE, which is the default value, but with the
154 * constraint explained near table_efficiency[].
155 */
156 if (min_capacity == max_capacity)
157 cpu_capacity[0].hwid = (unsigned long)(-1);
158 else if (4*max_capacity < (3*(max_capacity + min_capacity)))
159 middle_capacity = (min_capacity + max_capacity)
160 >> (SCHED_POWER_SHIFT+1);
161 else
162 middle_capacity = ((max_capacity / 3)
163 >> (SCHED_POWER_SHIFT-1)) + 1;
164
165}
166
167/*
168 * Look for a customed capacity of a CPU in the cpu_capacity table during the
169 * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the
170 * function returns directly for SMP system.
171 */
172void update_cpu_power(unsigned int cpu, unsigned long hwid)
173{
174 unsigned int idx = 0;
175
176 /* look for the cpu's hwid in the cpu capacity table */
177 for (idx = 0; idx < num_possible_cpus(); idx++) {
178 if (cpu_capacity[idx].hwid == hwid)
179 break;
180
181 if (cpu_capacity[idx].hwid == -1)
182 return;
183 }
184
185 if (idx == num_possible_cpus())
186 return;
187
188 set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
189
190 printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
191 cpu, arch_scale_freq_power(NULL, cpu));
192}
193
194#else
195static inline void parse_dt_topology(void) {}
196static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}
197#endif
198
199
200/*
201 * cpu topology management
202 */
203
25#define MPIDR_SMP_BITMASK (0x3 << 30) 204#define MPIDR_SMP_BITMASK (0x3 << 30)
26#define MPIDR_SMP_VALUE (0x2 << 30) 205#define MPIDR_SMP_VALUE (0x2 << 30)
27 206
@@ -31,6 +210,7 @@
31 * These masks reflect the current use of the affinity levels. 210 * These masks reflect the current use of the affinity levels.
32 * The affinity level can be up to 16 bits according to ARM ARM 211 * The affinity level can be up to 16 bits according to ARM ARM
33 */ 212 */
213#define MPIDR_HWID_BITMASK 0xFFFFFF
34 214
35#define MPIDR_LEVEL0_MASK 0x3 215#define MPIDR_LEVEL0_MASK 0x3
36#define MPIDR_LEVEL0_SHIFT 0 216#define MPIDR_LEVEL0_SHIFT 0
@@ -41,6 +221,9 @@
41#define MPIDR_LEVEL2_MASK 0xFF 221#define MPIDR_LEVEL2_MASK 0xFF
42#define MPIDR_LEVEL2_SHIFT 16 222#define MPIDR_LEVEL2_SHIFT 16
43 223
224/*
225 * cpu topology table
226 */
44struct cputopo_arm cpu_topology[NR_CPUS]; 227struct cputopo_arm cpu_topology[NR_CPUS];
45 228
46const struct cpumask *cpu_coregroup_mask(int cpu) 229const struct cpumask *cpu_coregroup_mask(int cpu)
@@ -48,6 +231,32 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
48 return &cpu_topology[cpu].core_sibling; 231 return &cpu_topology[cpu].core_sibling;
49} 232}
50 233
234void update_siblings_masks(unsigned int cpuid)
235{
236 struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
237 int cpu;
238
239 /* update core and thread sibling masks */
240 for_each_possible_cpu(cpu) {
241 cpu_topo = &cpu_topology[cpu];
242
243 if (cpuid_topo->socket_id != cpu_topo->socket_id)
244 continue;
245
246 cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
247 if (cpu != cpuid)
248 cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);
249
250 if (cpuid_topo->core_id != cpu_topo->core_id)
251 continue;
252
253 cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling);
254 if (cpu != cpuid)
255 cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);
256 }
257 smp_wmb();
258}
259
51/* 260/*
52 * store_cpu_topology is called at boot when only one cpu is running 261 * store_cpu_topology is called at boot when only one cpu is running
53 * and with the mutex cpu_hotplug.lock locked, when several cpus have booted, 262 * and with the mutex cpu_hotplug.lock locked, when several cpus have booted,
@@ -57,7 +266,6 @@ void store_cpu_topology(unsigned int cpuid)
57{ 266{
58 struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid]; 267 struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid];
59 unsigned int mpidr; 268 unsigned int mpidr;
60 unsigned int cpu;
61 269
62 /* If the cpu topology has been already set, just return */ 270 /* If the cpu topology has been already set, just return */
63 if (cpuid_topo->core_id != -1) 271 if (cpuid_topo->core_id != -1)
@@ -99,26 +307,9 @@ void store_cpu_topology(unsigned int cpuid)
99 cpuid_topo->socket_id = -1; 307 cpuid_topo->socket_id = -1;
100 } 308 }
101 309
102 /* update core and thread sibling masks */ 310 update_siblings_masks(cpuid);
103 for_each_possible_cpu(cpu) { 311
104 struct cputopo_arm *cpu_topo = &cpu_topology[cpu]; 312 update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
105
106 if (cpuid_topo->socket_id == cpu_topo->socket_id) {
107 cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
108 if (cpu != cpuid)
109 cpumask_set_cpu(cpu,
110 &cpuid_topo->core_sibling);
111
112 if (cpuid_topo->core_id == cpu_topo->core_id) {
113 cpumask_set_cpu(cpuid,
114 &cpu_topo->thread_sibling);
115 if (cpu != cpuid)
116 cpumask_set_cpu(cpu,
117 &cpuid_topo->thread_sibling);
118 }
119 }
120 }
121 smp_wmb();
122 313
123 printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n", 314 printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
124 cpuid, cpu_topology[cpuid].thread_id, 315 cpuid, cpu_topology[cpuid].thread_id,
@@ -134,7 +325,7 @@ void init_cpu_topology(void)
134{ 325{
135 unsigned int cpu; 326 unsigned int cpu;
136 327
137 /* init core mask */ 328 /* init core mask and power*/
138 for_each_possible_cpu(cpu) { 329 for_each_possible_cpu(cpu) {
139 struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]); 330 struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]);
140 331
@@ -143,6 +334,10 @@ void init_cpu_topology(void)
143 cpu_topo->socket_id = -1; 334 cpu_topo->socket_id = -1;
144 cpumask_clear(&cpu_topo->core_sibling); 335 cpumask_clear(&cpu_topo->core_sibling);
145 cpumask_clear(&cpu_topo->thread_sibling); 336 cpumask_clear(&cpu_topo->thread_sibling);
337
338 set_power_scale(cpu, SCHED_POWER_SCALE);
146 } 339 }
147 smp_wmb(); 340 smp_wmb();
341
342 parse_dt_topology();
148} 343}
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 3647170e9a1..8b97d739b17 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -233,9 +233,9 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
233#define S_ISA " ARM" 233#define S_ISA " ARM"
234#endif 234#endif
235 235
236static int __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs) 236static int __die(const char *str, int err, struct pt_regs *regs)
237{ 237{
238 struct task_struct *tsk = thread->task; 238 struct task_struct *tsk = current;
239 static int die_counter; 239 static int die_counter;
240 int ret; 240 int ret;
241 241
@@ -245,12 +245,12 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
245 /* trap and error numbers are mostly meaningless on ARM */ 245 /* trap and error numbers are mostly meaningless on ARM */
246 ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV); 246 ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV);
247 if (ret == NOTIFY_STOP) 247 if (ret == NOTIFY_STOP)
248 return ret; 248 return 1;
249 249
250 print_modules(); 250 print_modules();
251 __show_regs(regs); 251 __show_regs(regs);
252 printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n", 252 printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
253 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); 253 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
254 254
255 if (!user_mode(regs) || in_interrupt()) { 255 if (!user_mode(regs) || in_interrupt()) {
256 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, 256 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
@@ -259,45 +259,77 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
259 dump_instr(KERN_EMERG, regs); 259 dump_instr(KERN_EMERG, regs);
260 } 260 }
261 261
262 return ret; 262 return 0;
263} 263}
264 264
265static DEFINE_RAW_SPINLOCK(die_lock); 265static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
266static int die_owner = -1;
267static unsigned int die_nest_count;
266 268
267/* 269static unsigned long oops_begin(void)
268 * This function is protected against re-entrancy.
269 */
270void die(const char *str, struct pt_regs *regs, int err)
271{ 270{
272 struct thread_info *thread = current_thread_info(); 271 int cpu;
273 int ret; 272 unsigned long flags;
274 enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
275 273
276 oops_enter(); 274 oops_enter();
277 275
278 raw_spin_lock_irq(&die_lock); 276 /* racy, but better than risking deadlock. */
277 raw_local_irq_save(flags);
278 cpu = smp_processor_id();
279 if (!arch_spin_trylock(&die_lock)) {
280 if (cpu == die_owner)
281 /* nested oops. should stop eventually */;
282 else
283 arch_spin_lock(&die_lock);
284 }
285 die_nest_count++;
286 die_owner = cpu;
279 console_verbose(); 287 console_verbose();
280 bust_spinlocks(1); 288 bust_spinlocks(1);
281 if (!user_mode(regs)) 289 return flags;
282 bug_type = report_bug(regs->ARM_pc, regs); 290}
283 if (bug_type != BUG_TRAP_TYPE_NONE)
284 str = "Oops - BUG";
285 ret = __die(str, err, thread, regs);
286 291
287 if (regs && kexec_should_crash(thread->task)) 292static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
293{
294 if (regs && kexec_should_crash(current))
288 crash_kexec(regs); 295 crash_kexec(regs);
289 296
290 bust_spinlocks(0); 297 bust_spinlocks(0);
298 die_owner = -1;
291 add_taint(TAINT_DIE); 299 add_taint(TAINT_DIE);
292 raw_spin_unlock_irq(&die_lock); 300 die_nest_count--;
301 if (!die_nest_count)
302 /* Nest count reaches zero, release the lock. */
303 arch_spin_unlock(&die_lock);
304 raw_local_irq_restore(flags);
293 oops_exit(); 305 oops_exit();
294 306
295 if (in_interrupt()) 307 if (in_interrupt())
296 panic("Fatal exception in interrupt"); 308 panic("Fatal exception in interrupt");
297 if (panic_on_oops) 309 if (panic_on_oops)
298 panic("Fatal exception"); 310 panic("Fatal exception");
299 if (ret != NOTIFY_STOP) 311 if (signr)
300 do_exit(SIGSEGV); 312 do_exit(signr);
313}
314
315/*
316 * This function is protected against re-entrancy.
317 */
318void die(const char *str, struct pt_regs *regs, int err)
319{
320 enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
321 unsigned long flags = oops_begin();
322 int sig = SIGSEGV;
323
324 if (!user_mode(regs))
325 bug_type = report_bug(regs->ARM_pc, regs);
326 if (bug_type != BUG_TRAP_TYPE_NONE)
327 str = "Oops - BUG";
328
329 if (__die(str, err, regs))
330 sig = 0;
331
332 oops_end(flags, regs, sig);
301} 333}
302 334
303void arm_notify_die(const char *str, struct pt_regs *regs, 335void arm_notify_die(const char *str, struct pt_regs *regs,
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 992769ae259..2473fd1fd51 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -6,9 +6,8 @@
6 6
7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \ 7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \ 8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \
9 delay.o findbit.o memchr.o memcpy.o \ 9 delay.o delay-loop.o findbit.o memchr.o memcpy.o \
10 memmove.o memset.o memzero.o setbit.o \ 10 memmove.o memset.o memzero.o setbit.o \
11 strncpy_from_user.o strnlen_user.o \
12 strchr.o strrchr.o \ 11 strchr.o strrchr.o \
13 testchangebit.o testclearbit.o testsetbit.o \ 12 testchangebit.o testclearbit.o testsetbit.o \
14 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 13 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay-loop.S
index 3c9a05c8d20..36b668d8e12 100644
--- a/arch/arm/lib/delay.S
+++ b/arch/arm/lib/delay-loop.S
@@ -9,11 +9,11 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/param.h> 12#include <asm/delay.h>
13 .text 13 .text
14 14
15.LC0: .word loops_per_jiffy 15.LC0: .word loops_per_jiffy
16.LC1: .word (2199023*HZ)>>11 16.LC1: .word UDELAY_MULT
17 17
18/* 18/*
19 * r0 <= 2000 19 * r0 <= 2000
@@ -21,10 +21,10 @@
21 * HZ <= 1000 21 * HZ <= 1000
22 */ 22 */
23 23
24ENTRY(__udelay) 24ENTRY(__loop_udelay)
25 ldr r2, .LC1 25 ldr r2, .LC1
26 mul r0, r2, r0 26 mul r0, r2, r0
27ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06 27ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0x7fffff06
28 mov r1, #-1 28 mov r1, #-1
29 ldr r2, .LC0 29 ldr r2, .LC0
30 ldr r2, [r2] @ max = 0x01ffffff 30 ldr r2, [r2] @ max = 0x01ffffff
@@ -39,12 +39,10 @@ ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
39 39
40/* 40/*
41 * loops = r0 * HZ * loops_per_jiffy / 1000000 41 * loops = r0 * HZ * loops_per_jiffy / 1000000
42 *
43 * Oh, if only we had a cycle counter...
44 */ 42 */
45 43
46@ Delay routine 44@ Delay routine
47ENTRY(__delay) 45ENTRY(__loop_delay)
48 subs r0, r0, #1 46 subs r0, r0, #1
49#if 0 47#if 0
50 movls pc, lr 48 movls pc, lr
@@ -62,8 +60,8 @@ ENTRY(__delay)
62 movls pc, lr 60 movls pc, lr
63 subs r0, r0, #1 61 subs r0, r0, #1
64#endif 62#endif
65 bhi __delay 63 bhi __loop_delay
66 mov pc, lr 64 mov pc, lr
67ENDPROC(__udelay) 65ENDPROC(__loop_udelay)
68ENDPROC(__const_udelay) 66ENDPROC(__loop_const_udelay)
69ENDPROC(__delay) 67ENDPROC(__loop_delay)
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
new file mode 100644
index 00000000000..d6dacc69254
--- /dev/null
+++ b/arch/arm/lib/delay.c
@@ -0,0 +1,71 @@
1/*
2 * Delay loops based on the OpenRISC implementation.
3 *
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Will Deacon <will.deacon@arm.com>
20 */
21
22#include <linux/delay.h>
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/timex.h>
27
28/*
29 * Default to the loop-based delay implementation.
30 */
31struct arm_delay_ops arm_delay_ops = {
32 .delay = __loop_delay,
33 .const_udelay = __loop_const_udelay,
34 .udelay = __loop_udelay,
35};
36
37#ifdef ARCH_HAS_READ_CURRENT_TIMER
38static void __timer_delay(unsigned long cycles)
39{
40 cycles_t start = get_cycles();
41
42 while ((get_cycles() - start) < cycles)
43 cpu_relax();
44}
45
46static void __timer_const_udelay(unsigned long xloops)
47{
48 unsigned long long loops = xloops;
49 loops *= loops_per_jiffy;
50 __timer_delay(loops >> UDELAY_SHIFT);
51}
52
53static void __timer_udelay(unsigned long usecs)
54{
55 __timer_const_udelay(usecs * UDELAY_MULT);
56}
57
58void __init init_current_timer_delay(unsigned long freq)
59{
60 pr_info("Switching to timer-based delay loop\n");
61 lpj_fine = freq / HZ;
62 arm_delay_ops.delay = __timer_delay;
63 arm_delay_ops.const_udelay = __timer_const_udelay;
64 arm_delay_ops.udelay = __timer_udelay;
65}
66
67unsigned long __cpuinit calibrate_delay_is_known(void)
68{
69 return lpj_fine;
70}
71#endif
diff --git a/arch/arm/lib/strncpy_from_user.S b/arch/arm/lib/strncpy_from_user.S
deleted file mode 100644
index f202d7bd164..00000000000
--- a/arch/arm/lib/strncpy_from_user.S
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * linux/arch/arm/lib/strncpy_from_user.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/errno.h>
13
14 .text
15 .align 5
16
17/*
18 * Copy a string from user space to kernel space.
19 * r0 = dst, r1 = src, r2 = byte length
20 * returns the number of characters copied (strlen of copied string),
21 * -EFAULT on exception, or "len" if we fill the whole buffer
22 */
23ENTRY(__strncpy_from_user)
24 mov ip, r1
251: subs r2, r2, #1
26 ldrusr r3, r1, 1, pl
27 bmi 2f
28 strb r3, [r0], #1
29 teq r3, #0
30 bne 1b
31 sub r1, r1, #1 @ take NUL character out of count
322: sub r0, r1, ip
33 mov pc, lr
34ENDPROC(__strncpy_from_user)
35
36 .pushsection .fixup,"ax"
37 .align 0
389001: mov r3, #0
39 strb r3, [r0, #0] @ null terminate
40 mov r0, #-EFAULT
41 mov pc, lr
42 .popsection
43
diff --git a/arch/arm/lib/strnlen_user.S b/arch/arm/lib/strnlen_user.S
deleted file mode 100644
index 0ecbb459c4f..00000000000
--- a/arch/arm/lib/strnlen_user.S
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * linux/arch/arm/lib/strnlen_user.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/errno.h>
13
14 .text
15 .align 5
16
17/* Prototype: unsigned long __strnlen_user(const char *str, long n)
18 * Purpose : get length of a string in user memory
19 * Params : str - address of string in user memory
20 * Returns : length of string *including terminator*
21 * or zero on exception, or n + 1 if too long
22 */
23ENTRY(__strnlen_user)
24 mov r2, r0
251:
26 ldrusr r3, r0, 1
27 teq r3, #0
28 beq 2f
29 subs r1, r1, #1
30 bne 1b
31 add r0, r0, #1
322: sub r0, r0, r2
33 mov pc, lr
34ENDPROC(__strnlen_user)
35
36 .pushsection .fixup,"ax"
37 .align 0
389001: mov r0, #0
39 mov pc, lr
40 .popsection
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index e9fafcf163d..373c3c00d24 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -119,7 +119,9 @@ static __init void exynos_pm_add_dev_to_genpd(struct platform_device *pdev,
119 struct exynos_pm_domain *pd) 119 struct exynos_pm_domain *pd)
120{ 120{
121 if (pdev->dev.bus) { 121 if (pdev->dev.bus) {
122 if (pm_genpd_add_device(&pd->pd, &pdev->dev)) 122 if (!pm_genpd_add_device(&pd->pd, &pdev->dev))
123 pm_genpd_dev_need_restore(&pdev->dev, true);
124 else
123 pr_info("%s: error in adding %s device to %s power" 125 pr_info("%s: error in adding %s device to %s power"
124 "domain\n", __func__, dev_name(&pdev->dev), 126 "domain\n", __func__, dev_name(&pdev->dev),
125 pd->name); 127 pd->name);
@@ -151,9 +153,12 @@ static __init int exynos4_pm_init_power_domain(void)
151 if (of_have_populated_dt()) 153 if (of_have_populated_dt())
152 return exynos_pm_dt_parse_domains(); 154 return exynos_pm_dt_parse_domains();
153 155
154 for (idx = 0; idx < ARRAY_SIZE(exynos4_pm_domains); idx++) 156 for (idx = 0; idx < ARRAY_SIZE(exynos4_pm_domains); idx++) {
155 pm_genpd_init(&exynos4_pm_domains[idx]->pd, NULL, 157 struct exynos_pm_domain *pd = exynos4_pm_domains[idx];
156 exynos4_pm_domains[idx]->is_off); 158 int on = __raw_readl(pd->base + 0x4) & S5P_INT_LOCAL_PWR_EN;
159
160 pm_genpd_init(&pd->pd, NULL, !on);
161 }
157 162
158#ifdef CONFIG_S5P_DEV_FIMD0 163#ifdef CONFIG_S5P_DEV_FIMD0
159 exynos_pm_add_dev_to_genpd(&s5p_device_fimd0, &exynos4_pd_lcd0); 164 exynos_pm_add_dev_to_genpd(&s5p_device_fimd0, &exynos4_pd_lcd0);
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index db0117ec55f..e012dc8391c 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -127,7 +127,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
127 * the boot monitor to read the system wide flags register, 127 * the boot monitor to read the system wide flags register,
128 * and branch to the address found there. 128 * and branch to the address found there.
129 */ 129 */
130 gic_raise_softirq(cpumask_of(cpu), 1); 130 gic_raise_softirq(cpumask_of(cpu), 0);
131 131
132 timeout = jiffies + (1 * HZ); 132 timeout = jiffies + (1 * HZ);
133 while (time_before(jiffies, timeout)) { 133 while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h
index f7b58609bad..6227e9505c2 100644
--- a/arch/arm/mach-omap2/clockdomain.h
+++ b/arch/arm/mach-omap2/clockdomain.h
@@ -31,12 +31,16 @@
31 * 31 *
32 * CLKDM_NO_AUTODEPS: Prevent "autodeps" from being added/removed from this 32 * CLKDM_NO_AUTODEPS: Prevent "autodeps" from being added/removed from this
33 * clockdomain. (Currently, this applies to OMAP3 clockdomains only.) 33 * clockdomain. (Currently, this applies to OMAP3 clockdomains only.)
34 * CLKDM_ACTIVE_WITH_MPU: The PRCM guarantees that this clockdomain is
35 * active whenever the MPU is active. True for interconnects and
36 * the WKUP clockdomains.
34 */ 37 */
35#define CLKDM_CAN_FORCE_SLEEP (1 << 0) 38#define CLKDM_CAN_FORCE_SLEEP (1 << 0)
36#define CLKDM_CAN_FORCE_WAKEUP (1 << 1) 39#define CLKDM_CAN_FORCE_WAKEUP (1 << 1)
37#define CLKDM_CAN_ENABLE_AUTO (1 << 2) 40#define CLKDM_CAN_ENABLE_AUTO (1 << 2)
38#define CLKDM_CAN_DISABLE_AUTO (1 << 3) 41#define CLKDM_CAN_DISABLE_AUTO (1 << 3)
39#define CLKDM_NO_AUTODEPS (1 << 4) 42#define CLKDM_NO_AUTODEPS (1 << 4)
43#define CLKDM_ACTIVE_WITH_MPU (1 << 5)
40 44
41#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO) 45#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
42#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP) 46#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
diff --git a/arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c b/arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c
index 839145e1cfb..4972219653c 100644
--- a/arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c
+++ b/arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c
@@ -88,4 +88,5 @@ struct clockdomain wkup_common_clkdm = {
88 .name = "wkup_clkdm", 88 .name = "wkup_clkdm",
89 .pwrdm = { .name = "wkup_pwrdm" }, 89 .pwrdm = { .name = "wkup_pwrdm" },
90 .dep_bit = OMAP_EN_WKUP_SHIFT, 90 .dep_bit = OMAP_EN_WKUP_SHIFT,
91 .flags = CLKDM_ACTIVE_WITH_MPU,
91}; 92};
diff --git a/arch/arm/mach-omap2/clockdomains44xx_data.c b/arch/arm/mach-omap2/clockdomains44xx_data.c
index c5342584749..7f2133abe7d 100644
--- a/arch/arm/mach-omap2/clockdomains44xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains44xx_data.c
@@ -381,7 +381,7 @@ static struct clockdomain l4_wkup_44xx_clkdm = {
381 .cm_inst = OMAP4430_PRM_WKUP_CM_INST, 381 .cm_inst = OMAP4430_PRM_WKUP_CM_INST,
382 .clkdm_offs = OMAP4430_PRM_WKUP_CM_WKUP_CDOFFS, 382 .clkdm_offs = OMAP4430_PRM_WKUP_CM_WKUP_CDOFFS,
383 .dep_bit = OMAP4430_L4WKUP_STATDEP_SHIFT, 383 .dep_bit = OMAP4430_L4WKUP_STATDEP_SHIFT,
384 .flags = CLKDM_CAN_HWSUP, 384 .flags = CLKDM_CAN_HWSUP | CLKDM_ACTIVE_WITH_MPU,
385}; 385};
386 386
387static struct clockdomain emu_sys_44xx_clkdm = { 387static struct clockdomain emu_sys_44xx_clkdm = {
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index deffbf1c962..596eb70d37b 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -111,7 +111,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
111 booted = true; 111 booted = true;
112 } 112 }
113 113
114 gic_raise_softirq(cpumask_of(cpu), 1); 114 gic_raise_softirq(cpumask_of(cpu), 0);
115 115
116 /* 116 /*
117 * Now the secondary core is starting up let it run its 117 * Now the secondary core is starting up let it run its
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 773193670ea..2d710f50fca 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1124,15 +1124,18 @@ static struct omap_hwmod_addr_space * __init _find_mpu_rt_addr_space(struct omap
1124 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG 1124 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG
1125 * @oh: struct omap_hwmod * 1125 * @oh: struct omap_hwmod *
1126 * 1126 *
1127 * If module is marked as SWSUP_SIDLE, force the module out of slave 1127 * Ensure that the OCP_SYSCONFIG register for the IP block represented
1128 * idle; otherwise, configure it for smart-idle. If module is marked 1128 * by @oh is set to indicate to the PRCM that the IP block is active.
1129 * as SWSUP_MSUSPEND, force the module out of master standby; 1129 * Usually this means placing the module into smart-idle mode and
1130 * otherwise, configure it for smart-standby. No return value. 1130 * smart-standby, but if there is a bug in the automatic idle handling
1131 * for the IP block, it may need to be placed into the force-idle or
1132 * no-idle variants of these modes. No return value.
1131 */ 1133 */
1132static void _enable_sysc(struct omap_hwmod *oh) 1134static void _enable_sysc(struct omap_hwmod *oh)
1133{ 1135{
1134 u8 idlemode, sf; 1136 u8 idlemode, sf;
1135 u32 v; 1137 u32 v;
1138 bool clkdm_act;
1136 1139
1137 if (!oh->class->sysc) 1140 if (!oh->class->sysc)
1138 return; 1141 return;
@@ -1141,8 +1144,16 @@ static void _enable_sysc(struct omap_hwmod *oh)
1141 sf = oh->class->sysc->sysc_flags; 1144 sf = oh->class->sysc->sysc_flags;
1142 1145
1143 if (sf & SYSC_HAS_SIDLEMODE) { 1146 if (sf & SYSC_HAS_SIDLEMODE) {
1144 idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? 1147 clkdm_act = ((oh->clkdm &&
1145 HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; 1148 oh->clkdm->flags & CLKDM_ACTIVE_WITH_MPU) ||
1149 (oh->_clk && oh->_clk->clkdm &&
1150 oh->_clk->clkdm->flags & CLKDM_ACTIVE_WITH_MPU));
1151 if (clkdm_act && !(oh->class->sysc->idlemodes &
1152 (SIDLE_SMART | SIDLE_SMART_WKUP)))
1153 idlemode = HWMOD_IDLEMODE_FORCE;
1154 else
1155 idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ?
1156 HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART;
1146 _set_slave_idlemode(oh, idlemode, &v); 1157 _set_slave_idlemode(oh, idlemode, &v);
1147 } 1158 }
1148 1159
@@ -1208,8 +1219,13 @@ static void _idle_sysc(struct omap_hwmod *oh)
1208 sf = oh->class->sysc->sysc_flags; 1219 sf = oh->class->sysc->sysc_flags;
1209 1220
1210 if (sf & SYSC_HAS_SIDLEMODE) { 1221 if (sf & SYSC_HAS_SIDLEMODE) {
1211 idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? 1222 /* XXX What about HWMOD_IDLEMODE_SMART_WKUP? */
1212 HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; 1223 if (oh->flags & HWMOD_SWSUP_SIDLE ||
1224 !(oh->class->sysc->idlemodes &
1225 (SIDLE_SMART | SIDLE_SMART_WKUP)))
1226 idlemode = HWMOD_IDLEMODE_FORCE;
1227 else
1228 idlemode = HWMOD_IDLEMODE_SMART;
1213 _set_slave_idlemode(oh, idlemode, &v); 1229 _set_slave_idlemode(oh, idlemode, &v);
1214 } 1230 }
1215 1231
diff --git a/arch/arm/mach-pxa/include/mach/regs-ost.h b/arch/arm/mach-pxa/include/mach/regs-ost.h
index a3e5f86ef67..628819995c5 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ost.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ost.h
@@ -7,17 +7,17 @@
7 * OS Timer & Match Registers 7 * OS Timer & Match Registers
8 */ 8 */
9 9
10#define OSMR0 __REG(0x40A00000) /* */ 10#define OSMR0 io_p2v(0x40A00000) /* */
11#define OSMR1 __REG(0x40A00004) /* */ 11#define OSMR1 io_p2v(0x40A00004) /* */
12#define OSMR2 __REG(0x40A00008) /* */ 12#define OSMR2 io_p2v(0x40A00008) /* */
13#define OSMR3 __REG(0x40A0000C) /* */ 13#define OSMR3 io_p2v(0x40A0000C) /* */
14#define OSMR4 __REG(0x40A00080) /* */ 14#define OSMR4 io_p2v(0x40A00080) /* */
15#define OSCR __REG(0x40A00010) /* OS Timer Counter Register */ 15#define OSCR io_p2v(0x40A00010) /* OS Timer Counter Register */
16#define OSCR4 __REG(0x40A00040) /* OS Timer Counter Register */ 16#define OSCR4 io_p2v(0x40A00040) /* OS Timer Counter Register */
17#define OMCR4 __REG(0x40A000C0) /* */ 17#define OMCR4 io_p2v(0x40A000C0) /* */
18#define OSSR __REG(0x40A00014) /* OS Timer Status Register */ 18#define OSSR io_p2v(0x40A00014) /* OS Timer Status Register */
19#define OWER __REG(0x40A00018) /* OS Timer Watchdog Enable Register */ 19#define OWER io_p2v(0x40A00018) /* OS Timer Watchdog Enable Register */
20#define OIER __REG(0x40A0001C) /* OS Timer Interrupt Enable Register */ 20#define OIER io_p2v(0x40A0001C) /* OS Timer Interrupt Enable Register */
21 21
22#define OSSR_M3 (1 << 3) /* Match status channel 3 */ 22#define OSSR_M3 (1 << 3) /* Match status channel 3 */
23#define OSSR_M2 (1 << 2) /* Match status channel 2 */ 23#define OSSR_M2 (1 << 2) /* Match status channel 2 */
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index b4528899ef0..3fab583755d 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -77,9 +77,10 @@ static void do_gpio_reset(void)
77static void do_hw_reset(void) 77static void do_hw_reset(void)
78{ 78{
79 /* Initialize the watchdog and let it fire */ 79 /* Initialize the watchdog and let it fire */
80 OWER = OWER_WME; 80 writel_relaxed(OWER_WME, OWER);
81 OSSR = OSSR_M3; 81 writel_relaxed(OSSR_M3, OSSR);
82 OSMR3 = OSCR + 368640; /* ... in 100 ms */ 82 /* ... in 100 ms */
83 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
83} 84}
84 85
85void pxa_restart(char mode, const char *cmd) 86void pxa_restart(char mode, const char *cmd)
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 3d6c9bd90de..4bc47d63698 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -35,7 +35,7 @@
35 35
36static u32 notrace pxa_read_sched_clock(void) 36static u32 notrace pxa_read_sched_clock(void)
37{ 37{
38 return OSCR; 38 return readl_relaxed(OSCR);
39} 39}
40 40
41 41
@@ -47,8 +47,8 @@ pxa_ost0_interrupt(int irq, void *dev_id)
47 struct clock_event_device *c = dev_id; 47 struct clock_event_device *c = dev_id;
48 48
49 /* Disarm the compare/match, signal the event. */ 49 /* Disarm the compare/match, signal the event. */
50 OIER &= ~OIER_E0; 50 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
51 OSSR = OSSR_M0; 51 writel_relaxed(OSSR_M0, OSSR);
52 c->event_handler(c); 52 c->event_handler(c);
53 53
54 return IRQ_HANDLED; 54 return IRQ_HANDLED;
@@ -59,10 +59,10 @@ pxa_osmr0_set_next_event(unsigned long delta, struct clock_event_device *dev)
59{ 59{
60 unsigned long next, oscr; 60 unsigned long next, oscr;
61 61
62 OIER |= OIER_E0; 62 writel_relaxed(readl_relaxed(OIER) | OIER_E0, OIER);
63 next = OSCR + delta; 63 next = readl_relaxed(OSCR) + delta;
64 OSMR0 = next; 64 writel_relaxed(next, OSMR0);
65 oscr = OSCR; 65 oscr = readl_relaxed(OSCR);
66 66
67 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0; 67 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0;
68} 68}
@@ -72,15 +72,15 @@ pxa_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *dev)
72{ 72{
73 switch (mode) { 73 switch (mode) {
74 case CLOCK_EVT_MODE_ONESHOT: 74 case CLOCK_EVT_MODE_ONESHOT:
75 OIER &= ~OIER_E0; 75 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
76 OSSR = OSSR_M0; 76 writel_relaxed(OSSR_M0, OSSR);
77 break; 77 break;
78 78
79 case CLOCK_EVT_MODE_UNUSED: 79 case CLOCK_EVT_MODE_UNUSED:
80 case CLOCK_EVT_MODE_SHUTDOWN: 80 case CLOCK_EVT_MODE_SHUTDOWN:
81 /* initializing, released, or preparing for suspend */ 81 /* initializing, released, or preparing for suspend */
82 OIER &= ~OIER_E0; 82 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
83 OSSR = OSSR_M0; 83 writel_relaxed(OSSR_M0, OSSR);
84 break; 84 break;
85 85
86 case CLOCK_EVT_MODE_RESUME: 86 case CLOCK_EVT_MODE_RESUME:
@@ -108,8 +108,8 @@ static void __init pxa_timer_init(void)
108{ 108{
109 unsigned long clock_tick_rate = get_clock_tick_rate(); 109 unsigned long clock_tick_rate = get_clock_tick_rate();
110 110
111 OIER = 0; 111 writel_relaxed(0, OIER);
112 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 112 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
113 113
114 setup_sched_clock(pxa_read_sched_clock, 32, clock_tick_rate); 114 setup_sched_clock(pxa_read_sched_clock, 32, clock_tick_rate);
115 115
@@ -122,7 +122,7 @@ static void __init pxa_timer_init(void)
122 122
123 setup_irq(IRQ_OST0, &pxa_ost0_irq); 123 setup_irq(IRQ_OST0, &pxa_ost0_irq);
124 124
125 clocksource_mmio_init(&OSCR, "oscr0", clock_tick_rate, 200, 32, 125 clocksource_mmio_init(OSCR, "oscr0", clock_tick_rate, 200, 32,
126 clocksource_mmio_readl_up); 126 clocksource_mmio_readl_up);
127 clockevents_register_device(&ckevt_pxa_osmr0); 127 clockevents_register_device(&ckevt_pxa_osmr0);
128} 128}
@@ -132,12 +132,12 @@ static unsigned long osmr[4], oier, oscr;
132 132
133static void pxa_timer_suspend(void) 133static void pxa_timer_suspend(void)
134{ 134{
135 osmr[0] = OSMR0; 135 osmr[0] = readl_relaxed(OSMR0);
136 osmr[1] = OSMR1; 136 osmr[1] = readl_relaxed(OSMR1);
137 osmr[2] = OSMR2; 137 osmr[2] = readl_relaxed(OSMR2);
138 osmr[3] = OSMR3; 138 osmr[3] = readl_relaxed(OSMR3);
139 oier = OIER; 139 oier = readl_relaxed(OIER);
140 oscr = OSCR; 140 oscr = readl_relaxed(OSCR);
141} 141}
142 142
143static void pxa_timer_resume(void) 143static void pxa_timer_resume(void)
@@ -151,12 +151,12 @@ static void pxa_timer_resume(void)
151 if (osmr[0] - oscr < MIN_OSCR_DELTA) 151 if (osmr[0] - oscr < MIN_OSCR_DELTA)
152 osmr[0] += MIN_OSCR_DELTA; 152 osmr[0] += MIN_OSCR_DELTA;
153 153
154 OSMR0 = osmr[0]; 154 writel_relaxed(osmr[0], OSMR0);
155 OSMR1 = osmr[1]; 155 writel_relaxed(osmr[1], OSMR1);
156 OSMR2 = osmr[2]; 156 writel_relaxed(osmr[2], OSMR2);
157 OSMR3 = osmr[3]; 157 writel_relaxed(osmr[3], OSMR3);
158 OIER = oier; 158 writel_relaxed(oier, OIER);
159 OSCR = oscr; 159 writel_relaxed(oscr, OSCR);
160} 160}
161#else 161#else
162#define pxa_timer_suspend NULL 162#define pxa_timer_suspend NULL
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2440.c b/arch/arm/mach-s3c24xx/clock-s3c2440.c
index 414364eb426..cb2883d553b 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2440.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2440.c
@@ -106,7 +106,7 @@ static struct clk s3c2440_clk_cam_upll = {
106static struct clk s3c2440_clk_ac97 = { 106static struct clk s3c2440_clk_ac97 = {
107 .name = "ac97", 107 .name = "ac97",
108 .enable = s3c2410_clkcon_enable, 108 .enable = s3c2410_clkcon_enable,
109 .ctrlbit = S3C2440_CLKCON_CAMERA, 109 .ctrlbit = S3C2440_CLKCON_AC97,
110}; 110};
111 111
112static unsigned long s3c2440_fclk_n_getrate(struct clk *clk) 112static unsigned long s3c2440_fclk_n_getrate(struct clk *clk)
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index d1dc7f1a239..d673211f121 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -362,7 +362,7 @@ static void __init assabet_init(void)
362static void __init map_sa1100_gpio_regs( void ) 362static void __init map_sa1100_gpio_regs( void )
363{ 363{
364 unsigned long phys = __PREG(GPLR) & PMD_MASK; 364 unsigned long phys = __PREG(GPLR) & PMD_MASK;
365 unsigned long virt = io_p2v(phys); 365 unsigned long virt = (unsigned long)io_p2v(phys);
366 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO); 366 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
367 pmd_t *pmd; 367 pmd_t *pmd;
368 368
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index 19b2053f5af..e8f4d1e1923 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -87,6 +87,7 @@
87#include <linux/types.h> 87#include <linux/types.h>
88#include <linux/init.h> 88#include <linux/init.h>
89#include <linux/cpufreq.h> 89#include <linux/cpufreq.h>
90#include <linux/io.h>
90 91
91#include <asm/cputype.h> 92#include <asm/cputype.h>
92 93
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c
index 675bf8ef97e..48c45b0c92b 100644
--- a/arch/arm/mach-sa1100/cpu-sa1110.c
+++ b/arch/arm/mach-sa1100/cpu-sa1110.c
@@ -19,6 +19,7 @@
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/io.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
24#include <linux/types.h> 25#include <linux/types.h>
diff --git a/arch/arm/mach-sa1100/include/mach/SA-1100.h b/arch/arm/mach-sa1100/include/mach/SA-1100.h
index 3f2d1b60188..0ac6cc08a19 100644
--- a/arch/arm/mach-sa1100/include/mach/SA-1100.h
+++ b/arch/arm/mach-sa1100/include/mach/SA-1100.h
@@ -830,14 +830,14 @@
830 * (read/write). 830 * (read/write).
831 */ 831 */
832 832
833#define OSMR0 __REG(0x90000000) /* OS timer Match Reg. 0 */ 833#define OSMR0 io_p2v(0x90000000) /* OS timer Match Reg. 0 */
834#define OSMR1 __REG(0x90000004) /* OS timer Match Reg. 1 */ 834#define OSMR1 io_p2v(0x90000004) /* OS timer Match Reg. 1 */
835#define OSMR2 __REG(0x90000008) /* OS timer Match Reg. 2 */ 835#define OSMR2 io_p2v(0x90000008) /* OS timer Match Reg. 2 */
836#define OSMR3 __REG(0x9000000c) /* OS timer Match Reg. 3 */ 836#define OSMR3 io_p2v(0x9000000c) /* OS timer Match Reg. 3 */
837#define OSCR __REG(0x90000010) /* OS timer Counter Reg. */ 837#define OSCR io_p2v(0x90000010) /* OS timer Counter Reg. */
838#define OSSR __REG(0x90000014 ) /* OS timer Status Reg. */ 838#define OSSR io_p2v(0x90000014) /* OS timer Status Reg. */
839#define OWER __REG(0x90000018 ) /* OS timer Watch-dog Enable Reg. */ 839#define OWER io_p2v(0x90000018) /* OS timer Watch-dog Enable Reg. */
840#define OIER __REG(0x9000001C ) /* OS timer Interrupt Enable Reg. */ 840#define OIER io_p2v(0x9000001C) /* OS timer Interrupt Enable Reg. */
841 841
842#define OSSR_M(Nb) /* Match detected [0..3] */ \ 842#define OSSR_M(Nb) /* Match detected [0..3] */ \
843 (0x00000001 << (Nb)) 843 (0x00000001 << (Nb))
diff --git a/arch/arm/mach-sa1100/include/mach/gpio.h b/arch/arm/mach-sa1100/include/mach/gpio.h
index a38fc4f5424..6a9eecf3137 100644
--- a/arch/arm/mach-sa1100/include/mach/gpio.h
+++ b/arch/arm/mach-sa1100/include/mach/gpio.h
@@ -24,6 +24,7 @@
24#ifndef __ASM_ARCH_SA1100_GPIO_H 24#ifndef __ASM_ARCH_SA1100_GPIO_H
25#define __ASM_ARCH_SA1100_GPIO_H 25#define __ASM_ARCH_SA1100_GPIO_H
26 26
27#include <linux/io.h>
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/irq.h> 29#include <asm/irq.h>
29#include <asm-generic/gpio.h> 30#include <asm-generic/gpio.h>
diff --git a/arch/arm/mach-sa1100/include/mach/hardware.h b/arch/arm/mach-sa1100/include/mach/hardware.h
index 99f5856d8de..cbedd75a9d6 100644
--- a/arch/arm/mach-sa1100/include/mach/hardware.h
+++ b/arch/arm/mach-sa1100/include/mach/hardware.h
@@ -32,7 +32,7 @@
32#define PIO_START 0x80000000 /* physical start of IO space */ 32#define PIO_START 0x80000000 /* physical start of IO space */
33 33
34#define io_p2v( x ) \ 34#define io_p2v( x ) \
35 ( (((x)&0x00ffffff) | (((x)&0x30000000)>>VIO_SHIFT)) + VIO_BASE ) 35 IOMEM( (((x)&0x00ffffff) | (((x)&0x30000000)>>VIO_SHIFT)) + VIO_BASE )
36#define io_v2p( x ) \ 36#define io_v2p( x ) \
37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START ) 37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START )
38 38
@@ -47,6 +47,8 @@
47#define CPU_SA1110_ID (0x6901b110) 47#define CPU_SA1110_ID (0x6901b110)
48#define CPU_SA1110_MASK (0xfffffff0) 48#define CPU_SA1110_MASK (0xfffffff0)
49 49
50#define __MREG(x) IOMEM(io_p2v(x))
51
50#ifndef __ASSEMBLY__ 52#ifndef __ASSEMBLY__
51 53
52#include <asm/cputype.h> 54#include <asm/cputype.h>
@@ -56,7 +58,7 @@
56#define cpu_is_sa1100() ((read_cpuid_id() & CPU_SA1100_MASK) == CPU_SA1100_ID) 58#define cpu_is_sa1100() ((read_cpuid_id() & CPU_SA1100_MASK) == CPU_SA1100_ID)
57#define cpu_is_sa1110() ((read_cpuid_id() & CPU_SA1110_MASK) == CPU_SA1110_ID) 59#define cpu_is_sa1110() ((read_cpuid_id() & CPU_SA1110_MASK) == CPU_SA1110_ID)
58 60
59# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 61# define __REG(x) (*((volatile unsigned long __iomem *)io_p2v(x)))
60# define __PREG(x) (io_v2p((unsigned long)&(x))) 62# define __PREG(x) (io_v2p((unsigned long)&(x)))
61 63
62static inline unsigned long get_clock_tick_rate(void) 64static inline unsigned long get_clock_tick_rate(void)
diff --git a/arch/arm/mach-sa1100/include/mach/uncompress.h b/arch/arm/mach-sa1100/include/mach/uncompress.h
index 6cb39ddde65..5cf71da60e4 100644
--- a/arch/arm/mach-sa1100/include/mach/uncompress.h
+++ b/arch/arm/mach-sa1100/include/mach/uncompress.h
@@ -8,6 +8,8 @@
8 8
9#include "hardware.h" 9#include "hardware.h"
10 10
11#define IOMEM(x) (x)
12
11/* 13/*
12 * The following code assumes the serial port has already been 14 * The following code assumes the serial port has already been
13 * initialized by the bootloader. We search for the first enabled 15 * initialized by the bootloader. We search for the first enabled
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index 516ccc25d7f..2124f1fc2fb 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/io.h>
15#include <linux/irq.h> 16#include <linux/irq.h>
16#include <linux/ioport.h> 17#include <linux/ioport.h>
17#include <linux/syscore_ops.h> 18#include <linux/syscore_ops.h>
diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index b412fc09c80..7f07f08d896 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/jornada720.h> 24#include <mach/jornada720.h>
diff --git a/arch/arm/mach-sa1100/leds-cerf.c b/arch/arm/mach-sa1100/leds-cerf.c
index 040540fb7d8..30fc3b2bf55 100644
--- a/arch/arm/mach-sa1100/leds-cerf.c
+++ b/arch/arm/mach-sa1100/leds-cerf.c
@@ -4,6 +4,7 @@
4 * Author: ??? 4 * Author: ???
5 */ 5 */
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/io.h>
7 8
8#include <mach/hardware.h> 9#include <mach/hardware.h>
9#include <asm/leds.h> 10#include <asm/leds.h>
diff --git a/arch/arm/mach-sa1100/leds-lart.c b/arch/arm/mach-sa1100/leds-lart.c
index a51830c60e5..50a5b143b46 100644
--- a/arch/arm/mach-sa1100/leds-lart.c
+++ b/arch/arm/mach-sa1100/leds-lart.c
@@ -10,6 +10,7 @@
10 * pace of the LED. 10 * pace of the LED.
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13 14
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <asm/leds.h> 16#include <asm/leds.h>
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index 690cf0ce5c0..6645d1e31f1 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -23,6 +23,7 @@
23 * Storage is local on the stack now. 23 * Storage is local on the stack now.
24 */ 24 */
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/io.h>
26#include <linux/suspend.h> 27#include <linux/suspend.h>
27#include <linux/errno.h> 28#include <linux/errno.h>
28#include <linux/time.h> 29#include <linux/time.h>
diff --git a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S
index 30cc6721665..85863741ef8 100644
--- a/arch/arm/mach-sa1100/sleep.S
+++ b/arch/arm/mach-sa1100/sleep.S
@@ -38,9 +38,9 @@ ENTRY(sa1100_finish_suspend)
38 orr r4, r4, #MDREFR_K1DB2 38 orr r4, r4, #MDREFR_K1DB2
39 ldr r5, =PPCR 39 ldr r5, =PPCR
40 40
41 @ Pre-load __udelay into the I-cache 41 @ Pre-load __loop_udelay into the I-cache
42 mov r0, #1 42 mov r0, #1
43 bl __udelay 43 bl __loop_udelay
44 mov r0, r0 44 mov r0, r0
45 45
46 @ The following must all exist in a single cache line to 46 @ The following must all exist in a single cache line to
@@ -53,11 +53,11 @@ ENTRY(sa1100_finish_suspend)
53 @ delay 90us and set CPU PLL to lowest speed 53 @ delay 90us and set CPU PLL to lowest speed
54 @ fixes resume problem on high speed SA1110 54 @ fixes resume problem on high speed SA1110
55 mov r0, #90 55 mov r0, #90
56 bl __udelay 56 bl __loop_udelay
57 mov r1, #0 57 mov r1, #0
58 str r1, [r5] 58 str r1, [r5]
59 mov r0, #90 59 mov r0, #90
60 bl __udelay 60 bl __loop_udelay
61 61
62 /* 62 /*
63 * SA1110 SDRAM controller workaround. register values: 63 * SA1110 SDRAM controller workaround. register values:
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 6af26e8d55e..80702c9ecc7 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -22,7 +22,7 @@
22 22
23static u32 notrace sa1100_read_sched_clock(void) 23static u32 notrace sa1100_read_sched_clock(void)
24{ 24{
25 return OSCR; 25 return readl_relaxed(OSCR);
26} 26}
27 27
28#define MIN_OSCR_DELTA 2 28#define MIN_OSCR_DELTA 2
@@ -32,8 +32,8 @@ static irqreturn_t sa1100_ost0_interrupt(int irq, void *dev_id)
32 struct clock_event_device *c = dev_id; 32 struct clock_event_device *c = dev_id;
33 33
34 /* Disarm the compare/match, signal the event. */ 34 /* Disarm the compare/match, signal the event. */
35 OIER &= ~OIER_E0; 35 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
36 OSSR = OSSR_M0; 36 writel_relaxed(OSSR_M0, OSSR);
37 c->event_handler(c); 37 c->event_handler(c);
38 38
39 return IRQ_HANDLED; 39 return IRQ_HANDLED;
@@ -44,10 +44,10 @@ sa1100_osmr0_set_next_event(unsigned long delta, struct clock_event_device *c)
44{ 44{
45 unsigned long next, oscr; 45 unsigned long next, oscr;
46 46
47 OIER |= OIER_E0; 47 writel_relaxed(readl_relaxed(OIER) | OIER_E0, OIER);
48 next = OSCR + delta; 48 next = readl_relaxed(OSCR) + delta;
49 OSMR0 = next; 49 writel_relaxed(next, OSMR0);
50 oscr = OSCR; 50 oscr = readl_relaxed(OSCR);
51 51
52 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0; 52 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0;
53} 53}
@@ -59,8 +59,8 @@ sa1100_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *c)
59 case CLOCK_EVT_MODE_ONESHOT: 59 case CLOCK_EVT_MODE_ONESHOT:
60 case CLOCK_EVT_MODE_UNUSED: 60 case CLOCK_EVT_MODE_UNUSED:
61 case CLOCK_EVT_MODE_SHUTDOWN: 61 case CLOCK_EVT_MODE_SHUTDOWN:
62 OIER &= ~OIER_E0; 62 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
63 OSSR = OSSR_M0; 63 writel_relaxed(OSSR_M0, OSSR);
64 break; 64 break;
65 65
66 case CLOCK_EVT_MODE_RESUME: 66 case CLOCK_EVT_MODE_RESUME:
@@ -86,8 +86,8 @@ static struct irqaction sa1100_timer_irq = {
86 86
87static void __init sa1100_timer_init(void) 87static void __init sa1100_timer_init(void)
88{ 88{
89 OIER = 0; 89 writel_relaxed(0, OIER);
90 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 90 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
91 91
92 setup_sched_clock(sa1100_read_sched_clock, 32, 3686400); 92 setup_sched_clock(sa1100_read_sched_clock, 32, 3686400);
93 93
@@ -100,7 +100,7 @@ static void __init sa1100_timer_init(void)
100 100
101 setup_irq(IRQ_OST0, &sa1100_timer_irq); 101 setup_irq(IRQ_OST0, &sa1100_timer_irq);
102 102
103 clocksource_mmio_init(&OSCR, "oscr", CLOCK_TICK_RATE, 200, 32, 103 clocksource_mmio_init(OSCR, "oscr", CLOCK_TICK_RATE, 200, 32,
104 clocksource_mmio_readl_up); 104 clocksource_mmio_readl_up);
105 clockevents_register_device(&ckevt_sa1100_osmr0); 105 clockevents_register_device(&ckevt_sa1100_osmr0);
106} 106}
@@ -110,26 +110,26 @@ unsigned long osmr[4], oier;
110 110
111static void sa1100_timer_suspend(void) 111static void sa1100_timer_suspend(void)
112{ 112{
113 osmr[0] = OSMR0; 113 osmr[0] = readl_relaxed(OSMR0);
114 osmr[1] = OSMR1; 114 osmr[1] = readl_relaxed(OSMR1);
115 osmr[2] = OSMR2; 115 osmr[2] = readl_relaxed(OSMR2);
116 osmr[3] = OSMR3; 116 osmr[3] = readl_relaxed(OSMR3);
117 oier = OIER; 117 oier = readl_relaxed(OIER);
118} 118}
119 119
120static void sa1100_timer_resume(void) 120static void sa1100_timer_resume(void)
121{ 121{
122 OSSR = 0x0f; 122 writel_relaxed(0x0f, OSSR);
123 OSMR0 = osmr[0]; 123 writel_relaxed(osmr[0], OSMR0);
124 OSMR1 = osmr[1]; 124 writel_relaxed(osmr[1], OSMR1);
125 OSMR2 = osmr[2]; 125 writel_relaxed(osmr[2], OSMR2);
126 OSMR3 = osmr[3]; 126 writel_relaxed(osmr[3], OSMR3);
127 OIER = oier; 127 writel_relaxed(oier, OIER);
128 128
129 /* 129 /*
130 * OSMR0 is the system timer: make sure OSCR is sufficiently behind 130 * OSMR0 is the system timer: make sure OSCR is sufficiently behind
131 */ 131 */
132 OSCR = OSMR0 - LATCH; 132 writel_relaxed(OSMR0 - LATCH, OSCR);
133} 133}
134#else 134#else
135#define sa1100_timer_suspend NULL 135#define sa1100_timer_suspend NULL
diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c
index e859fcdb3d5..fde0d23121d 100644
--- a/arch/arm/mach-shmobile/platsmp.c
+++ b/arch/arm/mach-shmobile/platsmp.c
@@ -22,8 +22,13 @@
22#include <mach/common.h> 22#include <mach/common.h>
23#include <mach/emev2.h> 23#include <mach/emev2.h>
24 24
25#ifdef CONFIG_ARCH_SH73A0
25#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \ 26#define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
26 of_machine_is_compatible("renesas,sh73a0")) 27 of_machine_is_compatible("renesas,sh73a0"))
28#else
29#define is_sh73a0() (0)
30#endif
31
27#define is_r8a7779() machine_is_marzen() 32#define is_r8a7779() machine_is_marzen()
28 33
29#ifdef CONFIG_ARCH_EMEV2 34#ifdef CONFIG_ARCH_EMEV2
diff --git a/arch/arm/mach-spear3xx/spear3xx.c b/arch/arm/mach-spear3xx/spear3xx.c
index 0f41bd1c47c..66db5f13af8 100644
--- a/arch/arm/mach-spear3xx/spear3xx.c
+++ b/arch/arm/mach-spear3xx/spear3xx.c
@@ -87,7 +87,7 @@ void __init spear3xx_map_io(void)
87 87
88static void __init spear3xx_timer_init(void) 88static void __init spear3xx_timer_init(void)
89{ 89{
90 char pclk_name[] = "pll3_48m_clk"; 90 char pclk_name[] = "pll3_clk";
91 struct clk *gpt_clk, *pclk; 91 struct clk *gpt_clk, *pclk;
92 92
93 spear3xx_clk_init(); 93 spear3xx_clk_init();
diff --git a/arch/arm/mach-spear6xx/spear6xx.c b/arch/arm/mach-spear6xx/spear6xx.c
index 2e2e3596583..9af67d003c6 100644
--- a/arch/arm/mach-spear6xx/spear6xx.c
+++ b/arch/arm/mach-spear6xx/spear6xx.c
@@ -423,7 +423,7 @@ void __init spear6xx_map_io(void)
423 423
424static void __init spear6xx_timer_init(void) 424static void __init spear6xx_timer_init(void)
425{ 425{
426 char pclk_name[] = "pll3_48m_clk"; 426 char pclk_name[] = "pll3_clk";
427 struct clk *gpt_clk, *pclk; 427 struct clk *gpt_clk, *pclk;
428 428
429 spear6xx_clk_init(); 429 spear6xx_clk_init();
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 1509a3cb583..4fd93f5c49e 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -625,11 +625,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
625 &ab8500_device, 625 &ab8500_device,
626}; 626};
627 627
628static struct platform_device *snowball_of_platform_devs[] __initdata = {
629 &snowball_led_dev,
630 &snowball_key_dev,
631};
632
633static void __init mop500_init_machine(void) 628static void __init mop500_init_machine(void)
634{ 629{
635 struct device *parent = NULL; 630 struct device *parent = NULL;
@@ -769,6 +764,11 @@ MACHINE_END
769 764
770#ifdef CONFIG_MACH_UX500_DT 765#ifdef CONFIG_MACH_UX500_DT
771 766
767static struct platform_device *snowball_of_platform_devs[] __initdata = {
768 &snowball_led_dev,
769 &snowball_key_dev,
770};
771
772struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = { 772struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
773 /* Requires DMA and call-back bindings. */ 773 /* Requires DMA and call-back bindings. */
774 OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat), 774 OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
@@ -786,6 +786,8 @@ struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
786 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL), 786 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL),
787 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL), 787 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL),
788 OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL), 788 OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL),
789 /* Requires device name bindings. */
790 OF_DEV_AUXDATA("stericsson,nmk_pinctrl", 0, "pinctrl-db8500", NULL),
789 {}, 791 {},
790}; 792};
791 793
diff --git a/arch/arm/mach-ux500/timer.c b/arch/arm/mach-ux500/timer.c
index 741e71feca7..66e7f00884a 100644
--- a/arch/arm/mach-ux500/timer.c
+++ b/arch/arm/mach-ux500/timer.c
@@ -63,8 +63,10 @@ static void __init ux500_timer_init(void)
63 63
64 /* TODO: Once MTU has been DT:ed place code above into else. */ 64 /* TODO: Once MTU has been DT:ed place code above into else. */
65 if (of_have_populated_dt()) { 65 if (of_have_populated_dt()) {
66#ifdef CONFIG_OF
66 np = of_find_matching_node(NULL, prcmu_timer_of_match); 67 np = of_find_matching_node(NULL, prcmu_timer_of_match);
67 if (!np) 68 if (!np)
69#endif
68 goto dt_fail; 70 goto dt_fail;
69 71
70 tmp_base = of_iomap(np, 0); 72 tmp_base = of_iomap(np, 0);
diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
index 806cc4f6351..119bc52ab93 100644
--- a/arch/arm/mm/context.c
+++ b/arch/arm/mm/context.c
@@ -14,6 +14,7 @@
14#include <linux/percpu.h> 14#include <linux/percpu.h>
15 15
16#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
17#include <asm/thread_notify.h>
17#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
18 19
19static DEFINE_RAW_SPINLOCK(cpu_asid_lock); 20static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
@@ -48,6 +49,40 @@ void cpu_set_reserved_ttbr0(void)
48} 49}
49#endif 50#endif
50 51
52#ifdef CONFIG_PID_IN_CONTEXTIDR
53static int contextidr_notifier(struct notifier_block *unused, unsigned long cmd,
54 void *t)
55{
56 u32 contextidr;
57 pid_t pid;
58 struct thread_info *thread = t;
59
60 if (cmd != THREAD_NOTIFY_SWITCH)
61 return NOTIFY_DONE;
62
63 pid = task_pid_nr(thread->task) << ASID_BITS;
64 asm volatile(
65 " mrc p15, 0, %0, c13, c0, 1\n"
66 " bfi %1, %0, #0, %2\n"
67 " mcr p15, 0, %1, c13, c0, 1\n"
68 : "=r" (contextidr), "+r" (pid)
69 : "I" (ASID_BITS));
70 isb();
71
72 return NOTIFY_OK;
73}
74
75static struct notifier_block contextidr_notifier_block = {
76 .notifier_call = contextidr_notifier,
77};
78
79static int __init contextidr_notifier_init(void)
80{
81 return thread_register_notifier(&contextidr_notifier_block);
82}
83arch_initcall(contextidr_notifier_init);
84#endif
85
51/* 86/*
52 * We fork()ed a process, and we need a new context for the child 87 * We fork()ed a process, and we need a new context for the child
53 * to run in. 88 * to run in.
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 4044abcf6f9..5cfc9899407 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -23,12 +23,12 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/iommu.h> 24#include <linux/iommu.h>
25#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
26#include <linux/sizes.h>
26 27
27#include <asm/memory.h> 28#include <asm/memory.h>
28#include <asm/highmem.h> 29#include <asm/highmem.h>
29#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
30#include <asm/tlbflush.h> 31#include <asm/tlbflush.h>
31#include <asm/sizes.h>
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33#include <asm/dma-iommu.h> 33#include <asm/dma-iommu.h>
34#include <asm/mach/map.h> 34#include <asm/mach/map.h>
@@ -1091,7 +1091,7 @@ error:
1091 while (--i) 1091 while (--i)
1092 if (pages[i]) 1092 if (pages[i])
1093 __free_pages(pages[i], 0); 1093 __free_pages(pages[i], 0);
1094 if (array_size < PAGE_SIZE) 1094 if (array_size <= PAGE_SIZE)
1095 kfree(pages); 1095 kfree(pages);
1096 else 1096 else
1097 vfree(pages); 1097 vfree(pages);
@@ -1106,7 +1106,7 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, size_t s
1106 for (i = 0; i < count; i++) 1106 for (i = 0; i < count; i++)
1107 if (pages[i]) 1107 if (pages[i])
1108 __free_pages(pages[i], 0); 1108 __free_pages(pages[i], 0);
1109 if (array_size < PAGE_SIZE) 1109 if (array_size <= PAGE_SIZE)
1110 kfree(pages); 1110 kfree(pages);
1111 else 1111 else
1112 vfree(pages); 1112 vfree(pages);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index f54d5921976..9aec41fa80a 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -21,13 +21,13 @@
21#include <linux/gfp.h> 21#include <linux/gfp.h>
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/dma-contiguous.h> 23#include <linux/dma-contiguous.h>
24#include <linux/sizes.h>
24 25
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
26#include <asm/memblock.h> 27#include <asm/memblock.h>
27#include <asm/prom.h> 28#include <asm/prom.h>
28#include <asm/sections.h> 29#include <asm/sections.h>
29#include <asm/setup.h> 30#include <asm/setup.h>
30#include <asm/sizes.h>
31#include <asm/tlb.h> 31#include <asm/tlb.h>
32#include <asm/fixmap.h> 32#include <asm/fixmap.h>
33 33
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 4f55f5062ab..566750fa57d 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -25,6 +25,7 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/sizes.h>
28 29
29#include <asm/cp15.h> 30#include <asm/cp15.h>
30#include <asm/cputype.h> 31#include <asm/cputype.h>
@@ -32,7 +33,6 @@
32#include <asm/mmu_context.h> 33#include <asm/mmu_context.h>
33#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
34#include <asm/tlbflush.h> 35#include <asm/tlbflush.h>
35#include <asm/sizes.h>
36#include <asm/system_info.h> 36#include <asm/system_info.h>
37 37
38#include <asm/mach/map.h> 38#include <asm/mach/map.h>
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index cf4528d5177..4c2d0451e84 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -16,13 +16,13 @@
16#include <linux/memblock.h> 16#include <linux/memblock.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/sizes.h>
19 20
20#include <asm/cp15.h> 21#include <asm/cp15.h>
21#include <asm/cputype.h> 22#include <asm/cputype.h>
22#include <asm/sections.h> 23#include <asm/sections.h>
23#include <asm/cachetype.h> 24#include <asm/cachetype.h>
24#include <asm/setup.h> 25#include <asm/setup.h>
25#include <asm/sizes.h>
26#include <asm/smp_plat.h> 26#include <asm/smp_plat.h>
27#include <asm/tlb.h> 27#include <asm/tlb.h>
28#include <asm/highmem.h> 28#include <asm/highmem.h>
@@ -422,12 +422,6 @@ static void __init build_mem_type_table(void)
422 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte; 422 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
423 423
424 /* 424 /*
425 * Only use write-through for non-SMP systems
426 */
427 if (!is_smp() && cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH)
428 vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte;
429
430 /*
431 * Enable CPU-specific coherency if supported. 425 * Enable CPU-specific coherency if supported.
432 * (Only available on XSC3 at the moment.) 426 * (Only available on XSC3 at the moment.)
433 */ 427 */
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 5900cd520e8..86b8b480634 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -107,6 +107,12 @@ ENTRY(cpu_v6_switch_mm)
107 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 107 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
108 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer 108 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
109 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 109 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
110#ifdef CONFIG_PID_IN_CONTEXTIDR
111 mrc p15, 0, r2, c13, c0, 1 @ read current context ID
112 bic r2, r2, #0xff @ extract the PID
113 and r1, r1, #0xff
114 orr r1, r1, r2 @ insert into new context ID
115#endif
110 mcr p15, 0, r1, c13, c0, 1 @ set context ID 116 mcr p15, 0, r1, c13, c0, 1 @ set context ID
111#endif 117#endif
112 mov pc, lr 118 mov pc, lr
diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
index 42ac069c801..fd045e70639 100644
--- a/arch/arm/mm/proc-v7-2level.S
+++ b/arch/arm/mm/proc-v7-2level.S
@@ -46,6 +46,11 @@ ENTRY(cpu_v7_switch_mm)
46#ifdef CONFIG_ARM_ERRATA_430973 46#ifdef CONFIG_ARM_ERRATA_430973
47 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 47 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
48#endif 48#endif
49#ifdef CONFIG_PID_IN_CONTEXTIDR
50 mrc p15, 0, r2, c13, c0, 1 @ read current context ID
51 lsr r2, r2, #8 @ extract the PID
52 bfi r1, r2, #8, #24 @ insert into new context ID
53#endif
49#ifdef CONFIG_ARM_ERRATA_754322 54#ifdef CONFIG_ARM_ERRATA_754322
50 dsb 55 dsb
51#endif 56#endif
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 4e0a371630b..99c63d4b6af 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -23,26 +23,37 @@
23#include <asm/ptrace.h> 23#include <asm/ptrace.h>
24 24
25#ifdef CONFIG_HW_PERF_EVENTS 25#ifdef CONFIG_HW_PERF_EVENTS
26
27/*
28 * OProfile has a curious naming scheme for the ARM PMUs, but they are
29 * part of the user ABI so we need to map from the perf PMU name for
30 * supported PMUs.
31 */
32static struct op_perf_name {
33 char *perf_name;
34 char *op_name;
35} op_perf_name_map[] = {
36 { "xscale1", "arm/xscale1" },
37 { "xscale1", "arm/xscale2" },
38 { "v6", "arm/armv6" },
39 { "v6mpcore", "arm/mpcore" },
40 { "ARMv7 Cortex-A8", "arm/armv7" },
41 { "ARMv7 Cortex-A9", "arm/armv7-ca9" },
42};
43
26char *op_name_from_perf_id(void) 44char *op_name_from_perf_id(void)
27{ 45{
28 enum arm_perf_pmu_ids id = armpmu_get_pmu_id(); 46 int i;
29 47 struct op_perf_name names;
30 switch (id) { 48 const char *perf_name = perf_pmu_name();
31 case ARM_PERF_PMU_ID_XSCALE1: 49
32 return "arm/xscale1"; 50 for (i = 0; i < ARRAY_SIZE(op_perf_name_map); ++i) {
33 case ARM_PERF_PMU_ID_XSCALE2: 51 names = op_perf_name_map[i];
34 return "arm/xscale2"; 52 if (!strcmp(names.perf_name, perf_name))
35 case ARM_PERF_PMU_ID_V6: 53 return names.op_name;
36 return "arm/armv6";
37 case ARM_PERF_PMU_ID_V6MP:
38 return "arm/mpcore";
39 case ARM_PERF_PMU_ID_CA8:
40 return "arm/armv7";
41 case ARM_PERF_PMU_ID_CA9:
42 return "arm/armv7-ca9";
43 default:
44 return NULL;
45 } 54 }
55
56 return NULL;
46} 57}
47#endif 58#endif
48 59
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c
index 33ecd0c9f0c..b1e05ccff3a 100644
--- a/arch/arm/plat-samsung/adc.c
+++ b/arch/arm/plat-samsung/adc.c
@@ -157,11 +157,13 @@ int s3c_adc_start(struct s3c_adc_client *client,
157 return -EINVAL; 157 return -EINVAL;
158 } 158 }
159 159
160 if (client->is_ts && adc->ts_pend)
161 return -EAGAIN;
162
163 spin_lock_irqsave(&adc->lock, flags); 160 spin_lock_irqsave(&adc->lock, flags);
164 161
162 if (client->is_ts && adc->ts_pend) {
163 spin_unlock_irqrestore(&adc->lock, flags);
164 return -EAGAIN;
165 }
166
165 client->channel = channel; 167 client->channel = channel;
166 client->nr_samples = nr_samples; 168 client->nr_samples = nr_samples;
167 169
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index 1d214cb9d77..6303974c2ee 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -126,7 +126,8 @@ struct platform_device s3c_device_adc = {
126#ifdef CONFIG_CPU_S3C2440 126#ifdef CONFIG_CPU_S3C2440
127static struct resource s3c_camif_resource[] = { 127static struct resource s3c_camif_resource[] = {
128 [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF), 128 [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF),
129 [1] = DEFINE_RES_IRQ(IRQ_CAM), 129 [1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C),
130 [2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P),
130}; 131};
131 132
132struct platform_device s3c_device_camif = { 133struct platform_device s3c_device_camif = {
diff --git a/arch/arm/plat-samsung/s5p-clock.c b/arch/arm/plat-samsung/s5p-clock.c
index 031a61899be..48a15991103 100644
--- a/arch/arm/plat-samsung/s5p-clock.c
+++ b/arch/arm/plat-samsung/s5p-clock.c
@@ -37,6 +37,7 @@ struct clk clk_ext_xtal_mux = {
37struct clk clk_xusbxti = { 37struct clk clk_xusbxti = {
38 .name = "xusbxti", 38 .name = "xusbxti",
39 .id = -1, 39 .id = -1,
40 .rate = 24000000,
40}; 41};
41 42
42struct clk s5p_clk_27m = { 43struct clk s5p_clk_27m = {
diff --git a/arch/arm/plat-versatile/platsmp.c b/arch/arm/plat-versatile/platsmp.c
index 49c7db48c7f..d7c5c171f5a 100644
--- a/arch/arm/plat-versatile/platsmp.c
+++ b/arch/arm/plat-versatile/platsmp.c
@@ -85,7 +85,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
85 * the boot monitor to read the system wide flags register, 85 * the boot monitor to read the system wide flags register,
86 * and branch to the address found there. 86 * and branch to the address found there.
87 */ 87 */
88 gic_raise_softirq(cpumask_of(cpu), 1); 88 gic_raise_softirq(cpumask_of(cpu), 0);
89 89
90 timeout = jiffies + (1 * HZ); 90 timeout = jiffies + (1 * HZ);
91 while (time_before(jiffies, timeout)) { 91 while (time_before(jiffies, timeout)) {
diff --git a/arch/h8300/include/asm/pgtable.h b/arch/h8300/include/asm/pgtable.h
index a09230a08e0..62ef17676b4 100644
--- a/arch/h8300/include/asm/pgtable.h
+++ b/arch/h8300/include/asm/pgtable.h
@@ -70,4 +70,7 @@ extern int is_in_rom(unsigned long);
70#define VMALLOC_END 0xffffffff 70#define VMALLOC_END 0xffffffff
71 71
72#define arch_enter_lazy_cpu_mode() do {} while (0) 72#define arch_enter_lazy_cpu_mode() do {} while (0)
73
74#include <asm-generic/pgtable.h>
75
73#endif /* _H8300_PGTABLE_H */ 76#endif /* _H8300_PGTABLE_H */
diff --git a/arch/h8300/include/asm/uaccess.h b/arch/h8300/include/asm/uaccess.h
index 356068cd087..8725d1ad427 100644
--- a/arch/h8300/include/asm/uaccess.h
+++ b/arch/h8300/include/asm/uaccess.h
@@ -100,7 +100,6 @@ extern int __put_user_bad(void);
100 break; \ 100 break; \
101 default: \ 101 default: \
102 __gu_err = __get_user_bad(); \ 102 __gu_err = __get_user_bad(); \
103 __gu_val = 0; \
104 break; \ 103 break; \
105 } \ 104 } \
106 (x) = __gu_val; \ 105 (x) = __gu_val; \
@@ -159,4 +158,6 @@ clear_user(void *to, unsigned long n)
159 return 0; 158 return 0;
160} 159}
161 160
161#define __clear_user clear_user
162
162#endif /* _H8300_UACCESS_H */ 163#endif /* _H8300_UACCESS_H */
diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index fca10378701..5adaadaf921 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -447,7 +447,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
447 * want to handle. Thus you cannot kill init even with a SIGKILL even by 447 * want to handle. Thus you cannot kill init even with a SIGKILL even by
448 * mistake. 448 * mistake.
449 */ 449 */
450statis void do_signal(struct pt_regs *regs) 450static void do_signal(struct pt_regs *regs)
451{ 451{
452 siginfo_t info; 452 siginfo_t info;
453 int signr; 453 int signr;
diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
index 32263a138aa..e0f74191d55 100644
--- a/arch/h8300/kernel/time.c
+++ b/arch/h8300/kernel/time.c
@@ -27,6 +27,7 @@
27#include <linux/profile.h> 27#include <linux/profile.h>
28 28
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/irq_regs.h>
30#include <asm/timer.h> 31#include <asm/timer.h>
31 32
32#define TICK_SIZE (tick_nsec / 1000) 33#define TICK_SIZE (tick_nsec / 1000)
diff --git a/arch/m32r/boot/compressed/Makefile b/arch/m32r/boot/compressed/Makefile
index 177716b1d61..01729c2979b 100644
--- a/arch/m32r/boot/compressed/Makefile
+++ b/arch/m32r/boot/compressed/Makefile
@@ -43,9 +43,9 @@ endif
43 43
44OBJCOPYFLAGS += -R .empty_zero_page 44OBJCOPYFLAGS += -R .empty_zero_page
45 45
46suffix_$(CONFIG_KERNEL_GZIP) = gz 46suffix-$(CONFIG_KERNEL_GZIP) = gz
47suffix_$(CONFIG_KERNEL_BZIP2) = bz2 47suffix-$(CONFIG_KERNEL_BZIP2) = bz2
48suffix_$(CONFIG_KERNEL_LZMA) = lzma 48suffix-$(CONFIG_KERNEL_LZMA) = lzma
49 49
50$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE 50$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
51 $(call if_changed,ld) 51 $(call if_changed,ld)
diff --git a/arch/m32r/boot/compressed/misc.c b/arch/m32r/boot/compressed/misc.c
index 370d6088197..28a09529f20 100644
--- a/arch/m32r/boot/compressed/misc.c
+++ b/arch/m32r/boot/compressed/misc.c
@@ -28,7 +28,7 @@ static unsigned long free_mem_ptr;
28static unsigned long free_mem_end_ptr; 28static unsigned long free_mem_end_ptr;
29 29
30#ifdef CONFIG_KERNEL_BZIP2 30#ifdef CONFIG_KERNEL_BZIP2
31static void *memset(void *s, int c, size_t n) 31void *memset(void *s, int c, size_t n)
32{ 32{
33 char *ss = s; 33 char *ss = s;
34 34
@@ -39,6 +39,16 @@ static void *memset(void *s, int c, size_t n)
39#endif 39#endif
40 40
41#ifdef CONFIG_KERNEL_GZIP 41#ifdef CONFIG_KERNEL_GZIP
42void *memcpy(void *dest, const void *src, size_t n)
43{
44 char *d = dest;
45 const char *s = src;
46 while (n--)
47 *d++ = *s++;
48
49 return dest;
50}
51
42#define BOOT_HEAP_SIZE 0x10000 52#define BOOT_HEAP_SIZE 0x10000
43#include "../../../../lib/decompress_inflate.c" 53#include "../../../../lib/decompress_inflate.c"
44#endif 54#endif
diff --git a/arch/m32r/include/asm/ptrace.h b/arch/m32r/include/asm/ptrace.h
index 527527584dd..4313aa62b51 100644
--- a/arch/m32r/include/asm/ptrace.h
+++ b/arch/m32r/include/asm/ptrace.h
@@ -113,9 +113,6 @@ struct pt_regs {
113 113
114#define PTRACE_OLDSETOPTIONS 21 114#define PTRACE_OLDSETOPTIONS 21
115 115
116/* options set using PTRACE_SETOPTIONS */
117#define PTRACE_O_TRACESYSGOOD 0x00000001
118
119#ifdef __KERNEL__ 116#ifdef __KERNEL__
120 117
121#include <asm/m32r.h> /* M32R_PSW_BSM, M32R_PSW_BPM */ 118#include <asm/m32r.h> /* M32R_PSW_BSM, M32R_PSW_BPM */
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index 4c03361537a..51f5e9aa490 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -591,17 +591,16 @@ void user_enable_single_step(struct task_struct *child)
591 591
592 if (access_process_vm(child, pc&~3, &insn, sizeof(insn), 0) 592 if (access_process_vm(child, pc&~3, &insn, sizeof(insn), 0)
593 != sizeof(insn)) 593 != sizeof(insn))
594 return -EIO; 594 return;
595 595
596 compute_next_pc(insn, pc, &next_pc, child); 596 compute_next_pc(insn, pc, &next_pc, child);
597 if (next_pc & 0x80000000) 597 if (next_pc & 0x80000000)
598 return -EIO; 598 return;
599 599
600 if (embed_debug_trap(child, next_pc)) 600 if (embed_debug_trap(child, next_pc))
601 return -EIO; 601 return;
602 602
603 invalidate_cache(); 603 invalidate_cache();
604 return 0;
605} 604}
606 605
607void user_disable_single_step(struct task_struct *child) 606void user_disable_single_step(struct task_struct *child)
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index f3fb2c029cf..d0f60b97bbc 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -286,7 +286,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
286 case -ERESTARTNOINTR: 286 case -ERESTARTNOINTR:
287 regs->r0 = regs->orig_r0; 287 regs->r0 = regs->orig_r0;
288 if (prev_insn(regs) < 0) 288 if (prev_insn(regs) < 0)
289 return -EFAULT; 289 return;
290 } 290 }
291 } 291 }
292 292
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 09ab87ee6fe..b3e10fdd389 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -288,6 +288,7 @@ config MIPS_MALTA
288 select SYS_HAS_CPU_MIPS32_R1 288 select SYS_HAS_CPU_MIPS32_R1
289 select SYS_HAS_CPU_MIPS32_R2 289 select SYS_HAS_CPU_MIPS32_R2
290 select SYS_HAS_CPU_MIPS64_R1 290 select SYS_HAS_CPU_MIPS64_R1
291 select SYS_HAS_CPU_MIPS64_R2
291 select SYS_HAS_CPU_NEVADA 292 select SYS_HAS_CPU_NEVADA
292 select SYS_HAS_CPU_RM7000 293 select SYS_HAS_CPU_RM7000
293 select SYS_HAS_EARLY_PRINTK 294 select SYS_HAS_EARLY_PRINTK
@@ -1423,6 +1424,7 @@ config CPU_SB1
1423config CPU_CAVIUM_OCTEON 1424config CPU_CAVIUM_OCTEON
1424 bool "Cavium Octeon processor" 1425 bool "Cavium Octeon processor"
1425 depends on SYS_HAS_CPU_CAVIUM_OCTEON 1426 depends on SYS_HAS_CPU_CAVIUM_OCTEON
1427 select ARCH_SPARSEMEM_ENABLE
1426 select CPU_HAS_PREFETCH 1428 select CPU_HAS_PREFETCH
1427 select CPU_SUPPORTS_64BIT_KERNEL 1429 select CPU_SUPPORTS_64BIT_KERNEL
1428 select SYS_SUPPORTS_SMP 1430 select SYS_SUPPORTS_SMP
diff --git a/arch/mips/bcm47xx/Kconfig b/arch/mips/bcm47xx/Kconfig
index 6210b8d8410..b311be45a72 100644
--- a/arch/mips/bcm47xx/Kconfig
+++ b/arch/mips/bcm47xx/Kconfig
@@ -21,6 +21,7 @@ config BCM47XX_BCMA
21 select BCMA 21 select BCMA
22 select BCMA_HOST_SOC 22 select BCMA_HOST_SOC
23 select BCMA_DRIVER_MIPS 23 select BCMA_DRIVER_MIPS
24 select BCMA_HOST_PCI if PCI
24 select BCMA_DRIVER_PCI_HOSTMODE if PCI 25 select BCMA_DRIVER_PCI_HOSTMODE if PCI
25 default y 26 default y
26 help 27 help
diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
index de4d917fd54..a551bab5ecb 100644
--- a/arch/mips/bcm63xx/dev-pcmcia.c
+++ b/arch/mips/bcm63xx/dev-pcmcia.c
@@ -79,11 +79,11 @@ static int __init config_pcmcia_cs(unsigned int cs,
79 return ret; 79 return ret;
80} 80}
81 81
82static const __initdata struct { 82static const struct {
83 unsigned int cs; 83 unsigned int cs;
84 unsigned int base; 84 unsigned int base;
85 unsigned int size; 85 unsigned int size;
86} pcmcia_cs[3] = { 86} pcmcia_cs[3] __initconst = {
87 { 87 {
88 .cs = MPI_CS_PCMCIA_COMMON, 88 .cs = MPI_CS_PCMCIA_COMMON,
89 .base = BCM_PCMCIA_COMMON_BASE_PA, 89 .base = BCM_PCMCIA_COMMON_BASE_PA,
diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig
index f9e275a50d9..2f4f6d5e05b 100644
--- a/arch/mips/cavium-octeon/Kconfig
+++ b/arch/mips/cavium-octeon/Kconfig
@@ -82,10 +82,6 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY
82 help 82 help
83 Lock the kernel's implementation of memcpy() into L2. 83 Lock the kernel's implementation of memcpy() into L2.
84 84
85config ARCH_SPARSEMEM_ENABLE
86 def_bool y
87 select SPARSEMEM_STATIC
88
89config IOMMU_HELPER 85config IOMMU_HELPER
90 bool 86 bool
91 87
diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index 4b93048044e..ee1fb9f7f51 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -185,7 +185,6 @@ static void __cpuinit octeon_init_secondary(void)
185 octeon_init_cvmcount(); 185 octeon_init_cvmcount();
186 186
187 octeon_irq_setup_secondary(); 187 octeon_irq_setup_secondary();
188 raw_local_irq_enable();
189} 188}
190 189
191/** 190/**
@@ -233,6 +232,7 @@ static void octeon_smp_finish(void)
233 232
234 /* to generate the first CPU timer interrupt */ 233 /* to generate the first CPU timer interrupt */
235 write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ); 234 write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
235 local_irq_enable();
236} 236}
237 237
238/** 238/**
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index 2e1ad4c652b..82ad35ce2b4 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -17,7 +17,6 @@
17#include <linux/irqflags.h> 17#include <linux/irqflags.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <asm/barrier.h> 19#include <asm/barrier.h>
20#include <asm/bug.h>
21#include <asm/byteorder.h> /* sigh ... */ 20#include <asm/byteorder.h> /* sigh ... */
22#include <asm/cpu-features.h> 21#include <asm/cpu-features.h>
23#include <asm/sgidefs.h> 22#include <asm/sgidefs.h>
diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
index 285a41fa0b1..eee10dc07ac 100644
--- a/arch/mips/include/asm/cmpxchg.h
+++ b/arch/mips/include/asm/cmpxchg.h
@@ -8,6 +8,7 @@
8#ifndef __ASM_CMPXCHG_H 8#ifndef __ASM_CMPXCHG_H
9#define __ASM_CMPXCHG_H 9#define __ASM_CMPXCHG_H
10 10
11#include <linux/bug.h>
11#include <linux/irqflags.h> 12#include <linux/irqflags.h>
12#include <asm/war.h> 13#include <asm/war.h>
13 14
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index f9fa2a479dd..95e40c1e8ed 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -94,6 +94,7 @@
94#define PRID_IMP_24KE 0x9600 94#define PRID_IMP_24KE 0x9600
95#define PRID_IMP_74K 0x9700 95#define PRID_IMP_74K 0x9700
96#define PRID_IMP_1004K 0x9900 96#define PRID_IMP_1004K 0x9900
97#define PRID_IMP_M14KC 0x9c00
97 98
98/* 99/*
99 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE 100 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
@@ -260,12 +261,12 @@ enum cpu_type_enum {
260 */ 261 */
261 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K, 262 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
262 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350, 263 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350,
263 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, 264 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, CPU_M14KC,
264 265
265 /* 266 /*
266 * MIPS64 class processors 267 * MIPS64 class processors
267 */ 268 */
268 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2, 269 CPU_5KC, CPU_5KE, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
269 CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, CPU_CAVIUM_OCTEON2, 270 CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, CPU_CAVIUM_OCTEON2,
270 CPU_XLR, CPU_XLP, 271 CPU_XLR, CPU_XLP,
271 272
@@ -288,7 +289,7 @@ enum cpu_type_enum {
288#define MIPS_CPU_ISA_M64R2 0x00000100 289#define MIPS_CPU_ISA_M64R2 0x00000100
289 290
290#define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_I | MIPS_CPU_ISA_II | \ 291#define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_I | MIPS_CPU_ISA_II | \
291 MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 ) 292 MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2)
292#define MIPS_CPU_ISA_64BIT (MIPS_CPU_ISA_III | MIPS_CPU_ISA_IV | \ 293#define MIPS_CPU_ISA_64BIT (MIPS_CPU_ISA_III | MIPS_CPU_ISA_IV | \
293 MIPS_CPU_ISA_V | MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2) 294 MIPS_CPU_ISA_V | MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)
294 295
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
index 86548da650e..991b659e254 100644
--- a/arch/mips/include/asm/gic.h
+++ b/arch/mips/include/asm/gic.h
@@ -206,7 +206,7 @@
206 206
207#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100 207#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
208#define GIC_VPE_EIC_SS(intr) \ 208#define GIC_VPE_EIC_SS(intr) \
209 (GIC_EIC_SHADOW_SET_BASE + (4 * intr)) 209 (GIC_VPE_EIC_SHADOW_SET_BASE + (4 * intr))
210 210
211#define GIC_VPE_EIC_VEC_BASE 0x0800 211#define GIC_VPE_EIC_VEC_BASE 0x0800
212#define GIC_VPE_EIC_VEC(intr) \ 212#define GIC_VPE_EIC_VEC(intr) \
@@ -330,6 +330,17 @@ struct gic_intr_map {
330#define GIC_FLAG_TRANSPARENT 0x02 330#define GIC_FLAG_TRANSPARENT 0x02
331}; 331};
332 332
333/*
334 * This is only used in EIC mode. This helps to figure out which
335 * shared interrupts we need to process when we get a vector interrupt.
336 */
337#define GIC_MAX_SHARED_INTR 0x5
338struct gic_shared_intr_map {
339 unsigned int num_shared_intr;
340 unsigned int intr_list[GIC_MAX_SHARED_INTR];
341 unsigned int local_intr_mask;
342};
343
333extern void gic_init(unsigned long gic_base_addr, 344extern void gic_init(unsigned long gic_base_addr,
334 unsigned long gic_addrspace_size, struct gic_intr_map *intrmap, 345 unsigned long gic_addrspace_size, struct gic_intr_map *intrmap,
335 unsigned int intrmap_size, unsigned int irqbase); 346 unsigned int intrmap_size, unsigned int irqbase);
@@ -338,5 +349,7 @@ extern unsigned int gic_get_int(void);
338extern void gic_send_ipi(unsigned int intr); 349extern void gic_send_ipi(unsigned int intr);
339extern unsigned int plat_ipi_call_int_xlate(unsigned int); 350extern unsigned int plat_ipi_call_int_xlate(unsigned int);
340extern unsigned int plat_ipi_resched_int_xlate(unsigned int); 351extern unsigned int plat_ipi_resched_int_xlate(unsigned int);
352extern void gic_bind_eic_interrupt(int irq, int set);
353extern unsigned int gic_get_timer_pending(void);
341 354
342#endif /* _ASM_GICREGS_H */ 355#endif /* _ASM_GICREGS_H */
diff --git a/arch/mips/include/asm/inst.h b/arch/mips/include/asm/inst.h
index 7ebfc392e58..ab84064283d 100644
--- a/arch/mips/include/asm/inst.h
+++ b/arch/mips/include/asm/inst.h
@@ -251,7 +251,7 @@ struct f_format { /* FPU register format */
251 unsigned int func : 6; 251 unsigned int func : 6;
252}; 252};
253 253
254struct ma_format { /* FPU multipy and add format (MIPS IV) */ 254struct ma_format { /* FPU multiply and add format (MIPS IV) */
255 unsigned int opcode : 6; 255 unsigned int opcode : 6;
256 unsigned int fr : 5; 256 unsigned int fr : 5;
257 unsigned int ft : 5; 257 unsigned int ft : 5;
@@ -324,7 +324,7 @@ struct f_format { /* FPU register format */
324 unsigned int opcode : 6; 324 unsigned int opcode : 6;
325}; 325};
326 326
327struct ma_format { /* FPU multipy and add format (MIPS IV) */ 327struct ma_format { /* FPU multiply and add format (MIPS IV) */
328 unsigned int fmt : 2; 328 unsigned int fmt : 2;
329 unsigned int func : 4; 329 unsigned int func : 4;
330 unsigned int fd : 5; 330 unsigned int fd : 5;
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index a58f22998a8..29d9c23c20c 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -17,6 +17,7 @@
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19#include <asm/addrspace.h> 19#include <asm/addrspace.h>
20#include <asm/bug.h>
20#include <asm/byteorder.h> 21#include <asm/byteorder.h>
21#include <asm/cpu.h> 22#include <asm/cpu.h>
22#include <asm/cpu-features.h> 23#include <asm/cpu-features.h>
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index fb698dc09bc..78dbb8a86da 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -136,6 +136,7 @@ extern void free_irqno(unsigned int irq);
136 * IE7. Since R2 their number has to be read from the c0_intctl register. 136 * IE7. Since R2 their number has to be read from the c0_intctl register.
137 */ 137 */
138#define CP0_LEGACY_COMPARE_IRQ 7 138#define CP0_LEGACY_COMPARE_IRQ 7
139#define CP0_LEGACY_PERFCNT_IRQ 7
139 140
140extern int cp0_compare_irq; 141extern int cp0_compare_irq;
141extern int cp0_compare_irq_shift; 142extern int cp0_compare_irq_shift;
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index 94d4faad29a..fdcd78ca1b0 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -99,7 +99,7 @@
99#define CKCTL_6368_USBH_CLK_EN (1 << 15) 99#define CKCTL_6368_USBH_CLK_EN (1 << 15)
100#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16) 100#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16)
101#define CKCTL_6368_NAND_CLK_EN (1 << 17) 101#define CKCTL_6368_NAND_CLK_EN (1 << 17)
102#define CKCTL_6368_IPSEC_CLK_EN (1 << 17) 102#define CKCTL_6368_IPSEC_CLK_EN (1 << 18)
103 103
104#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \ 104#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \
105 CKCTL_6368_SWPKT_SAR_EN | \ 105 CKCTL_6368_SWPKT_SAR_EN | \
diff --git a/arch/mips/include/asm/mips-boards/maltaint.h b/arch/mips/include/asm/mips-boards/maltaint.h
index d11aa02a956..5447d9fc421 100644
--- a/arch/mips/include/asm/mips-boards/maltaint.h
+++ b/arch/mips/include/asm/mips-boards/maltaint.h
@@ -86,6 +86,16 @@
86#define GIC_CPU_INT4 4 /* . */ 86#define GIC_CPU_INT4 4 /* . */
87#define GIC_CPU_INT5 5 /* Core Interrupt 5 */ 87#define GIC_CPU_INT5 5 /* Core Interrupt 5 */
88 88
89/* MALTA GIC local interrupts */
90#define GIC_INT_TMR (GIC_CPU_INT5)
91#define GIC_INT_PERFCTR (GIC_CPU_INT5)
92
93/* GIC constants */
94/* Add 2 to convert non-eic hw int # to eic vector # */
95#define GIC_CPU_TO_VEC_OFFSET (2)
96/* If we map an intr to pin X, GIC will actually generate vector X+1 */
97#define GIC_PIN_TO_VEC_OFFSET (1)
98
89#define GIC_EXT_INTR(x) x 99#define GIC_EXT_INTR(x) x
90 100
91/* External Interrupts used for IPI */ 101/* External Interrupts used for IPI */
diff --git a/arch/mips/include/asm/mipsmtregs.h b/arch/mips/include/asm/mipsmtregs.h
index c9420aa97e3..e71ff4c317f 100644
--- a/arch/mips/include/asm/mipsmtregs.h
+++ b/arch/mips/include/asm/mipsmtregs.h
@@ -48,7 +48,7 @@
48#define CP0_VPECONF0 $1, 2 48#define CP0_VPECONF0 $1, 2
49#define CP0_VPECONF1 $1, 3 49#define CP0_VPECONF1 $1, 3
50#define CP0_YQMASK $1, 4 50#define CP0_YQMASK $1, 4
51#define CP0_VPESCHEDULE $1, 5 51#define CP0_VPESCHEDULE $1, 5
52#define CP0_VPESCHEFBK $1, 6 52#define CP0_VPESCHEFBK $1, 6
53#define CP0_TCSTATUS $2, 1 53#define CP0_TCSTATUS $2, 1
54#define CP0_TCBIND $2, 2 54#define CP0_TCBIND $2, 2
diff --git a/arch/mips/include/asm/switch_to.h b/arch/mips/include/asm/switch_to.h
index 5d33621b565..4f8ddba8c36 100644
--- a/arch/mips/include/asm/switch_to.h
+++ b/arch/mips/include/asm/switch_to.h
@@ -22,7 +22,7 @@ struct task_struct;
22 * switch_to(n) should switch tasks to task nr n, first 22 * switch_to(n) should switch tasks to task nr n, first
23 * checking that n isn't the current task, in which case it does nothing. 23 * checking that n isn't the current task, in which case it does nothing.
24 */ 24 */
25extern asmlinkage void *resume(void *last, void *next, void *next_ti); 25extern asmlinkage void *resume(void *last, void *next, void *next_ti, u32 __usedfpu);
26 26
27extern unsigned int ll_bit; 27extern unsigned int ll_bit;
28extern struct task_struct *ll_task; 28extern struct task_struct *ll_task;
@@ -66,11 +66,13 @@ do { \
66 66
67#define switch_to(prev, next, last) \ 67#define switch_to(prev, next, last) \
68do { \ 68do { \
69 u32 __usedfpu; \
69 __mips_mt_fpaff_switch_to(prev); \ 70 __mips_mt_fpaff_switch_to(prev); \
70 if (cpu_has_dsp) \ 71 if (cpu_has_dsp) \
71 __save_dsp(prev); \ 72 __save_dsp(prev); \
72 __clear_software_ll_bit(); \ 73 __clear_software_ll_bit(); \
73 (last) = resume(prev, next, task_thread_info(next)); \ 74 __usedfpu = test_and_clear_tsk_thread_flag(prev, TIF_USEDFPU); \
75 (last) = resume(prev, next, task_thread_info(next), __usedfpu); \
74} while (0) 76} while (0)
75 77
76#define finish_arch_switch(prev) \ 78#define finish_arch_switch(prev) \
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index e2eca7d1059..ca97e0ecb64 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -60,6 +60,8 @@ struct thread_info {
60register struct thread_info *__current_thread_info __asm__("$28"); 60register struct thread_info *__current_thread_info __asm__("$28");
61#define current_thread_info() __current_thread_info 61#define current_thread_info() __current_thread_info
62 62
63#endif /* !__ASSEMBLY__ */
64
63/* thread information allocation */ 65/* thread information allocation */
64#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT) 66#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
65#define THREAD_SIZE_ORDER (1) 67#define THREAD_SIZE_ORDER (1)
@@ -85,8 +87,6 @@ register struct thread_info *__current_thread_info __asm__("$28");
85 87
86#define STACK_WARN (THREAD_SIZE / 8) 88#define STACK_WARN (THREAD_SIZE / 8)
87 89
88#endif /* !__ASSEMBLY__ */
89
90#define PREEMPT_ACTIVE 0x10000000 90#define PREEMPT_ACTIVE 0x10000000
91 91
92/* 92/*
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 6ae7ce4ac63..f4630e1082a 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -4,7 +4,7 @@
4 * Copyright (C) xxxx the Anonymous 4 * Copyright (C) xxxx the Anonymous
5 * Copyright (C) 1994 - 2006 Ralf Baechle 5 * Copyright (C) 1994 - 2006 Ralf Baechle
6 * Copyright (C) 2003, 2004 Maciej W. Rozycki 6 * Copyright (C) 2003, 2004 Maciej W. Rozycki
7 * Copyright (C) 2001, 2004 MIPS Inc. 7 * Copyright (C) 2001, 2004, 2011, 2012 MIPS Technologies, Inc.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -199,6 +199,7 @@ void __init check_wait(void)
199 cpu_wait = rm7k_wait_irqoff; 199 cpu_wait = rm7k_wait_irqoff;
200 break; 200 break;
201 201
202 case CPU_M14KC:
202 case CPU_24K: 203 case CPU_24K:
203 case CPU_34K: 204 case CPU_34K:
204 case CPU_1004K: 205 case CPU_1004K:
@@ -810,6 +811,10 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
810 c->cputype = CPU_5KC; 811 c->cputype = CPU_5KC;
811 __cpu_name[cpu] = "MIPS 5Kc"; 812 __cpu_name[cpu] = "MIPS 5Kc";
812 break; 813 break;
814 case PRID_IMP_5KE:
815 c->cputype = CPU_5KE;
816 __cpu_name[cpu] = "MIPS 5KE";
817 break;
813 case PRID_IMP_20KC: 818 case PRID_IMP_20KC:
814 c->cputype = CPU_20KC; 819 c->cputype = CPU_20KC;
815 __cpu_name[cpu] = "MIPS 20Kc"; 820 __cpu_name[cpu] = "MIPS 20Kc";
@@ -831,6 +836,10 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
831 c->cputype = CPU_74K; 836 c->cputype = CPU_74K;
832 __cpu_name[cpu] = "MIPS 74Kc"; 837 __cpu_name[cpu] = "MIPS 74Kc";
833 break; 838 break;
839 case PRID_IMP_M14KC:
840 c->cputype = CPU_M14KC;
841 __cpu_name[cpu] = "MIPS M14Kc";
842 break;
834 case PRID_IMP_1004K: 843 case PRID_IMP_1004K:
835 c->cputype = CPU_1004K; 844 c->cputype = CPU_1004K;
836 __cpu_name[cpu] = "MIPS 1004Kc"; 845 __cpu_name[cpu] = "MIPS 1004Kc";
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
index 57ba13edb03..3fc1691110d 100644
--- a/arch/mips/kernel/mips_ksyms.c
+++ b/arch/mips/kernel/mips_ksyms.c
@@ -5,7 +5,7 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05 by Ralf Baechle 8 * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05, 12 by Ralf Baechle
9 * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc. 9 * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc.
10 */ 10 */
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
@@ -35,6 +35,12 @@ EXPORT_SYMBOL(memmove);
35EXPORT_SYMBOL(kernel_thread); 35EXPORT_SYMBOL(kernel_thread);
36 36
37/* 37/*
38 * Functions that operate on entire pages. Mostly used by memory management.
39 */
40EXPORT_SYMBOL(clear_page);
41EXPORT_SYMBOL(copy_page);
42
43/*
38 * Userspace access stuff. 44 * Userspace access stuff.
39 */ 45 */
40EXPORT_SYMBOL(__copy_user); 46EXPORT_SYMBOL(__copy_user);
diff --git a/arch/mips/kernel/octeon_switch.S b/arch/mips/kernel/octeon_switch.S
index ce89c806170..0441f54b2a6 100644
--- a/arch/mips/kernel/octeon_switch.S
+++ b/arch/mips/kernel/octeon_switch.S
@@ -31,7 +31,7 @@
31 31
32/* 32/*
33 * task_struct *resume(task_struct *prev, task_struct *next, 33 * task_struct *resume(task_struct *prev, task_struct *next,
34 * struct thread_info *next_ti) 34 * struct thread_info *next_ti, int usedfpu)
35 */ 35 */
36 .align 7 36 .align 7
37 LEAF(resume) 37 LEAF(resume)
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index f29099b104c..eb5e394a465 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -162,11 +162,6 @@ static unsigned int counters_total_to_per_cpu(unsigned int counters)
162 return counters >> vpe_shift(); 162 return counters >> vpe_shift();
163} 163}
164 164
165static unsigned int counters_per_cpu_to_total(unsigned int counters)
166{
167 return counters << vpe_shift();
168}
169
170#else /* !CONFIG_MIPS_MT_SMP */ 165#else /* !CONFIG_MIPS_MT_SMP */
171#define vpe_id() 0 166#define vpe_id() 0
172 167
diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S
index 293898391e6..9c51be5a163 100644
--- a/arch/mips/kernel/r2300_switch.S
+++ b/arch/mips/kernel/r2300_switch.S
@@ -43,7 +43,7 @@
43 43
44/* 44/*
45 * task_struct *resume(task_struct *prev, task_struct *next, 45 * task_struct *resume(task_struct *prev, task_struct *next,
46 * struct thread_info *next_ti) ) 46 * struct thread_info *next_ti, int usedfpu)
47 */ 47 */
48LEAF(resume) 48LEAF(resume)
49 mfc0 t1, CP0_STATUS 49 mfc0 t1, CP0_STATUS
@@ -51,18 +51,9 @@ LEAF(resume)
51 cpu_save_nonscratch a0 51 cpu_save_nonscratch a0
52 sw ra, THREAD_REG31(a0) 52 sw ra, THREAD_REG31(a0)
53 53
54 /* 54 beqz a3, 1f
55 * check if we need to save FPU registers
56 */
57 lw t3, TASK_THREAD_INFO(a0)
58 lw t0, TI_FLAGS(t3)
59 li t1, _TIF_USEDFPU
60 and t2, t0, t1
61 beqz t2, 1f
62 nor t1, zero, t1
63 55
64 and t0, t0, t1 56 PTR_L t3, TASK_THREAD_INFO(a0)
65 sw t0, TI_FLAGS(t3)
66 57
67 /* 58 /*
68 * clear saved user stack CU1 bit 59 * clear saved user stack CU1 bit
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index 9414f935446..42d2a393842 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -41,7 +41,7 @@
41 41
42/* 42/*
43 * task_struct *resume(task_struct *prev, task_struct *next, 43 * task_struct *resume(task_struct *prev, task_struct *next,
44 * struct thread_info *next_ti) 44 * struct thread_info *next_ti, int usedfpu)
45 */ 45 */
46 .align 5 46 .align 5
47 LEAF(resume) 47 LEAF(resume)
@@ -53,16 +53,10 @@
53 /* 53 /*
54 * check if we need to save FPU registers 54 * check if we need to save FPU registers
55 */ 55 */
56 PTR_L t3, TASK_THREAD_INFO(a0)
57 LONG_L t0, TI_FLAGS(t3)
58 li t1, _TIF_USEDFPU
59 and t2, t0, t1
60 beqz t2, 1f
61 nor t1, zero, t1
62 56
63 and t0, t0, t1 57 beqz a3, 1f
64 LONG_S t0, TI_FLAGS(t3)
65 58
59 PTR_L t3, TASK_THREAD_INFO(a0)
66 /* 60 /*
67 * clear saved user stack CU1 bit 61 * clear saved user stack CU1 bit
68 */ 62 */
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index 3046e298600..8e393b8443f 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -15,7 +15,6 @@
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/init.h>
19#include <linux/cpu.h> 18#include <linux/cpu.h>
20#include <linux/cpumask.h> 19#include <linux/cpumask.h>
21#include <linux/reboot.h> 20#include <linux/reboot.h>
@@ -197,13 +196,6 @@ static void bmips_init_secondary(void)
197 196
198 write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), 0)); 197 write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), 0));
199#endif 198#endif
200
201 /* make sure there won't be a timer interrupt for a little while */
202 write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
203
204 irq_enable_hazard();
205 set_c0_status(IE_SW0 | IE_SW1 | IE_IRQ1 | IE_IRQ5 | ST0_IE);
206 irq_enable_hazard();
207} 199}
208 200
209/* 201/*
@@ -212,6 +204,13 @@ static void bmips_init_secondary(void)
212static void bmips_smp_finish(void) 204static void bmips_smp_finish(void)
213{ 205{
214 pr_info("SMP: CPU%d is running\n", smp_processor_id()); 206 pr_info("SMP: CPU%d is running\n", smp_processor_id());
207
208 /* make sure there won't be a timer interrupt for a little while */
209 write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
210
211 irq_enable_hazard();
212 set_c0_status(IE_SW0 | IE_SW1 | IE_IRQ1 | IE_IRQ5 | ST0_IE);
213 irq_enable_hazard();
215} 214}
216 215
217/* 216/*
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 48650c81804..1268392f1d2 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -122,13 +122,21 @@ asmlinkage __cpuinit void start_secondary(void)
122 122
123 notify_cpu_starting(cpu); 123 notify_cpu_starting(cpu);
124 124
125 mp_ops->smp_finish(); 125 set_cpu_online(cpu, true);
126
126 set_cpu_sibling_map(cpu); 127 set_cpu_sibling_map(cpu);
127 128
128 cpu_set(cpu, cpu_callin_map); 129 cpu_set(cpu, cpu_callin_map);
129 130
130 synchronise_count_slave(); 131 synchronise_count_slave();
131 132
133 /*
134 * irq will be enabled in ->smp_finish(), enabling it too early
135 * is dangerous.
136 */
137 WARN_ON_ONCE(!irqs_disabled());
138 mp_ops->smp_finish();
139
132 cpu_idle(); 140 cpu_idle();
133} 141}
134 142
@@ -196,8 +204,6 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
196 while (!cpu_isset(cpu, cpu_callin_map)) 204 while (!cpu_isset(cpu, cpu_callin_map))
197 udelay(100); 205 udelay(100);
198 206
199 set_cpu_online(cpu, true);
200
201 return 0; 207 return 0;
202} 208}
203 209
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index f5dd38f1d01..15b5f3cfd20 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -322,7 +322,7 @@ int __init smtc_build_cpu_map(int start_cpu_slot)
322 322
323/* 323/*
324 * Common setup before any secondaries are started 324 * Common setup before any secondaries are started
325 * Make sure all CPU's are in a sensible state before we boot any of the 325 * Make sure all CPUs are in a sensible state before we boot any of the
326 * secondaries. 326 * secondaries.
327 * 327 *
328 * For MIPS MT "SMTC" operation, we set up all TCs, spread as evenly 328 * For MIPS MT "SMTC" operation, we set up all TCs, spread as evenly
@@ -340,12 +340,12 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
340 /* 340 /*
341 * TCContext gets an offset from the base of the IPIQ array 341 * TCContext gets an offset from the base of the IPIQ array
342 * to be used in low-level code to detect the presence of 342 * to be used in low-level code to detect the presence of
343 * an active IPI queue 343 * an active IPI queue.
344 */ 344 */
345 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16); 345 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16);
346 /* Bind tc to vpe */ 346 /* Bind tc to vpe */
347 write_tc_c0_tcbind(vpe); 347 write_tc_c0_tcbind(vpe);
348 /* In general, all TCs should have the same cpu_data indications */ 348 /* In general, all TCs should have the same cpu_data indications. */
349 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips)); 349 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips));
350 /* For 34Kf, start with TC/CPU 0 as sole owner of single FPU context */ 350 /* For 34Kf, start with TC/CPU 0 as sole owner of single FPU context */
351 if (cpu_data[0].cputype == CPU_34K || 351 if (cpu_data[0].cputype == CPU_34K ||
@@ -358,8 +358,8 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
358} 358}
359 359
360/* 360/*
361 * Tweak to get Count registes in as close a sync as possible. 361 * Tweak to get Count registes in as close a sync as possible. The
362 * Value seems good for 34K-class cores. 362 * value seems good for 34K-class cores.
363 */ 363 */
364 364
365#define CP0_SKEW 8 365#define CP0_SKEW 8
@@ -615,7 +615,6 @@ void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle)
615 615
616void smtc_init_secondary(void) 616void smtc_init_secondary(void)
617{ 617{
618 local_irq_enable();
619} 618}
620 619
621void smtc_smp_finish(void) 620void smtc_smp_finish(void)
@@ -631,6 +630,8 @@ void smtc_smp_finish(void)
631 if (cpu > 0 && (cpu_data[cpu].vpe_id != cpu_data[cpu - 1].vpe_id)) 630 if (cpu > 0 && (cpu_data[cpu].vpe_id != cpu_data[cpu - 1].vpe_id))
632 write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ); 631 write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ);
633 632
633 local_irq_enable();
634
634 printk("TC %d going on-line as CPU %d\n", 635 printk("TC %d going on-line as CPU %d\n",
635 cpu_data[smp_processor_id()].tc_id, smp_processor_id()); 636 cpu_data[smp_processor_id()].tc_id, smp_processor_id());
636} 637}
diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
index 99f913c8d7a..842d55e411f 100644
--- a/arch/mips/kernel/sync-r4k.c
+++ b/arch/mips/kernel/sync-r4k.c
@@ -111,7 +111,6 @@ void __cpuinit synchronise_count_master(void)
111void __cpuinit synchronise_count_slave(void) 111void __cpuinit synchronise_count_slave(void)
112{ 112{
113 int i; 113 int i;
114 unsigned long flags;
115 unsigned int initcount; 114 unsigned int initcount;
116 int ncpus; 115 int ncpus;
117 116
@@ -123,8 +122,6 @@ void __cpuinit synchronise_count_slave(void)
123 return; 122 return;
124#endif 123#endif
125 124
126 local_irq_save(flags);
127
128 /* 125 /*
129 * Not every cpu is online at the time this gets called, 126 * Not every cpu is online at the time this gets called,
130 * so we first wait for the master to say everyone is ready 127 * so we first wait for the master to say everyone is ready
@@ -154,7 +151,5 @@ void __cpuinit synchronise_count_slave(void)
154 } 151 }
155 /* Arrange for an interrupt in a short while */ 152 /* Arrange for an interrupt in a short while */
156 write_c0_compare(read_c0_count() + COUNTON); 153 write_c0_compare(read_c0_count() + COUNTON);
157
158 local_irq_restore(flags);
159} 154}
160#undef NR_LOOPS 155#undef NR_LOOPS
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 2d0c2a277f5..c3c29354370 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -132,6 +132,9 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
132 unsigned long ra = regs->regs[31]; 132 unsigned long ra = regs->regs[31];
133 unsigned long pc = regs->cp0_epc; 133 unsigned long pc = regs->cp0_epc;
134 134
135 if (!task)
136 task = current;
137
135 if (raw_show_trace || !__kernel_text_address(pc)) { 138 if (raw_show_trace || !__kernel_text_address(pc)) {
136 show_raw_backtrace(sp); 139 show_raw_backtrace(sp);
137 return; 140 return;
@@ -1249,6 +1252,7 @@ static inline void parity_protection_init(void)
1249 break; 1252 break;
1250 1253
1251 case CPU_5KC: 1254 case CPU_5KC:
1255 case CPU_5KE:
1252 write_c0_ecc(0x80000000); 1256 write_c0_ecc(0x80000000);
1253 back_to_back_c0_hazard(); 1257 back_to_back_c0_hazard();
1254 /* Set the PE bit (bit 31) in the c0_errctl register. */ 1258 /* Set the PE bit (bit 31) in the c0_errctl register. */
@@ -1498,6 +1502,7 @@ extern void flush_tlb_handlers(void);
1498 * Timer interrupt 1502 * Timer interrupt
1499 */ 1503 */
1500int cp0_compare_irq; 1504int cp0_compare_irq;
1505EXPORT_SYMBOL_GPL(cp0_compare_irq);
1501int cp0_compare_irq_shift; 1506int cp0_compare_irq_shift;
1502 1507
1503/* 1508/*
@@ -1597,7 +1602,7 @@ void __cpuinit per_cpu_trap_init(bool is_boot_cpu)
1597 cp0_perfcount_irq = -1; 1602 cp0_perfcount_irq = -1;
1598 } else { 1603 } else {
1599 cp0_compare_irq = CP0_LEGACY_COMPARE_IRQ; 1604 cp0_compare_irq = CP0_LEGACY_COMPARE_IRQ;
1600 cp0_compare_irq_shift = cp0_compare_irq; 1605 cp0_compare_irq_shift = CP0_LEGACY_PERFCNT_IRQ;
1601 cp0_perfcount_irq = -1; 1606 cp0_perfcount_irq = -1;
1602 } 1607 }
1603 1608
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 924da5eb703..df243a64f43 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -1,5 +1,6 @@
1#include <asm/asm-offsets.h> 1#include <asm/asm-offsets.h>
2#include <asm/page.h> 2#include <asm/page.h>
3#include <asm/thread_info.h>
3#include <asm-generic/vmlinux.lds.h> 4#include <asm-generic/vmlinux.lds.h>
4 5
5#undef mips 6#undef mips
@@ -72,7 +73,7 @@ SECTIONS
72 .data : { /* Data */ 73 .data : { /* Data */
73 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ 74 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
74 75
75 INIT_TASK_DATA(PAGE_SIZE) 76 INIT_TASK_DATA(THREAD_SIZE)
76 NOSAVE_DATA 77 NOSAVE_DATA
77 CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 78 CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
78 READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 79 READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 4aa20280613..fd6203f14f1 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -3,8 +3,8 @@
3# 3#
4 4
5obj-y += cache.o dma-default.o extable.o fault.o \ 5obj-y += cache.o dma-default.o extable.o fault.o \
6 gup.o init.o mmap.o page.o tlbex.o \ 6 gup.o init.o mmap.o page.o page-funcs.o \
7 tlbex-fault.o uasm.o 7 tlbex.o tlbex-fault.o uasm.o
8 8
9obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o 9obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
10obj-$(CONFIG_64BIT) += pgtable-64.o 10obj-$(CONFIG_64BIT) += pgtable-64.o
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 5109be96d98..f092c265dc6 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -977,7 +977,7 @@ static void __cpuinit probe_pcache(void)
977 c->icache.linesz = 2 << lsize; 977 c->icache.linesz = 2 << lsize;
978 else 978 else
979 c->icache.linesz = lsize; 979 c->icache.linesz = lsize;
980 c->icache.sets = 64 << ((config1 >> 22) & 7); 980 c->icache.sets = 32 << (((config1 >> 22) + 1) & 7);
981 c->icache.ways = 1 + ((config1 >> 16) & 7); 981 c->icache.ways = 1 + ((config1 >> 16) & 7);
982 982
983 icache_size = c->icache.sets * 983 icache_size = c->icache.sets *
@@ -997,7 +997,7 @@ static void __cpuinit probe_pcache(void)
997 c->dcache.linesz = 2 << lsize; 997 c->dcache.linesz = 2 << lsize;
998 else 998 else
999 c->dcache.linesz= lsize; 999 c->dcache.linesz= lsize;
1000 c->dcache.sets = 64 << ((config1 >> 13) & 7); 1000 c->dcache.sets = 32 << (((config1 >> 13) + 1) & 7);
1001 c->dcache.ways = 1 + ((config1 >> 7) & 7); 1001 c->dcache.ways = 1 + ((config1 >> 7) & 7);
1002 1002
1003 dcache_size = c->dcache.sets * 1003 dcache_size = c->dcache.sets *
@@ -1051,6 +1051,7 @@ static void __cpuinit probe_pcache(void)
1051 case CPU_R14000: 1051 case CPU_R14000:
1052 break; 1052 break;
1053 1053
1054 case CPU_M14KC:
1054 case CPU_24K: 1055 case CPU_24K:
1055 case CPU_34K: 1056 case CPU_34K:
1056 case CPU_74K: 1057 case CPU_74K:
diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S
new file mode 100644
index 00000000000..48a6b38ff13
--- /dev/null
+++ b/arch/mips/mm/page-funcs.S
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Micro-assembler generated clear_page/copy_page functions.
7 *
8 * Copyright (C) 2012 MIPS Technologies, Inc.
9 * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
10 */
11#include <asm/asm.h>
12#include <asm/regdef.h>
13
14#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
15#define cpu_clear_page_function_name clear_page_cpu
16#define cpu_copy_page_function_name copy_page_cpu
17#else
18#define cpu_clear_page_function_name clear_page
19#define cpu_copy_page_function_name copy_page
20#endif
21
22/*
23 * Maximum sizes:
24 *
25 * R4000 128 bytes S-cache: 0x058 bytes
26 * R4600 v1.7: 0x05c bytes
27 * R4600 v2.0: 0x060 bytes
28 * With prefetching, 16 word strides 0x120 bytes
29 */
30EXPORT(__clear_page_start)
31LEAF(cpu_clear_page_function_name)
321: j 1b /* Dummy, will be replaced. */
33 .space 288
34END(cpu_clear_page_function_name)
35EXPORT(__clear_page_end)
36
37/*
38 * Maximum sizes:
39 *
40 * R4000 128 bytes S-cache: 0x11c bytes
41 * R4600 v1.7: 0x080 bytes
42 * R4600 v2.0: 0x07c bytes
43 * With prefetching, 16 word strides 0x540 bytes
44 */
45EXPORT(__copy_page_start)
46LEAF(cpu_copy_page_function_name)
471: j 1b /* Dummy, will be replaced. */
48 .space 1344
49END(cpu_copy_page_function_name)
50EXPORT(__copy_page_end)
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
index cc0b626858b..98f530e1821 100644
--- a/arch/mips/mm/page.c
+++ b/arch/mips/mm/page.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org) 6 * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 2007 Maciej W. Rozycki 7 * Copyright (C) 2007 Maciej W. Rozycki
8 * Copyright (C) 2008 Thiemo Seufer 8 * Copyright (C) 2008 Thiemo Seufer
9 * Copyright (C) 2012 MIPS Technologies, Inc.
9 */ 10 */
10#include <linux/init.h> 11#include <linux/init.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -71,45 +72,6 @@ static struct uasm_reloc __cpuinitdata relocs[5];
71#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) 72#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
72#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) 73#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
73 74
74/*
75 * Maximum sizes:
76 *
77 * R4000 128 bytes S-cache: 0x058 bytes
78 * R4600 v1.7: 0x05c bytes
79 * R4600 v2.0: 0x060 bytes
80 * With prefetching, 16 word strides 0x120 bytes
81 */
82
83static u32 clear_page_array[0x120 / 4];
84
85#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
86void clear_page_cpu(void *page) __attribute__((alias("clear_page_array")));
87#else
88void clear_page(void *page) __attribute__((alias("clear_page_array")));
89#endif
90
91EXPORT_SYMBOL(clear_page);
92
93/*
94 * Maximum sizes:
95 *
96 * R4000 128 bytes S-cache: 0x11c bytes
97 * R4600 v1.7: 0x080 bytes
98 * R4600 v2.0: 0x07c bytes
99 * With prefetching, 16 word strides 0x540 bytes
100 */
101static u32 copy_page_array[0x540 / 4];
102
103#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
104void
105copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array")));
106#else
107void copy_page(void *to, void *from) __attribute__((alias("copy_page_array")));
108#endif
109
110EXPORT_SYMBOL(copy_page);
111
112
113static int pref_bias_clear_store __cpuinitdata; 75static int pref_bias_clear_store __cpuinitdata;
114static int pref_bias_copy_load __cpuinitdata; 76static int pref_bias_copy_load __cpuinitdata;
115static int pref_bias_copy_store __cpuinitdata; 77static int pref_bias_copy_store __cpuinitdata;
@@ -282,10 +244,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off)
282 } 244 }
283} 245}
284 246
247extern u32 __clear_page_start;
248extern u32 __clear_page_end;
249extern u32 __copy_page_start;
250extern u32 __copy_page_end;
251
285void __cpuinit build_clear_page(void) 252void __cpuinit build_clear_page(void)
286{ 253{
287 int off; 254 int off;
288 u32 *buf = (u32 *)&clear_page_array; 255 u32 *buf = &__clear_page_start;
289 struct uasm_label *l = labels; 256 struct uasm_label *l = labels;
290 struct uasm_reloc *r = relocs; 257 struct uasm_reloc *r = relocs;
291 int i; 258 int i;
@@ -356,17 +323,17 @@ void __cpuinit build_clear_page(void)
356 uasm_i_jr(&buf, RA); 323 uasm_i_jr(&buf, RA);
357 uasm_i_nop(&buf); 324 uasm_i_nop(&buf);
358 325
359 BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array)); 326 BUG_ON(buf > &__clear_page_end);
360 327
361 uasm_resolve_relocs(relocs, labels); 328 uasm_resolve_relocs(relocs, labels);
362 329
363 pr_debug("Synthesized clear page handler (%u instructions).\n", 330 pr_debug("Synthesized clear page handler (%u instructions).\n",
364 (u32)(buf - clear_page_array)); 331 (u32)(buf - &__clear_page_start));
365 332
366 pr_debug("\t.set push\n"); 333 pr_debug("\t.set push\n");
367 pr_debug("\t.set noreorder\n"); 334 pr_debug("\t.set noreorder\n");
368 for (i = 0; i < (buf - clear_page_array); i++) 335 for (i = 0; i < (buf - &__clear_page_start); i++)
369 pr_debug("\t.word 0x%08x\n", clear_page_array[i]); 336 pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]);
370 pr_debug("\t.set pop\n"); 337 pr_debug("\t.set pop\n");
371} 338}
372 339
@@ -427,7 +394,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
427void __cpuinit build_copy_page(void) 394void __cpuinit build_copy_page(void)
428{ 395{
429 int off; 396 int off;
430 u32 *buf = (u32 *)&copy_page_array; 397 u32 *buf = &__copy_page_start;
431 struct uasm_label *l = labels; 398 struct uasm_label *l = labels;
432 struct uasm_reloc *r = relocs; 399 struct uasm_reloc *r = relocs;
433 int i; 400 int i;
@@ -595,21 +562,23 @@ void __cpuinit build_copy_page(void)
595 uasm_i_jr(&buf, RA); 562 uasm_i_jr(&buf, RA);
596 uasm_i_nop(&buf); 563 uasm_i_nop(&buf);
597 564
598 BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array)); 565 BUG_ON(buf > &__copy_page_end);
599 566
600 uasm_resolve_relocs(relocs, labels); 567 uasm_resolve_relocs(relocs, labels);
601 568
602 pr_debug("Synthesized copy page handler (%u instructions).\n", 569 pr_debug("Synthesized copy page handler (%u instructions).\n",
603 (u32)(buf - copy_page_array)); 570 (u32)(buf - &__copy_page_start));
604 571
605 pr_debug("\t.set push\n"); 572 pr_debug("\t.set push\n");
606 pr_debug("\t.set noreorder\n"); 573 pr_debug("\t.set noreorder\n");
607 for (i = 0; i < (buf - copy_page_array); i++) 574 for (i = 0; i < (buf - &__copy_page_start); i++)
608 pr_debug("\t.word 0x%08x\n", copy_page_array[i]); 575 pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]);
609 pr_debug("\t.set pop\n"); 576 pr_debug("\t.set pop\n");
610} 577}
611 578
612#ifdef CONFIG_SIBYTE_DMA_PAGEOPS 579#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
580extern void clear_page_cpu(void *page);
581extern void copy_page_cpu(void *to, void *from);
613 582
614/* 583/*
615 * Pad descriptors to cacheline, since each is exclusively owned by a 584 * Pad descriptors to cacheline, since each is exclusively owned by a
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 0bc485b3cd6..03eb0ef9158 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -9,6 +9,7 @@
9 * Copyright (C) 2005, 2007, 2008, 2009 Maciej W. Rozycki 9 * Copyright (C) 2005, 2007, 2008, 2009 Maciej W. Rozycki
10 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org) 10 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
11 * Copyright (C) 2008, 2009 Cavium Networks, Inc. 11 * Copyright (C) 2008, 2009 Cavium Networks, Inc.
12 * Copyright (C) 2011 MIPS Technologies, Inc.
12 * 13 *
13 * ... and the days got worse and worse and now you see 14 * ... and the days got worse and worse and now you see
14 * I've gone completly out of my mind. 15 * I've gone completly out of my mind.
@@ -494,6 +495,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
494 case CPU_R14000: 495 case CPU_R14000:
495 case CPU_4KC: 496 case CPU_4KC:
496 case CPU_4KEC: 497 case CPU_4KEC:
498 case CPU_M14KC:
497 case CPU_SB1: 499 case CPU_SB1:
498 case CPU_SB1A: 500 case CPU_SB1A:
499 case CPU_4KSC: 501 case CPU_4KSC:
diff --git a/arch/mips/mti-malta/malta-pci.c b/arch/mips/mti-malta/malta-pci.c
index bf80921f2f5..284dea54faf 100644
--- a/arch/mips/mti-malta/malta-pci.c
+++ b/arch/mips/mti-malta/malta-pci.c
@@ -241,8 +241,9 @@ void __init mips_pcibios_init(void)
241 return; 241 return;
242 } 242 }
243 243
244 if (controller->io_resource->start < 0x00001000UL) /* FIXME */ 244 /* Change start address to avoid conflicts with ACPI and SMB devices */
245 controller->io_resource->start = 0x00001000UL; 245 if (controller->io_resource->start < 0x00002000UL)
246 controller->io_resource->start = 0x00002000UL;
246 247
247 iomem_resource.end &= 0xfffffffffULL; /* 64 GB */ 248 iomem_resource.end &= 0xfffffffffULL; /* 64 GB */
248 ioport_resource.end = controller->io_resource->end; 249 ioport_resource.end = controller->io_resource->end;
@@ -253,7 +254,7 @@ void __init mips_pcibios_init(void)
253} 254}
254 255
255/* Enable PCI 2.1 compatibility in PIIX4 */ 256/* Enable PCI 2.1 compatibility in PIIX4 */
256static void __init quirk_dlcsetup(struct pci_dev *dev) 257static void __devinit quirk_dlcsetup(struct pci_dev *dev)
257{ 258{
258 u8 odlc, ndlc; 259 u8 odlc, ndlc;
259 (void) pci_read_config_byte(dev, 0x82, &odlc); 260 (void) pci_read_config_byte(dev, 0x82, &odlc);
diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c
index b7f37d4982f..2e28f653f66 100644
--- a/arch/mips/mti-malta/malta-setup.c
+++ b/arch/mips/mti-malta/malta-setup.c
@@ -111,7 +111,7 @@ static void __init pci_clock_check(void)
111 unsigned int __iomem *jmpr_p = 111 unsigned int __iomem *jmpr_p =
112 (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int)); 112 (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));
113 int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07; 113 int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;
114 static const int pciclocks[] __initdata = { 114 static const int pciclocks[] __initconst = {
115 33, 20, 25, 30, 12, 16, 37, 10 115 33, 20, 25, 30, 12, 16, 37, 10
116 }; 116 };
117 int pciclock = pciclocks[jmpr]; 117 int pciclock = pciclocks[jmpr];
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index acb677a1227..b3df7c2aad1 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -82,8 +82,10 @@ void __init prom_free_prom_memory(void)
82 82
83void xlp_mmu_init(void) 83void xlp_mmu_init(void)
84{ 84{
85 /* enable extended TLB and Large Fixed TLB */
85 write_c0_config6(read_c0_config6() | 0x24); 86 write_c0_config6(read_c0_config6() | 0x24);
86 current_cpu_data.tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1; 87
88 /* set page mask of Fixed TLB in config7 */
87 write_c0_config7(PM_DEFAULT_MASK >> 89 write_c0_config7(PM_DEFAULT_MASK >>
88 (13 + (ffz(PM_DEFAULT_MASK >> 13) / 2))); 90 (13 + (ffz(PM_DEFAULT_MASK >> 13) / 2)));
89} 91}
@@ -100,6 +102,10 @@ void __init prom_init(void)
100 nlm_common_ebase = read_c0_ebase() & (~((1 << 12) - 1)); 102 nlm_common_ebase = read_c0_ebase() & (~((1 << 12) - 1));
101#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
102 nlm_wakeup_secondary_cpus(0xffffffff); 104 nlm_wakeup_secondary_cpus(0xffffffff);
105
106 /* update TLB size after waking up threads */
107 current_cpu_data.tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
108
103 register_smp_ops(&nlm_smp_ops); 109 register_smp_ops(&nlm_smp_ops);
104#endif 110#endif
105} 111}
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index d1f2d4c52d4..b6e378211a2 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -78,6 +78,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
78 78
79 switch (current_cpu_type()) { 79 switch (current_cpu_type()) {
80 case CPU_5KC: 80 case CPU_5KC:
81 case CPU_M14KC:
81 case CPU_20KC: 82 case CPU_20KC:
82 case CPU_24K: 83 case CPU_24K:
83 case CPU_25KF: 84 case CPU_25KF:
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index baba3bcaa3c..4d80a856048 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -322,6 +322,10 @@ static int __init mipsxx_init(void)
322 322
323 op_model_mipsxx_ops.num_counters = counters; 323 op_model_mipsxx_ops.num_counters = counters;
324 switch (current_cpu_type()) { 324 switch (current_cpu_type()) {
325 case CPU_M14KC:
326 op_model_mipsxx_ops.cpu_type = "mips/M14Kc";
327 break;
328
325 case CPU_20KC: 329 case CPU_20KC:
326 op_model_mipsxx_ops.cpu_type = "mips/20K"; 330 op_model_mipsxx_ops.cpu_type = "mips/20K";
327 break; 331 break;
diff --git a/arch/mips/pci/fixup-fuloong2e.c b/arch/mips/pci/fixup-fuloong2e.c
index d5d4c018fb0..0857ab8c391 100644
--- a/arch/mips/pci/fixup-fuloong2e.c
+++ b/arch/mips/pci/fixup-fuloong2e.c
@@ -48,7 +48,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
48 return 0; 48 return 0;
49} 49}
50 50
51static void __init loongson2e_nec_fixup(struct pci_dev *pdev) 51static void __devinit loongson2e_nec_fixup(struct pci_dev *pdev)
52{ 52{
53 unsigned int val; 53 unsigned int val;
54 54
@@ -60,7 +60,7 @@ static void __init loongson2e_nec_fixup(struct pci_dev *pdev)
60 pci_write_config_dword(pdev, 0xe4, 1 << 5); 60 pci_write_config_dword(pdev, 0xe4, 1 << 5);
61} 61}
62 62
63static void __init loongson2e_686b_func0_fixup(struct pci_dev *pdev) 63static void __devinit loongson2e_686b_func0_fixup(struct pci_dev *pdev)
64{ 64{
65 unsigned char c; 65 unsigned char c;
66 66
@@ -135,7 +135,7 @@ static void __init loongson2e_686b_func0_fixup(struct pci_dev *pdev)
135 printk(KERN_INFO"via686b fix: ISA bridge done\n"); 135 printk(KERN_INFO"via686b fix: ISA bridge done\n");
136} 136}
137 137
138static void __init loongson2e_686b_func1_fixup(struct pci_dev *pdev) 138static void __devinit loongson2e_686b_func1_fixup(struct pci_dev *pdev)
139{ 139{
140 printk(KERN_INFO"via686b fix: IDE\n"); 140 printk(KERN_INFO"via686b fix: IDE\n");
141 141
@@ -168,19 +168,19 @@ static void __init loongson2e_686b_func1_fixup(struct pci_dev *pdev)
168 printk(KERN_INFO"via686b fix: IDE done\n"); 168 printk(KERN_INFO"via686b fix: IDE done\n");
169} 169}
170 170
171static void __init loongson2e_686b_func2_fixup(struct pci_dev *pdev) 171static void __devinit loongson2e_686b_func2_fixup(struct pci_dev *pdev)
172{ 172{
173 /* irq routing */ 173 /* irq routing */
174 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 10); 174 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 10);
175} 175}
176 176
177static void __init loongson2e_686b_func3_fixup(struct pci_dev *pdev) 177static void __devinit loongson2e_686b_func3_fixup(struct pci_dev *pdev)
178{ 178{
179 /* irq routing */ 179 /* irq routing */
180 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 11); 180 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 11);
181} 181}
182 182
183static void __init loongson2e_686b_func5_fixup(struct pci_dev *pdev) 183static void __devinit loongson2e_686b_func5_fixup(struct pci_dev *pdev)
184{ 184{
185 unsigned int val; 185 unsigned int val;
186 unsigned char c; 186 unsigned char c;
diff --git a/arch/mips/pci/fixup-lemote2f.c b/arch/mips/pci/fixup-lemote2f.c
index 4b9768d5d72..a7b917dcf60 100644
--- a/arch/mips/pci/fixup-lemote2f.c
+++ b/arch/mips/pci/fixup-lemote2f.c
@@ -96,21 +96,21 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
96} 96}
97 97
98/* CS5536 SPEC. fixup */ 98/* CS5536 SPEC. fixup */
99static void __init loongson_cs5536_isa_fixup(struct pci_dev *pdev) 99static void __devinit loongson_cs5536_isa_fixup(struct pci_dev *pdev)
100{ 100{
101 /* the uart1 and uart2 interrupt in PIC is enabled as default */ 101 /* the uart1 and uart2 interrupt in PIC is enabled as default */
102 pci_write_config_dword(pdev, PCI_UART1_INT_REG, 1); 102 pci_write_config_dword(pdev, PCI_UART1_INT_REG, 1);
103 pci_write_config_dword(pdev, PCI_UART2_INT_REG, 1); 103 pci_write_config_dword(pdev, PCI_UART2_INT_REG, 1);
104} 104}
105 105
106static void __init loongson_cs5536_ide_fixup(struct pci_dev *pdev) 106static void __devinit loongson_cs5536_ide_fixup(struct pci_dev *pdev)
107{ 107{
108 /* setting the mutex pin as IDE function */ 108 /* setting the mutex pin as IDE function */
109 pci_write_config_dword(pdev, PCI_IDE_CFG_REG, 109 pci_write_config_dword(pdev, PCI_IDE_CFG_REG,
110 CS5536_IDE_FLASH_SIGNATURE); 110 CS5536_IDE_FLASH_SIGNATURE);
111} 111}
112 112
113static void __init loongson_cs5536_acc_fixup(struct pci_dev *pdev) 113static void __devinit loongson_cs5536_acc_fixup(struct pci_dev *pdev)
114{ 114{
115 /* enable the AUDIO interrupt in PIC */ 115 /* enable the AUDIO interrupt in PIC */
116 pci_write_config_dword(pdev, PCI_ACC_INT_REG, 1); 116 pci_write_config_dword(pdev, PCI_ACC_INT_REG, 1);
@@ -118,14 +118,14 @@ static void __init loongson_cs5536_acc_fixup(struct pci_dev *pdev)
118 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xc0); 118 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xc0);
119} 119}
120 120
121static void __init loongson_cs5536_ohci_fixup(struct pci_dev *pdev) 121static void __devinit loongson_cs5536_ohci_fixup(struct pci_dev *pdev)
122{ 122{
123 /* enable the OHCI interrupt in PIC */ 123 /* enable the OHCI interrupt in PIC */
124 /* THE OHCI, EHCI, UDC, OTG are shared with interrupt in PIC */ 124 /* THE OHCI, EHCI, UDC, OTG are shared with interrupt in PIC */
125 pci_write_config_dword(pdev, PCI_OHCI_INT_REG, 1); 125 pci_write_config_dword(pdev, PCI_OHCI_INT_REG, 1);
126} 126}
127 127
128static void __init loongson_cs5536_ehci_fixup(struct pci_dev *pdev) 128static void __devinit loongson_cs5536_ehci_fixup(struct pci_dev *pdev)
129{ 129{
130 u32 hi, lo; 130 u32 hi, lo;
131 131
@@ -137,7 +137,7 @@ static void __init loongson_cs5536_ehci_fixup(struct pci_dev *pdev)
137 pci_write_config_dword(pdev, PCI_EHCI_FLADJ_REG, 0x2000); 137 pci_write_config_dword(pdev, PCI_EHCI_FLADJ_REG, 0x2000);
138} 138}
139 139
140static void __init loongson_nec_fixup(struct pci_dev *pdev) 140static void __devinit loongson_nec_fixup(struct pci_dev *pdev)
141{ 141{
142 unsigned int val; 142 unsigned int val;
143 143
diff --git a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
index 0f48498bc23..70073c98ed3 100644
--- a/arch/mips/pci/fixup-malta.c
+++ b/arch/mips/pci/fixup-malta.c
@@ -49,10 +49,10 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
49 return 0; 49 return 0;
50} 50}
51 51
52static void __init malta_piix_func0_fixup(struct pci_dev *pdev) 52static void __devinit malta_piix_func0_fixup(struct pci_dev *pdev)
53{ 53{
54 unsigned char reg_val; 54 unsigned char reg_val;
55 static int piixirqmap[16] __initdata = { /* PIIX PIRQC[A:D] irq mappings */ 55 static int piixirqmap[16] __devinitdata = { /* PIIX PIRQC[A:D] irq mappings */
56 0, 0, 0, 3, 56 0, 0, 0, 3,
57 4, 5, 6, 7, 57 4, 5, 6, 7,
58 0, 9, 10, 11, 58 0, 9, 10, 11,
@@ -83,7 +83,7 @@ static void __init malta_piix_func0_fixup(struct pci_dev *pdev)
83DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, 83DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
84 malta_piix_func0_fixup); 84 malta_piix_func0_fixup);
85 85
86static void __init malta_piix_func1_fixup(struct pci_dev *pdev) 86static void __devinit malta_piix_func1_fixup(struct pci_dev *pdev)
87{ 87{
88 unsigned char reg_val; 88 unsigned char reg_val;
89 89
diff --git a/arch/mips/pci/fixup-mpc30x.c b/arch/mips/pci/fixup-mpc30x.c
index e08f49cb687..8e4f8288eca 100644
--- a/arch/mips/pci/fixup-mpc30x.c
+++ b/arch/mips/pci/fixup-mpc30x.c
@@ -22,13 +22,13 @@
22 22
23#include <asm/vr41xx/mpc30x.h> 23#include <asm/vr41xx/mpc30x.h>
24 24
25static const int internal_func_irqs[] __initdata = { 25static const int internal_func_irqs[] __initconst = {
26 VRC4173_CASCADE_IRQ, 26 VRC4173_CASCADE_IRQ,
27 VRC4173_AC97_IRQ, 27 VRC4173_AC97_IRQ,
28 VRC4173_USB_IRQ, 28 VRC4173_USB_IRQ,
29}; 29};
30 30
31static const int irq_tab_mpc30x[] __initdata = { 31static const int irq_tab_mpc30x[] __initconst = {
32 [12] = VRC4173_PCMCIA1_IRQ, 32 [12] = VRC4173_PCMCIA1_IRQ,
33 [13] = VRC4173_PCMCIA2_IRQ, 33 [13] = VRC4173_PCMCIA2_IRQ,
34 [29] = MQ200_IRQ, 34 [29] = MQ200_IRQ,
diff --git a/arch/mips/pci/fixup-sb1250.c b/arch/mips/pci/fixup-sb1250.c
index f0bb9146e6c..d02900a7291 100644
--- a/arch/mips/pci/fixup-sb1250.c
+++ b/arch/mips/pci/fixup-sb1250.c
@@ -15,7 +15,7 @@
15 * Set the BCM1250, etc. PCI host bridge's TRDY timeout 15 * Set the BCM1250, etc. PCI host bridge's TRDY timeout
16 * to the finite max. 16 * to the finite max.
17 */ 17 */
18static void __init quirk_sb1250_pci(struct pci_dev *dev) 18static void __devinit quirk_sb1250_pci(struct pci_dev *dev)
19{ 19{
20 pci_write_config_byte(dev, 0x40, 0xff); 20 pci_write_config_byte(dev, 0x40, 0xff);
21} 21}
@@ -25,7 +25,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SIBYTE, PCI_DEVICE_ID_BCM1250_PCI,
25/* 25/*
26 * The BCM1250, etc. PCI/HT bridge reports as a host bridge. 26 * The BCM1250, etc. PCI/HT bridge reports as a host bridge.
27 */ 27 */
28static void __init quirk_sb1250_ht(struct pci_dev *dev) 28static void __devinit quirk_sb1250_ht(struct pci_dev *dev)
29{ 29{
30 dev->class = PCI_CLASS_BRIDGE_PCI << 8; 30 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
31} 31}
@@ -35,7 +35,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SIBYTE, PCI_DEVICE_ID_BCM1250_HT,
35/* 35/*
36 * Set the SP1011 HT/PCI bridge's TRDY timeout to the finite max. 36 * Set the SP1011 HT/PCI bridge's TRDY timeout to the finite max.
37 */ 37 */
38static void __init quirk_sp1011(struct pci_dev *dev) 38static void __devinit quirk_sp1011(struct pci_dev *dev)
39{ 39{
40 pci_write_config_byte(dev, 0x64, 0xff); 40 pci_write_config_byte(dev, 0x64, 0xff);
41} 41}
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index a1e7e6d80c8..bc13e29d2bb 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -495,7 +495,7 @@ irqreturn_t tx4927_pcierr_interrupt(int irq, void *dev_id)
495} 495}
496 496
497#ifdef CONFIG_TOSHIBA_FPCIB0 497#ifdef CONFIG_TOSHIBA_FPCIB0
498static void __init tx4927_quirk_slc90e66_bridge(struct pci_dev *dev) 498static void __devinit tx4927_quirk_slc90e66_bridge(struct pci_dev *dev)
499{ 499{
500 struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(dev->bus); 500 struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(dev->bus);
501 501
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index 0fbe4c0c170..fdc24440294 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -212,7 +212,7 @@ static inline void pci_enable_swapping(struct pci_dev *dev)
212 bridge->b_widget.w_tflush; /* Flush */ 212 bridge->b_widget.w_tflush; /* Flush */
213} 213}
214 214
215static void __init pci_fixup_ioc3(struct pci_dev *d) 215static void __devinit pci_fixup_ioc3(struct pci_dev *d)
216{ 216{
217 pci_disable_swapping(d); 217 pci_disable_swapping(d);
218} 218}
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index ea453532a33..075d87acd12 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -129,7 +129,7 @@ static int __devinit ltq_pci_startup(struct platform_device *pdev)
129 129
130 /* setup reset gpio used by pci */ 130 /* setup reset gpio used by pci */
131 reset_gpio = of_get_named_gpio(node, "gpio-reset", 0); 131 reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
132 if (reset_gpio > 0) 132 if (gpio_is_valid(reset_gpio))
133 devm_gpio_request(&pdev->dev, reset_gpio, "pci-reset"); 133 devm_gpio_request(&pdev->dev, reset_gpio, "pci-reset");
134 134
135 /* enable auto-switching between PCI and EBU */ 135 /* enable auto-switching between PCI and EBU */
@@ -192,7 +192,7 @@ static int __devinit ltq_pci_startup(struct platform_device *pdev)
192 ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_IEN) | 0x10, LTQ_EBU_PCC_IEN); 192 ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_IEN) | 0x10, LTQ_EBU_PCC_IEN);
193 193
194 /* toggle reset pin */ 194 /* toggle reset pin */
195 if (reset_gpio > 0) { 195 if (gpio_is_valid(reset_gpio)) {
196 __gpio_set_value(reset_gpio, 0); 196 __gpio_set_value(reset_gpio, 0);
197 wmb(); 197 wmb();
198 mdelay(1); 198 mdelay(1);
diff --git a/arch/mips/pci/pci-xlr.c b/arch/mips/pci/pci-xlr.c
index 1644805a673..172af1cd586 100644
--- a/arch/mips/pci/pci-xlr.c
+++ b/arch/mips/pci/pci-xlr.c
@@ -41,6 +41,7 @@
41#include <linux/irq.h> 41#include <linux/irq.h>
42#include <linux/irqdesc.h> 42#include <linux/irqdesc.h>
43#include <linux/console.h> 43#include <linux/console.h>
44#include <linux/pci_regs.h>
44 45
45#include <asm/io.h> 46#include <asm/io.h>
46 47
@@ -156,35 +157,55 @@ struct pci_controller nlm_pci_controller = {
156 .io_offset = 0x00000000UL, 157 .io_offset = 0x00000000UL,
157}; 158};
158 159
160/*
161 * The top level PCIe links on the XLS PCIe controller appear as
162 * bridges. Given a device, this function finds which link it is
163 * on.
164 */
165static struct pci_dev *xls_get_pcie_link(const struct pci_dev *dev)
166{
167 struct pci_bus *bus, *p;
168
169 /* Find the bridge on bus 0 */
170 bus = dev->bus;
171 for (p = bus->parent; p && p->number != 0; p = p->parent)
172 bus = p;
173
174 return p ? bus->self : NULL;
175}
176
159static int get_irq_vector(const struct pci_dev *dev) 177static int get_irq_vector(const struct pci_dev *dev)
160{ 178{
179 struct pci_dev *lnk;
180
161 if (!nlm_chip_is_xls()) 181 if (!nlm_chip_is_xls())
162 return PIC_PCIX_IRQ; /* for XLR just one IRQ*/ 182 return PIC_PCIX_IRQ; /* for XLR just one IRQ */
163 183
164 /* 184 /*
165 * For XLS PCIe, there is an IRQ per Link, find out which 185 * For XLS PCIe, there is an IRQ per Link, find out which
166 * link the device is on to assign interrupts 186 * link the device is on to assign interrupts
167 */ 187 */
168 if (dev->bus->self == NULL) 188 lnk = xls_get_pcie_link(dev);
189 if (lnk == NULL)
169 return 0; 190 return 0;
170 191
171 switch (dev->bus->self->devfn) { 192 switch (PCI_SLOT(lnk->devfn)) {
172 case 0x0: 193 case 0:
173 return PIC_PCIE_LINK0_IRQ; 194 return PIC_PCIE_LINK0_IRQ;
174 case 0x8: 195 case 1:
175 return PIC_PCIE_LINK1_IRQ; 196 return PIC_PCIE_LINK1_IRQ;
176 case 0x10: 197 case 2:
177 if (nlm_chip_is_xls_b()) 198 if (nlm_chip_is_xls_b())
178 return PIC_PCIE_XLSB0_LINK2_IRQ; 199 return PIC_PCIE_XLSB0_LINK2_IRQ;
179 else 200 else
180 return PIC_PCIE_LINK2_IRQ; 201 return PIC_PCIE_LINK2_IRQ;
181 case 0x18: 202 case 3:
182 if (nlm_chip_is_xls_b()) 203 if (nlm_chip_is_xls_b())
183 return PIC_PCIE_XLSB0_LINK3_IRQ; 204 return PIC_PCIE_XLSB0_LINK3_IRQ;
184 else 205 else
185 return PIC_PCIE_LINK3_IRQ; 206 return PIC_PCIE_LINK3_IRQ;
186 } 207 }
187 WARN(1, "Unexpected devfn %d\n", dev->bus->self->devfn); 208 WARN(1, "Unexpected devfn %d\n", lnk->devfn);
188 return 0; 209 return 0;
189} 210}
190 211
@@ -202,7 +223,27 @@ void arch_teardown_msi_irq(unsigned int irq)
202int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) 223int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
203{ 224{
204 struct msi_msg msg; 225 struct msi_msg msg;
226 struct pci_dev *lnk;
205 int irq, ret; 227 int irq, ret;
228 u16 val;
229
230 /* MSI not supported on XLR */
231 if (!nlm_chip_is_xls())
232 return 1;
233
234 /*
235 * Enable MSI on the XLS PCIe controller bridge which was disabled
236 * at enumeration, the bridge MSI capability is at 0x50
237 */
238 lnk = xls_get_pcie_link(dev);
239 if (lnk == NULL)
240 return 1;
241
242 pci_read_config_word(lnk, 0x50 + PCI_MSI_FLAGS, &val);
243 if ((val & PCI_MSI_FLAGS_ENABLE) == 0) {
244 val |= PCI_MSI_FLAGS_ENABLE;
245 pci_write_config_word(lnk, 0x50 + PCI_MSI_FLAGS, val);
246 }
206 247
207 irq = get_irq_vector(dev); 248 irq = get_irq_vector(dev);
208 if (irq <= 0) 249 if (irq <= 0)
@@ -327,7 +368,7 @@ static int __init pcibios_init(void)
327 } 368 }
328 } else { 369 } else {
329 /* XLR PCI controller ACK */ 370 /* XLR PCI controller ACK */
330 irq_set_handler_data(PIC_PCIE_XLSB0_LINK3_IRQ, xlr_pci_ack); 371 irq_set_handler_data(PIC_PCIX_IRQ, xlr_pci_ack);
331 } 372 }
332 373
333 return 0; 374 return 0;
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index b71fae23104..5edab2bc6fc 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -115,11 +115,11 @@ static void yos_send_ipi_mask(const struct cpumask *mask, unsigned int action)
115 */ 115 */
116static void __cpuinit yos_init_secondary(void) 116static void __cpuinit yos_init_secondary(void)
117{ 117{
118 set_c0_status(ST0_CO | ST0_IE | ST0_IM);
119} 118}
120 119
121static void __cpuinit yos_smp_finish(void) 120static void __cpuinit yos_smp_finish(void)
122{ 121{
122 set_c0_status(ST0_CO | ST0_IM | ST0_IE);
123} 123}
124 124
125/* Hook for after all CPUs are online */ 125/* Hook for after all CPUs are online */
diff --git a/arch/mips/powertv/asic/asic-calliope.c b/arch/mips/powertv/asic/asic-calliope.c
index 0a170e0ffea..7773f3d956b 100644
--- a/arch/mips/powertv/asic/asic-calliope.c
+++ b/arch/mips/powertv/asic/asic-calliope.c
@@ -28,7 +28,7 @@
28 28
29#define CALLIOPE_ADDR(x) (CALLIOPE_IO_BASE + (x)) 29#define CALLIOPE_ADDR(x) (CALLIOPE_IO_BASE + (x))
30 30
31const struct register_map calliope_register_map __initdata = { 31const struct register_map calliope_register_map __initconst = {
32 .eic_slow0_strt_add = {.phys = CALLIOPE_ADDR(0x800000)}, 32 .eic_slow0_strt_add = {.phys = CALLIOPE_ADDR(0x800000)},
33 .eic_cfg_bits = {.phys = CALLIOPE_ADDR(0x800038)}, 33 .eic_cfg_bits = {.phys = CALLIOPE_ADDR(0x800038)},
34 .eic_ready_status = {.phys = CALLIOPE_ADDR(0x80004c)}, 34 .eic_ready_status = {.phys = CALLIOPE_ADDR(0x80004c)},
diff --git a/arch/mips/powertv/asic/asic-cronus.c b/arch/mips/powertv/asic/asic-cronus.c
index bbc0c122be5..da076db7b7e 100644
--- a/arch/mips/powertv/asic/asic-cronus.c
+++ b/arch/mips/powertv/asic/asic-cronus.c
@@ -28,7 +28,7 @@
28 28
29#define CRONUS_ADDR(x) (CRONUS_IO_BASE + (x)) 29#define CRONUS_ADDR(x) (CRONUS_IO_BASE + (x))
30 30
31const struct register_map cronus_register_map __initdata = { 31const struct register_map cronus_register_map __initconst = {
32 .eic_slow0_strt_add = {.phys = CRONUS_ADDR(0x000000)}, 32 .eic_slow0_strt_add = {.phys = CRONUS_ADDR(0x000000)},
33 .eic_cfg_bits = {.phys = CRONUS_ADDR(0x000038)}, 33 .eic_cfg_bits = {.phys = CRONUS_ADDR(0x000038)},
34 .eic_ready_status = {.phys = CRONUS_ADDR(0x00004C)}, 34 .eic_ready_status = {.phys = CRONUS_ADDR(0x00004C)},
diff --git a/arch/mips/powertv/asic/asic-gaia.c b/arch/mips/powertv/asic/asic-gaia.c
index 91dda682752..47683b370e7 100644
--- a/arch/mips/powertv/asic/asic-gaia.c
+++ b/arch/mips/powertv/asic/asic-gaia.c
@@ -23,7 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <asm/mach-powertv/asic.h> 24#include <asm/mach-powertv/asic.h>
25 25
26const struct register_map gaia_register_map __initdata = { 26const struct register_map gaia_register_map __initconst = {
27 .eic_slow0_strt_add = {.phys = GAIA_IO_BASE + 0x000000}, 27 .eic_slow0_strt_add = {.phys = GAIA_IO_BASE + 0x000000},
28 .eic_cfg_bits = {.phys = GAIA_IO_BASE + 0x000038}, 28 .eic_cfg_bits = {.phys = GAIA_IO_BASE + 0x000038},
29 .eic_ready_status = {.phys = GAIA_IO_BASE + 0x00004C}, 29 .eic_ready_status = {.phys = GAIA_IO_BASE + 0x00004C},
diff --git a/arch/mips/powertv/asic/asic-zeus.c b/arch/mips/powertv/asic/asic-zeus.c
index 4a05bb09647..6ff4b10f09d 100644
--- a/arch/mips/powertv/asic/asic-zeus.c
+++ b/arch/mips/powertv/asic/asic-zeus.c
@@ -28,7 +28,7 @@
28 28
29#define ZEUS_ADDR(x) (ZEUS_IO_BASE + (x)) 29#define ZEUS_ADDR(x) (ZEUS_IO_BASE + (x))
30 30
31const struct register_map zeus_register_map __initdata = { 31const struct register_map zeus_register_map __initconst = {
32 .eic_slow0_strt_add = {.phys = ZEUS_ADDR(0x000000)}, 32 .eic_slow0_strt_add = {.phys = ZEUS_ADDR(0x000000)},
33 .eic_cfg_bits = {.phys = ZEUS_ADDR(0x000038)}, 33 .eic_cfg_bits = {.phys = ZEUS_ADDR(0x000038)},
34 .eic_ready_status = {.phys = ZEUS_ADDR(0x00004c)}, 34 .eic_ready_status = {.phys = ZEUS_ADDR(0x00004c)},
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index 682efb0c108..64eb71b1528 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -269,7 +269,7 @@ txx9_i8259_irq_setup(int irq)
269 return err; 269 return err;
270} 270}
271 271
272static void __init quirk_slc90e66_bridge(struct pci_dev *dev) 272static void __devinit quirk_slc90e66_bridge(struct pci_dev *dev)
273{ 273{
274 int irq; /* PCI/ISA Bridge interrupt */ 274 int irq; /* PCI/ISA Bridge interrupt */
275 u8 reg_64; 275 u8 reg_64;
diff --git a/arch/mn10300/include/asm/ptrace.h b/arch/mn10300/include/asm/ptrace.h
index 55b79ef1002..44251b974f1 100644
--- a/arch/mn10300/include/asm/ptrace.h
+++ b/arch/mn10300/include/asm/ptrace.h
@@ -81,9 +81,6 @@ struct pt_regs {
81#define PTRACE_GETFPREGS 14 81#define PTRACE_GETFPREGS 14
82#define PTRACE_SETFPREGS 15 82#define PTRACE_SETFPREGS 15
83 83
84/* options set using PTRACE_SETOPTIONS */
85#define PTRACE_O_TRACESYSGOOD 0x00000001
86
87#ifdef __KERNEL__ 84#ifdef __KERNEL__
88 85
89#define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL) 86#define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL)
diff --git a/arch/mn10300/include/asm/thread_info.h b/arch/mn10300/include/asm/thread_info.h
index 08251d6f6b1..ac519bbd42f 100644
--- a/arch/mn10300/include/asm/thread_info.h
+++ b/arch/mn10300/include/asm/thread_info.h
@@ -123,7 +123,7 @@ static inline unsigned long current_stack_pointer(void)
123} 123}
124 124
125#ifndef CONFIG_KGDB 125#ifndef CONFIG_KGDB
126void arch_release_thread_info(struct thread_info *ti) 126void arch_release_thread_info(struct thread_info *ti);
127#endif 127#endif
128#define get_thread_info(ti) get_task_struct((ti)->task) 128#define get_thread_info(ti) get_task_struct((ti)->task)
129#define put_thread_info(ti) put_task_struct((ti)->task) 129#define put_thread_info(ti) put_task_struct((ti)->task)
diff --git a/arch/mn10300/include/asm/timex.h b/arch/mn10300/include/asm/timex.h
index bd4e90dfe6c..f8e66425cbf 100644
--- a/arch/mn10300/include/asm/timex.h
+++ b/arch/mn10300/include/asm/timex.h
@@ -11,7 +11,6 @@
11#ifndef _ASM_TIMEX_H 11#ifndef _ASM_TIMEX_H
12#define _ASM_TIMEX_H 12#define _ASM_TIMEX_H
13 13
14#include <asm/hardirq.h>
15#include <unit/timex.h> 14#include <unit/timex.h>
16 15
17#define TICK_SIZE (tick_nsec / 1000) 16#define TICK_SIZE (tick_nsec / 1000)
@@ -30,16 +29,6 @@ static inline cycles_t get_cycles(void)
30extern int init_clockevents(void); 29extern int init_clockevents(void);
31extern int init_clocksource(void); 30extern int init_clocksource(void);
32 31
33static inline void setup_jiffies_interrupt(int irq,
34 struct irqaction *action)
35{
36 u16 tmp;
37 setup_irq(irq, action);
38 set_intr_level(irq, NUM2GxICR_LEVEL(CONFIG_TIMER_IRQ_LEVEL));
39 GxICR(irq) |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
40 tmp = GxICR(irq);
41}
42
43#endif /* __KERNEL__ */ 32#endif /* __KERNEL__ */
44 33
45#endif /* _ASM_TIMEX_H */ 34#endif /* _ASM_TIMEX_H */
diff --git a/arch/mn10300/kernel/cevt-mn10300.c b/arch/mn10300/kernel/cevt-mn10300.c
index 69cae026078..ccce35e3e17 100644
--- a/arch/mn10300/kernel/cevt-mn10300.c
+++ b/arch/mn10300/kernel/cevt-mn10300.c
@@ -70,6 +70,16 @@ static void event_handler(struct clock_event_device *dev)
70{ 70{
71} 71}
72 72
73static inline void setup_jiffies_interrupt(int irq,
74 struct irqaction *action)
75{
76 u16 tmp;
77 setup_irq(irq, action);
78 set_intr_level(irq, NUM2GxICR_LEVEL(CONFIG_TIMER_IRQ_LEVEL));
79 GxICR(irq) |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
80 tmp = GxICR(irq);
81}
82
73int __init init_clockevents(void) 83int __init init_clockevents(void)
74{ 84{
75 struct clock_event_device *cd; 85 struct clock_event_device *cd;
diff --git a/arch/mn10300/kernel/internal.h b/arch/mn10300/kernel/internal.h
index a5ac755dd69..2df440105a8 100644
--- a/arch/mn10300/kernel/internal.h
+++ b/arch/mn10300/kernel/internal.h
@@ -9,6 +9,8 @@
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/irqreturn.h>
13
12struct clocksource; 14struct clocksource;
13struct clock_event_device; 15struct clock_event_device;
14 16
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c
index 2381df83bd0..35932a8de8b 100644
--- a/arch/mn10300/kernel/irq.c
+++ b/arch/mn10300/kernel/irq.c
@@ -170,9 +170,9 @@ mn10300_cpupic_setaffinity(struct irq_data *d, const struct cpumask *mask,
170 case SC1TXIRQ: 170 case SC1TXIRQ:
171#ifdef CONFIG_MN10300_TTYSM1_TIMER12 171#ifdef CONFIG_MN10300_TTYSM1_TIMER12
172 case TM12IRQ: 172 case TM12IRQ:
173#elif CONFIG_MN10300_TTYSM1_TIMER9 173#elif defined(CONFIG_MN10300_TTYSM1_TIMER9)
174 case TM9IRQ: 174 case TM9IRQ:
175#elif CONFIG_MN10300_TTYSM1_TIMER3 175#elif defined(CONFIG_MN10300_TTYSM1_TIMER3)
176 case TM3IRQ: 176 case TM3IRQ:
177#endif /* CONFIG_MN10300_TTYSM1_TIMER12 */ 177#endif /* CONFIG_MN10300_TTYSM1_TIMER12 */
178#endif /* CONFIG_MN10300_TTYSM1 */ 178#endif /* CONFIG_MN10300_TTYSM1 */
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c
index 6ab0bee2a54..4d584ae29ae 100644
--- a/arch/mn10300/kernel/signal.c
+++ b/arch/mn10300/kernel/signal.c
@@ -459,10 +459,11 @@ static int handle_signal(int sig,
459 else 459 else
460 ret = setup_frame(sig, ka, oldset, regs); 460 ret = setup_frame(sig, ka, oldset, regs);
461 if (ret) 461 if (ret)
462 return; 462 return ret;
463 463
464 signal_delivered(sig, info, ka, regs, 464 signal_delivered(sig, info, ka, regs,
465 test_thread_flag(TIF_SINGLESTEP)); 465 test_thread_flag(TIF_SINGLESTEP));
466 return 0;
466} 467}
467 468
468/* 469/*
diff --git a/arch/mn10300/kernel/traps.c b/arch/mn10300/kernel/traps.c
index 94a9c6d53e1..b900e5afa0a 100644
--- a/arch/mn10300/kernel/traps.c
+++ b/arch/mn10300/kernel/traps.c
@@ -26,6 +26,7 @@
26#include <linux/kdebug.h> 26#include <linux/kdebug.h>
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/irq.h> 28#include <linux/irq.h>
29#include <linux/export.h>
29#include <asm/processor.h> 30#include <asm/processor.h>
30#include <linux/uaccess.h> 31#include <linux/uaccess.h>
31#include <asm/io.h> 32#include <asm/io.h>
diff --git a/arch/mn10300/mm/dma-alloc.c b/arch/mn10300/mm/dma-alloc.c
index 159acb02cfd..e244ebe637e 100644
--- a/arch/mn10300/mm/dma-alloc.c
+++ b/arch/mn10300/mm/dma-alloc.c
@@ -15,6 +15,7 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/gfp.h> 17#include <linux/gfp.h>
18#include <linux/export.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20static unsigned long pci_sram_allocated = 0xbc000000; 21static unsigned long pci_sram_allocated = 0xbc000000;
diff --git a/arch/mn10300/unit-asb2303/include/unit/timex.h b/arch/mn10300/unit-asb2303/include/unit/timex.h
index cc18fe7d8b9..c37f9832cf1 100644
--- a/arch/mn10300/unit-asb2303/include/unit/timex.h
+++ b/arch/mn10300/unit-asb2303/include/unit/timex.h
@@ -11,10 +11,6 @@
11#ifndef _ASM_UNIT_TIMEX_H 11#ifndef _ASM_UNIT_TIMEX_H
12#define _ASM_UNIT_TIMEX_H 12#define _ASM_UNIT_TIMEX_H
13 13
14#ifndef __ASSEMBLY__
15#include <linux/irq.h>
16#endif /* __ASSEMBLY__ */
17
18#include <asm/timer-regs.h> 14#include <asm/timer-regs.h>
19#include <unit/clock.h> 15#include <unit/clock.h>
20#include <asm/param.h> 16#include <asm/param.h>
diff --git a/arch/mn10300/unit-asb2303/smc91111.c b/arch/mn10300/unit-asb2303/smc91111.c
index 43c24643941..53677694b16 100644
--- a/arch/mn10300/unit-asb2303/smc91111.c
+++ b/arch/mn10300/unit-asb2303/smc91111.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16 16
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/irq.h>
18#include <asm/timex.h> 19#include <asm/timex.h>
19#include <asm/processor.h> 20#include <asm/processor.h>
20#include <asm/intctl-regs.h> 21#include <asm/intctl-regs.h>
diff --git a/arch/mn10300/unit-asb2305/include/unit/timex.h b/arch/mn10300/unit-asb2305/include/unit/timex.h
index 758af30d1a1..4cefc224f44 100644
--- a/arch/mn10300/unit-asb2305/include/unit/timex.h
+++ b/arch/mn10300/unit-asb2305/include/unit/timex.h
@@ -11,10 +11,6 @@
11#ifndef _ASM_UNIT_TIMEX_H 11#ifndef _ASM_UNIT_TIMEX_H
12#define _ASM_UNIT_TIMEX_H 12#define _ASM_UNIT_TIMEX_H
13 13
14#ifndef __ASSEMBLY__
15#include <linux/irq.h>
16#endif /* __ASSEMBLY__ */
17
18#include <asm/timer-regs.h> 14#include <asm/timer-regs.h>
19#include <unit/clock.h> 15#include <unit/clock.h>
20#include <asm/param.h> 16#include <asm/param.h>
diff --git a/arch/mn10300/unit-asb2305/unit-init.c b/arch/mn10300/unit-asb2305/unit-init.c
index e1becd6b757..bc4adfaf815 100644
--- a/arch/mn10300/unit-asb2305/unit-init.c
+++ b/arch/mn10300/unit-asb2305/unit-init.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/irq.h>
16#include <asm/setup.h> 17#include <asm/setup.h>
17#include <asm/processor.h> 18#include <asm/processor.h>
18#include <asm/intctl-regs.h> 19#include <asm/intctl-regs.h>
diff --git a/arch/mn10300/unit-asb2364/include/unit/timex.h b/arch/mn10300/unit-asb2364/include/unit/timex.h
index ddb7ed01070..42f32db7508 100644
--- a/arch/mn10300/unit-asb2364/include/unit/timex.h
+++ b/arch/mn10300/unit-asb2364/include/unit/timex.h
@@ -11,10 +11,6 @@
11#ifndef _ASM_UNIT_TIMEX_H 11#ifndef _ASM_UNIT_TIMEX_H
12#define _ASM_UNIT_TIMEX_H 12#define _ASM_UNIT_TIMEX_H
13 13
14#ifndef __ASSEMBLY__
15#include <linux/irq.h>
16#endif /* __ASSEMBLY__ */
17
18#include <asm/timer-regs.h> 14#include <asm/timer-regs.h>
19#include <unit/clock.h> 15#include <unit/clock.h>
20#include <asm/param.h> 16#include <asm/param.h>
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 6eb75b80488..0554ab062bd 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -86,8 +86,8 @@ static inline bool arch_irqs_disabled(void)
86} 86}
87 87
88#ifdef CONFIG_PPC_BOOK3E 88#ifdef CONFIG_PPC_BOOK3E
89#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory"); 89#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
90#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory"); 90#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
91#else 91#else
92#define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1) 92#define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
93#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1) 93#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
@@ -125,6 +125,8 @@ static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
125 return !regs->softe; 125 return !regs->softe;
126} 126}
127 127
128extern bool prep_irq_for_idle(void);
129
128#else /* CONFIG_PPC64 */ 130#else /* CONFIG_PPC64 */
129 131
130#define SET_MSR_EE(x) mtmsr(x) 132#define SET_MSR_EE(x) mtmsr(x)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 1b415027ec0..1f017bb7a7c 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -229,7 +229,7 @@ notrace void arch_local_irq_restore(unsigned long en)
229 */ 229 */
230 if (unlikely(irq_happened != PACA_IRQ_HARD_DIS)) 230 if (unlikely(irq_happened != PACA_IRQ_HARD_DIS))
231 __hard_irq_disable(); 231 __hard_irq_disable();
232#ifdef CONFIG_TRACE_IRQFLAG 232#ifdef CONFIG_TRACE_IRQFLAGS
233 else { 233 else {
234 /* 234 /*
235 * We should already be hard disabled here. We had bugs 235 * We should already be hard disabled here. We had bugs
@@ -286,6 +286,52 @@ void notrace restore_interrupts(void)
286 __hard_irq_enable(); 286 __hard_irq_enable();
287} 287}
288 288
289/*
290 * This is a helper to use when about to go into idle low-power
291 * when the latter has the side effect of re-enabling interrupts
292 * (such as calling H_CEDE under pHyp).
293 *
294 * You call this function with interrupts soft-disabled (this is
295 * already the case when ppc_md.power_save is called). The function
296 * will return whether to enter power save or just return.
297 *
298 * In the former case, it will have notified lockdep of interrupts
299 * being re-enabled and generally sanitized the lazy irq state,
300 * and in the latter case it will leave with interrupts hard
301 * disabled and marked as such, so the local_irq_enable() call
302 * in cpu_idle() will properly re-enable everything.
303 */
304bool prep_irq_for_idle(void)
305{
306 /*
307 * First we need to hard disable to ensure no interrupt
308 * occurs before we effectively enter the low power state
309 */
310 hard_irq_disable();
311
312 /*
313 * If anything happened while we were soft-disabled,
314 * we return now and do not enter the low power state.
315 */
316 if (lazy_irq_pending())
317 return false;
318
319 /* Tell lockdep we are about to re-enable */
320 trace_hardirqs_on();
321
322 /*
323 * Mark interrupts as soft-enabled and clear the
324 * PACA_IRQ_HARD_DIS from the pending mask since we
325 * are about to hard enable as well as a side effect
326 * of entering the low power state.
327 */
328 local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
329 local_paca->soft_enabled = 1;
330
331 /* Tell the caller to enter the low power state */
332 return true;
333}
334
289#endif /* CONFIG_PPC64 */ 335#endif /* CONFIG_PPC64 */
290 336
291int arch_show_interrupts(struct seq_file *p, int prec) 337int arch_show_interrupts(struct seq_file *p, int prec)
diff --git a/arch/powerpc/kvm/book3s_pr_papr.c b/arch/powerpc/kvm/book3s_pr_papr.c
index 3ff9013d6e7..ee02b30878e 100644
--- a/arch/powerpc/kvm/book3s_pr_papr.c
+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -241,6 +241,7 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd)
241 case H_PUT_TCE: 241 case H_PUT_TCE:
242 return kvmppc_h_pr_put_tce(vcpu); 242 return kvmppc_h_pr_put_tce(vcpu);
243 case H_CEDE: 243 case H_CEDE:
244 vcpu->arch.shared->msr |= MSR_EE;
244 kvm_vcpu_block(vcpu); 245 kvm_vcpu_block(vcpu);
245 clear_bit(KVM_REQ_UNHALT, &vcpu->requests); 246 clear_bit(KVM_REQ_UNHALT, &vcpu->requests);
246 vcpu->stat.halt_wakeup++; 247 vcpu->stat.halt_wakeup++;
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 6e8f677f564..1e95556dc69 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -639,7 +639,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
639 unsigned int n, rc, ranges, is_kexec_kdump = 0; 639 unsigned int n, rc, ranges, is_kexec_kdump = 0;
640 unsigned long lmb_size, base, size, sz; 640 unsigned long lmb_size, base, size, sz;
641 int nid; 641 int nid;
642 struct assoc_arrays aa; 642 struct assoc_arrays aa = { .arrays = NULL };
643 643
644 n = of_get_drconf_memory(memory, &dm); 644 n = of_get_drconf_memory(memory, &dm);
645 if (!n) 645 if (!n)
diff --git a/arch/powerpc/platforms/cell/pervasive.c b/arch/powerpc/platforms/cell/pervasive.c
index efdacc82957..d17e98bc0c1 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -42,11 +42,9 @@ static void cbe_power_save(void)
42{ 42{
43 unsigned long ctrl, thread_switch_control; 43 unsigned long ctrl, thread_switch_control;
44 44
45 /* 45 /* Ensure our interrupt state is properly tracked */
46 * We need to hard disable interrupts, the local_irq_enable() done by 46 if (!prep_irq_for_idle())
47 * our caller upon return will hard re-enable. 47 return;
48 */
49 hard_irq_disable();
50 48
51 ctrl = mfspr(SPRN_CTRLF); 49 ctrl = mfspr(SPRN_CTRLF);
52 50
@@ -81,6 +79,9 @@ static void cbe_power_save(void)
81 */ 79 */
82 ctrl &= ~(CTRL_RUNLATCH | CTRL_TE); 80 ctrl &= ~(CTRL_RUNLATCH | CTRL_TE);
83 mtspr(SPRN_CTRLT, ctrl); 81 mtspr(SPRN_CTRLT, ctrl);
82
83 /* Re-enable interrupts in MSR */
84 __hard_irq_enable();
84} 85}
85 86
86static int cbe_system_reset_exception(struct pt_regs *regs) 87static int cbe_system_reset_exception(struct pt_regs *regs)
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index e61483e8e96..c71be66bd5d 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -99,15 +99,18 @@ out:
99static void check_and_cede_processor(void) 99static void check_and_cede_processor(void)
100{ 100{
101 /* 101 /*
102 * Interrupts are soft-disabled at this point, 102 * Ensure our interrupt state is properly tracked,
103 * but not hard disabled. So an interrupt might have 103 * also checks if no interrupt has occurred while we
104 * occurred before entering NAP, and would be potentially 104 * were soft-disabled
105 * lost (edge events, decrementer events, etc...) unless
106 * we first hard disable then check.
107 */ 105 */
108 hard_irq_disable(); 106 if (prep_irq_for_idle()) {
109 if (!lazy_irq_pending())
110 cede_processor(); 107 cede_processor();
108#ifdef CONFIG_TRACE_IRQFLAGS
109 /* Ensure that H_CEDE returns with IRQs on */
110 if (WARN_ON(!(mfmsr() & MSR_EE)))
111 __hard_irq_enable();
112#endif
113 }
111} 114}
112 115
113static int dedicated_cede_loop(struct cpuidle_device *dev, 116static int dedicated_cede_loop(struct cpuidle_device *dev,
diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h
index e136d28d1d2..4d48f1436a6 100644
--- a/arch/sh/include/asm/io_noioport.h
+++ b/arch/sh/include/asm/io_noioport.h
@@ -19,9 +19,20 @@ static inline u32 inl(unsigned long addr)
19 return -1; 19 return -1;
20} 20}
21 21
22#define outb(x, y) BUG() 22static inline void outb(unsigned char x, unsigned long port)
23#define outw(x, y) BUG() 23{
24#define outl(x, y) BUG() 24 BUG();
25}
26
27static inline void outw(unsigned short x, unsigned long port)
28{
29 BUG();
30}
31
32static inline void outl(unsigned int x, unsigned long port)
33{
34 BUG();
35}
25 36
26#define inb_p(addr) inb(addr) 37#define inb_p(addr) inb(addr)
27#define inw_p(addr) inw(addr) 38#define inw_p(addr) inw(addr)
diff --git a/arch/sh/kernel/cpu/sh3/serial-sh7720.c b/arch/sh/kernel/cpu/sh3/serial-sh7720.c
index 8832c526cdf..c4a0336660d 100644
--- a/arch/sh/kernel/cpu/sh3/serial-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/serial-sh7720.c
@@ -2,7 +2,7 @@
2#include <linux/serial_core.h> 2#include <linux/serial_core.h>
3#include <linux/io.h> 3#include <linux/io.h>
4#include <cpu/serial.h> 4#include <cpu/serial.h>
5#include <asm/gpio.h> 5#include <cpu/gpio.h>
6 6
7static void sh7720_sci_init_pins(struct uart_port *port, unsigned int cflag) 7static void sh7720_sci_init_pins(struct uart_port *port, unsigned int cflag)
8{ 8{
diff --git a/arch/tile/kernel/backtrace.c b/arch/tile/kernel/backtrace.c
index 9092ce8aa6b..f8b74ca83b9 100644
--- a/arch/tile/kernel/backtrace.c
+++ b/arch/tile/kernel/backtrace.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <asm/byteorder.h>
17#include <asm/backtrace.h> 18#include <asm/backtrace.h>
18#include <asm/tile-desc.h> 19#include <asm/tile-desc.h>
19#include <arch/abi.h> 20#include <arch/abi.h>
@@ -336,8 +337,12 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location,
336 bytes_to_prefetch / sizeof(tile_bundle_bits); 337 bytes_to_prefetch / sizeof(tile_bundle_bits);
337 } 338 }
338 339
339 /* Decode the next bundle. */ 340 /*
340 bundle.bits = prefetched_bundles[next_bundle++]; 341 * Decode the next bundle.
342 * TILE always stores instruction bundles in little-endian
343 * mode, even when the chip is running in big-endian mode.
344 */
345 bundle.bits = le64_to_cpu(prefetched_bundles[next_bundle++]);
341 bundle.num_insns = 346 bundle.num_insns =
342 parse_insn_tile(bundle.bits, pc, bundle.insns); 347 parse_insn_tile(bundle.bits, pc, bundle.insns);
343 num_info_ops = bt_get_info_ops(&bundle, info_operands); 348 num_info_ops = bt_get_info_ops(&bundle, info_operands);
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 88e466b159d..43b39d61b53 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -705,7 +705,6 @@ static void stack_proc(void *arg)
705 struct task_struct *from = current, *to = arg; 705 struct task_struct *from = current, *to = arg;
706 706
707 to->thread.saved_task = from; 707 to->thread.saved_task = from;
708 rcu_switch_from(from);
709 switch_to(from, to, from); 708 switch_to(from, to, from);
710} 709}
711 710
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 7515cf0e180..5db36caf428 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -139,6 +139,19 @@ static int addr_to_vsyscall_nr(unsigned long addr)
139 return nr; 139 return nr;
140} 140}
141 141
142#ifdef CONFIG_SECCOMP
143static int vsyscall_seccomp(struct task_struct *tsk, int syscall_nr)
144{
145 if (!seccomp_mode(&tsk->seccomp))
146 return 0;
147 task_pt_regs(tsk)->orig_ax = syscall_nr;
148 task_pt_regs(tsk)->ax = syscall_nr;
149 return __secure_computing(syscall_nr);
150}
151#else
152#define vsyscall_seccomp(_tsk, _nr) 0
153#endif
154
142static bool write_ok_or_segv(unsigned long ptr, size_t size) 155static bool write_ok_or_segv(unsigned long ptr, size_t size)
143{ 156{
144 /* 157 /*
@@ -174,6 +187,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
174 int vsyscall_nr; 187 int vsyscall_nr;
175 int prev_sig_on_uaccess_error; 188 int prev_sig_on_uaccess_error;
176 long ret; 189 long ret;
190 int skip;
177 191
178 /* 192 /*
179 * No point in checking CS -- the only way to get here is a user mode 193 * No point in checking CS -- the only way to get here is a user mode
@@ -205,9 +219,6 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
205 } 219 }
206 220
207 tsk = current; 221 tsk = current;
208 if (seccomp_mode(&tsk->seccomp))
209 do_exit(SIGKILL);
210
211 /* 222 /*
212 * With a real vsyscall, page faults cause SIGSEGV. We want to 223 * With a real vsyscall, page faults cause SIGSEGV. We want to
213 * preserve that behavior to make writing exploits harder. 224 * preserve that behavior to make writing exploits harder.
@@ -222,8 +233,13 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
222 * address 0". 233 * address 0".
223 */ 234 */
224 ret = -EFAULT; 235 ret = -EFAULT;
236 skip = 0;
225 switch (vsyscall_nr) { 237 switch (vsyscall_nr) {
226 case 0: 238 case 0:
239 skip = vsyscall_seccomp(tsk, __NR_gettimeofday);
240 if (skip)
241 break;
242
227 if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) || 243 if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) ||
228 !write_ok_or_segv(regs->si, sizeof(struct timezone))) 244 !write_ok_or_segv(regs->si, sizeof(struct timezone)))
229 break; 245 break;
@@ -234,6 +250,10 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
234 break; 250 break;
235 251
236 case 1: 252 case 1:
253 skip = vsyscall_seccomp(tsk, __NR_time);
254 if (skip)
255 break;
256
237 if (!write_ok_or_segv(regs->di, sizeof(time_t))) 257 if (!write_ok_or_segv(regs->di, sizeof(time_t)))
238 break; 258 break;
239 259
@@ -241,6 +261,10 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
241 break; 261 break;
242 262
243 case 2: 263 case 2:
264 skip = vsyscall_seccomp(tsk, __NR_getcpu);
265 if (skip)
266 break;
267
244 if (!write_ok_or_segv(regs->di, sizeof(unsigned)) || 268 if (!write_ok_or_segv(regs->di, sizeof(unsigned)) ||
245 !write_ok_or_segv(regs->si, sizeof(unsigned))) 269 !write_ok_or_segv(regs->si, sizeof(unsigned)))
246 break; 270 break;
@@ -253,6 +277,12 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
253 277
254 current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error; 278 current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
255 279
280 if (skip) {
281 if ((long)regs->ax <= 0L) /* seccomp errno emulation */
282 goto do_ret;
283 goto done; /* seccomp trace/trap */
284 }
285
256 if (ret == -EFAULT) { 286 if (ret == -EFAULT) {
257 /* Bad news -- userspace fed a bad pointer to a vsyscall. */ 287 /* Bad news -- userspace fed a bad pointer to a vsyscall. */
258 warn_bad_vsyscall(KERN_INFO, regs, 288 warn_bad_vsyscall(KERN_INFO, regs,
@@ -271,10 +301,11 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
271 301
272 regs->ax = ret; 302 regs->ax = ret;
273 303
304do_ret:
274 /* Emulate a ret instruction. */ 305 /* Emulate a ret instruction. */
275 regs->ip = caller; 306 regs->ip = caller;
276 regs->sp += 8; 307 regs->sp += 8;
277 308done:
278 return true; 309 return true;
279 310
280sigsegv: 311sigsegv:
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 9b306e550e3..2c8d6a3d250 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -277,7 +277,7 @@ void xtensa_elf_core_copy_regs (xtensa_gregset_t *elfregs, struct pt_regs *regs)
277 277
278 /* Don't leak any random bits. */ 278 /* Don't leak any random bits. */
279 279
280 memset(elfregs, 0, sizeof (elfregs)); 280 memset(elfregs, 0, sizeof(*elfregs));
281 281
282 /* Note: PS.EXCM is not set while user task is running; its 282 /* Note: PS.EXCM is not set while user task is running; its
283 * being set in regs->ps is for exception handling convenience. 283 * being set in regs->ps is for exception handling convenience.
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 0ed85cac323..615996a36be 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -95,18 +95,6 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags)
95 return_ACPI_STATUS(status); 95 return_ACPI_STATUS(status);
96 } 96 }
97 97
98 if (sleep_state != ACPI_STATE_S5) {
99 /*
100 * Disable BM arbitration. This feature is contained within an
101 * optional register (PM2 Control), so ignore a BAD_ADDRESS
102 * exception.
103 */
104 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1);
105 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
106 return_ACPI_STATUS(status);
107 }
108 }
109
110 /* 98 /*
111 * 1) Disable/Clear all GPEs 99 * 1) Disable/Clear all GPEs
112 * 2) Enable all wakeup GPEs 100 * 2) Enable all wakeup GPEs
@@ -364,16 +352,6 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags)
364 [ACPI_EVENT_POWER_BUTTON]. 352 [ACPI_EVENT_POWER_BUTTON].
365 status_register_id, ACPI_CLEAR_STATUS); 353 status_register_id, ACPI_CLEAR_STATUS);
366 354
367 /*
368 * Enable BM arbitration. This feature is contained within an
369 * optional register (PM2 Control), so ignore a BAD_ADDRESS
370 * exception.
371 */
372 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0);
373 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
374 return_ACPI_STATUS(status);
375 }
376
377 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING); 355 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
378 return_ACPI_STATUS(status); 356 return_ACPI_STATUS(status);
379} 357}
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 23ce0968641..fe662603549 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -638,7 +638,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
638 /* Create the new outer package and populate it */ 638 /* Create the new outer package and populate it */
639 639
640 status = 640 status =
641 acpi_ns_wrap_with_package(data, *elements, 641 acpi_ns_wrap_with_package(data, return_object,
642 return_object_ptr); 642 return_object_ptr);
643 if (ACPI_FAILURE(status)) { 643 if (ACPI_FAILURE(status)) {
644 return (status); 644 return (status);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index c850de4c9a1..eff722278ff 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -189,10 +189,12 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
189 * Processor (CPU3, 0x03, 0x00000410, 0x06) {} 189 * Processor (CPU3, 0x03, 0x00000410, 0x06) {}
190 * } 190 * }
191 * 191 *
192 * Ignores apic_id and always return 0 for CPU0's handle. 192 * Ignores apic_id and always returns 0 for the processor
193 * handle with acpi id 0 if nr_cpu_ids is 1.
194 * This should be the case if SMP tables are not found.
193 * Return -1 for other CPU's handle. 195 * Return -1 for other CPU's handle.
194 */ 196 */
195 if (acpi_id == 0) 197 if (nr_cpu_ids <= 1 && acpi_id == 0)
196 return acpi_id; 198 return acpi_id;
197 else 199 else
198 return apic_id; 200 return apic_id;
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index b7e72851728..e8eb91bd0d2 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -16,9 +16,9 @@
16#include <linux/pm.h> 16#include <linux/pm.h>
17#include <linux/pm_runtime.h> 17#include <linux/pm_runtime.h>
18#include <linux/amba/bus.h> 18#include <linux/amba/bus.h>
19#include <linux/sizes.h>
19 20
20#include <asm/irq.h> 21#include <asm/irq.h>
21#include <asm/sizes.h>
22 22
23#define to_amba_driver(d) container_of(d, struct amba_driver, drv) 23#define to_amba_driver(d) container_of(d, struct amba_driver, drv)
24 24
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index dcb8a6e4869..4b01ab3d2c2 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -24,6 +24,7 @@
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/async.h> 25#include <linux/async.h>
26#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
27#include <scsi/scsi_scan.h>
27 28
28#include "base.h" 29#include "base.h"
29#include "power/power.h" 30#include "power/power.h"
@@ -332,6 +333,7 @@ void wait_for_device_probe(void)
332 /* wait for the known devices to complete their probing */ 333 /* wait for the known devices to complete their probing */
333 wait_event(probe_waitqueue, atomic_read(&probe_count) == 0); 334 wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
334 async_synchronize_full(); 335 async_synchronize_full();
336 scsi_complete_async_scans();
335} 337}
336EXPORT_SYMBOL_GPL(wait_for_device_probe); 338EXPORT_SYMBOL_GPL(wait_for_device_probe);
337 339
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index bbca966f8f6..3bba65510d2 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1597,14 +1597,12 @@ static int loop_add(struct loop_device **l, int i)
1597 struct gendisk *disk; 1597 struct gendisk *disk;
1598 int err; 1598 int err;
1599 1599
1600 err = -ENOMEM;
1600 lo = kzalloc(sizeof(*lo), GFP_KERNEL); 1601 lo = kzalloc(sizeof(*lo), GFP_KERNEL);
1601 if (!lo) { 1602 if (!lo)
1602 err = -ENOMEM;
1603 goto out; 1603 goto out;
1604 }
1605 1604
1606 err = idr_pre_get(&loop_index_idr, GFP_KERNEL); 1605 if (!idr_pre_get(&loop_index_idr, GFP_KERNEL))
1607 if (err < 0)
1608 goto out_free_dev; 1606 goto out_free_dev;
1609 1607
1610 if (i >= 0) { 1608 if (i >= 0) {
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 65665c9c42c..8f428a8ab00 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -499,7 +499,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
499 / sizeof (*ondisk)) 499 / sizeof (*ondisk))
500 return -EINVAL; 500 return -EINVAL;
501 header->snapc = kmalloc(sizeof(struct ceph_snap_context) + 501 header->snapc = kmalloc(sizeof(struct ceph_snap_context) +
502 snap_count * sizeof (*ondisk), 502 snap_count * sizeof(u64),
503 gfp_flags); 503 gfp_flags);
504 if (!header->snapc) 504 if (!header->snapc)
505 return -ENOMEM; 505 return -ENOMEM;
@@ -977,7 +977,7 @@ static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg)
977 op = (void *)(replyhead + 1); 977 op = (void *)(replyhead + 1);
978 rc = le32_to_cpu(replyhead->result); 978 rc = le32_to_cpu(replyhead->result);
979 bytes = le64_to_cpu(op->extent.length); 979 bytes = le64_to_cpu(op->extent.length);
980 read_op = (le32_to_cpu(op->op) == CEPH_OSD_OP_READ); 980 read_op = (le16_to_cpu(op->op) == CEPH_OSD_OP_READ);
981 981
982 dout("rbd_req_cb bytes=%lld readop=%d rc=%d\n", bytes, read_op, rc); 982 dout("rbd_req_cb bytes=%lld readop=%d rc=%d\n", bytes, read_op, rc);
983 983
diff --git a/drivers/clk/spear/spear1310_clock.c b/drivers/clk/spear/spear1310_clock.c
index 8f05652d53e..0fcec2aae19 100644
--- a/drivers/clk/spear/spear1310_clock.c
+++ b/drivers/clk/spear/spear1310_clock.c
@@ -345,31 +345,30 @@ static struct frac_rate_tbl gen_rtbl[] = {
345/* clock parents */ 345/* clock parents */
346static const char *vco_parents[] = { "osc_24m_clk", "osc_25m_clk", }; 346static const char *vco_parents[] = { "osc_24m_clk", "osc_25m_clk", };
347static const char *gpt_parents[] = { "osc_24m_clk", "apb_clk", }; 347static const char *gpt_parents[] = { "osc_24m_clk", "apb_clk", };
348static const char *uart0_parents[] = { "pll5_clk", "uart_synth_gate_clk", }; 348static const char *uart0_parents[] = { "pll5_clk", "uart_syn_gclk", };
349static const char *c3_parents[] = { "pll5_clk", "c3_synth_gate_clk", }; 349static const char *c3_parents[] = { "pll5_clk", "c3_syn_gclk", };
350static const char *gmac_phy_input_parents[] = { "gmii_125m_pad_clk", "pll2_clk", 350static const char *gmac_phy_input_parents[] = { "gmii_pad_clk", "pll2_clk",
351 "osc_25m_clk", }; 351 "osc_25m_clk", };
352static const char *gmac_phy_parents[] = { "gmac_phy_input_mux_clk", 352static const char *gmac_phy_parents[] = { "phy_input_mclk", "phy_syn_gclk", };
353 "gmac_phy_synth_gate_clk", };
354static const char *clcd_synth_parents[] = { "vco1div4_clk", "pll2_clk", }; 353static const char *clcd_synth_parents[] = { "vco1div4_clk", "pll2_clk", };
355static const char *clcd_pixel_parents[] = { "pll5_clk", "clcd_synth_clk", }; 354static const char *clcd_pixel_parents[] = { "pll5_clk", "clcd_syn_clk", };
356static const char *i2s_src_parents[] = { "vco1div2_clk", "none", "pll3_clk", 355static const char *i2s_src_parents[] = { "vco1div2_clk", "none", "pll3_clk",
357 "i2s_src_pad_clk", }; 356 "i2s_src_pad_clk", };
358static const char *i2s_ref_parents[] = { "i2s_src_mux_clk", "i2s_prs1_clk", }; 357static const char *i2s_ref_parents[] = { "i2s_src_mclk", "i2s_prs1_clk", };
359static const char *gen_synth0_1_parents[] = { "vco1div4_clk", "vco3div2_clk", 358static const char *gen_synth0_1_parents[] = { "vco1div4_clk", "vco3div2_clk",
360 "pll3_clk", }; 359 "pll3_clk", };
361static const char *gen_synth2_3_parents[] = { "vco1div4_clk", "vco3div2_clk", 360static const char *gen_synth2_3_parents[] = { "vco1div4_clk", "vco3div2_clk",
362 "pll2_clk", }; 361 "pll2_clk", };
363static const char *rmii_phy_parents[] = { "ras_tx50_clk", "none", 362static const char *rmii_phy_parents[] = { "ras_tx50_clk", "none",
364 "ras_pll2_clk", "ras_synth0_clk", }; 363 "ras_pll2_clk", "ras_syn0_clk", };
365static const char *smii_rgmii_phy_parents[] = { "none", "ras_tx125_clk", 364static const char *smii_rgmii_phy_parents[] = { "none", "ras_tx125_clk",
366 "ras_pll2_clk", "ras_synth0_clk", }; 365 "ras_pll2_clk", "ras_syn0_clk", };
367static const char *uart_parents[] = { "ras_apb_clk", "gen_synth3_clk", }; 366static const char *uart_parents[] = { "ras_apb_clk", "gen_syn3_clk", };
368static const char *i2c_parents[] = { "ras_apb_clk", "gen_synth1_clk", }; 367static const char *i2c_parents[] = { "ras_apb_clk", "gen_syn1_clk", };
369static const char *ssp1_parents[] = { "ras_apb_clk", "gen_synth1_clk", 368static const char *ssp1_parents[] = { "ras_apb_clk", "gen_syn1_clk",
370 "ras_plclk0_clk", }; 369 "ras_plclk0_clk", };
371static const char *pci_parents[] = { "ras_pll3_clk", "gen_synth2_clk", }; 370static const char *pci_parents[] = { "ras_pll3_clk", "gen_syn2_clk", };
372static const char *tdm_parents[] = { "ras_pll3_clk", "gen_synth1_clk", }; 371static const char *tdm_parents[] = { "ras_pll3_clk", "gen_syn1_clk", };
373 372
374void __init spear1310_clk_init(void) 373void __init spear1310_clk_init(void)
375{ 374{
@@ -390,9 +389,9 @@ void __init spear1310_clk_init(void)
390 25000000); 389 25000000);
391 clk_register_clkdev(clk, "osc_25m_clk", NULL); 390 clk_register_clkdev(clk, "osc_25m_clk", NULL);
392 391
393 clk = clk_register_fixed_rate(NULL, "gmii_125m_pad_clk", NULL, 392 clk = clk_register_fixed_rate(NULL, "gmii_pad_clk", NULL, CLK_IS_ROOT,
394 CLK_IS_ROOT, 125000000); 393 125000000);
395 clk_register_clkdev(clk, "gmii_125m_pad_clk", NULL); 394 clk_register_clkdev(clk, "gmii_pad_clk", NULL);
396 395
397 clk = clk_register_fixed_rate(NULL, "i2s_src_pad_clk", NULL, 396 clk = clk_register_fixed_rate(NULL, "i2s_src_pad_clk", NULL,
398 CLK_IS_ROOT, 12288000); 397 CLK_IS_ROOT, 12288000);
@@ -406,34 +405,34 @@ void __init spear1310_clk_init(void)
406 405
407 /* clock derived from 24 or 25 MHz osc clk */ 406 /* clock derived from 24 or 25 MHz osc clk */
408 /* vco-pll */ 407 /* vco-pll */
409 clk = clk_register_mux(NULL, "vco1_mux_clk", vco_parents, 408 clk = clk_register_mux(NULL, "vco1_mclk", vco_parents,
410 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG, 409 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG,
411 SPEAR1310_PLL1_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0, 410 SPEAR1310_PLL1_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0,
412 &_lock); 411 &_lock);
413 clk_register_clkdev(clk, "vco1_mux_clk", NULL); 412 clk_register_clkdev(clk, "vco1_mclk", NULL);
414 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "vco1_mux_clk", 413 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "vco1_mclk",
415 0, SPEAR1310_PLL1_CTR, SPEAR1310_PLL1_FRQ, pll_rtbl, 414 0, SPEAR1310_PLL1_CTR, SPEAR1310_PLL1_FRQ, pll_rtbl,
416 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 415 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
417 clk_register_clkdev(clk, "vco1_clk", NULL); 416 clk_register_clkdev(clk, "vco1_clk", NULL);
418 clk_register_clkdev(clk1, "pll1_clk", NULL); 417 clk_register_clkdev(clk1, "pll1_clk", NULL);
419 418
420 clk = clk_register_mux(NULL, "vco2_mux_clk", vco_parents, 419 clk = clk_register_mux(NULL, "vco2_mclk", vco_parents,
421 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG, 420 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG,
422 SPEAR1310_PLL2_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0, 421 SPEAR1310_PLL2_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0,
423 &_lock); 422 &_lock);
424 clk_register_clkdev(clk, "vco2_mux_clk", NULL); 423 clk_register_clkdev(clk, "vco2_mclk", NULL);
425 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "vco2_mux_clk", 424 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "vco2_mclk",
426 0, SPEAR1310_PLL2_CTR, SPEAR1310_PLL2_FRQ, pll_rtbl, 425 0, SPEAR1310_PLL2_CTR, SPEAR1310_PLL2_FRQ, pll_rtbl,
427 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 426 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
428 clk_register_clkdev(clk, "vco2_clk", NULL); 427 clk_register_clkdev(clk, "vco2_clk", NULL);
429 clk_register_clkdev(clk1, "pll2_clk", NULL); 428 clk_register_clkdev(clk1, "pll2_clk", NULL);
430 429
431 clk = clk_register_mux(NULL, "vco3_mux_clk", vco_parents, 430 clk = clk_register_mux(NULL, "vco3_mclk", vco_parents,
432 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG, 431 ARRAY_SIZE(vco_parents), 0, SPEAR1310_PLL_CFG,
433 SPEAR1310_PLL3_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0, 432 SPEAR1310_PLL3_CLK_SHIFT, SPEAR1310_PLL_CLK_MASK, 0,
434 &_lock); 433 &_lock);
435 clk_register_clkdev(clk, "vco3_mux_clk", NULL); 434 clk_register_clkdev(clk, "vco3_mclk", NULL);
436 clk = clk_register_vco_pll("vco3_clk", "pll3_clk", NULL, "vco3_mux_clk", 435 clk = clk_register_vco_pll("vco3_clk", "pll3_clk", NULL, "vco3_mclk",
437 0, SPEAR1310_PLL3_CTR, SPEAR1310_PLL3_FRQ, pll_rtbl, 436 0, SPEAR1310_PLL3_CTR, SPEAR1310_PLL3_FRQ, pll_rtbl,
438 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 437 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
439 clk_register_clkdev(clk, "vco3_clk", NULL); 438 clk_register_clkdev(clk, "vco3_clk", NULL);
@@ -473,7 +472,7 @@ void __init spear1310_clk_init(void)
473 /* peripherals */ 472 /* peripherals */
474 clk_register_fixed_factor(NULL, "thermal_clk", "osc_24m_clk", 0, 1, 473 clk_register_fixed_factor(NULL, "thermal_clk", "osc_24m_clk", 0, 1,
475 128); 474 128);
476 clk = clk_register_gate(NULL, "thermal_gate_clk", "thermal_clk", 0, 475 clk = clk_register_gate(NULL, "thermal_gclk", "thermal_clk", 0,
477 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_THSENS_CLK_ENB, 0, 476 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_THSENS_CLK_ENB, 0,
478 &_lock); 477 &_lock);
479 clk_register_clkdev(clk, NULL, "spear_thermal"); 478 clk_register_clkdev(clk, NULL, "spear_thermal");
@@ -500,177 +499,176 @@ void __init spear1310_clk_init(void)
500 clk_register_clkdev(clk, "apb_clk", NULL); 499 clk_register_clkdev(clk, "apb_clk", NULL);
501 500
502 /* gpt clocks */ 501 /* gpt clocks */
503 clk = clk_register_mux(NULL, "gpt0_mux_clk", gpt_parents, 502 clk = clk_register_mux(NULL, "gpt0_mclk", gpt_parents,
504 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG, 503 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG,
505 SPEAR1310_GPT0_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0, 504 SPEAR1310_GPT0_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0,
506 &_lock); 505 &_lock);
507 clk_register_clkdev(clk, "gpt0_mux_clk", NULL); 506 clk_register_clkdev(clk, "gpt0_mclk", NULL);
508 clk = clk_register_gate(NULL, "gpt0_clk", "gpt0_mux_clk", 0, 507 clk = clk_register_gate(NULL, "gpt0_clk", "gpt0_mclk", 0,
509 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_GPT0_CLK_ENB, 0, 508 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_GPT0_CLK_ENB, 0,
510 &_lock); 509 &_lock);
511 clk_register_clkdev(clk, NULL, "gpt0"); 510 clk_register_clkdev(clk, NULL, "gpt0");
512 511
513 clk = clk_register_mux(NULL, "gpt1_mux_clk", gpt_parents, 512 clk = clk_register_mux(NULL, "gpt1_mclk", gpt_parents,
514 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG, 513 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG,
515 SPEAR1310_GPT1_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0, 514 SPEAR1310_GPT1_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0,
516 &_lock); 515 &_lock);
517 clk_register_clkdev(clk, "gpt1_mux_clk", NULL); 516 clk_register_clkdev(clk, "gpt1_mclk", NULL);
518 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mux_clk", 0, 517 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
519 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_GPT1_CLK_ENB, 0, 518 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_GPT1_CLK_ENB, 0,
520 &_lock); 519 &_lock);
521 clk_register_clkdev(clk, NULL, "gpt1"); 520 clk_register_clkdev(clk, NULL, "gpt1");
522 521
523 clk = clk_register_mux(NULL, "gpt2_mux_clk", gpt_parents, 522 clk = clk_register_mux(NULL, "gpt2_mclk", gpt_parents,
524 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG, 523 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG,
525 SPEAR1310_GPT2_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0, 524 SPEAR1310_GPT2_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0,
526 &_lock); 525 &_lock);
527 clk_register_clkdev(clk, "gpt2_mux_clk", NULL); 526 clk_register_clkdev(clk, "gpt2_mclk", NULL);
528 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mux_clk", 0, 527 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
529 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_GPT2_CLK_ENB, 0, 528 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_GPT2_CLK_ENB, 0,
530 &_lock); 529 &_lock);
531 clk_register_clkdev(clk, NULL, "gpt2"); 530 clk_register_clkdev(clk, NULL, "gpt2");
532 531
533 clk = clk_register_mux(NULL, "gpt3_mux_clk", gpt_parents, 532 clk = clk_register_mux(NULL, "gpt3_mclk", gpt_parents,
534 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG, 533 ARRAY_SIZE(gpt_parents), 0, SPEAR1310_PERIP_CLK_CFG,
535 SPEAR1310_GPT3_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0, 534 SPEAR1310_GPT3_CLK_SHIFT, SPEAR1310_GPT_CLK_MASK, 0,
536 &_lock); 535 &_lock);
537 clk_register_clkdev(clk, "gpt3_mux_clk", NULL); 536 clk_register_clkdev(clk, "gpt3_mclk", NULL);
538 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mux_clk", 0, 537 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mclk", 0,
539 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_GPT3_CLK_ENB, 0, 538 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_GPT3_CLK_ENB, 0,
540 &_lock); 539 &_lock);
541 clk_register_clkdev(clk, NULL, "gpt3"); 540 clk_register_clkdev(clk, NULL, "gpt3");
542 541
543 /* others */ 542 /* others */
544 clk = clk_register_aux("uart_synth_clk", "uart_synth_gate_clk", 543 clk = clk_register_aux("uart_syn_clk", "uart_syn_gclk", "vco1div2_clk",
545 "vco1div2_clk", 0, SPEAR1310_UART_CLK_SYNT, NULL, 544 0, SPEAR1310_UART_CLK_SYNT, NULL, aux_rtbl,
546 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 545 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
547 clk_register_clkdev(clk, "uart_synth_clk", NULL); 546 clk_register_clkdev(clk, "uart_syn_clk", NULL);
548 clk_register_clkdev(clk1, "uart_synth_gate_clk", NULL); 547 clk_register_clkdev(clk1, "uart_syn_gclk", NULL);
549 548
550 clk = clk_register_mux(NULL, "uart0_mux_clk", uart0_parents, 549 clk = clk_register_mux(NULL, "uart0_mclk", uart0_parents,
551 ARRAY_SIZE(uart0_parents), 0, SPEAR1310_PERIP_CLK_CFG, 550 ARRAY_SIZE(uart0_parents), 0, SPEAR1310_PERIP_CLK_CFG,
552 SPEAR1310_UART_CLK_SHIFT, SPEAR1310_UART_CLK_MASK, 0, 551 SPEAR1310_UART_CLK_SHIFT, SPEAR1310_UART_CLK_MASK, 0,
553 &_lock); 552 &_lock);
554 clk_register_clkdev(clk, "uart0_mux_clk", NULL); 553 clk_register_clkdev(clk, "uart0_mclk", NULL);
555 554
556 clk = clk_register_gate(NULL, "uart0_clk", "uart0_mux_clk", 0, 555 clk = clk_register_gate(NULL, "uart0_clk", "uart0_mclk", 0,
557 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_UART_CLK_ENB, 0, 556 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_UART_CLK_ENB, 0,
558 &_lock); 557 &_lock);
559 clk_register_clkdev(clk, NULL, "e0000000.serial"); 558 clk_register_clkdev(clk, NULL, "e0000000.serial");
560 559
561 clk = clk_register_aux("sdhci_synth_clk", "sdhci_synth_gate_clk", 560 clk = clk_register_aux("sdhci_syn_clk", "sdhci_syn_gclk",
562 "vco1div2_clk", 0, SPEAR1310_SDHCI_CLK_SYNT, NULL, 561 "vco1div2_clk", 0, SPEAR1310_SDHCI_CLK_SYNT, NULL,
563 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 562 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
564 clk_register_clkdev(clk, "sdhci_synth_clk", NULL); 563 clk_register_clkdev(clk, "sdhci_syn_clk", NULL);
565 clk_register_clkdev(clk1, "sdhci_synth_gate_clk", NULL); 564 clk_register_clkdev(clk1, "sdhci_syn_gclk", NULL);
566 565
567 clk = clk_register_gate(NULL, "sdhci_clk", "sdhci_synth_gate_clk", 0, 566 clk = clk_register_gate(NULL, "sdhci_clk", "sdhci_syn_gclk", 0,
568 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_SDHCI_CLK_ENB, 0, 567 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_SDHCI_CLK_ENB, 0,
569 &_lock); 568 &_lock);
570 clk_register_clkdev(clk, NULL, "b3000000.sdhci"); 569 clk_register_clkdev(clk, NULL, "b3000000.sdhci");
571 570
572 clk = clk_register_aux("cfxd_synth_clk", "cfxd_synth_gate_clk", 571 clk = clk_register_aux("cfxd_syn_clk", "cfxd_syn_gclk", "vco1div2_clk",
573 "vco1div2_clk", 0, SPEAR1310_CFXD_CLK_SYNT, NULL, 572 0, SPEAR1310_CFXD_CLK_SYNT, NULL, aux_rtbl,
574 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 573 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
575 clk_register_clkdev(clk, "cfxd_synth_clk", NULL); 574 clk_register_clkdev(clk, "cfxd_syn_clk", NULL);
576 clk_register_clkdev(clk1, "cfxd_synth_gate_clk", NULL); 575 clk_register_clkdev(clk1, "cfxd_syn_gclk", NULL);
577 576
578 clk = clk_register_gate(NULL, "cfxd_clk", "cfxd_synth_gate_clk", 0, 577 clk = clk_register_gate(NULL, "cfxd_clk", "cfxd_syn_gclk", 0,
579 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_CFXD_CLK_ENB, 0, 578 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_CFXD_CLK_ENB, 0,
580 &_lock); 579 &_lock);
581 clk_register_clkdev(clk, NULL, "b2800000.cf"); 580 clk_register_clkdev(clk, NULL, "b2800000.cf");
582 clk_register_clkdev(clk, NULL, "arasan_xd"); 581 clk_register_clkdev(clk, NULL, "arasan_xd");
583 582
584 clk = clk_register_aux("c3_synth_clk", "c3_synth_gate_clk", 583 clk = clk_register_aux("c3_syn_clk", "c3_syn_gclk", "vco1div2_clk",
585 "vco1div2_clk", 0, SPEAR1310_C3_CLK_SYNT, NULL, 584 0, SPEAR1310_C3_CLK_SYNT, NULL, aux_rtbl,
586 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 585 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
587 clk_register_clkdev(clk, "c3_synth_clk", NULL); 586 clk_register_clkdev(clk, "c3_syn_clk", NULL);
588 clk_register_clkdev(clk1, "c3_synth_gate_clk", NULL); 587 clk_register_clkdev(clk1, "c3_syn_gclk", NULL);
589 588
590 clk = clk_register_mux(NULL, "c3_mux_clk", c3_parents, 589 clk = clk_register_mux(NULL, "c3_mclk", c3_parents,
591 ARRAY_SIZE(c3_parents), 0, SPEAR1310_PERIP_CLK_CFG, 590 ARRAY_SIZE(c3_parents), 0, SPEAR1310_PERIP_CLK_CFG,
592 SPEAR1310_C3_CLK_SHIFT, SPEAR1310_C3_CLK_MASK, 0, 591 SPEAR1310_C3_CLK_SHIFT, SPEAR1310_C3_CLK_MASK, 0,
593 &_lock); 592 &_lock);
594 clk_register_clkdev(clk, "c3_mux_clk", NULL); 593 clk_register_clkdev(clk, "c3_mclk", NULL);
595 594
596 clk = clk_register_gate(NULL, "c3_clk", "c3_mux_clk", 0, 595 clk = clk_register_gate(NULL, "c3_clk", "c3_mclk", 0,
597 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_C3_CLK_ENB, 0, 596 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_C3_CLK_ENB, 0,
598 &_lock); 597 &_lock);
599 clk_register_clkdev(clk, NULL, "c3"); 598 clk_register_clkdev(clk, NULL, "c3");
600 599
601 /* gmac */ 600 /* gmac */
602 clk = clk_register_mux(NULL, "gmac_phy_input_mux_clk", 601 clk = clk_register_mux(NULL, "phy_input_mclk", gmac_phy_input_parents,
603 gmac_phy_input_parents,
604 ARRAY_SIZE(gmac_phy_input_parents), 0, 602 ARRAY_SIZE(gmac_phy_input_parents), 0,
605 SPEAR1310_GMAC_CLK_CFG, 603 SPEAR1310_GMAC_CLK_CFG,
606 SPEAR1310_GMAC_PHY_INPUT_CLK_SHIFT, 604 SPEAR1310_GMAC_PHY_INPUT_CLK_SHIFT,
607 SPEAR1310_GMAC_PHY_INPUT_CLK_MASK, 0, &_lock); 605 SPEAR1310_GMAC_PHY_INPUT_CLK_MASK, 0, &_lock);
608 clk_register_clkdev(clk, "gmac_phy_input_mux_clk", NULL); 606 clk_register_clkdev(clk, "phy_input_mclk", NULL);
609 607
610 clk = clk_register_aux("gmac_phy_synth_clk", "gmac_phy_synth_gate_clk", 608 clk = clk_register_aux("phy_syn_clk", "phy_syn_gclk", "phy_input_mclk",
611 "gmac_phy_input_mux_clk", 0, SPEAR1310_GMAC_CLK_SYNT, 609 0, SPEAR1310_GMAC_CLK_SYNT, NULL, gmac_rtbl,
612 NULL, gmac_rtbl, ARRAY_SIZE(gmac_rtbl), &_lock, &clk1); 610 ARRAY_SIZE(gmac_rtbl), &_lock, &clk1);
613 clk_register_clkdev(clk, "gmac_phy_synth_clk", NULL); 611 clk_register_clkdev(clk, "phy_syn_clk", NULL);
614 clk_register_clkdev(clk1, "gmac_phy_synth_gate_clk", NULL); 612 clk_register_clkdev(clk1, "phy_syn_gclk", NULL);
615 613
616 clk = clk_register_mux(NULL, "gmac_phy_mux_clk", gmac_phy_parents, 614 clk = clk_register_mux(NULL, "phy_mclk", gmac_phy_parents,
617 ARRAY_SIZE(gmac_phy_parents), 0, 615 ARRAY_SIZE(gmac_phy_parents), 0,
618 SPEAR1310_PERIP_CLK_CFG, SPEAR1310_GMAC_PHY_CLK_SHIFT, 616 SPEAR1310_PERIP_CLK_CFG, SPEAR1310_GMAC_PHY_CLK_SHIFT,
619 SPEAR1310_GMAC_PHY_CLK_MASK, 0, &_lock); 617 SPEAR1310_GMAC_PHY_CLK_MASK, 0, &_lock);
620 clk_register_clkdev(clk, NULL, "stmmacphy.0"); 618 clk_register_clkdev(clk, NULL, "stmmacphy.0");
621 619
622 /* clcd */ 620 /* clcd */
623 clk = clk_register_mux(NULL, "clcd_synth_mux_clk", clcd_synth_parents, 621 clk = clk_register_mux(NULL, "clcd_syn_mclk", clcd_synth_parents,
624 ARRAY_SIZE(clcd_synth_parents), 0, 622 ARRAY_SIZE(clcd_synth_parents), 0,
625 SPEAR1310_CLCD_CLK_SYNT, SPEAR1310_CLCD_SYNT_CLK_SHIFT, 623 SPEAR1310_CLCD_CLK_SYNT, SPEAR1310_CLCD_SYNT_CLK_SHIFT,
626 SPEAR1310_CLCD_SYNT_CLK_MASK, 0, &_lock); 624 SPEAR1310_CLCD_SYNT_CLK_MASK, 0, &_lock);
627 clk_register_clkdev(clk, "clcd_synth_mux_clk", NULL); 625 clk_register_clkdev(clk, "clcd_syn_mclk", NULL);
628 626
629 clk = clk_register_frac("clcd_synth_clk", "clcd_synth_mux_clk", 0, 627 clk = clk_register_frac("clcd_syn_clk", "clcd_syn_mclk", 0,
630 SPEAR1310_CLCD_CLK_SYNT, clcd_rtbl, 628 SPEAR1310_CLCD_CLK_SYNT, clcd_rtbl,
631 ARRAY_SIZE(clcd_rtbl), &_lock); 629 ARRAY_SIZE(clcd_rtbl), &_lock);
632 clk_register_clkdev(clk, "clcd_synth_clk", NULL); 630 clk_register_clkdev(clk, "clcd_syn_clk", NULL);
633 631
634 clk = clk_register_mux(NULL, "clcd_pixel_mux_clk", clcd_pixel_parents, 632 clk = clk_register_mux(NULL, "clcd_pixel_mclk", clcd_pixel_parents,
635 ARRAY_SIZE(clcd_pixel_parents), 0, 633 ARRAY_SIZE(clcd_pixel_parents), 0,
636 SPEAR1310_PERIP_CLK_CFG, SPEAR1310_CLCD_CLK_SHIFT, 634 SPEAR1310_PERIP_CLK_CFG, SPEAR1310_CLCD_CLK_SHIFT,
637 SPEAR1310_CLCD_CLK_MASK, 0, &_lock); 635 SPEAR1310_CLCD_CLK_MASK, 0, &_lock);
638 clk_register_clkdev(clk, "clcd_pixel_clk", NULL); 636 clk_register_clkdev(clk, "clcd_pixel_clk", NULL);
639 637
640 clk = clk_register_gate(NULL, "clcd_clk", "clcd_pixel_mux_clk", 0, 638 clk = clk_register_gate(NULL, "clcd_clk", "clcd_pixel_mclk", 0,
641 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_CLCD_CLK_ENB, 0, 639 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_CLCD_CLK_ENB, 0,
642 &_lock); 640 &_lock);
643 clk_register_clkdev(clk, "clcd_clk", NULL); 641 clk_register_clkdev(clk, "clcd_clk", NULL);
644 642
645 /* i2s */ 643 /* i2s */
646 clk = clk_register_mux(NULL, "i2s_src_mux_clk", i2s_src_parents, 644 clk = clk_register_mux(NULL, "i2s_src_mclk", i2s_src_parents,
647 ARRAY_SIZE(i2s_src_parents), 0, SPEAR1310_I2S_CLK_CFG, 645 ARRAY_SIZE(i2s_src_parents), 0, SPEAR1310_I2S_CLK_CFG,
648 SPEAR1310_I2S_SRC_CLK_SHIFT, SPEAR1310_I2S_SRC_CLK_MASK, 646 SPEAR1310_I2S_SRC_CLK_SHIFT, SPEAR1310_I2S_SRC_CLK_MASK,
649 0, &_lock); 647 0, &_lock);
650 clk_register_clkdev(clk, "i2s_src_clk", NULL); 648 clk_register_clkdev(clk, "i2s_src_clk", NULL);
651 649
652 clk = clk_register_aux("i2s_prs1_clk", NULL, "i2s_src_mux_clk", 0, 650 clk = clk_register_aux("i2s_prs1_clk", NULL, "i2s_src_mclk", 0,
653 SPEAR1310_I2S_CLK_CFG, &i2s_prs1_masks, i2s_prs1_rtbl, 651 SPEAR1310_I2S_CLK_CFG, &i2s_prs1_masks, i2s_prs1_rtbl,
654 ARRAY_SIZE(i2s_prs1_rtbl), &_lock, NULL); 652 ARRAY_SIZE(i2s_prs1_rtbl), &_lock, NULL);
655 clk_register_clkdev(clk, "i2s_prs1_clk", NULL); 653 clk_register_clkdev(clk, "i2s_prs1_clk", NULL);
656 654
657 clk = clk_register_mux(NULL, "i2s_ref_mux_clk", i2s_ref_parents, 655 clk = clk_register_mux(NULL, "i2s_ref_mclk", i2s_ref_parents,
658 ARRAY_SIZE(i2s_ref_parents), 0, SPEAR1310_I2S_CLK_CFG, 656 ARRAY_SIZE(i2s_ref_parents), 0, SPEAR1310_I2S_CLK_CFG,
659 SPEAR1310_I2S_REF_SHIFT, SPEAR1310_I2S_REF_SEL_MASK, 0, 657 SPEAR1310_I2S_REF_SHIFT, SPEAR1310_I2S_REF_SEL_MASK, 0,
660 &_lock); 658 &_lock);
661 clk_register_clkdev(clk, "i2s_ref_clk", NULL); 659 clk_register_clkdev(clk, "i2s_ref_clk", NULL);
662 660
663 clk = clk_register_gate(NULL, "i2s_ref_pad_clk", "i2s_ref_mux_clk", 0, 661 clk = clk_register_gate(NULL, "i2s_ref_pad_clk", "i2s_ref_mclk", 0,
664 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_I2S_REF_PAD_CLK_ENB, 662 SPEAR1310_PERIP2_CLK_ENB, SPEAR1310_I2S_REF_PAD_CLK_ENB,
665 0, &_lock); 663 0, &_lock);
666 clk_register_clkdev(clk, "i2s_ref_pad_clk", NULL); 664 clk_register_clkdev(clk, "i2s_ref_pad_clk", NULL);
667 665
668 clk = clk_register_aux("i2s_sclk_clk", "i2s_sclk_gate_clk", 666 clk = clk_register_aux("i2s_sclk_clk", "i2s_sclk_gclk",
669 "i2s_ref_pad_clk", 0, SPEAR1310_I2S_CLK_CFG, 667 "i2s_ref_pad_clk", 0, SPEAR1310_I2S_CLK_CFG,
670 &i2s_sclk_masks, i2s_sclk_rtbl, 668 &i2s_sclk_masks, i2s_sclk_rtbl,
671 ARRAY_SIZE(i2s_sclk_rtbl), &_lock, &clk1); 669 ARRAY_SIZE(i2s_sclk_rtbl), &_lock, &clk1);
672 clk_register_clkdev(clk, "i2s_sclk_clk", NULL); 670 clk_register_clkdev(clk, "i2s_sclk_clk", NULL);
673 clk_register_clkdev(clk1, "i2s_sclk_gate_clk", NULL); 671 clk_register_clkdev(clk1, "i2s_sclk_gclk", NULL);
674 672
675 /* clock derived from ahb clk */ 673 /* clock derived from ahb clk */
676 clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0, 674 clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0,
@@ -747,13 +745,13 @@ void __init spear1310_clk_init(void)
747 &_lock); 745 &_lock);
748 clk_register_clkdev(clk, "sysram1_clk", NULL); 746 clk_register_clkdev(clk, "sysram1_clk", NULL);
749 747
750 clk = clk_register_aux("adc_synth_clk", "adc_synth_gate_clk", "ahb_clk", 748 clk = clk_register_aux("adc_syn_clk", "adc_syn_gclk", "ahb_clk",
751 0, SPEAR1310_ADC_CLK_SYNT, NULL, adc_rtbl, 749 0, SPEAR1310_ADC_CLK_SYNT, NULL, adc_rtbl,
752 ARRAY_SIZE(adc_rtbl), &_lock, &clk1); 750 ARRAY_SIZE(adc_rtbl), &_lock, &clk1);
753 clk_register_clkdev(clk, "adc_synth_clk", NULL); 751 clk_register_clkdev(clk, "adc_syn_clk", NULL);
754 clk_register_clkdev(clk1, "adc_synth_gate_clk", NULL); 752 clk_register_clkdev(clk1, "adc_syn_gclk", NULL);
755 753
756 clk = clk_register_gate(NULL, "adc_clk", "adc_synth_gate_clk", 0, 754 clk = clk_register_gate(NULL, "adc_clk", "adc_syn_gclk", 0,
757 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_ADC_CLK_ENB, 0, 755 SPEAR1310_PERIP1_CLK_ENB, SPEAR1310_ADC_CLK_ENB, 0,
758 &_lock); 756 &_lock);
759 clk_register_clkdev(clk, NULL, "adc_clk"); 757 clk_register_clkdev(clk, NULL, "adc_clk");
@@ -790,37 +788,37 @@ void __init spear1310_clk_init(void)
790 clk_register_clkdev(clk, NULL, "e0300000.kbd"); 788 clk_register_clkdev(clk, NULL, "e0300000.kbd");
791 789
792 /* RAS clks */ 790 /* RAS clks */
793 clk = clk_register_mux(NULL, "gen_synth0_1_mux_clk", 791 clk = clk_register_mux(NULL, "gen_syn0_1_mclk", gen_synth0_1_parents,
794 gen_synth0_1_parents, ARRAY_SIZE(gen_synth0_1_parents), 792 ARRAY_SIZE(gen_synth0_1_parents), 0, SPEAR1310_PLL_CFG,
795 0, SPEAR1310_PLL_CFG, SPEAR1310_RAS_SYNT0_1_CLK_SHIFT, 793 SPEAR1310_RAS_SYNT0_1_CLK_SHIFT,
796 SPEAR1310_RAS_SYNT_CLK_MASK, 0, &_lock); 794 SPEAR1310_RAS_SYNT_CLK_MASK, 0, &_lock);
797 clk_register_clkdev(clk, "gen_synth0_1_clk", NULL); 795 clk_register_clkdev(clk, "gen_syn0_1_clk", NULL);
798 796
799 clk = clk_register_mux(NULL, "gen_synth2_3_mux_clk", 797 clk = clk_register_mux(NULL, "gen_syn2_3_mclk", gen_synth2_3_parents,
800 gen_synth2_3_parents, ARRAY_SIZE(gen_synth2_3_parents), 798 ARRAY_SIZE(gen_synth2_3_parents), 0, SPEAR1310_PLL_CFG,
801 0, SPEAR1310_PLL_CFG, SPEAR1310_RAS_SYNT2_3_CLK_SHIFT, 799 SPEAR1310_RAS_SYNT2_3_CLK_SHIFT,
802 SPEAR1310_RAS_SYNT_CLK_MASK, 0, &_lock); 800 SPEAR1310_RAS_SYNT_CLK_MASK, 0, &_lock);
803 clk_register_clkdev(clk, "gen_synth2_3_clk", NULL); 801 clk_register_clkdev(clk, "gen_syn2_3_clk", NULL);
804 802
805 clk = clk_register_frac("gen_synth0_clk", "gen_synth0_1_clk", 0, 803 clk = clk_register_frac("gen_syn0_clk", "gen_syn0_1_clk", 0,
806 SPEAR1310_RAS_CLK_SYNT0, gen_rtbl, ARRAY_SIZE(gen_rtbl), 804 SPEAR1310_RAS_CLK_SYNT0, gen_rtbl, ARRAY_SIZE(gen_rtbl),
807 &_lock); 805 &_lock);
808 clk_register_clkdev(clk, "gen_synth0_clk", NULL); 806 clk_register_clkdev(clk, "gen_syn0_clk", NULL);
809 807
810 clk = clk_register_frac("gen_synth1_clk", "gen_synth0_1_clk", 0, 808 clk = clk_register_frac("gen_syn1_clk", "gen_syn0_1_clk", 0,
811 SPEAR1310_RAS_CLK_SYNT1, gen_rtbl, ARRAY_SIZE(gen_rtbl), 809 SPEAR1310_RAS_CLK_SYNT1, gen_rtbl, ARRAY_SIZE(gen_rtbl),
812 &_lock); 810 &_lock);
813 clk_register_clkdev(clk, "gen_synth1_clk", NULL); 811 clk_register_clkdev(clk, "gen_syn1_clk", NULL);
814 812
815 clk = clk_register_frac("gen_synth2_clk", "gen_synth2_3_clk", 0, 813 clk = clk_register_frac("gen_syn2_clk", "gen_syn2_3_clk", 0,
816 SPEAR1310_RAS_CLK_SYNT2, gen_rtbl, ARRAY_SIZE(gen_rtbl), 814 SPEAR1310_RAS_CLK_SYNT2, gen_rtbl, ARRAY_SIZE(gen_rtbl),
817 &_lock); 815 &_lock);
818 clk_register_clkdev(clk, "gen_synth2_clk", NULL); 816 clk_register_clkdev(clk, "gen_syn2_clk", NULL);
819 817
820 clk = clk_register_frac("gen_synth3_clk", "gen_synth2_3_clk", 0, 818 clk = clk_register_frac("gen_syn3_clk", "gen_syn2_3_clk", 0,
821 SPEAR1310_RAS_CLK_SYNT3, gen_rtbl, ARRAY_SIZE(gen_rtbl), 819 SPEAR1310_RAS_CLK_SYNT3, gen_rtbl, ARRAY_SIZE(gen_rtbl),
822 &_lock); 820 &_lock);
823 clk_register_clkdev(clk, "gen_synth3_clk", NULL); 821 clk_register_clkdev(clk, "gen_syn3_clk", NULL);
824 822
825 clk = clk_register_gate(NULL, "ras_osc_24m_clk", "osc_24m_clk", 0, 823 clk = clk_register_gate(NULL, "ras_osc_24m_clk", "osc_24m_clk", 0,
826 SPEAR1310_RAS_CLK_ENB, SPEAR1310_OSC_24M_CLK_ENB, 0, 824 SPEAR1310_RAS_CLK_ENB, SPEAR1310_OSC_24M_CLK_ENB, 0,
@@ -847,7 +845,7 @@ void __init spear1310_clk_init(void)
847 &_lock); 845 &_lock);
848 clk_register_clkdev(clk, "ras_pll3_clk", NULL); 846 clk_register_clkdev(clk, "ras_pll3_clk", NULL);
849 847
850 clk = clk_register_gate(NULL, "ras_tx125_clk", "gmii_125m_pad_clk", 0, 848 clk = clk_register_gate(NULL, "ras_tx125_clk", "gmii_pad_clk", 0,
851 SPEAR1310_RAS_CLK_ENB, SPEAR1310_C125M_PAD_CLK_ENB, 0, 849 SPEAR1310_RAS_CLK_ENB, SPEAR1310_C125M_PAD_CLK_ENB, 0,
852 &_lock); 850 &_lock);
853 clk_register_clkdev(clk, "ras_tx125_clk", NULL); 851 clk_register_clkdev(clk, "ras_tx125_clk", NULL);
@@ -912,7 +910,7 @@ void __init spear1310_clk_init(void)
912 &_lock); 910 &_lock);
913 clk_register_clkdev(clk, NULL, "5c700000.eth"); 911 clk_register_clkdev(clk, NULL, "5c700000.eth");
914 912
915 clk = clk_register_mux(NULL, "smii_rgmii_phy_mux_clk", 913 clk = clk_register_mux(NULL, "smii_rgmii_phy_mclk",
916 smii_rgmii_phy_parents, 914 smii_rgmii_phy_parents,
917 ARRAY_SIZE(smii_rgmii_phy_parents), 0, 915 ARRAY_SIZE(smii_rgmii_phy_parents), 0,
918 SPEAR1310_RAS_CTRL_REG1, 916 SPEAR1310_RAS_CTRL_REG1,
@@ -922,184 +920,184 @@ void __init spear1310_clk_init(void)
922 clk_register_clkdev(clk, NULL, "stmmacphy.2"); 920 clk_register_clkdev(clk, NULL, "stmmacphy.2");
923 clk_register_clkdev(clk, NULL, "stmmacphy.4"); 921 clk_register_clkdev(clk, NULL, "stmmacphy.4");
924 922
925 clk = clk_register_mux(NULL, "rmii_phy_mux_clk", rmii_phy_parents, 923 clk = clk_register_mux(NULL, "rmii_phy_mclk", rmii_phy_parents,
926 ARRAY_SIZE(rmii_phy_parents), 0, 924 ARRAY_SIZE(rmii_phy_parents), 0,
927 SPEAR1310_RAS_CTRL_REG1, SPEAR1310_RMII_PHY_CLK_SHIFT, 925 SPEAR1310_RAS_CTRL_REG1, SPEAR1310_RMII_PHY_CLK_SHIFT,
928 SPEAR1310_PHY_CLK_MASK, 0, &_lock); 926 SPEAR1310_PHY_CLK_MASK, 0, &_lock);
929 clk_register_clkdev(clk, NULL, "stmmacphy.3"); 927 clk_register_clkdev(clk, NULL, "stmmacphy.3");
930 928
931 clk = clk_register_mux(NULL, "uart1_mux_clk", uart_parents, 929 clk = clk_register_mux(NULL, "uart1_mclk", uart_parents,
932 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0, 930 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0,
933 SPEAR1310_UART1_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK, 931 SPEAR1310_UART1_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK,
934 0, &_lock); 932 0, &_lock);
935 clk_register_clkdev(clk, "uart1_mux_clk", NULL); 933 clk_register_clkdev(clk, "uart1_mclk", NULL);
936 934
937 clk = clk_register_gate(NULL, "uart1_clk", "uart1_mux_clk", 0, 935 clk = clk_register_gate(NULL, "uart1_clk", "uart1_mclk", 0,
938 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART1_CLK_ENB, 0, 936 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART1_CLK_ENB, 0,
939 &_lock); 937 &_lock);
940 clk_register_clkdev(clk, NULL, "5c800000.serial"); 938 clk_register_clkdev(clk, NULL, "5c800000.serial");
941 939
942 clk = clk_register_mux(NULL, "uart2_mux_clk", uart_parents, 940 clk = clk_register_mux(NULL, "uart2_mclk", uart_parents,
943 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0, 941 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0,
944 SPEAR1310_UART2_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK, 942 SPEAR1310_UART2_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK,
945 0, &_lock); 943 0, &_lock);
946 clk_register_clkdev(clk, "uart2_mux_clk", NULL); 944 clk_register_clkdev(clk, "uart2_mclk", NULL);
947 945
948 clk = clk_register_gate(NULL, "uart2_clk", "uart2_mux_clk", 0, 946 clk = clk_register_gate(NULL, "uart2_clk", "uart2_mclk", 0,
949 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART2_CLK_ENB, 0, 947 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART2_CLK_ENB, 0,
950 &_lock); 948 &_lock);
951 clk_register_clkdev(clk, NULL, "5c900000.serial"); 949 clk_register_clkdev(clk, NULL, "5c900000.serial");
952 950
953 clk = clk_register_mux(NULL, "uart3_mux_clk", uart_parents, 951 clk = clk_register_mux(NULL, "uart3_mclk", uart_parents,
954 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0, 952 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0,
955 SPEAR1310_UART3_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK, 953 SPEAR1310_UART3_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK,
956 0, &_lock); 954 0, &_lock);
957 clk_register_clkdev(clk, "uart3_mux_clk", NULL); 955 clk_register_clkdev(clk, "uart3_mclk", NULL);
958 956
959 clk = clk_register_gate(NULL, "uart3_clk", "uart3_mux_clk", 0, 957 clk = clk_register_gate(NULL, "uart3_clk", "uart3_mclk", 0,
960 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART3_CLK_ENB, 0, 958 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART3_CLK_ENB, 0,
961 &_lock); 959 &_lock);
962 clk_register_clkdev(clk, NULL, "5ca00000.serial"); 960 clk_register_clkdev(clk, NULL, "5ca00000.serial");
963 961
964 clk = clk_register_mux(NULL, "uart4_mux_clk", uart_parents, 962 clk = clk_register_mux(NULL, "uart4_mclk", uart_parents,
965 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0, 963 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0,
966 SPEAR1310_UART4_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK, 964 SPEAR1310_UART4_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK,
967 0, &_lock); 965 0, &_lock);
968 clk_register_clkdev(clk, "uart4_mux_clk", NULL); 966 clk_register_clkdev(clk, "uart4_mclk", NULL);
969 967
970 clk = clk_register_gate(NULL, "uart4_clk", "uart4_mux_clk", 0, 968 clk = clk_register_gate(NULL, "uart4_clk", "uart4_mclk", 0,
971 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART4_CLK_ENB, 0, 969 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART4_CLK_ENB, 0,
972 &_lock); 970 &_lock);
973 clk_register_clkdev(clk, NULL, "5cb00000.serial"); 971 clk_register_clkdev(clk, NULL, "5cb00000.serial");
974 972
975 clk = clk_register_mux(NULL, "uart5_mux_clk", uart_parents, 973 clk = clk_register_mux(NULL, "uart5_mclk", uart_parents,
976 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0, 974 ARRAY_SIZE(uart_parents), 0, SPEAR1310_RAS_CTRL_REG0,
977 SPEAR1310_UART5_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK, 975 SPEAR1310_UART5_CLK_SHIFT, SPEAR1310_RAS_UART_CLK_MASK,
978 0, &_lock); 976 0, &_lock);
979 clk_register_clkdev(clk, "uart5_mux_clk", NULL); 977 clk_register_clkdev(clk, "uart5_mclk", NULL);
980 978
981 clk = clk_register_gate(NULL, "uart5_clk", "uart5_mux_clk", 0, 979 clk = clk_register_gate(NULL, "uart5_clk", "uart5_mclk", 0,
982 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART5_CLK_ENB, 0, 980 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_UART5_CLK_ENB, 0,
983 &_lock); 981 &_lock);
984 clk_register_clkdev(clk, NULL, "5cc00000.serial"); 982 clk_register_clkdev(clk, NULL, "5cc00000.serial");
985 983
986 clk = clk_register_mux(NULL, "i2c1_mux_clk", i2c_parents, 984 clk = clk_register_mux(NULL, "i2c1_mclk", i2c_parents,
987 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 985 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
988 SPEAR1310_I2C1_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 986 SPEAR1310_I2C1_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
989 &_lock); 987 &_lock);
990 clk_register_clkdev(clk, "i2c1_mux_clk", NULL); 988 clk_register_clkdev(clk, "i2c1_mclk", NULL);
991 989
992 clk = clk_register_gate(NULL, "i2c1_clk", "i2c1_mux_clk", 0, 990 clk = clk_register_gate(NULL, "i2c1_clk", "i2c1_mclk", 0,
993 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C1_CLK_ENB, 0, 991 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C1_CLK_ENB, 0,
994 &_lock); 992 &_lock);
995 clk_register_clkdev(clk, NULL, "5cd00000.i2c"); 993 clk_register_clkdev(clk, NULL, "5cd00000.i2c");
996 994
997 clk = clk_register_mux(NULL, "i2c2_mux_clk", i2c_parents, 995 clk = clk_register_mux(NULL, "i2c2_mclk", i2c_parents,
998 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 996 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
999 SPEAR1310_I2C2_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 997 SPEAR1310_I2C2_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1000 &_lock); 998 &_lock);
1001 clk_register_clkdev(clk, "i2c2_mux_clk", NULL); 999 clk_register_clkdev(clk, "i2c2_mclk", NULL);
1002 1000
1003 clk = clk_register_gate(NULL, "i2c2_clk", "i2c2_mux_clk", 0, 1001 clk = clk_register_gate(NULL, "i2c2_clk", "i2c2_mclk", 0,
1004 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C2_CLK_ENB, 0, 1002 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C2_CLK_ENB, 0,
1005 &_lock); 1003 &_lock);
1006 clk_register_clkdev(clk, NULL, "5ce00000.i2c"); 1004 clk_register_clkdev(clk, NULL, "5ce00000.i2c");
1007 1005
1008 clk = clk_register_mux(NULL, "i2c3_mux_clk", i2c_parents, 1006 clk = clk_register_mux(NULL, "i2c3_mclk", i2c_parents,
1009 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1007 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1010 SPEAR1310_I2C3_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 1008 SPEAR1310_I2C3_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1011 &_lock); 1009 &_lock);
1012 clk_register_clkdev(clk, "i2c3_mux_clk", NULL); 1010 clk_register_clkdev(clk, "i2c3_mclk", NULL);
1013 1011
1014 clk = clk_register_gate(NULL, "i2c3_clk", "i2c3_mux_clk", 0, 1012 clk = clk_register_gate(NULL, "i2c3_clk", "i2c3_mclk", 0,
1015 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C3_CLK_ENB, 0, 1013 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C3_CLK_ENB, 0,
1016 &_lock); 1014 &_lock);
1017 clk_register_clkdev(clk, NULL, "5cf00000.i2c"); 1015 clk_register_clkdev(clk, NULL, "5cf00000.i2c");
1018 1016
1019 clk = clk_register_mux(NULL, "i2c4_mux_clk", i2c_parents, 1017 clk = clk_register_mux(NULL, "i2c4_mclk", i2c_parents,
1020 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1018 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1021 SPEAR1310_I2C4_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 1019 SPEAR1310_I2C4_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1022 &_lock); 1020 &_lock);
1023 clk_register_clkdev(clk, "i2c4_mux_clk", NULL); 1021 clk_register_clkdev(clk, "i2c4_mclk", NULL);
1024 1022
1025 clk = clk_register_gate(NULL, "i2c4_clk", "i2c4_mux_clk", 0, 1023 clk = clk_register_gate(NULL, "i2c4_clk", "i2c4_mclk", 0,
1026 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C4_CLK_ENB, 0, 1024 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C4_CLK_ENB, 0,
1027 &_lock); 1025 &_lock);
1028 clk_register_clkdev(clk, NULL, "5d000000.i2c"); 1026 clk_register_clkdev(clk, NULL, "5d000000.i2c");
1029 1027
1030 clk = clk_register_mux(NULL, "i2c5_mux_clk", i2c_parents, 1028 clk = clk_register_mux(NULL, "i2c5_mclk", i2c_parents,
1031 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1029 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1032 SPEAR1310_I2C5_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 1030 SPEAR1310_I2C5_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1033 &_lock); 1031 &_lock);
1034 clk_register_clkdev(clk, "i2c5_mux_clk", NULL); 1032 clk_register_clkdev(clk, "i2c5_mclk", NULL);
1035 1033
1036 clk = clk_register_gate(NULL, "i2c5_clk", "i2c5_mux_clk", 0, 1034 clk = clk_register_gate(NULL, "i2c5_clk", "i2c5_mclk", 0,
1037 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C5_CLK_ENB, 0, 1035 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C5_CLK_ENB, 0,
1038 &_lock); 1036 &_lock);
1039 clk_register_clkdev(clk, NULL, "5d100000.i2c"); 1037 clk_register_clkdev(clk, NULL, "5d100000.i2c");
1040 1038
1041 clk = clk_register_mux(NULL, "i2c6_mux_clk", i2c_parents, 1039 clk = clk_register_mux(NULL, "i2c6_mclk", i2c_parents,
1042 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1040 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1043 SPEAR1310_I2C6_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 1041 SPEAR1310_I2C6_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1044 &_lock); 1042 &_lock);
1045 clk_register_clkdev(clk, "i2c6_mux_clk", NULL); 1043 clk_register_clkdev(clk, "i2c6_mclk", NULL);
1046 1044
1047 clk = clk_register_gate(NULL, "i2c6_clk", "i2c6_mux_clk", 0, 1045 clk = clk_register_gate(NULL, "i2c6_clk", "i2c6_mclk", 0,
1048 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C6_CLK_ENB, 0, 1046 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C6_CLK_ENB, 0,
1049 &_lock); 1047 &_lock);
1050 clk_register_clkdev(clk, NULL, "5d200000.i2c"); 1048 clk_register_clkdev(clk, NULL, "5d200000.i2c");
1051 1049
1052 clk = clk_register_mux(NULL, "i2c7_mux_clk", i2c_parents, 1050 clk = clk_register_mux(NULL, "i2c7_mclk", i2c_parents,
1053 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1051 ARRAY_SIZE(i2c_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1054 SPEAR1310_I2C7_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0, 1052 SPEAR1310_I2C7_CLK_SHIFT, SPEAR1310_I2C_CLK_MASK, 0,
1055 &_lock); 1053 &_lock);
1056 clk_register_clkdev(clk, "i2c7_mux_clk", NULL); 1054 clk_register_clkdev(clk, "i2c7_mclk", NULL);
1057 1055
1058 clk = clk_register_gate(NULL, "i2c7_clk", "i2c7_mux_clk", 0, 1056 clk = clk_register_gate(NULL, "i2c7_clk", "i2c7_mclk", 0,
1059 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C7_CLK_ENB, 0, 1057 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_I2C7_CLK_ENB, 0,
1060 &_lock); 1058 &_lock);
1061 clk_register_clkdev(clk, NULL, "5d300000.i2c"); 1059 clk_register_clkdev(clk, NULL, "5d300000.i2c");
1062 1060
1063 clk = clk_register_mux(NULL, "ssp1_mux_clk", ssp1_parents, 1061 clk = clk_register_mux(NULL, "ssp1_mclk", ssp1_parents,
1064 ARRAY_SIZE(ssp1_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1062 ARRAY_SIZE(ssp1_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1065 SPEAR1310_SSP1_CLK_SHIFT, SPEAR1310_SSP1_CLK_MASK, 0, 1063 SPEAR1310_SSP1_CLK_SHIFT, SPEAR1310_SSP1_CLK_MASK, 0,
1066 &_lock); 1064 &_lock);
1067 clk_register_clkdev(clk, "ssp1_mux_clk", NULL); 1065 clk_register_clkdev(clk, "ssp1_mclk", NULL);
1068 1066
1069 clk = clk_register_gate(NULL, "ssp1_clk", "ssp1_mux_clk", 0, 1067 clk = clk_register_gate(NULL, "ssp1_clk", "ssp1_mclk", 0,
1070 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_SSP1_CLK_ENB, 0, 1068 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_SSP1_CLK_ENB, 0,
1071 &_lock); 1069 &_lock);
1072 clk_register_clkdev(clk, NULL, "5d400000.spi"); 1070 clk_register_clkdev(clk, NULL, "5d400000.spi");
1073 1071
1074 clk = clk_register_mux(NULL, "pci_mux_clk", pci_parents, 1072 clk = clk_register_mux(NULL, "pci_mclk", pci_parents,
1075 ARRAY_SIZE(pci_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1073 ARRAY_SIZE(pci_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1076 SPEAR1310_PCI_CLK_SHIFT, SPEAR1310_PCI_CLK_MASK, 0, 1074 SPEAR1310_PCI_CLK_SHIFT, SPEAR1310_PCI_CLK_MASK, 0,
1077 &_lock); 1075 &_lock);
1078 clk_register_clkdev(clk, "pci_mux_clk", NULL); 1076 clk_register_clkdev(clk, "pci_mclk", NULL);
1079 1077
1080 clk = clk_register_gate(NULL, "pci_clk", "pci_mux_clk", 0, 1078 clk = clk_register_gate(NULL, "pci_clk", "pci_mclk", 0,
1081 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_PCI_CLK_ENB, 0, 1079 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_PCI_CLK_ENB, 0,
1082 &_lock); 1080 &_lock);
1083 clk_register_clkdev(clk, NULL, "pci"); 1081 clk_register_clkdev(clk, NULL, "pci");
1084 1082
1085 clk = clk_register_mux(NULL, "tdm1_mux_clk", tdm_parents, 1083 clk = clk_register_mux(NULL, "tdm1_mclk", tdm_parents,
1086 ARRAY_SIZE(tdm_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1084 ARRAY_SIZE(tdm_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1087 SPEAR1310_TDM1_CLK_SHIFT, SPEAR1310_TDM_CLK_MASK, 0, 1085 SPEAR1310_TDM1_CLK_SHIFT, SPEAR1310_TDM_CLK_MASK, 0,
1088 &_lock); 1086 &_lock);
1089 clk_register_clkdev(clk, "tdm1_mux_clk", NULL); 1087 clk_register_clkdev(clk, "tdm1_mclk", NULL);
1090 1088
1091 clk = clk_register_gate(NULL, "tdm1_clk", "tdm1_mux_clk", 0, 1089 clk = clk_register_gate(NULL, "tdm1_clk", "tdm1_mclk", 0,
1092 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_TDM1_CLK_ENB, 0, 1090 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_TDM1_CLK_ENB, 0,
1093 &_lock); 1091 &_lock);
1094 clk_register_clkdev(clk, NULL, "tdm_hdlc.0"); 1092 clk_register_clkdev(clk, NULL, "tdm_hdlc.0");
1095 1093
1096 clk = clk_register_mux(NULL, "tdm2_mux_clk", tdm_parents, 1094 clk = clk_register_mux(NULL, "tdm2_mclk", tdm_parents,
1097 ARRAY_SIZE(tdm_parents), 0, SPEAR1310_RAS_CTRL_REG0, 1095 ARRAY_SIZE(tdm_parents), 0, SPEAR1310_RAS_CTRL_REG0,
1098 SPEAR1310_TDM2_CLK_SHIFT, SPEAR1310_TDM_CLK_MASK, 0, 1096 SPEAR1310_TDM2_CLK_SHIFT, SPEAR1310_TDM_CLK_MASK, 0,
1099 &_lock); 1097 &_lock);
1100 clk_register_clkdev(clk, "tdm2_mux_clk", NULL); 1098 clk_register_clkdev(clk, "tdm2_mclk", NULL);
1101 1099
1102 clk = clk_register_gate(NULL, "tdm2_clk", "tdm2_mux_clk", 0, 1100 clk = clk_register_gate(NULL, "tdm2_clk", "tdm2_mclk", 0,
1103 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_TDM2_CLK_ENB, 0, 1101 SPEAR1310_RAS_SW_CLK_CTRL, SPEAR1310_TDM2_CLK_ENB, 0,
1104 &_lock); 1102 &_lock);
1105 clk_register_clkdev(clk, NULL, "tdm_hdlc.1"); 1103 clk_register_clkdev(clk, NULL, "tdm_hdlc.1");
diff --git a/drivers/clk/spear/spear1340_clock.c b/drivers/clk/spear/spear1340_clock.c
index e3ea7216223..2352cee7f64 100644
--- a/drivers/clk/spear/spear1340_clock.c
+++ b/drivers/clk/spear/spear1340_clock.c
@@ -369,27 +369,25 @@ static struct frac_rate_tbl gen_rtbl[] = {
369 369
370/* clock parents */ 370/* clock parents */
371static const char *vco_parents[] = { "osc_24m_clk", "osc_25m_clk", }; 371static const char *vco_parents[] = { "osc_24m_clk", "osc_25m_clk", };
372static const char *sys_parents[] = { "none", "pll1_clk", "none", "none", 372static const char *sys_parents[] = { "pll1_clk", "pll1_clk", "pll1_clk",
373 "sys_synth_clk", "none", "pll2_clk", "pll3_clk", }; 373 "pll1_clk", "sys_synth_clk", "sys_synth_clk", "pll2_clk", "pll3_clk", };
374static const char *ahb_parents[] = { "cpu_div3_clk", "amba_synth_clk", }; 374static const char *ahb_parents[] = { "cpu_div3_clk", "amba_syn_clk", };
375static const char *gpt_parents[] = { "osc_24m_clk", "apb_clk", }; 375static const char *gpt_parents[] = { "osc_24m_clk", "apb_clk", };
376static const char *uart0_parents[] = { "pll5_clk", "osc_24m_clk", 376static const char *uart0_parents[] = { "pll5_clk", "osc_24m_clk",
377 "uart0_synth_gate_clk", }; 377 "uart0_syn_gclk", };
378static const char *uart1_parents[] = { "pll5_clk", "osc_24m_clk", 378static const char *uart1_parents[] = { "pll5_clk", "osc_24m_clk",
379 "uart1_synth_gate_clk", }; 379 "uart1_syn_gclk", };
380static const char *c3_parents[] = { "pll5_clk", "c3_synth_gate_clk", }; 380static const char *c3_parents[] = { "pll5_clk", "c3_syn_gclk", };
381static const char *gmac_phy_input_parents[] = { "gmii_125m_pad_clk", "pll2_clk", 381static const char *gmac_phy_input_parents[] = { "gmii_pad_clk", "pll2_clk",
382 "osc_25m_clk", }; 382 "osc_25m_clk", };
383static const char *gmac_phy_parents[] = { "gmac_phy_input_mux_clk", 383static const char *gmac_phy_parents[] = { "phy_input_mclk", "phy_syn_gclk", };
384 "gmac_phy_synth_gate_clk", };
385static const char *clcd_synth_parents[] = { "vco1div4_clk", "pll2_clk", }; 384static const char *clcd_synth_parents[] = { "vco1div4_clk", "pll2_clk", };
386static const char *clcd_pixel_parents[] = { "pll5_clk", "clcd_synth_clk", }; 385static const char *clcd_pixel_parents[] = { "pll5_clk", "clcd_syn_clk", };
387static const char *i2s_src_parents[] = { "vco1div2_clk", "pll2_clk", "pll3_clk", 386static const char *i2s_src_parents[] = { "vco1div2_clk", "pll2_clk", "pll3_clk",
388 "i2s_src_pad_clk", }; 387 "i2s_src_pad_clk", };
389static const char *i2s_ref_parents[] = { "i2s_src_mux_clk", "i2s_prs1_clk", }; 388static const char *i2s_ref_parents[] = { "i2s_src_mclk", "i2s_prs1_clk", };
390static const char *spdif_out_parents[] = { "i2s_src_pad_clk", "gen_synth2_clk", 389static const char *spdif_out_parents[] = { "i2s_src_pad_clk", "gen_syn2_clk", };
391}; 390static const char *spdif_in_parents[] = { "pll2_clk", "gen_syn3_clk", };
392static const char *spdif_in_parents[] = { "pll2_clk", "gen_synth3_clk", };
393 391
394static const char *gen_synth0_1_parents[] = { "vco1div4_clk", "vco3div2_clk", 392static const char *gen_synth0_1_parents[] = { "vco1div4_clk", "vco3div2_clk",
395 "pll3_clk", }; 393 "pll3_clk", };
@@ -415,9 +413,9 @@ void __init spear1340_clk_init(void)
415 25000000); 413 25000000);
416 clk_register_clkdev(clk, "osc_25m_clk", NULL); 414 clk_register_clkdev(clk, "osc_25m_clk", NULL);
417 415
418 clk = clk_register_fixed_rate(NULL, "gmii_125m_pad_clk", NULL, 416 clk = clk_register_fixed_rate(NULL, "gmii_pad_clk", NULL, CLK_IS_ROOT,
419 CLK_IS_ROOT, 125000000); 417 125000000);
420 clk_register_clkdev(clk, "gmii_125m_pad_clk", NULL); 418 clk_register_clkdev(clk, "gmii_pad_clk", NULL);
421 419
422 clk = clk_register_fixed_rate(NULL, "i2s_src_pad_clk", NULL, 420 clk = clk_register_fixed_rate(NULL, "i2s_src_pad_clk", NULL,
423 CLK_IS_ROOT, 12288000); 421 CLK_IS_ROOT, 12288000);
@@ -431,35 +429,35 @@ void __init spear1340_clk_init(void)
431 429
432 /* clock derived from 24 or 25 MHz osc clk */ 430 /* clock derived from 24 or 25 MHz osc clk */
433 /* vco-pll */ 431 /* vco-pll */
434 clk = clk_register_mux(NULL, "vco1_mux_clk", vco_parents, 432 clk = clk_register_mux(NULL, "vco1_mclk", vco_parents,
435 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG, 433 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG,
436 SPEAR1340_PLL1_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0, 434 SPEAR1340_PLL1_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0,
437 &_lock); 435 &_lock);
438 clk_register_clkdev(clk, "vco1_mux_clk", NULL); 436 clk_register_clkdev(clk, "vco1_mclk", NULL);
439 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "vco1_mux_clk", 437 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "vco1_mclk", 0,
440 0, SPEAR1340_PLL1_CTR, SPEAR1340_PLL1_FRQ, pll_rtbl, 438 SPEAR1340_PLL1_CTR, SPEAR1340_PLL1_FRQ, pll_rtbl,
441 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 439 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
442 clk_register_clkdev(clk, "vco1_clk", NULL); 440 clk_register_clkdev(clk, "vco1_clk", NULL);
443 clk_register_clkdev(clk1, "pll1_clk", NULL); 441 clk_register_clkdev(clk1, "pll1_clk", NULL);
444 442
445 clk = clk_register_mux(NULL, "vco2_mux_clk", vco_parents, 443 clk = clk_register_mux(NULL, "vco2_mclk", vco_parents,
446 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG, 444 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG,
447 SPEAR1340_PLL2_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0, 445 SPEAR1340_PLL2_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0,
448 &_lock); 446 &_lock);
449 clk_register_clkdev(clk, "vco2_mux_clk", NULL); 447 clk_register_clkdev(clk, "vco2_mclk", NULL);
450 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "vco2_mux_clk", 448 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "vco2_mclk", 0,
451 0, SPEAR1340_PLL2_CTR, SPEAR1340_PLL2_FRQ, pll_rtbl, 449 SPEAR1340_PLL2_CTR, SPEAR1340_PLL2_FRQ, pll_rtbl,
452 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 450 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
453 clk_register_clkdev(clk, "vco2_clk", NULL); 451 clk_register_clkdev(clk, "vco2_clk", NULL);
454 clk_register_clkdev(clk1, "pll2_clk", NULL); 452 clk_register_clkdev(clk1, "pll2_clk", NULL);
455 453
456 clk = clk_register_mux(NULL, "vco3_mux_clk", vco_parents, 454 clk = clk_register_mux(NULL, "vco3_mclk", vco_parents,
457 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG, 455 ARRAY_SIZE(vco_parents), 0, SPEAR1340_PLL_CFG,
458 SPEAR1340_PLL3_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0, 456 SPEAR1340_PLL3_CLK_SHIFT, SPEAR1340_PLL_CLK_MASK, 0,
459 &_lock); 457 &_lock);
460 clk_register_clkdev(clk, "vco3_mux_clk", NULL); 458 clk_register_clkdev(clk, "vco3_mclk", NULL);
461 clk = clk_register_vco_pll("vco3_clk", "pll3_clk", NULL, "vco3_mux_clk", 459 clk = clk_register_vco_pll("vco3_clk", "pll3_clk", NULL, "vco3_mclk", 0,
462 0, SPEAR1340_PLL3_CTR, SPEAR1340_PLL3_FRQ, pll_rtbl, 460 SPEAR1340_PLL3_CTR, SPEAR1340_PLL3_FRQ, pll_rtbl,
463 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 461 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
464 clk_register_clkdev(clk, "vco3_clk", NULL); 462 clk_register_clkdev(clk, "vco3_clk", NULL);
465 clk_register_clkdev(clk1, "pll3_clk", NULL); 463 clk_register_clkdev(clk1, "pll3_clk", NULL);
@@ -498,7 +496,7 @@ void __init spear1340_clk_init(void)
498 /* peripherals */ 496 /* peripherals */
499 clk_register_fixed_factor(NULL, "thermal_clk", "osc_24m_clk", 0, 1, 497 clk_register_fixed_factor(NULL, "thermal_clk", "osc_24m_clk", 0, 1,
500 128); 498 128);
501 clk = clk_register_gate(NULL, "thermal_gate_clk", "thermal_clk", 0, 499 clk = clk_register_gate(NULL, "thermal_gclk", "thermal_clk", 0,
502 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_THSENS_CLK_ENB, 0, 500 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_THSENS_CLK_ENB, 0,
503 &_lock); 501 &_lock);
504 clk_register_clkdev(clk, NULL, "spear_thermal"); 502 clk_register_clkdev(clk, NULL, "spear_thermal");
@@ -509,23 +507,23 @@ void __init spear1340_clk_init(void)
509 clk_register_clkdev(clk, "ddr_clk", NULL); 507 clk_register_clkdev(clk, "ddr_clk", NULL);
510 508
511 /* clock derived from pll1 clk */ 509 /* clock derived from pll1 clk */
512 clk = clk_register_frac("sys_synth_clk", "vco1div2_clk", 0, 510 clk = clk_register_frac("sys_syn_clk", "vco1div2_clk", 0,
513 SPEAR1340_SYS_CLK_SYNT, sys_synth_rtbl, 511 SPEAR1340_SYS_CLK_SYNT, sys_synth_rtbl,
514 ARRAY_SIZE(sys_synth_rtbl), &_lock); 512 ARRAY_SIZE(sys_synth_rtbl), &_lock);
515 clk_register_clkdev(clk, "sys_synth_clk", NULL); 513 clk_register_clkdev(clk, "sys_syn_clk", NULL);
516 514
517 clk = clk_register_frac("amba_synth_clk", "vco1div2_clk", 0, 515 clk = clk_register_frac("amba_syn_clk", "vco1div2_clk", 0,
518 SPEAR1340_AMBA_CLK_SYNT, amba_synth_rtbl, 516 SPEAR1340_AMBA_CLK_SYNT, amba_synth_rtbl,
519 ARRAY_SIZE(amba_synth_rtbl), &_lock); 517 ARRAY_SIZE(amba_synth_rtbl), &_lock);
520 clk_register_clkdev(clk, "amba_synth_clk", NULL); 518 clk_register_clkdev(clk, "amba_syn_clk", NULL);
521 519
522 clk = clk_register_mux(NULL, "sys_mux_clk", sys_parents, 520 clk = clk_register_mux(NULL, "sys_mclk", sys_parents,
523 ARRAY_SIZE(sys_parents), 0, SPEAR1340_SYS_CLK_CTRL, 521 ARRAY_SIZE(sys_parents), 0, SPEAR1340_SYS_CLK_CTRL,
524 SPEAR1340_SCLK_SRC_SEL_SHIFT, 522 SPEAR1340_SCLK_SRC_SEL_SHIFT,
525 SPEAR1340_SCLK_SRC_SEL_MASK, 0, &_lock); 523 SPEAR1340_SCLK_SRC_SEL_MASK, 0, &_lock);
526 clk_register_clkdev(clk, "sys_clk", NULL); 524 clk_register_clkdev(clk, "sys_clk", NULL);
527 525
528 clk = clk_register_fixed_factor(NULL, "cpu_clk", "sys_mux_clk", 0, 1, 526 clk = clk_register_fixed_factor(NULL, "cpu_clk", "sys_mclk", 0, 1,
529 2); 527 2);
530 clk_register_clkdev(clk, "cpu_clk", NULL); 528 clk_register_clkdev(clk, "cpu_clk", NULL);
531 529
@@ -548,194 +546,193 @@ void __init spear1340_clk_init(void)
548 clk_register_clkdev(clk, "apb_clk", NULL); 546 clk_register_clkdev(clk, "apb_clk", NULL);
549 547
550 /* gpt clocks */ 548 /* gpt clocks */
551 clk = clk_register_mux(NULL, "gpt0_mux_clk", gpt_parents, 549 clk = clk_register_mux(NULL, "gpt0_mclk", gpt_parents,
552 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG, 550 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG,
553 SPEAR1340_GPT0_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0, 551 SPEAR1340_GPT0_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0,
554 &_lock); 552 &_lock);
555 clk_register_clkdev(clk, "gpt0_mux_clk", NULL); 553 clk_register_clkdev(clk, "gpt0_mclk", NULL);
556 clk = clk_register_gate(NULL, "gpt0_clk", "gpt0_mux_clk", 0, 554 clk = clk_register_gate(NULL, "gpt0_clk", "gpt0_mclk", 0,
557 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT0_CLK_ENB, 0, 555 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT0_CLK_ENB, 0,
558 &_lock); 556 &_lock);
559 clk_register_clkdev(clk, NULL, "gpt0"); 557 clk_register_clkdev(clk, NULL, "gpt0");
560 558
561 clk = clk_register_mux(NULL, "gpt1_mux_clk", gpt_parents, 559 clk = clk_register_mux(NULL, "gpt1_mclk", gpt_parents,
562 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG, 560 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG,
563 SPEAR1340_GPT1_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0, 561 SPEAR1340_GPT1_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0,
564 &_lock); 562 &_lock);
565 clk_register_clkdev(clk, "gpt1_mux_clk", NULL); 563 clk_register_clkdev(clk, "gpt1_mclk", NULL);
566 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mux_clk", 0, 564 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
567 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT1_CLK_ENB, 0, 565 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT1_CLK_ENB, 0,
568 &_lock); 566 &_lock);
569 clk_register_clkdev(clk, NULL, "gpt1"); 567 clk_register_clkdev(clk, NULL, "gpt1");
570 568
571 clk = clk_register_mux(NULL, "gpt2_mux_clk", gpt_parents, 569 clk = clk_register_mux(NULL, "gpt2_mclk", gpt_parents,
572 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG, 570 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG,
573 SPEAR1340_GPT2_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0, 571 SPEAR1340_GPT2_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0,
574 &_lock); 572 &_lock);
575 clk_register_clkdev(clk, "gpt2_mux_clk", NULL); 573 clk_register_clkdev(clk, "gpt2_mclk", NULL);
576 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mux_clk", 0, 574 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
577 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT2_CLK_ENB, 0, 575 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT2_CLK_ENB, 0,
578 &_lock); 576 &_lock);
579 clk_register_clkdev(clk, NULL, "gpt2"); 577 clk_register_clkdev(clk, NULL, "gpt2");
580 578
581 clk = clk_register_mux(NULL, "gpt3_mux_clk", gpt_parents, 579 clk = clk_register_mux(NULL, "gpt3_mclk", gpt_parents,
582 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG, 580 ARRAY_SIZE(gpt_parents), 0, SPEAR1340_PERIP_CLK_CFG,
583 SPEAR1340_GPT3_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0, 581 SPEAR1340_GPT3_CLK_SHIFT, SPEAR1340_GPT_CLK_MASK, 0,
584 &_lock); 582 &_lock);
585 clk_register_clkdev(clk, "gpt3_mux_clk", NULL); 583 clk_register_clkdev(clk, "gpt3_mclk", NULL);
586 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mux_clk", 0, 584 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mclk", 0,
587 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT3_CLK_ENB, 0, 585 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT3_CLK_ENB, 0,
588 &_lock); 586 &_lock);
589 clk_register_clkdev(clk, NULL, "gpt3"); 587 clk_register_clkdev(clk, NULL, "gpt3");
590 588
591 /* others */ 589 /* others */
592 clk = clk_register_aux("uart0_synth_clk", "uart0_synth_gate_clk", 590 clk = clk_register_aux("uart0_syn_clk", "uart0_syn_gclk",
593 "vco1div2_clk", 0, SPEAR1340_UART0_CLK_SYNT, NULL, 591 "vco1div2_clk", 0, SPEAR1340_UART0_CLK_SYNT, NULL,
594 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 592 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
595 clk_register_clkdev(clk, "uart0_synth_clk", NULL); 593 clk_register_clkdev(clk, "uart0_syn_clk", NULL);
596 clk_register_clkdev(clk1, "uart0_synth_gate_clk", NULL); 594 clk_register_clkdev(clk1, "uart0_syn_gclk", NULL);
597 595
598 clk = clk_register_mux(NULL, "uart0_mux_clk", uart0_parents, 596 clk = clk_register_mux(NULL, "uart0_mclk", uart0_parents,
599 ARRAY_SIZE(uart0_parents), 0, SPEAR1340_PERIP_CLK_CFG, 597 ARRAY_SIZE(uart0_parents), 0, SPEAR1340_PERIP_CLK_CFG,
600 SPEAR1340_UART0_CLK_SHIFT, SPEAR1340_UART_CLK_MASK, 0, 598 SPEAR1340_UART0_CLK_SHIFT, SPEAR1340_UART_CLK_MASK, 0,
601 &_lock); 599 &_lock);
602 clk_register_clkdev(clk, "uart0_mux_clk", NULL); 600 clk_register_clkdev(clk, "uart0_mclk", NULL);
603 601
604 clk = clk_register_gate(NULL, "uart0_clk", "uart0_mux_clk", 0, 602 clk = clk_register_gate(NULL, "uart0_clk", "uart0_mclk", 0,
605 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UART0_CLK_ENB, 0, 603 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UART0_CLK_ENB, 0,
606 &_lock); 604 &_lock);
607 clk_register_clkdev(clk, NULL, "e0000000.serial"); 605 clk_register_clkdev(clk, NULL, "e0000000.serial");
608 606
609 clk = clk_register_aux("uart1_synth_clk", "uart1_synth_gate_clk", 607 clk = clk_register_aux("uart1_syn_clk", "uart1_syn_gclk",
610 "vco1div2_clk", 0, SPEAR1340_UART1_CLK_SYNT, NULL, 608 "vco1div2_clk", 0, SPEAR1340_UART1_CLK_SYNT, NULL,
611 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 609 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
612 clk_register_clkdev(clk, "uart1_synth_clk", NULL); 610 clk_register_clkdev(clk, "uart1_syn_clk", NULL);
613 clk_register_clkdev(clk1, "uart1_synth_gate_clk", NULL); 611 clk_register_clkdev(clk1, "uart1_syn_gclk", NULL);
614 612
615 clk = clk_register_mux(NULL, "uart1_mux_clk", uart1_parents, 613 clk = clk_register_mux(NULL, "uart1_mclk", uart1_parents,
616 ARRAY_SIZE(uart1_parents), 0, SPEAR1340_PERIP_CLK_CFG, 614 ARRAY_SIZE(uart1_parents), 0, SPEAR1340_PERIP_CLK_CFG,
617 SPEAR1340_UART1_CLK_SHIFT, SPEAR1340_UART_CLK_MASK, 0, 615 SPEAR1340_UART1_CLK_SHIFT, SPEAR1340_UART_CLK_MASK, 0,
618 &_lock); 616 &_lock);
619 clk_register_clkdev(clk, "uart1_mux_clk", NULL); 617 clk_register_clkdev(clk, "uart1_mclk", NULL);
620 618
621 clk = clk_register_gate(NULL, "uart1_clk", "uart1_mux_clk", 0, 619 clk = clk_register_gate(NULL, "uart1_clk", "uart1_mclk", 0,
622 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UART1_CLK_ENB, 0, 620 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_UART1_CLK_ENB, 0,
623 &_lock); 621 &_lock);
624 clk_register_clkdev(clk, NULL, "b4100000.serial"); 622 clk_register_clkdev(clk, NULL, "b4100000.serial");
625 623
626 clk = clk_register_aux("sdhci_synth_clk", "sdhci_synth_gate_clk", 624 clk = clk_register_aux("sdhci_syn_clk", "sdhci_syn_gclk",
627 "vco1div2_clk", 0, SPEAR1340_SDHCI_CLK_SYNT, NULL, 625 "vco1div2_clk", 0, SPEAR1340_SDHCI_CLK_SYNT, NULL,
628 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 626 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
629 clk_register_clkdev(clk, "sdhci_synth_clk", NULL); 627 clk_register_clkdev(clk, "sdhci_syn_clk", NULL);
630 clk_register_clkdev(clk1, "sdhci_synth_gate_clk", NULL); 628 clk_register_clkdev(clk1, "sdhci_syn_gclk", NULL);
631 629
632 clk = clk_register_gate(NULL, "sdhci_clk", "sdhci_synth_gate_clk", 0, 630 clk = clk_register_gate(NULL, "sdhci_clk", "sdhci_syn_gclk", 0,
633 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SDHCI_CLK_ENB, 0, 631 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SDHCI_CLK_ENB, 0,
634 &_lock); 632 &_lock);
635 clk_register_clkdev(clk, NULL, "b3000000.sdhci"); 633 clk_register_clkdev(clk, NULL, "b3000000.sdhci");
636 634
637 clk = clk_register_aux("cfxd_synth_clk", "cfxd_synth_gate_clk", 635 clk = clk_register_aux("cfxd_syn_clk", "cfxd_syn_gclk", "vco1div2_clk",
638 "vco1div2_clk", 0, SPEAR1340_CFXD_CLK_SYNT, NULL, 636 0, SPEAR1340_CFXD_CLK_SYNT, NULL, aux_rtbl,
639 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 637 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
640 clk_register_clkdev(clk, "cfxd_synth_clk", NULL); 638 clk_register_clkdev(clk, "cfxd_syn_clk", NULL);
641 clk_register_clkdev(clk1, "cfxd_synth_gate_clk", NULL); 639 clk_register_clkdev(clk1, "cfxd_syn_gclk", NULL);
642 640
643 clk = clk_register_gate(NULL, "cfxd_clk", "cfxd_synth_gate_clk", 0, 641 clk = clk_register_gate(NULL, "cfxd_clk", "cfxd_syn_gclk", 0,
644 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_CFXD_CLK_ENB, 0, 642 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_CFXD_CLK_ENB, 0,
645 &_lock); 643 &_lock);
646 clk_register_clkdev(clk, NULL, "b2800000.cf"); 644 clk_register_clkdev(clk, NULL, "b2800000.cf");
647 clk_register_clkdev(clk, NULL, "arasan_xd"); 645 clk_register_clkdev(clk, NULL, "arasan_xd");
648 646
649 clk = clk_register_aux("c3_synth_clk", "c3_synth_gate_clk", 647 clk = clk_register_aux("c3_syn_clk", "c3_syn_gclk", "vco1div2_clk", 0,
650 "vco1div2_clk", 0, SPEAR1340_C3_CLK_SYNT, NULL, 648 SPEAR1340_C3_CLK_SYNT, NULL, aux_rtbl,
651 aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 649 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
652 clk_register_clkdev(clk, "c3_synth_clk", NULL); 650 clk_register_clkdev(clk, "c3_syn_clk", NULL);
653 clk_register_clkdev(clk1, "c3_synth_gate_clk", NULL); 651 clk_register_clkdev(clk1, "c3_syn_gclk", NULL);
654 652
655 clk = clk_register_mux(NULL, "c3_mux_clk", c3_parents, 653 clk = clk_register_mux(NULL, "c3_mclk", c3_parents,
656 ARRAY_SIZE(c3_parents), 0, SPEAR1340_PERIP_CLK_CFG, 654 ARRAY_SIZE(c3_parents), 0, SPEAR1340_PERIP_CLK_CFG,
657 SPEAR1340_C3_CLK_SHIFT, SPEAR1340_C3_CLK_MASK, 0, 655 SPEAR1340_C3_CLK_SHIFT, SPEAR1340_C3_CLK_MASK, 0,
658 &_lock); 656 &_lock);
659 clk_register_clkdev(clk, "c3_mux_clk", NULL); 657 clk_register_clkdev(clk, "c3_mclk", NULL);
660 658
661 clk = clk_register_gate(NULL, "c3_clk", "c3_mux_clk", 0, 659 clk = clk_register_gate(NULL, "c3_clk", "c3_mclk", 0,
662 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_C3_CLK_ENB, 0, 660 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_C3_CLK_ENB, 0,
663 &_lock); 661 &_lock);
664 clk_register_clkdev(clk, NULL, "c3"); 662 clk_register_clkdev(clk, NULL, "c3");
665 663
666 /* gmac */ 664 /* gmac */
667 clk = clk_register_mux(NULL, "gmac_phy_input_mux_clk", 665 clk = clk_register_mux(NULL, "phy_input_mclk", gmac_phy_input_parents,
668 gmac_phy_input_parents,
669 ARRAY_SIZE(gmac_phy_input_parents), 0, 666 ARRAY_SIZE(gmac_phy_input_parents), 0,
670 SPEAR1340_GMAC_CLK_CFG, 667 SPEAR1340_GMAC_CLK_CFG,
671 SPEAR1340_GMAC_PHY_INPUT_CLK_SHIFT, 668 SPEAR1340_GMAC_PHY_INPUT_CLK_SHIFT,
672 SPEAR1340_GMAC_PHY_INPUT_CLK_MASK, 0, &_lock); 669 SPEAR1340_GMAC_PHY_INPUT_CLK_MASK, 0, &_lock);
673 clk_register_clkdev(clk, "gmac_phy_input_mux_clk", NULL); 670 clk_register_clkdev(clk, "phy_input_mclk", NULL);
674 671
675 clk = clk_register_aux("gmac_phy_synth_clk", "gmac_phy_synth_gate_clk", 672 clk = clk_register_aux("phy_syn_clk", "phy_syn_gclk", "phy_input_mclk",
676 "gmac_phy_input_mux_clk", 0, SPEAR1340_GMAC_CLK_SYNT, 673 0, SPEAR1340_GMAC_CLK_SYNT, NULL, gmac_rtbl,
677 NULL, gmac_rtbl, ARRAY_SIZE(gmac_rtbl), &_lock, &clk1); 674 ARRAY_SIZE(gmac_rtbl), &_lock, &clk1);
678 clk_register_clkdev(clk, "gmac_phy_synth_clk", NULL); 675 clk_register_clkdev(clk, "phy_syn_clk", NULL);
679 clk_register_clkdev(clk1, "gmac_phy_synth_gate_clk", NULL); 676 clk_register_clkdev(clk1, "phy_syn_gclk", NULL);
680 677
681 clk = clk_register_mux(NULL, "gmac_phy_mux_clk", gmac_phy_parents, 678 clk = clk_register_mux(NULL, "phy_mclk", gmac_phy_parents,
682 ARRAY_SIZE(gmac_phy_parents), 0, 679 ARRAY_SIZE(gmac_phy_parents), 0,
683 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GMAC_PHY_CLK_SHIFT, 680 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GMAC_PHY_CLK_SHIFT,
684 SPEAR1340_GMAC_PHY_CLK_MASK, 0, &_lock); 681 SPEAR1340_GMAC_PHY_CLK_MASK, 0, &_lock);
685 clk_register_clkdev(clk, NULL, "stmmacphy.0"); 682 clk_register_clkdev(clk, NULL, "stmmacphy.0");
686 683
687 /* clcd */ 684 /* clcd */
688 clk = clk_register_mux(NULL, "clcd_synth_mux_clk", clcd_synth_parents, 685 clk = clk_register_mux(NULL, "clcd_syn_mclk", clcd_synth_parents,
689 ARRAY_SIZE(clcd_synth_parents), 0, 686 ARRAY_SIZE(clcd_synth_parents), 0,
690 SPEAR1340_CLCD_CLK_SYNT, SPEAR1340_CLCD_SYNT_CLK_SHIFT, 687 SPEAR1340_CLCD_CLK_SYNT, SPEAR1340_CLCD_SYNT_CLK_SHIFT,
691 SPEAR1340_CLCD_SYNT_CLK_MASK, 0, &_lock); 688 SPEAR1340_CLCD_SYNT_CLK_MASK, 0, &_lock);
692 clk_register_clkdev(clk, "clcd_synth_mux_clk", NULL); 689 clk_register_clkdev(clk, "clcd_syn_mclk", NULL);
693 690
694 clk = clk_register_frac("clcd_synth_clk", "clcd_synth_mux_clk", 0, 691 clk = clk_register_frac("clcd_syn_clk", "clcd_syn_mclk", 0,
695 SPEAR1340_CLCD_CLK_SYNT, clcd_rtbl, 692 SPEAR1340_CLCD_CLK_SYNT, clcd_rtbl,
696 ARRAY_SIZE(clcd_rtbl), &_lock); 693 ARRAY_SIZE(clcd_rtbl), &_lock);
697 clk_register_clkdev(clk, "clcd_synth_clk", NULL); 694 clk_register_clkdev(clk, "clcd_syn_clk", NULL);
698 695
699 clk = clk_register_mux(NULL, "clcd_pixel_mux_clk", clcd_pixel_parents, 696 clk = clk_register_mux(NULL, "clcd_pixel_mclk", clcd_pixel_parents,
700 ARRAY_SIZE(clcd_pixel_parents), 0, 697 ARRAY_SIZE(clcd_pixel_parents), 0,
701 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_CLCD_CLK_SHIFT, 698 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_CLCD_CLK_SHIFT,
702 SPEAR1340_CLCD_CLK_MASK, 0, &_lock); 699 SPEAR1340_CLCD_CLK_MASK, 0, &_lock);
703 clk_register_clkdev(clk, "clcd_pixel_clk", NULL); 700 clk_register_clkdev(clk, "clcd_pixel_clk", NULL);
704 701
705 clk = clk_register_gate(NULL, "clcd_clk", "clcd_pixel_mux_clk", 0, 702 clk = clk_register_gate(NULL, "clcd_clk", "clcd_pixel_mclk", 0,
706 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_CLCD_CLK_ENB, 0, 703 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_CLCD_CLK_ENB, 0,
707 &_lock); 704 &_lock);
708 clk_register_clkdev(clk, "clcd_clk", NULL); 705 clk_register_clkdev(clk, "clcd_clk", NULL);
709 706
710 /* i2s */ 707 /* i2s */
711 clk = clk_register_mux(NULL, "i2s_src_mux_clk", i2s_src_parents, 708 clk = clk_register_mux(NULL, "i2s_src_mclk", i2s_src_parents,
712 ARRAY_SIZE(i2s_src_parents), 0, SPEAR1340_I2S_CLK_CFG, 709 ARRAY_SIZE(i2s_src_parents), 0, SPEAR1340_I2S_CLK_CFG,
713 SPEAR1340_I2S_SRC_CLK_SHIFT, SPEAR1340_I2S_SRC_CLK_MASK, 710 SPEAR1340_I2S_SRC_CLK_SHIFT, SPEAR1340_I2S_SRC_CLK_MASK,
714 0, &_lock); 711 0, &_lock);
715 clk_register_clkdev(clk, "i2s_src_clk", NULL); 712 clk_register_clkdev(clk, "i2s_src_clk", NULL);
716 713
717 clk = clk_register_aux("i2s_prs1_clk", NULL, "i2s_src_mux_clk", 0, 714 clk = clk_register_aux("i2s_prs1_clk", NULL, "i2s_src_mclk", 0,
718 SPEAR1340_I2S_CLK_CFG, &i2s_prs1_masks, i2s_prs1_rtbl, 715 SPEAR1340_I2S_CLK_CFG, &i2s_prs1_masks, i2s_prs1_rtbl,
719 ARRAY_SIZE(i2s_prs1_rtbl), &_lock, NULL); 716 ARRAY_SIZE(i2s_prs1_rtbl), &_lock, NULL);
720 clk_register_clkdev(clk, "i2s_prs1_clk", NULL); 717 clk_register_clkdev(clk, "i2s_prs1_clk", NULL);
721 718
722 clk = clk_register_mux(NULL, "i2s_ref_mux_clk", i2s_ref_parents, 719 clk = clk_register_mux(NULL, "i2s_ref_mclk", i2s_ref_parents,
723 ARRAY_SIZE(i2s_ref_parents), 0, SPEAR1340_I2S_CLK_CFG, 720 ARRAY_SIZE(i2s_ref_parents), 0, SPEAR1340_I2S_CLK_CFG,
724 SPEAR1340_I2S_REF_SHIFT, SPEAR1340_I2S_REF_SEL_MASK, 0, 721 SPEAR1340_I2S_REF_SHIFT, SPEAR1340_I2S_REF_SEL_MASK, 0,
725 &_lock); 722 &_lock);
726 clk_register_clkdev(clk, "i2s_ref_clk", NULL); 723 clk_register_clkdev(clk, "i2s_ref_clk", NULL);
727 724
728 clk = clk_register_gate(NULL, "i2s_ref_pad_clk", "i2s_ref_mux_clk", 0, 725 clk = clk_register_gate(NULL, "i2s_ref_pad_clk", "i2s_ref_mclk", 0,
729 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_I2S_REF_PAD_CLK_ENB, 726 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_I2S_REF_PAD_CLK_ENB,
730 0, &_lock); 727 0, &_lock);
731 clk_register_clkdev(clk, "i2s_ref_pad_clk", NULL); 728 clk_register_clkdev(clk, "i2s_ref_pad_clk", NULL);
732 729
733 clk = clk_register_aux("i2s_sclk_clk", "i2s_sclk_gate_clk", 730 clk = clk_register_aux("i2s_sclk_clk", "i2s_sclk_gclk", "i2s_ref_mclk",
734 "i2s_ref_mux_clk", 0, SPEAR1340_I2S_CLK_CFG, 731 0, SPEAR1340_I2S_CLK_CFG, &i2s_sclk_masks,
735 &i2s_sclk_masks, i2s_sclk_rtbl, 732 i2s_sclk_rtbl, ARRAY_SIZE(i2s_sclk_rtbl), &_lock,
736 ARRAY_SIZE(i2s_sclk_rtbl), &_lock, &clk1); 733 &clk1);
737 clk_register_clkdev(clk, "i2s_sclk_clk", NULL); 734 clk_register_clkdev(clk, "i2s_sclk_clk", NULL);
738 clk_register_clkdev(clk1, "i2s_sclk_gate_clk", NULL); 735 clk_register_clkdev(clk1, "i2s_sclk_gclk", NULL);
739 736
740 /* clock derived from ahb clk */ 737 /* clock derived from ahb clk */
741 clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0, 738 clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0,
@@ -744,7 +741,7 @@ void __init spear1340_clk_init(void)
744 clk_register_clkdev(clk, NULL, "e0280000.i2c"); 741 clk_register_clkdev(clk, NULL, "e0280000.i2c");
745 742
746 clk = clk_register_gate(NULL, "i2c1_clk", "ahb_clk", 0, 743 clk = clk_register_gate(NULL, "i2c1_clk", "ahb_clk", 0,
747 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_I2C1_CLK_ENB, 0, 744 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_I2C1_CLK_ENB, 0,
748 &_lock); 745 &_lock);
749 clk_register_clkdev(clk, NULL, "b4000000.i2c"); 746 clk_register_clkdev(clk, NULL, "b4000000.i2c");
750 747
@@ -800,13 +797,13 @@ void __init spear1340_clk_init(void)
800 &_lock); 797 &_lock);
801 clk_register_clkdev(clk, "sysram1_clk", NULL); 798 clk_register_clkdev(clk, "sysram1_clk", NULL);
802 799
803 clk = clk_register_aux("adc_synth_clk", "adc_synth_gate_clk", "ahb_clk", 800 clk = clk_register_aux("adc_syn_clk", "adc_syn_gclk", "ahb_clk",
804 0, SPEAR1340_ADC_CLK_SYNT, NULL, adc_rtbl, 801 0, SPEAR1340_ADC_CLK_SYNT, NULL, adc_rtbl,
805 ARRAY_SIZE(adc_rtbl), &_lock, &clk1); 802 ARRAY_SIZE(adc_rtbl), &_lock, &clk1);
806 clk_register_clkdev(clk, "adc_synth_clk", NULL); 803 clk_register_clkdev(clk, "adc_syn_clk", NULL);
807 clk_register_clkdev(clk1, "adc_synth_gate_clk", NULL); 804 clk_register_clkdev(clk1, "adc_syn_gclk", NULL);
808 805
809 clk = clk_register_gate(NULL, "adc_clk", "adc_synth_gate_clk", 0, 806 clk = clk_register_gate(NULL, "adc_clk", "adc_syn_gclk", 0,
810 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_ADC_CLK_ENB, 0, 807 SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_ADC_CLK_ENB, 0,
811 &_lock); 808 &_lock);
812 clk_register_clkdev(clk, NULL, "adc_clk"); 809 clk_register_clkdev(clk, NULL, "adc_clk");
@@ -843,39 +840,39 @@ void __init spear1340_clk_init(void)
843 clk_register_clkdev(clk, NULL, "e0300000.kbd"); 840 clk_register_clkdev(clk, NULL, "e0300000.kbd");
844 841
845 /* RAS clks */ 842 /* RAS clks */
846 clk = clk_register_mux(NULL, "gen_synth0_1_mux_clk", 843 clk = clk_register_mux(NULL, "gen_syn0_1_mclk", gen_synth0_1_parents,
847 gen_synth0_1_parents, ARRAY_SIZE(gen_synth0_1_parents), 844 ARRAY_SIZE(gen_synth0_1_parents), 0, SPEAR1340_PLL_CFG,
848 0, SPEAR1340_PLL_CFG, SPEAR1340_GEN_SYNT0_1_CLK_SHIFT, 845 SPEAR1340_GEN_SYNT0_1_CLK_SHIFT,
849 SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock); 846 SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock);
850 clk_register_clkdev(clk, "gen_synth0_1_clk", NULL); 847 clk_register_clkdev(clk, "gen_syn0_1_clk", NULL);
851 848
852 clk = clk_register_mux(NULL, "gen_synth2_3_mux_clk", 849 clk = clk_register_mux(NULL, "gen_syn2_3_mclk", gen_synth2_3_parents,
853 gen_synth2_3_parents, ARRAY_SIZE(gen_synth2_3_parents), 850 ARRAY_SIZE(gen_synth2_3_parents), 0, SPEAR1340_PLL_CFG,
854 0, SPEAR1340_PLL_CFG, SPEAR1340_GEN_SYNT2_3_CLK_SHIFT, 851 SPEAR1340_GEN_SYNT2_3_CLK_SHIFT,
855 SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock); 852 SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock);
856 clk_register_clkdev(clk, "gen_synth2_3_clk", NULL); 853 clk_register_clkdev(clk, "gen_syn2_3_clk", NULL);
857 854
858 clk = clk_register_frac("gen_synth0_clk", "gen_synth0_1_clk", 0, 855 clk = clk_register_frac("gen_syn0_clk", "gen_syn0_1_clk", 0,
859 SPEAR1340_GEN_CLK_SYNT0, gen_rtbl, ARRAY_SIZE(gen_rtbl), 856 SPEAR1340_GEN_CLK_SYNT0, gen_rtbl, ARRAY_SIZE(gen_rtbl),
860 &_lock); 857 &_lock);
861 clk_register_clkdev(clk, "gen_synth0_clk", NULL); 858 clk_register_clkdev(clk, "gen_syn0_clk", NULL);
862 859
863 clk = clk_register_frac("gen_synth1_clk", "gen_synth0_1_clk", 0, 860 clk = clk_register_frac("gen_syn1_clk", "gen_syn0_1_clk", 0,
864 SPEAR1340_GEN_CLK_SYNT1, gen_rtbl, ARRAY_SIZE(gen_rtbl), 861 SPEAR1340_GEN_CLK_SYNT1, gen_rtbl, ARRAY_SIZE(gen_rtbl),
865 &_lock); 862 &_lock);
866 clk_register_clkdev(clk, "gen_synth1_clk", NULL); 863 clk_register_clkdev(clk, "gen_syn1_clk", NULL);
867 864
868 clk = clk_register_frac("gen_synth2_clk", "gen_synth2_3_clk", 0, 865 clk = clk_register_frac("gen_syn2_clk", "gen_syn2_3_clk", 0,
869 SPEAR1340_GEN_CLK_SYNT2, gen_rtbl, ARRAY_SIZE(gen_rtbl), 866 SPEAR1340_GEN_CLK_SYNT2, gen_rtbl, ARRAY_SIZE(gen_rtbl),
870 &_lock); 867 &_lock);
871 clk_register_clkdev(clk, "gen_synth2_clk", NULL); 868 clk_register_clkdev(clk, "gen_syn2_clk", NULL);
872 869
873 clk = clk_register_frac("gen_synth3_clk", "gen_synth2_3_clk", 0, 870 clk = clk_register_frac("gen_syn3_clk", "gen_syn2_3_clk", 0,
874 SPEAR1340_GEN_CLK_SYNT3, gen_rtbl, ARRAY_SIZE(gen_rtbl), 871 SPEAR1340_GEN_CLK_SYNT3, gen_rtbl, ARRAY_SIZE(gen_rtbl),
875 &_lock); 872 &_lock);
876 clk_register_clkdev(clk, "gen_synth3_clk", NULL); 873 clk_register_clkdev(clk, "gen_syn3_clk", NULL);
877 874
878 clk = clk_register_gate(NULL, "mali_clk", "gen_synth3_clk", 0, 875 clk = clk_register_gate(NULL, "mali_clk", "gen_syn3_clk", 0,
879 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_MALI_CLK_ENB, 0, 876 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_MALI_CLK_ENB, 0,
880 &_lock); 877 &_lock);
881 clk_register_clkdev(clk, NULL, "mali"); 878 clk_register_clkdev(clk, NULL, "mali");
@@ -890,74 +887,74 @@ void __init spear1340_clk_init(void)
890 &_lock); 887 &_lock);
891 clk_register_clkdev(clk, NULL, "spear_cec.1"); 888 clk_register_clkdev(clk, NULL, "spear_cec.1");
892 889
893 clk = clk_register_mux(NULL, "spdif_out_mux_clk", spdif_out_parents, 890 clk = clk_register_mux(NULL, "spdif_out_mclk", spdif_out_parents,
894 ARRAY_SIZE(spdif_out_parents), 0, 891 ARRAY_SIZE(spdif_out_parents), 0,
895 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_OUT_CLK_SHIFT, 892 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_OUT_CLK_SHIFT,
896 SPEAR1340_SPDIF_CLK_MASK, 0, &_lock); 893 SPEAR1340_SPDIF_CLK_MASK, 0, &_lock);
897 clk_register_clkdev(clk, "spdif_out_mux_clk", NULL); 894 clk_register_clkdev(clk, "spdif_out_mclk", NULL);
898 895
899 clk = clk_register_gate(NULL, "spdif_out_clk", "spdif_out_mux_clk", 0, 896 clk = clk_register_gate(NULL, "spdif_out_clk", "spdif_out_mclk", 0,
900 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_SPDIF_OUT_CLK_ENB, 897 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_SPDIF_OUT_CLK_ENB,
901 0, &_lock); 898 0, &_lock);
902 clk_register_clkdev(clk, NULL, "spdif-out"); 899 clk_register_clkdev(clk, NULL, "spdif-out");
903 900
904 clk = clk_register_mux(NULL, "spdif_in_mux_clk", spdif_in_parents, 901 clk = clk_register_mux(NULL, "spdif_in_mclk", spdif_in_parents,
905 ARRAY_SIZE(spdif_in_parents), 0, 902 ARRAY_SIZE(spdif_in_parents), 0,
906 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_IN_CLK_SHIFT, 903 SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_IN_CLK_SHIFT,
907 SPEAR1340_SPDIF_CLK_MASK, 0, &_lock); 904 SPEAR1340_SPDIF_CLK_MASK, 0, &_lock);
908 clk_register_clkdev(clk, "spdif_in_mux_clk", NULL); 905 clk_register_clkdev(clk, "spdif_in_mclk", NULL);
909 906
910 clk = clk_register_gate(NULL, "spdif_in_clk", "spdif_in_mux_clk", 0, 907 clk = clk_register_gate(NULL, "spdif_in_clk", "spdif_in_mclk", 0,
911 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_SPDIF_IN_CLK_ENB, 0, 908 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_SPDIF_IN_CLK_ENB, 0,
912 &_lock); 909 &_lock);
913 clk_register_clkdev(clk, NULL, "spdif-in"); 910 clk_register_clkdev(clk, NULL, "spdif-in");
914 911
915 clk = clk_register_gate(NULL, "acp_clk", "acp_mux_clk", 0, 912 clk = clk_register_gate(NULL, "acp_clk", "acp_mclk", 0,
916 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_ACP_CLK_ENB, 0, 913 SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_ACP_CLK_ENB, 0,
917 &_lock); 914 &_lock);
918 clk_register_clkdev(clk, NULL, "acp_clk"); 915 clk_register_clkdev(clk, NULL, "acp_clk");
919 916
920 clk = clk_register_gate(NULL, "plgpio_clk", "plgpio_mux_clk", 0, 917 clk = clk_register_gate(NULL, "plgpio_clk", "plgpio_mclk", 0,
921 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PLGPIO_CLK_ENB, 0, 918 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PLGPIO_CLK_ENB, 0,
922 &_lock); 919 &_lock);
923 clk_register_clkdev(clk, NULL, "plgpio"); 920 clk_register_clkdev(clk, NULL, "plgpio");
924 921
925 clk = clk_register_gate(NULL, "video_dec_clk", "video_dec_mux_clk", 0, 922 clk = clk_register_gate(NULL, "video_dec_clk", "video_dec_mclk", 0,
926 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_DEC_CLK_ENB, 923 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_DEC_CLK_ENB,
927 0, &_lock); 924 0, &_lock);
928 clk_register_clkdev(clk, NULL, "video_dec"); 925 clk_register_clkdev(clk, NULL, "video_dec");
929 926
930 clk = clk_register_gate(NULL, "video_enc_clk", "video_enc_mux_clk", 0, 927 clk = clk_register_gate(NULL, "video_enc_clk", "video_enc_mclk", 0,
931 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_ENC_CLK_ENB, 928 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_ENC_CLK_ENB,
932 0, &_lock); 929 0, &_lock);
933 clk_register_clkdev(clk, NULL, "video_enc"); 930 clk_register_clkdev(clk, NULL, "video_enc");
934 931
935 clk = clk_register_gate(NULL, "video_in_clk", "video_in_mux_clk", 0, 932 clk = clk_register_gate(NULL, "video_in_clk", "video_in_mclk", 0,
936 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_IN_CLK_ENB, 0, 933 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_IN_CLK_ENB, 0,
937 &_lock); 934 &_lock);
938 clk_register_clkdev(clk, NULL, "spear_vip"); 935 clk_register_clkdev(clk, NULL, "spear_vip");
939 936
940 clk = clk_register_gate(NULL, "cam0_clk", "cam0_mux_clk", 0, 937 clk = clk_register_gate(NULL, "cam0_clk", "cam0_mclk", 0,
941 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM0_CLK_ENB, 0, 938 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM0_CLK_ENB, 0,
942 &_lock); 939 &_lock);
943 clk_register_clkdev(clk, NULL, "spear_camif.0"); 940 clk_register_clkdev(clk, NULL, "spear_camif.0");
944 941
945 clk = clk_register_gate(NULL, "cam1_clk", "cam1_mux_clk", 0, 942 clk = clk_register_gate(NULL, "cam1_clk", "cam1_mclk", 0,
946 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM1_CLK_ENB, 0, 943 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM1_CLK_ENB, 0,
947 &_lock); 944 &_lock);
948 clk_register_clkdev(clk, NULL, "spear_camif.1"); 945 clk_register_clkdev(clk, NULL, "spear_camif.1");
949 946
950 clk = clk_register_gate(NULL, "cam2_clk", "cam2_mux_clk", 0, 947 clk = clk_register_gate(NULL, "cam2_clk", "cam2_mclk", 0,
951 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM2_CLK_ENB, 0, 948 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM2_CLK_ENB, 0,
952 &_lock); 949 &_lock);
953 clk_register_clkdev(clk, NULL, "spear_camif.2"); 950 clk_register_clkdev(clk, NULL, "spear_camif.2");
954 951
955 clk = clk_register_gate(NULL, "cam3_clk", "cam3_mux_clk", 0, 952 clk = clk_register_gate(NULL, "cam3_clk", "cam3_mclk", 0,
956 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM3_CLK_ENB, 0, 953 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM3_CLK_ENB, 0,
957 &_lock); 954 &_lock);
958 clk_register_clkdev(clk, NULL, "spear_camif.3"); 955 clk_register_clkdev(clk, NULL, "spear_camif.3");
959 956
960 clk = clk_register_gate(NULL, "pwm_clk", "pwm_mux_clk", 0, 957 clk = clk_register_gate(NULL, "pwm_clk", "pwm_mclk", 0,
961 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PWM_CLK_ENB, 0, 958 SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PWM_CLK_ENB, 0,
962 &_lock); 959 &_lock);
963 clk_register_clkdev(clk, NULL, "pwm"); 960 clk_register_clkdev(clk, NULL, "pwm");
diff --git a/drivers/clk/spear/spear3xx_clock.c b/drivers/clk/spear/spear3xx_clock.c
index 01dd6daff2a..c3157454bb3 100644
--- a/drivers/clk/spear/spear3xx_clock.c
+++ b/drivers/clk/spear/spear3xx_clock.c
@@ -122,12 +122,12 @@ static struct gpt_rate_tbl gpt_rtbl[] = {
122}; 122};
123 123
124/* clock parents */ 124/* clock parents */
125static const char *uart0_parents[] = { "pll3_48m_clk", "uart_synth_gate_clk", }; 125static const char *uart0_parents[] = { "pll3_clk", "uart_syn_gclk", };
126static const char *firda_parents[] = { "pll3_48m_clk", "firda_synth_gate_clk", 126static const char *firda_parents[] = { "pll3_clk", "firda_syn_gclk",
127}; 127};
128static const char *gpt0_parents[] = { "pll3_48m_clk", "gpt0_synth_clk", }; 128static const char *gpt0_parents[] = { "pll3_clk", "gpt0_syn_clk", };
129static const char *gpt1_parents[] = { "pll3_48m_clk", "gpt1_synth_clk", }; 129static const char *gpt1_parents[] = { "pll3_clk", "gpt1_syn_clk", };
130static const char *gpt2_parents[] = { "pll3_48m_clk", "gpt2_synth_clk", }; 130static const char *gpt2_parents[] = { "pll3_clk", "gpt2_syn_clk", };
131static const char *gen2_3_parents[] = { "pll1_clk", "pll2_clk", }; 131static const char *gen2_3_parents[] = { "pll1_clk", "pll2_clk", };
132static const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none", 132static const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none",
133 "pll2_clk", }; 133 "pll2_clk", };
@@ -137,7 +137,7 @@ static void __init spear300_clk_init(void)
137{ 137{
138 struct clk *clk; 138 struct clk *clk;
139 139
140 clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_48m_clk", 0, 140 clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_clk", 0,
141 1, 1); 141 1, 1);
142 clk_register_clkdev(clk, NULL, "60000000.clcd"); 142 clk_register_clkdev(clk, NULL, "60000000.clcd");
143 143
@@ -219,15 +219,11 @@ static void __init spear310_clk_init(void)
219 #define SPEAR320_UARTX_PCLK_VAL_SYNTH1 0x0 219 #define SPEAR320_UARTX_PCLK_VAL_SYNTH1 0x0
220 #define SPEAR320_UARTX_PCLK_VAL_APB 0x1 220 #define SPEAR320_UARTX_PCLK_VAL_APB 0x1
221 221
222static const char *i2s_ref_parents[] = { "ras_pll2_clk", 222static const char *i2s_ref_parents[] = { "ras_pll2_clk", "ras_syn2_gclk", };
223 "ras_gen2_synth_gate_clk", }; 223static const char *sdhci_parents[] = { "ras_pll3_clk", "ras_syn3_gclk", };
224static const char *sdhci_parents[] = { "ras_pll3_48m_clk",
225 "ras_gen3_synth_gate_clk",
226};
227static const char *smii0_parents[] = { "smii_125m_pad", "ras_pll2_clk", 224static const char *smii0_parents[] = { "smii_125m_pad", "ras_pll2_clk",
228 "ras_gen0_synth_gate_clk", }; 225 "ras_syn0_gclk", };
229static const char *uartx_parents[] = { "ras_gen1_synth_gate_clk", "ras_apb_clk", 226static const char *uartx_parents[] = { "ras_syn1_gclk", "ras_apb_clk", };
230};
231 227
232static void __init spear320_clk_init(void) 228static void __init spear320_clk_init(void)
233{ 229{
@@ -237,7 +233,7 @@ static void __init spear320_clk_init(void)
237 CLK_IS_ROOT, 125000000); 233 CLK_IS_ROOT, 125000000);
238 clk_register_clkdev(clk, "smii_125m_pad", NULL); 234 clk_register_clkdev(clk, "smii_125m_pad", NULL);
239 235
240 clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_48m_clk", 0, 236 clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_clk", 0,
241 1, 1); 237 1, 1);
242 clk_register_clkdev(clk, NULL, "90000000.clcd"); 238 clk_register_clkdev(clk, NULL, "90000000.clcd");
243 239
@@ -363,9 +359,9 @@ void __init spear3xx_clk_init(void)
363 clk_register_clkdev(clk, NULL, "fc900000.rtc"); 359 clk_register_clkdev(clk, NULL, "fc900000.rtc");
364 360
365 /* clock derived from 24 MHz osc clk */ 361 /* clock derived from 24 MHz osc clk */
366 clk = clk_register_fixed_rate(NULL, "pll3_48m_clk", "osc_24m_clk", 0, 362 clk = clk_register_fixed_rate(NULL, "pll3_clk", "osc_24m_clk", 0,
367 48000000); 363 48000000);
368 clk_register_clkdev(clk, "pll3_48m_clk", NULL); 364 clk_register_clkdev(clk, "pll3_clk", NULL);
369 365
370 clk = clk_register_fixed_factor(NULL, "wdt_clk", "osc_24m_clk", 0, 1, 366 clk = clk_register_fixed_factor(NULL, "wdt_clk", "osc_24m_clk", 0, 1,
371 1); 367 1);
@@ -392,98 +388,98 @@ void __init spear3xx_clk_init(void)
392 HCLK_RATIO_MASK, 0, &_lock); 388 HCLK_RATIO_MASK, 0, &_lock);
393 clk_register_clkdev(clk, "ahb_clk", NULL); 389 clk_register_clkdev(clk, "ahb_clk", NULL);
394 390
395 clk = clk_register_aux("uart_synth_clk", "uart_synth_gate_clk", 391 clk = clk_register_aux("uart_syn_clk", "uart_syn_gclk", "pll1_clk", 0,
396 "pll1_clk", 0, UART_CLK_SYNT, NULL, aux_rtbl, 392 UART_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
397 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 393 &_lock, &clk1);
398 clk_register_clkdev(clk, "uart_synth_clk", NULL); 394 clk_register_clkdev(clk, "uart_syn_clk", NULL);
399 clk_register_clkdev(clk1, "uart_synth_gate_clk", NULL); 395 clk_register_clkdev(clk1, "uart_syn_gclk", NULL);
400 396
401 clk = clk_register_mux(NULL, "uart0_mux_clk", uart0_parents, 397 clk = clk_register_mux(NULL, "uart0_mclk", uart0_parents,
402 ARRAY_SIZE(uart0_parents), 0, PERIP_CLK_CFG, 398 ARRAY_SIZE(uart0_parents), 0, PERIP_CLK_CFG,
403 UART_CLK_SHIFT, UART_CLK_MASK, 0, &_lock); 399 UART_CLK_SHIFT, UART_CLK_MASK, 0, &_lock);
404 clk_register_clkdev(clk, "uart0_mux_clk", NULL); 400 clk_register_clkdev(clk, "uart0_mclk", NULL);
405 401
406 clk = clk_register_gate(NULL, "uart0", "uart0_mux_clk", 0, 402 clk = clk_register_gate(NULL, "uart0", "uart0_mclk", 0, PERIP1_CLK_ENB,
407 PERIP1_CLK_ENB, UART_CLK_ENB, 0, &_lock); 403 UART_CLK_ENB, 0, &_lock);
408 clk_register_clkdev(clk, NULL, "d0000000.serial"); 404 clk_register_clkdev(clk, NULL, "d0000000.serial");
409 405
410 clk = clk_register_aux("firda_synth_clk", "firda_synth_gate_clk", 406 clk = clk_register_aux("firda_syn_clk", "firda_syn_gclk", "pll1_clk", 0,
411 "pll1_clk", 0, FIRDA_CLK_SYNT, NULL, aux_rtbl, 407 FIRDA_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
412 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 408 &_lock, &clk1);
413 clk_register_clkdev(clk, "firda_synth_clk", NULL); 409 clk_register_clkdev(clk, "firda_syn_clk", NULL);
414 clk_register_clkdev(clk1, "firda_synth_gate_clk", NULL); 410 clk_register_clkdev(clk1, "firda_syn_gclk", NULL);
415 411
416 clk = clk_register_mux(NULL, "firda_mux_clk", firda_parents, 412 clk = clk_register_mux(NULL, "firda_mclk", firda_parents,
417 ARRAY_SIZE(firda_parents), 0, PERIP_CLK_CFG, 413 ARRAY_SIZE(firda_parents), 0, PERIP_CLK_CFG,
418 FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0, &_lock); 414 FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0, &_lock);
419 clk_register_clkdev(clk, "firda_mux_clk", NULL); 415 clk_register_clkdev(clk, "firda_mclk", NULL);
420 416
421 clk = clk_register_gate(NULL, "firda_clk", "firda_mux_clk", 0, 417 clk = clk_register_gate(NULL, "firda_clk", "firda_mclk", 0,
422 PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0, &_lock); 418 PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0, &_lock);
423 clk_register_clkdev(clk, NULL, "firda"); 419 clk_register_clkdev(clk, NULL, "firda");
424 420
425 /* gpt clocks */ 421 /* gpt clocks */
426 clk_register_gpt("gpt0_synth_clk", "pll1_clk", 0, PRSC0_CLK_CFG, 422 clk_register_gpt("gpt0_syn_clk", "pll1_clk", 0, PRSC0_CLK_CFG, gpt_rtbl,
427 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 423 ARRAY_SIZE(gpt_rtbl), &_lock);
428 clk = clk_register_mux(NULL, "gpt0_clk", gpt0_parents, 424 clk = clk_register_mux(NULL, "gpt0_clk", gpt0_parents,
429 ARRAY_SIZE(gpt0_parents), 0, PERIP_CLK_CFG, 425 ARRAY_SIZE(gpt0_parents), 0, PERIP_CLK_CFG,
430 GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 426 GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
431 clk_register_clkdev(clk, NULL, "gpt0"); 427 clk_register_clkdev(clk, NULL, "gpt0");
432 428
433 clk_register_gpt("gpt1_synth_clk", "pll1_clk", 0, PRSC1_CLK_CFG, 429 clk_register_gpt("gpt1_syn_clk", "pll1_clk", 0, PRSC1_CLK_CFG, gpt_rtbl,
434 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 430 ARRAY_SIZE(gpt_rtbl), &_lock);
435 clk = clk_register_mux(NULL, "gpt1_mux_clk", gpt1_parents, 431 clk = clk_register_mux(NULL, "gpt1_mclk", gpt1_parents,
436 ARRAY_SIZE(gpt1_parents), 0, PERIP_CLK_CFG, 432 ARRAY_SIZE(gpt1_parents), 0, PERIP_CLK_CFG,
437 GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 433 GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
438 clk_register_clkdev(clk, "gpt1_mux_clk", NULL); 434 clk_register_clkdev(clk, "gpt1_mclk", NULL);
439 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mux_clk", 0, 435 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
440 PERIP1_CLK_ENB, GPT1_CLK_ENB, 0, &_lock); 436 PERIP1_CLK_ENB, GPT1_CLK_ENB, 0, &_lock);
441 clk_register_clkdev(clk, NULL, "gpt1"); 437 clk_register_clkdev(clk, NULL, "gpt1");
442 438
443 clk_register_gpt("gpt2_synth_clk", "pll1_clk", 0, PRSC2_CLK_CFG, 439 clk_register_gpt("gpt2_syn_clk", "pll1_clk", 0, PRSC2_CLK_CFG, gpt_rtbl,
444 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 440 ARRAY_SIZE(gpt_rtbl), &_lock);
445 clk = clk_register_mux(NULL, "gpt2_mux_clk", gpt2_parents, 441 clk = clk_register_mux(NULL, "gpt2_mclk", gpt2_parents,
446 ARRAY_SIZE(gpt2_parents), 0, PERIP_CLK_CFG, 442 ARRAY_SIZE(gpt2_parents), 0, PERIP_CLK_CFG,
447 GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 443 GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
448 clk_register_clkdev(clk, "gpt2_mux_clk", NULL); 444 clk_register_clkdev(clk, "gpt2_mclk", NULL);
449 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mux_clk", 0, 445 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
450 PERIP1_CLK_ENB, GPT2_CLK_ENB, 0, &_lock); 446 PERIP1_CLK_ENB, GPT2_CLK_ENB, 0, &_lock);
451 clk_register_clkdev(clk, NULL, "gpt2"); 447 clk_register_clkdev(clk, NULL, "gpt2");
452 448
453 /* general synths clocks */ 449 /* general synths clocks */
454 clk = clk_register_aux("gen0_synth_clk", "gen0_synth_gate_clk", 450 clk = clk_register_aux("gen0_syn_clk", "gen0_syn_gclk", "pll1_clk",
455 "pll1_clk", 0, GEN0_CLK_SYNT, NULL, aux_rtbl, 451 0, GEN0_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
456 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 452 &_lock, &clk1);
457 clk_register_clkdev(clk, "gen0_synth_clk", NULL); 453 clk_register_clkdev(clk, "gen0_syn_clk", NULL);
458 clk_register_clkdev(clk1, "gen0_synth_gate_clk", NULL); 454 clk_register_clkdev(clk1, "gen0_syn_gclk", NULL);
459 455
460 clk = clk_register_aux("gen1_synth_clk", "gen1_synth_gate_clk", 456 clk = clk_register_aux("gen1_syn_clk", "gen1_syn_gclk", "pll1_clk",
461 "pll1_clk", 0, GEN1_CLK_SYNT, NULL, aux_rtbl, 457 0, GEN1_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
462 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 458 &_lock, &clk1);
463 clk_register_clkdev(clk, "gen1_synth_clk", NULL); 459 clk_register_clkdev(clk, "gen1_syn_clk", NULL);
464 clk_register_clkdev(clk1, "gen1_synth_gate_clk", NULL); 460 clk_register_clkdev(clk1, "gen1_syn_gclk", NULL);
465 461
466 clk = clk_register_mux(NULL, "gen2_3_parent_clk", gen2_3_parents, 462 clk = clk_register_mux(NULL, "gen2_3_par_clk", gen2_3_parents,
467 ARRAY_SIZE(gen2_3_parents), 0, CORE_CLK_CFG, 463 ARRAY_SIZE(gen2_3_parents), 0, CORE_CLK_CFG,
468 GEN_SYNTH2_3_CLK_SHIFT, GEN_SYNTH2_3_CLK_MASK, 0, 464 GEN_SYNTH2_3_CLK_SHIFT, GEN_SYNTH2_3_CLK_MASK, 0,
469 &_lock); 465 &_lock);
470 clk_register_clkdev(clk, "gen2_3_parent_clk", NULL); 466 clk_register_clkdev(clk, "gen2_3_par_clk", NULL);
471 467
472 clk = clk_register_aux("gen2_synth_clk", "gen2_synth_gate_clk", 468 clk = clk_register_aux("gen2_syn_clk", "gen2_syn_gclk",
473 "gen2_3_parent_clk", 0, GEN2_CLK_SYNT, NULL, aux_rtbl, 469 "gen2_3_par_clk", 0, GEN2_CLK_SYNT, NULL, aux_rtbl,
474 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 470 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
475 clk_register_clkdev(clk, "gen2_synth_clk", NULL); 471 clk_register_clkdev(clk, "gen2_syn_clk", NULL);
476 clk_register_clkdev(clk1, "gen2_synth_gate_clk", NULL); 472 clk_register_clkdev(clk1, "gen2_syn_gclk", NULL);
477 473
478 clk = clk_register_aux("gen3_synth_clk", "gen3_synth_gate_clk", 474 clk = clk_register_aux("gen3_syn_clk", "gen3_syn_gclk",
479 "gen2_3_parent_clk", 0, GEN3_CLK_SYNT, NULL, aux_rtbl, 475 "gen2_3_par_clk", 0, GEN3_CLK_SYNT, NULL, aux_rtbl,
480 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 476 ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
481 clk_register_clkdev(clk, "gen3_synth_clk", NULL); 477 clk_register_clkdev(clk, "gen3_syn_clk", NULL);
482 clk_register_clkdev(clk1, "gen3_synth_gate_clk", NULL); 478 clk_register_clkdev(clk1, "gen3_syn_gclk", NULL);
483 479
484 /* clock derived from pll3 clk */ 480 /* clock derived from pll3 clk */
485 clk = clk_register_gate(NULL, "usbh_clk", "pll3_48m_clk", 0, 481 clk = clk_register_gate(NULL, "usbh_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
486 PERIP1_CLK_ENB, USBH_CLK_ENB, 0, &_lock); 482 USBH_CLK_ENB, 0, &_lock);
487 clk_register_clkdev(clk, "usbh_clk", NULL); 483 clk_register_clkdev(clk, "usbh_clk", NULL);
488 484
489 clk = clk_register_fixed_factor(NULL, "usbh.0_clk", "usbh_clk", 0, 1, 485 clk = clk_register_fixed_factor(NULL, "usbh.0_clk", "usbh_clk", 0, 1,
@@ -494,8 +490,8 @@ void __init spear3xx_clk_init(void)
494 1); 490 1);
495 clk_register_clkdev(clk, "usbh.1_clk", NULL); 491 clk_register_clkdev(clk, "usbh.1_clk", NULL);
496 492
497 clk = clk_register_gate(NULL, "usbd_clk", "pll3_48m_clk", 0, 493 clk = clk_register_gate(NULL, "usbd_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
498 PERIP1_CLK_ENB, USBD_CLK_ENB, 0, &_lock); 494 USBD_CLK_ENB, 0, &_lock);
499 clk_register_clkdev(clk, NULL, "designware_udc"); 495 clk_register_clkdev(clk, NULL, "designware_udc");
500 496
501 /* clock derived from ahb clk */ 497 /* clock derived from ahb clk */
@@ -579,29 +575,25 @@ void __init spear3xx_clk_init(void)
579 RAS_CLK_ENB, RAS_PLL2_CLK_ENB, 0, &_lock); 575 RAS_CLK_ENB, RAS_PLL2_CLK_ENB, 0, &_lock);
580 clk_register_clkdev(clk, "ras_pll2_clk", NULL); 576 clk_register_clkdev(clk, "ras_pll2_clk", NULL);
581 577
582 clk = clk_register_gate(NULL, "ras_pll3_48m_clk", "pll3_48m_clk", 0, 578 clk = clk_register_gate(NULL, "ras_pll3_clk", "pll3_clk", 0,
583 RAS_CLK_ENB, RAS_48M_CLK_ENB, 0, &_lock); 579 RAS_CLK_ENB, RAS_48M_CLK_ENB, 0, &_lock);
584 clk_register_clkdev(clk, "ras_pll3_48m_clk", NULL); 580 clk_register_clkdev(clk, "ras_pll3_clk", NULL);
585 581
586 clk = clk_register_gate(NULL, "ras_gen0_synth_gate_clk", 582 clk = clk_register_gate(NULL, "ras_syn0_gclk", "gen0_syn_gclk", 0,
587 "gen0_synth_gate_clk", 0, RAS_CLK_ENB, 583 RAS_CLK_ENB, RAS_SYNT0_CLK_ENB, 0, &_lock);
588 RAS_SYNT0_CLK_ENB, 0, &_lock); 584 clk_register_clkdev(clk, "ras_syn0_gclk", NULL);
589 clk_register_clkdev(clk, "ras_gen0_synth_gate_clk", NULL); 585
590 586 clk = clk_register_gate(NULL, "ras_syn1_gclk", "gen1_syn_gclk", 0,
591 clk = clk_register_gate(NULL, "ras_gen1_synth_gate_clk", 587 RAS_CLK_ENB, RAS_SYNT1_CLK_ENB, 0, &_lock);
592 "gen1_synth_gate_clk", 0, RAS_CLK_ENB, 588 clk_register_clkdev(clk, "ras_syn1_gclk", NULL);
593 RAS_SYNT1_CLK_ENB, 0, &_lock); 589
594 clk_register_clkdev(clk, "ras_gen1_synth_gate_clk", NULL); 590 clk = clk_register_gate(NULL, "ras_syn2_gclk", "gen2_syn_gclk", 0,
595 591 RAS_CLK_ENB, RAS_SYNT2_CLK_ENB, 0, &_lock);
596 clk = clk_register_gate(NULL, "ras_gen2_synth_gate_clk", 592 clk_register_clkdev(clk, "ras_syn2_gclk", NULL);
597 "gen2_synth_gate_clk", 0, RAS_CLK_ENB, 593
598 RAS_SYNT2_CLK_ENB, 0, &_lock); 594 clk = clk_register_gate(NULL, "ras_syn3_gclk", "gen3_syn_gclk", 0,
599 clk_register_clkdev(clk, "ras_gen2_synth_gate_clk", NULL); 595 RAS_CLK_ENB, RAS_SYNT3_CLK_ENB, 0, &_lock);
600 596 clk_register_clkdev(clk, "ras_syn3_gclk", NULL);
601 clk = clk_register_gate(NULL, "ras_gen3_synth_gate_clk",
602 "gen3_synth_gate_clk", 0, RAS_CLK_ENB,
603 RAS_SYNT3_CLK_ENB, 0, &_lock);
604 clk_register_clkdev(clk, "ras_gen3_synth_gate_clk", NULL);
605 597
606 if (of_machine_is_compatible("st,spear300")) 598 if (of_machine_is_compatible("st,spear300"))
607 spear300_clk_init(); 599 spear300_clk_init();
diff --git a/drivers/clk/spear/spear6xx_clock.c b/drivers/clk/spear/spear6xx_clock.c
index 61026ae564a..a98d0866f54 100644
--- a/drivers/clk/spear/spear6xx_clock.c
+++ b/drivers/clk/spear/spear6xx_clock.c
@@ -97,13 +97,12 @@ static struct aux_rate_tbl aux_rtbl[] = {
97 {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ 97 {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */
98}; 98};
99 99
100static const char *clcd_parents[] = { "pll3_48m_clk", "clcd_synth_gate_clk", }; 100static const char *clcd_parents[] = { "pll3_clk", "clcd_syn_gclk", };
101static const char *firda_parents[] = { "pll3_48m_clk", "firda_synth_gate_clk", 101static const char *firda_parents[] = { "pll3_clk", "firda_syn_gclk", };
102}; 102static const char *uart_parents[] = { "pll3_clk", "uart_syn_gclk", };
103static const char *uart_parents[] = { "pll3_48m_clk", "uart_synth_gate_clk", }; 103static const char *gpt0_1_parents[] = { "pll3_clk", "gpt0_1_syn_clk", };
104static const char *gpt0_1_parents[] = { "pll3_48m_clk", "gpt0_1_synth_clk", }; 104static const char *gpt2_parents[] = { "pll3_clk", "gpt2_syn_clk", };
105static const char *gpt2_parents[] = { "pll3_48m_clk", "gpt2_synth_clk", }; 105static const char *gpt3_parents[] = { "pll3_clk", "gpt3_syn_clk", };
106static const char *gpt3_parents[] = { "pll3_48m_clk", "gpt3_synth_clk", };
107static const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none", 106static const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none",
108 "pll2_clk", }; 107 "pll2_clk", };
109 108
@@ -136,9 +135,9 @@ void __init spear6xx_clk_init(void)
136 clk_register_clkdev(clk, NULL, "rtc-spear"); 135 clk_register_clkdev(clk, NULL, "rtc-spear");
137 136
138 /* clock derived from 30 MHz osc clk */ 137 /* clock derived from 30 MHz osc clk */
139 clk = clk_register_fixed_rate(NULL, "pll3_48m_clk", "osc_24m_clk", 0, 138 clk = clk_register_fixed_rate(NULL, "pll3_clk", "osc_24m_clk", 0,
140 48000000); 139 48000000);
141 clk_register_clkdev(clk, "pll3_48m_clk", NULL); 140 clk_register_clkdev(clk, "pll3_clk", NULL);
142 141
143 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "osc_30m_clk", 142 clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "osc_30m_clk",
144 0, PLL1_CTR, PLL1_FRQ, pll_rtbl, ARRAY_SIZE(pll_rtbl), 143 0, PLL1_CTR, PLL1_FRQ, pll_rtbl, ARRAY_SIZE(pll_rtbl),
@@ -146,9 +145,9 @@ void __init spear6xx_clk_init(void)
146 clk_register_clkdev(clk, "vco1_clk", NULL); 145 clk_register_clkdev(clk, "vco1_clk", NULL);
147 clk_register_clkdev(clk1, "pll1_clk", NULL); 146 clk_register_clkdev(clk1, "pll1_clk", NULL);
148 147
149 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, 148 clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "osc_30m_clk",
150 "osc_30m_clk", 0, PLL2_CTR, PLL2_FRQ, pll_rtbl, 149 0, PLL2_CTR, PLL2_FRQ, pll_rtbl, ARRAY_SIZE(pll_rtbl),
151 ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL); 150 &_lock, &clk1, NULL);
152 clk_register_clkdev(clk, "vco2_clk", NULL); 151 clk_register_clkdev(clk, "vco2_clk", NULL);
153 clk_register_clkdev(clk1, "pll2_clk", NULL); 152 clk_register_clkdev(clk1, "pll2_clk", NULL);
154 153
@@ -165,111 +164,111 @@ void __init spear6xx_clk_init(void)
165 HCLK_RATIO_MASK, 0, &_lock); 164 HCLK_RATIO_MASK, 0, &_lock);
166 clk_register_clkdev(clk, "ahb_clk", NULL); 165 clk_register_clkdev(clk, "ahb_clk", NULL);
167 166
168 clk = clk_register_aux("uart_synth_clk", "uart_synth_gate_clk", 167 clk = clk_register_aux("uart_syn_clk", "uart_syn_gclk", "pll1_clk", 0,
169 "pll1_clk", 0, UART_CLK_SYNT, NULL, aux_rtbl, 168 UART_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
170 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 169 &_lock, &clk1);
171 clk_register_clkdev(clk, "uart_synth_clk", NULL); 170 clk_register_clkdev(clk, "uart_syn_clk", NULL);
172 clk_register_clkdev(clk1, "uart_synth_gate_clk", NULL); 171 clk_register_clkdev(clk1, "uart_syn_gclk", NULL);
173 172
174 clk = clk_register_mux(NULL, "uart_mux_clk", uart_parents, 173 clk = clk_register_mux(NULL, "uart_mclk", uart_parents,
175 ARRAY_SIZE(uart_parents), 0, PERIP_CLK_CFG, 174 ARRAY_SIZE(uart_parents), 0, PERIP_CLK_CFG,
176 UART_CLK_SHIFT, UART_CLK_MASK, 0, &_lock); 175 UART_CLK_SHIFT, UART_CLK_MASK, 0, &_lock);
177 clk_register_clkdev(clk, "uart_mux_clk", NULL); 176 clk_register_clkdev(clk, "uart_mclk", NULL);
178 177
179 clk = clk_register_gate(NULL, "uart0", "uart_mux_clk", 0, 178 clk = clk_register_gate(NULL, "uart0", "uart_mclk", 0, PERIP1_CLK_ENB,
180 PERIP1_CLK_ENB, UART0_CLK_ENB, 0, &_lock); 179 UART0_CLK_ENB, 0, &_lock);
181 clk_register_clkdev(clk, NULL, "d0000000.serial"); 180 clk_register_clkdev(clk, NULL, "d0000000.serial");
182 181
183 clk = clk_register_gate(NULL, "uart1", "uart_mux_clk", 0, 182 clk = clk_register_gate(NULL, "uart1", "uart_mclk", 0, PERIP1_CLK_ENB,
184 PERIP1_CLK_ENB, UART1_CLK_ENB, 0, &_lock); 183 UART1_CLK_ENB, 0, &_lock);
185 clk_register_clkdev(clk, NULL, "d0080000.serial"); 184 clk_register_clkdev(clk, NULL, "d0080000.serial");
186 185
187 clk = clk_register_aux("firda_synth_clk", "firda_synth_gate_clk", 186 clk = clk_register_aux("firda_syn_clk", "firda_syn_gclk", "pll1_clk",
188 "pll1_clk", 0, FIRDA_CLK_SYNT, NULL, aux_rtbl, 187 0, FIRDA_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
189 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 188 &_lock, &clk1);
190 clk_register_clkdev(clk, "firda_synth_clk", NULL); 189 clk_register_clkdev(clk, "firda_syn_clk", NULL);
191 clk_register_clkdev(clk1, "firda_synth_gate_clk", NULL); 190 clk_register_clkdev(clk1, "firda_syn_gclk", NULL);
192 191
193 clk = clk_register_mux(NULL, "firda_mux_clk", firda_parents, 192 clk = clk_register_mux(NULL, "firda_mclk", firda_parents,
194 ARRAY_SIZE(firda_parents), 0, PERIP_CLK_CFG, 193 ARRAY_SIZE(firda_parents), 0, PERIP_CLK_CFG,
195 FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0, &_lock); 194 FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0, &_lock);
196 clk_register_clkdev(clk, "firda_mux_clk", NULL); 195 clk_register_clkdev(clk, "firda_mclk", NULL);
197 196
198 clk = clk_register_gate(NULL, "firda_clk", "firda_mux_clk", 0, 197 clk = clk_register_gate(NULL, "firda_clk", "firda_mclk", 0,
199 PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0, &_lock); 198 PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0, &_lock);
200 clk_register_clkdev(clk, NULL, "firda"); 199 clk_register_clkdev(clk, NULL, "firda");
201 200
202 clk = clk_register_aux("clcd_synth_clk", "clcd_synth_gate_clk", 201 clk = clk_register_aux("clcd_syn_clk", "clcd_syn_gclk", "pll1_clk",
203 "pll1_clk", 0, CLCD_CLK_SYNT, NULL, aux_rtbl, 202 0, CLCD_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
204 ARRAY_SIZE(aux_rtbl), &_lock, &clk1); 203 &_lock, &clk1);
205 clk_register_clkdev(clk, "clcd_synth_clk", NULL); 204 clk_register_clkdev(clk, "clcd_syn_clk", NULL);
206 clk_register_clkdev(clk1, "clcd_synth_gate_clk", NULL); 205 clk_register_clkdev(clk1, "clcd_syn_gclk", NULL);
207 206
208 clk = clk_register_mux(NULL, "clcd_mux_clk", clcd_parents, 207 clk = clk_register_mux(NULL, "clcd_mclk", clcd_parents,
209 ARRAY_SIZE(clcd_parents), 0, PERIP_CLK_CFG, 208 ARRAY_SIZE(clcd_parents), 0, PERIP_CLK_CFG,
210 CLCD_CLK_SHIFT, CLCD_CLK_MASK, 0, &_lock); 209 CLCD_CLK_SHIFT, CLCD_CLK_MASK, 0, &_lock);
211 clk_register_clkdev(clk, "clcd_mux_clk", NULL); 210 clk_register_clkdev(clk, "clcd_mclk", NULL);
212 211
213 clk = clk_register_gate(NULL, "clcd_clk", "clcd_mux_clk", 0, 212 clk = clk_register_gate(NULL, "clcd_clk", "clcd_mclk", 0,
214 PERIP1_CLK_ENB, CLCD_CLK_ENB, 0, &_lock); 213 PERIP1_CLK_ENB, CLCD_CLK_ENB, 0, &_lock);
215 clk_register_clkdev(clk, NULL, "clcd"); 214 clk_register_clkdev(clk, NULL, "clcd");
216 215
217 /* gpt clocks */ 216 /* gpt clocks */
218 clk = clk_register_gpt("gpt0_1_synth_clk", "pll1_clk", 0, PRSC0_CLK_CFG, 217 clk = clk_register_gpt("gpt0_1_syn_clk", "pll1_clk", 0, PRSC0_CLK_CFG,
219 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 218 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
220 clk_register_clkdev(clk, "gpt0_1_synth_clk", NULL); 219 clk_register_clkdev(clk, "gpt0_1_syn_clk", NULL);
221 220
222 clk = clk_register_mux(NULL, "gpt0_mux_clk", gpt0_1_parents, 221 clk = clk_register_mux(NULL, "gpt0_mclk", gpt0_1_parents,
223 ARRAY_SIZE(gpt0_1_parents), 0, PERIP_CLK_CFG, 222 ARRAY_SIZE(gpt0_1_parents), 0, PERIP_CLK_CFG,
224 GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 223 GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
225 clk_register_clkdev(clk, NULL, "gpt0"); 224 clk_register_clkdev(clk, NULL, "gpt0");
226 225
227 clk = clk_register_mux(NULL, "gpt1_mux_clk", gpt0_1_parents, 226 clk = clk_register_mux(NULL, "gpt1_mclk", gpt0_1_parents,
228 ARRAY_SIZE(gpt0_1_parents), 0, PERIP_CLK_CFG, 227 ARRAY_SIZE(gpt0_1_parents), 0, PERIP_CLK_CFG,
229 GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 228 GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
230 clk_register_clkdev(clk, "gpt1_mux_clk", NULL); 229 clk_register_clkdev(clk, "gpt1_mclk", NULL);
231 230
232 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mux_clk", 0, 231 clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
233 PERIP1_CLK_ENB, GPT1_CLK_ENB, 0, &_lock); 232 PERIP1_CLK_ENB, GPT1_CLK_ENB, 0, &_lock);
234 clk_register_clkdev(clk, NULL, "gpt1"); 233 clk_register_clkdev(clk, NULL, "gpt1");
235 234
236 clk = clk_register_gpt("gpt2_synth_clk", "pll1_clk", 0, PRSC1_CLK_CFG, 235 clk = clk_register_gpt("gpt2_syn_clk", "pll1_clk", 0, PRSC1_CLK_CFG,
237 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 236 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
238 clk_register_clkdev(clk, "gpt2_synth_clk", NULL); 237 clk_register_clkdev(clk, "gpt2_syn_clk", NULL);
239 238
240 clk = clk_register_mux(NULL, "gpt2_mux_clk", gpt2_parents, 239 clk = clk_register_mux(NULL, "gpt2_mclk", gpt2_parents,
241 ARRAY_SIZE(gpt2_parents), 0, PERIP_CLK_CFG, 240 ARRAY_SIZE(gpt2_parents), 0, PERIP_CLK_CFG,
242 GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 241 GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
243 clk_register_clkdev(clk, "gpt2_mux_clk", NULL); 242 clk_register_clkdev(clk, "gpt2_mclk", NULL);
244 243
245 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mux_clk", 0, 244 clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
246 PERIP1_CLK_ENB, GPT2_CLK_ENB, 0, &_lock); 245 PERIP1_CLK_ENB, GPT2_CLK_ENB, 0, &_lock);
247 clk_register_clkdev(clk, NULL, "gpt2"); 246 clk_register_clkdev(clk, NULL, "gpt2");
248 247
249 clk = clk_register_gpt("gpt3_synth_clk", "pll1_clk", 0, PRSC2_CLK_CFG, 248 clk = clk_register_gpt("gpt3_syn_clk", "pll1_clk", 0, PRSC2_CLK_CFG,
250 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock); 249 gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
251 clk_register_clkdev(clk, "gpt3_synth_clk", NULL); 250 clk_register_clkdev(clk, "gpt3_syn_clk", NULL);
252 251
253 clk = clk_register_mux(NULL, "gpt3_mux_clk", gpt3_parents, 252 clk = clk_register_mux(NULL, "gpt3_mclk", gpt3_parents,
254 ARRAY_SIZE(gpt3_parents), 0, PERIP_CLK_CFG, 253 ARRAY_SIZE(gpt3_parents), 0, PERIP_CLK_CFG,
255 GPT3_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock); 254 GPT3_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
256 clk_register_clkdev(clk, "gpt3_mux_clk", NULL); 255 clk_register_clkdev(clk, "gpt3_mclk", NULL);
257 256
258 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mux_clk", 0, 257 clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mclk", 0,
259 PERIP1_CLK_ENB, GPT3_CLK_ENB, 0, &_lock); 258 PERIP1_CLK_ENB, GPT3_CLK_ENB, 0, &_lock);
260 clk_register_clkdev(clk, NULL, "gpt3"); 259 clk_register_clkdev(clk, NULL, "gpt3");
261 260
262 /* clock derived from pll3 clk */ 261 /* clock derived from pll3 clk */
263 clk = clk_register_gate(NULL, "usbh0_clk", "pll3_48m_clk", 0, 262 clk = clk_register_gate(NULL, "usbh0_clk", "pll3_clk", 0,
264 PERIP1_CLK_ENB, USBH0_CLK_ENB, 0, &_lock); 263 PERIP1_CLK_ENB, USBH0_CLK_ENB, 0, &_lock);
265 clk_register_clkdev(clk, NULL, "usbh.0_clk"); 264 clk_register_clkdev(clk, NULL, "usbh.0_clk");
266 265
267 clk = clk_register_gate(NULL, "usbh1_clk", "pll3_48m_clk", 0, 266 clk = clk_register_gate(NULL, "usbh1_clk", "pll3_clk", 0,
268 PERIP1_CLK_ENB, USBH1_CLK_ENB, 0, &_lock); 267 PERIP1_CLK_ENB, USBH1_CLK_ENB, 0, &_lock);
269 clk_register_clkdev(clk, NULL, "usbh.1_clk"); 268 clk_register_clkdev(clk, NULL, "usbh.1_clk");
270 269
271 clk = clk_register_gate(NULL, "usbd_clk", "pll3_48m_clk", 0, 270 clk = clk_register_gate(NULL, "usbd_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
272 PERIP1_CLK_ENB, USBD_CLK_ENB, 0, &_lock); 271 USBD_CLK_ENB, 0, &_lock);
273 clk_register_clkdev(clk, NULL, "designware_udc"); 272 clk_register_clkdev(clk, NULL, "designware_udc");
274 273
275 /* clock derived from ahb clk */ 274 /* clock derived from ahb clk */
@@ -278,9 +277,8 @@ void __init spear6xx_clk_init(void)
278 clk_register_clkdev(clk, "ahbmult2_clk", NULL); 277 clk_register_clkdev(clk, "ahbmult2_clk", NULL);
279 278
280 clk = clk_register_mux(NULL, "ddr_clk", ddr_parents, 279 clk = clk_register_mux(NULL, "ddr_clk", ddr_parents,
281 ARRAY_SIZE(ddr_parents), 280 ARRAY_SIZE(ddr_parents), 0, PLL_CLK_CFG, MCTR_CLK_SHIFT,
282 0, PLL_CLK_CFG, MCTR_CLK_SHIFT, MCTR_CLK_MASK, 0, 281 MCTR_CLK_MASK, 0, &_lock);
283 &_lock);
284 clk_register_clkdev(clk, "ddr_clk", NULL); 282 clk_register_clkdev(clk, "ddr_clk", NULL);
285 283
286 clk = clk_register_divider(NULL, "apb_clk", "ahb_clk", 284 clk = clk_register_divider(NULL, "apb_clk", "ahb_clk",
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index c4067d0141f..542f0c04b69 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -136,7 +136,7 @@ config GPIO_MPC8XXX
136 136
137config GPIO_MSM_V1 137config GPIO_MSM_V1
138 tristate "Qualcomm MSM GPIO v1" 138 tristate "Qualcomm MSM GPIO v1"
139 depends on GPIOLIB && ARCH_MSM 139 depends on GPIOLIB && ARCH_MSM && (ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50)
140 help 140 help
141 Say yes here to support the GPIO interface on ARM v6 based 141 Say yes here to support the GPIO interface on ARM v6 based
142 Qualcomm MSM chips. Most of the pins on the MSM can be 142 Qualcomm MSM chips. Most of the pins on the MSM can be
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index 9e9947cb86a..1077754f828 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -98,6 +98,7 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio,
98 98
99 return 0; 99 return 0;
100} 100}
101EXPORT_SYMBOL(devm_gpio_request_one);
101 102
102/** 103/**
103 * devm_gpio_free - free an interrupt 104 * devm_gpio_free - free an interrupt
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index c337143b18f..c89c4c1e668 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -398,10 +398,12 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev)
398 writel(~0, port->base + GPIO_ISR); 398 writel(~0, port->base + GPIO_ISR);
399 399
400 if (mxc_gpio_hwtype == IMX21_GPIO) { 400 if (mxc_gpio_hwtype == IMX21_GPIO) {
401 /* setup one handler for all GPIO interrupts */ 401 /*
402 if (pdev->id == 0) 402 * Setup one handler for all GPIO interrupts. Actually setting
403 irq_set_chained_handler(port->irq, 403 * the handler is needed only once, but doing it for every port
404 mx2_gpio_irq_handler); 404 * is more robust and easier.
405 */
406 irq_set_chained_handler(port->irq, mx2_gpio_irq_handler);
405 } else { 407 } else {
406 /* setup one handler for each entry */ 408 /* setup one handler for each entry */
407 irq_set_chained_handler(port->irq, mx3_gpio_irq_handler); 409 irq_set_chained_handler(port->irq, mx3_gpio_irq_handler);
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c4ed1722734..4fbc208c32c 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -174,12 +174,22 @@ static inline void _gpio_dbck_enable(struct gpio_bank *bank)
174 if (bank->dbck_enable_mask && !bank->dbck_enabled) { 174 if (bank->dbck_enable_mask && !bank->dbck_enabled) {
175 clk_enable(bank->dbck); 175 clk_enable(bank->dbck);
176 bank->dbck_enabled = true; 176 bank->dbck_enabled = true;
177
178 __raw_writel(bank->dbck_enable_mask,
179 bank->base + bank->regs->debounce_en);
177 } 180 }
178} 181}
179 182
180static inline void _gpio_dbck_disable(struct gpio_bank *bank) 183static inline void _gpio_dbck_disable(struct gpio_bank *bank)
181{ 184{
182 if (bank->dbck_enable_mask && bank->dbck_enabled) { 185 if (bank->dbck_enable_mask && bank->dbck_enabled) {
186 /*
187 * Disable debounce before cutting it's clock. If debounce is
188 * enabled but the clock is not, GPIO module seems to be unable
189 * to detect events and generate interrupts at least on OMAP3.
190 */
191 __raw_writel(0, bank->base + bank->regs->debounce_en);
192
183 clk_disable(bank->dbck); 193 clk_disable(bank->dbck);
184 bank->dbck_enabled = false; 194 bank->dbck_enabled = false;
185 } 195 }
@@ -1081,7 +1091,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
1081 bank->is_mpuio = pdata->is_mpuio; 1091 bank->is_mpuio = pdata->is_mpuio;
1082 bank->non_wakeup_gpios = pdata->non_wakeup_gpios; 1092 bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
1083 bank->loses_context = pdata->loses_context; 1093 bank->loses_context = pdata->loses_context;
1084 bank->get_context_loss_count = pdata->get_context_loss_count;
1085 bank->regs = pdata->regs; 1094 bank->regs = pdata->regs;
1086#ifdef CONFIG_OF_GPIO 1095#ifdef CONFIG_OF_GPIO
1087 bank->chip.of_node = of_node_get(node); 1096 bank->chip.of_node = of_node_get(node);
@@ -1135,6 +1144,9 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
1135 omap_gpio_chip_init(bank); 1144 omap_gpio_chip_init(bank);
1136 omap_gpio_show_rev(bank); 1145 omap_gpio_show_rev(bank);
1137 1146
1147 if (bank->loses_context)
1148 bank->get_context_loss_count = pdata->get_context_loss_count;
1149
1138 pm_runtime_put(bank->dev); 1150 pm_runtime_put(bank->dev);
1139 1151
1140 list_add_tail(&bank->node, &omap_gpio_list); 1152 list_add_tail(&bank->node, &omap_gpio_list);
diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c
index 38416be8ba1..6064fb376e1 100644
--- a/drivers/gpio/gpio-sta2x11.c
+++ b/drivers/gpio/gpio-sta2x11.c
@@ -383,8 +383,9 @@ static int __devinit gsta_probe(struct platform_device *dev)
383 } 383 }
384 spin_lock_init(&chip->lock); 384 spin_lock_init(&chip->lock);
385 gsta_gpio_setup(chip); 385 gsta_gpio_setup(chip);
386 for (i = 0; i < GSTA_NR_GPIO; i++) 386 if (gpio_pdata)
387 gsta_set_config(chip, i, gpio_pdata->pinconfig[i]); 387 for (i = 0; i < GSTA_NR_GPIO; i++)
388 gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
388 389
389 /* 384 was used in previous code: be compatible for other drivers */ 390 /* 384 was used in previous code: be compatible for other drivers */
390 err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE); 391 err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);
diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
index c1ad2884f2e..11f29c82253 100644
--- a/drivers/gpio/gpio-tps65910.c
+++ b/drivers/gpio/gpio-tps65910.c
@@ -149,6 +149,9 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
149 tps65910_gpio->gpio_chip.set = tps65910_gpio_set; 149 tps65910_gpio->gpio_chip.set = tps65910_gpio_set;
150 tps65910_gpio->gpio_chip.get = tps65910_gpio_get; 150 tps65910_gpio->gpio_chip.get = tps65910_gpio_get;
151 tps65910_gpio->gpio_chip.dev = &pdev->dev; 151 tps65910_gpio->gpio_chip.dev = &pdev->dev;
152#ifdef CONFIG_OF_GPIO
153 tps65910_gpio->gpio_chip.of_node = tps65910->dev->of_node;
154#endif
152 if (pdata && pdata->gpio_base) 155 if (pdata && pdata->gpio_base)
153 tps65910_gpio->gpio_chip.base = pdata->gpio_base; 156 tps65910_gpio->gpio_chip.base = pdata->gpio_base;
154 else 157 else
diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c
index 92ea5350dfe..aa61ad2fcaa 100644
--- a/drivers/gpio/gpio-wm8994.c
+++ b/drivers/gpio/gpio-wm8994.c
@@ -89,8 +89,11 @@ static int wm8994_gpio_direction_out(struct gpio_chip *chip,
89 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip); 89 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
90 struct wm8994 *wm8994 = wm8994_gpio->wm8994; 90 struct wm8994 *wm8994 = wm8994_gpio->wm8994;
91 91
92 if (value)
93 value = WM8994_GPN_LVL;
94
92 return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, 95 return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset,
93 WM8994_GPN_DIR, 0); 96 WM8994_GPN_DIR | WM8994_GPN_LVL, value);
94} 97}
95 98
96static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 99static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c
index 9764045428c..b7e7b49d8f6 100644
--- a/drivers/gpu/drm/gma500/cdv_device.c
+++ b/drivers/gpu/drm/gma500/cdv_device.c
@@ -78,21 +78,6 @@ static int cdv_backlight_combination_mode(struct drm_device *dev)
78 return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE; 78 return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE;
79} 79}
80 80
81static int cdv_get_brightness(struct backlight_device *bd)
82{
83 struct drm_device *dev = bl_get_data(bd);
84 u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
85
86 if (cdv_backlight_combination_mode(dev)) {
87 u8 lbpc;
88
89 val &= ~1;
90 pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
91 val *= lbpc;
92 }
93 return val;
94}
95
96static u32 cdv_get_max_backlight(struct drm_device *dev) 81static u32 cdv_get_max_backlight(struct drm_device *dev)
97{ 82{
98 u32 max = REG_READ(BLC_PWM_CTL); 83 u32 max = REG_READ(BLC_PWM_CTL);
@@ -110,6 +95,22 @@ static u32 cdv_get_max_backlight(struct drm_device *dev)
110 return max; 95 return max;
111} 96}
112 97
98static int cdv_get_brightness(struct backlight_device *bd)
99{
100 struct drm_device *dev = bl_get_data(bd);
101 u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
102
103 if (cdv_backlight_combination_mode(dev)) {
104 u8 lbpc;
105
106 val &= ~1;
107 pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
108 val *= lbpc;
109 }
110 return (val * 100)/cdv_get_max_backlight(dev);
111
112}
113
113static int cdv_set_brightness(struct backlight_device *bd) 114static int cdv_set_brightness(struct backlight_device *bd)
114{ 115{
115 struct drm_device *dev = bl_get_data(bd); 116 struct drm_device *dev = bl_get_data(bd);
@@ -120,6 +121,9 @@ static int cdv_set_brightness(struct backlight_device *bd)
120 if (level < 1) 121 if (level < 1)
121 level = 1; 122 level = 1;
122 123
124 level *= cdv_get_max_backlight(dev);
125 level /= 100;
126
123 if (cdv_backlight_combination_mode(dev)) { 127 if (cdv_backlight_combination_mode(dev)) {
124 u32 max = cdv_get_max_backlight(dev); 128 u32 max = cdv_get_max_backlight(dev);
125 u8 lbpc; 129 u8 lbpc;
@@ -157,7 +161,6 @@ static int cdv_backlight_init(struct drm_device *dev)
157 161
158 cdv_backlight_device->props.brightness = 162 cdv_backlight_device->props.brightness =
159 cdv_get_brightness(cdv_backlight_device); 163 cdv_get_brightness(cdv_backlight_device);
160 cdv_backlight_device->props.max_brightness = cdv_get_max_backlight(dev);
161 backlight_update_status(cdv_backlight_device); 164 backlight_update_status(cdv_backlight_device);
162 dev_priv->backlight_device = cdv_backlight_device; 165 dev_priv->backlight_device = cdv_backlight_device;
163 return 0; 166 return 0;
diff --git a/drivers/gpu/drm/gma500/opregion.c b/drivers/gpu/drm/gma500/opregion.c
index 4f186eca3a3..c430bd42468 100644
--- a/drivers/gpu/drm/gma500/opregion.c
+++ b/drivers/gpu/drm/gma500/opregion.c
@@ -144,6 +144,8 @@ struct opregion_asle {
144 144
145#define ASLE_CBLV_VALID (1<<31) 145#define ASLE_CBLV_VALID (1<<31)
146 146
147static struct psb_intel_opregion *system_opregion;
148
147static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) 149static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
148{ 150{
149 struct drm_psb_private *dev_priv = dev->dev_private; 151 struct drm_psb_private *dev_priv = dev->dev_private;
@@ -205,7 +207,7 @@ void psb_intel_opregion_enable_asle(struct drm_device *dev)
205 struct drm_psb_private *dev_priv = dev->dev_private; 207 struct drm_psb_private *dev_priv = dev->dev_private;
206 struct opregion_asle *asle = dev_priv->opregion.asle; 208 struct opregion_asle *asle = dev_priv->opregion.asle;
207 209
208 if (asle) { 210 if (asle && system_opregion ) {
209 /* Don't do this on Medfield or other non PC like devices, they 211 /* Don't do this on Medfield or other non PC like devices, they
210 use the bit for something different altogether */ 212 use the bit for something different altogether */
211 psb_enable_pipestat(dev_priv, 0, PIPE_LEGACY_BLC_EVENT_ENABLE); 213 psb_enable_pipestat(dev_priv, 0, PIPE_LEGACY_BLC_EVENT_ENABLE);
@@ -221,7 +223,6 @@ void psb_intel_opregion_enable_asle(struct drm_device *dev)
221#define ACPI_EV_LID (1<<1) 223#define ACPI_EV_LID (1<<1)
222#define ACPI_EV_DOCK (1<<2) 224#define ACPI_EV_DOCK (1<<2)
223 225
224static struct psb_intel_opregion *system_opregion;
225 226
226static int psb_intel_opregion_video_event(struct notifier_block *nb, 227static int psb_intel_opregion_video_event(struct notifier_block *nb,
227 unsigned long val, void *data) 228 unsigned long val, void *data)
@@ -266,9 +267,6 @@ void psb_intel_opregion_init(struct drm_device *dev)
266 system_opregion = opregion; 267 system_opregion = opregion;
267 register_acpi_notifier(&psb_intel_opregion_notifier); 268 register_acpi_notifier(&psb_intel_opregion_notifier);
268 } 269 }
269
270 if (opregion->asle)
271 psb_intel_opregion_enable_asle(dev);
272} 270}
273 271
274void psb_intel_opregion_fini(struct drm_device *dev) 272void psb_intel_opregion_fini(struct drm_device *dev)
diff --git a/drivers/gpu/drm/gma500/opregion.h b/drivers/gpu/drm/gma500/opregion.h
index 72dc6b92126..4a90f8b0e16 100644
--- a/drivers/gpu/drm/gma500/opregion.h
+++ b/drivers/gpu/drm/gma500/opregion.h
@@ -27,6 +27,7 @@ extern void psb_intel_opregion_asle_intr(struct drm_device *dev);
27extern void psb_intel_opregion_init(struct drm_device *dev); 27extern void psb_intel_opregion_init(struct drm_device *dev);
28extern void psb_intel_opregion_fini(struct drm_device *dev); 28extern void psb_intel_opregion_fini(struct drm_device *dev);
29extern int psb_intel_opregion_setup(struct drm_device *dev); 29extern int psb_intel_opregion_setup(struct drm_device *dev);
30extern void psb_intel_opregion_enable_asle(struct drm_device *dev);
30 31
31#else 32#else
32 33
@@ -46,4 +47,8 @@ extern inline int psb_intel_opregion_setup(struct drm_device *dev)
46{ 47{
47 return 0; 48 return 0;
48} 49}
50
51extern inline void psb_intel_opregion_enable_asle(struct drm_device *dev)
52{
53}
49#endif 54#endif
diff --git a/drivers/gpu/drm/gma500/psb_device.c b/drivers/gpu/drm/gma500/psb_device.c
index eff039bf92d..5971bc82b76 100644
--- a/drivers/gpu/drm/gma500/psb_device.c
+++ b/drivers/gpu/drm/gma500/psb_device.c
@@ -144,6 +144,10 @@ static int psb_backlight_init(struct drm_device *dev)
144 psb_backlight_device->props.max_brightness = 100; 144 psb_backlight_device->props.max_brightness = 100;
145 backlight_update_status(psb_backlight_device); 145 backlight_update_status(psb_backlight_device);
146 dev_priv->backlight_device = psb_backlight_device; 146 dev_priv->backlight_device = psb_backlight_device;
147
148 /* This must occur after the backlight is properly initialised */
149 psb_lid_timer_init(dev_priv);
150
147 return 0; 151 return 0;
148} 152}
149 153
@@ -354,13 +358,6 @@ static int psb_chip_setup(struct drm_device *dev)
354 return 0; 358 return 0;
355} 359}
356 360
357/* Not exactly an erratum more an irritation */
358static void psb_chip_errata(struct drm_device *dev)
359{
360 struct drm_psb_private *dev_priv = dev->dev_private;
361 psb_lid_timer_init(dev_priv);
362}
363
364static void psb_chip_teardown(struct drm_device *dev) 361static void psb_chip_teardown(struct drm_device *dev)
365{ 362{
366 struct drm_psb_private *dev_priv = dev->dev_private; 363 struct drm_psb_private *dev_priv = dev->dev_private;
@@ -379,7 +376,6 @@ const struct psb_ops psb_chip_ops = {
379 .sgx_offset = PSB_SGX_OFFSET, 376 .sgx_offset = PSB_SGX_OFFSET,
380 .chip_setup = psb_chip_setup, 377 .chip_setup = psb_chip_setup,
381 .chip_teardown = psb_chip_teardown, 378 .chip_teardown = psb_chip_teardown,
382 .errata = psb_chip_errata,
383 379
384 .crtc_helper = &psb_intel_helper_funcs, 380 .crtc_helper = &psb_intel_helper_funcs,
385 .crtc_funcs = &psb_intel_crtc_funcs, 381 .crtc_funcs = &psb_intel_crtc_funcs,
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index caba6e08693..a8858a907f4 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -374,6 +374,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
374 374
375 if (ret) 375 if (ret)
376 return ret; 376 return ret;
377 psb_intel_opregion_enable_asle(dev);
377#if 0 378#if 0
378 /*enable runtime pm at last*/ 379 /*enable runtime pm at last*/
379 pm_runtime_enable(&dev->pdev->dev); 380 pm_runtime_enable(&dev->pdev->dev);
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index bef04c19276..3fda8c87f02 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -386,6 +386,7 @@ config HID_MULTITOUCH
386 - Unitec Panels 386 - Unitec Panels
387 - XAT optical touch panels 387 - XAT optical touch panels
388 - Xiroku optical touch panels 388 - Xiroku optical touch panels
389 - Zytronic touch panels
389 390
390 If unsure, say N. 391 If unsure, say N.
391 392
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index fa10f847f7d..585344b6d33 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -517,6 +517,12 @@ static const struct hid_device_id apple_devices[] = {
517 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, 517 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
518 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS), 518 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
519 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, 519 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
520 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
521 .driver_data = APPLE_HAS_FN },
522 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
523 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
524 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
525 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
520 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), 526 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
521 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 527 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
522 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), 528 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 6ac0286b537..4c87276c8dd 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1503,6 +1503,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
1503 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1503 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1504 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1504 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1505 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 1505 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
1506 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
1507 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
1508 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
1506 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1509 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1507 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1510 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1508 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1511 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
@@ -1995,6 +1998,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1995 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 1998 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
1996 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 1999 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
1997 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 2000 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
2001 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) },
1998 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 2002 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
1999 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 2003 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
2000 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 2004 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
@@ -2089,6 +2093,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
2089 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 2093 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
2090 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 2094 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
2091 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 2095 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
2096 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
2097 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
2098 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
2092 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 2099 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
2093 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 2100 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
2094 { } 2101 { }
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d1cdd2d2840..32039235cfe 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -125,6 +125,9 @@
125#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c 125#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
126#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d 126#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
127#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e 127#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
128#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
129#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
130#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
128#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 131#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
129#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a 132#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
130#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b 133#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
@@ -518,6 +521,9 @@
518#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 521#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006
519#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007 522#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007
520 523
524#define USB_VENDOR_ID_MADCATZ 0x0738
525#define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540
526
521#define USB_VENDOR_ID_MCC 0x09db 527#define USB_VENDOR_ID_MCC 0x09db
522#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 528#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
523#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a 529#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a
@@ -653,6 +659,9 @@
653#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 659#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
654#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 660#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
655 661
662#define USB_VENDOR_ID_SENNHEISER 0x1395
663#define USB_DEVICE_ID_SENNHEISER_BTD500USB 0x002c
664
656#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f 665#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
657#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002 666#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
658 667
@@ -802,6 +811,9 @@
802#define USB_VENDOR_ID_ZYDACRON 0x13EC 811#define USB_VENDOR_ID_ZYDACRON 0x13EC
803#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006 812#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006
804 813
814#define USB_VENDOR_ID_ZYTRONIC 0x14c8
815#define USB_DEVICE_ID_ZYTRONIC_ZXY100 0x0005
816
805#define USB_VENDOR_ID_PRIMAX 0x0461 817#define USB_VENDOR_ID_PRIMAX 0x0461
806#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05 818#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05
807 819
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 132b0019365..5301006f6c1 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -301,6 +301,9 @@ static const struct hid_device_id hid_battery_quirks[] = {
301 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 301 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
302 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), 302 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
303 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, 303 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE },
304 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
305 USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
306 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE },
304 {} 307 {}
305}; 308};
306 309
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 6e3332a9997..76479246d4e 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1048,6 +1048,11 @@ static const struct hid_device_id mt_devices[] = {
1048 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, 1048 MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
1049 USB_DEVICE_ID_XIROKU_CSR2) }, 1049 USB_DEVICE_ID_XIROKU_CSR2) },
1050 1050
1051 /* Zytronic panels */
1052 { .driver_data = MT_CLS_SERIAL,
1053 MT_USB_DEVICE(USB_VENDOR_ID_ZYTRONIC,
1054 USB_DEVICE_ID_ZYTRONIC_ZXY100) },
1055
1051 /* Generic MT device */ 1056 /* Generic MT device */
1052 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, 1057 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) },
1053 { } 1058 { }
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 0597ee604f6..903eef3d3e1 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -76,6 +76,7 @@ static const struct hid_blacklist {
76 { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, 76 { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET },
77 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET }, 77 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET },
78 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET }, 78 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET },
79 { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET },
79 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 80 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
80 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET }, 81 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET },
81 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET }, 82 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET },
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index e7701d99f8e..f1de3979181 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -2341,7 +2341,7 @@ static void __devinit it87_init_device(struct platform_device *pdev)
2341 2341
2342 /* Start monitoring */ 2342 /* Start monitoring */
2343 it87_write_value(data, IT87_REG_CONFIG, 2343 it87_write_value(data, IT87_REG_CONFIG,
2344 (it87_read_value(data, IT87_REG_CONFIG) & 0x36) 2344 (it87_read_value(data, IT87_REG_CONFIG) & 0x3e)
2345 | (update_vbat ? 0x41 : 0x01)); 2345 | (update_vbat ? 0x41 : 0x01));
2346} 2346}
2347 2347
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
index 61c9cf15fa5..1201a15784c 100644
--- a/drivers/hwspinlock/hwspinlock_core.c
+++ b/drivers/hwspinlock/hwspinlock_core.c
@@ -345,7 +345,7 @@ int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
345 spin_lock_init(&hwlock->lock); 345 spin_lock_init(&hwlock->lock);
346 hwlock->bank = bank; 346 hwlock->bank = bank;
347 347
348 ret = hwspin_lock_register_single(hwlock, i); 348 ret = hwspin_lock_register_single(hwlock, base_id + i);
349 if (ret) 349 if (ret)
350 goto reg_failed; 350 goto reg_failed;
351 } 351 }
@@ -354,7 +354,7 @@ int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
354 354
355reg_failed: 355reg_failed:
356 while (--i >= 0) 356 while (--i >= 0)
357 hwspin_lock_unregister_single(i); 357 hwspin_lock_unregister_single(base_id + i);
358 return ret; 358 return ret;
359} 359}
360EXPORT_SYMBOL_GPL(hwspin_lock_register); 360EXPORT_SYMBOL_GPL(hwspin_lock_register);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 5c1bc995e56..f10221f4080 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -123,7 +123,7 @@ static void ipoib_ud_skb_put_frags(struct ipoib_dev_priv *priv,
123 123
124 skb_frag_size_set(frag, size); 124 skb_frag_size_set(frag, size);
125 skb->data_len += size; 125 skb->data_len += size;
126 skb->truesize += size; 126 skb->truesize += PAGE_SIZE;
127 } else 127 } else
128 skb_put(skb, length); 128 skb_put(skb, length);
129 129
@@ -156,14 +156,18 @@ static struct sk_buff *ipoib_alloc_rx_skb(struct net_device *dev, int id)
156 struct ipoib_dev_priv *priv = netdev_priv(dev); 156 struct ipoib_dev_priv *priv = netdev_priv(dev);
157 struct sk_buff *skb; 157 struct sk_buff *skb;
158 int buf_size; 158 int buf_size;
159 int tailroom;
159 u64 *mapping; 160 u64 *mapping;
160 161
161 if (ipoib_ud_need_sg(priv->max_ib_mtu)) 162 if (ipoib_ud_need_sg(priv->max_ib_mtu)) {
162 buf_size = IPOIB_UD_HEAD_SIZE; 163 buf_size = IPOIB_UD_HEAD_SIZE;
163 else 164 tailroom = 128; /* reserve some tailroom for IP/TCP headers */
165 } else {
164 buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu); 166 buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu);
167 tailroom = 0;
168 }
165 169
166 skb = dev_alloc_skb(buf_size + 4); 170 skb = dev_alloc_skb(buf_size + tailroom + 4);
167 if (unlikely(!skb)) 171 if (unlikely(!skb))
168 return NULL; 172 return NULL;
169 173
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index ee16fb67b7a..83811e45d63 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -142,6 +142,7 @@ static const struct xpad_device {
142 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX }, 142 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
143 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, 143 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
144 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX }, 144 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
145 { 0x0d2f, 0x0002, "Andamiro Pump It Up pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
145 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX }, 146 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
146 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX }, 147 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
147 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX }, 148 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
@@ -164,6 +165,7 @@ static const struct xpad_device {
164 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 165 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
165 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 166 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
166 { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 167 { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
168 { 0x1689, 0xfd00, "Razer Onza Tournament Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
167 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 169 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
168 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } 170 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
169}; 171};
@@ -238,12 +240,14 @@ static struct usb_device_id xpad_table [] = {
238 XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ 240 XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */
239 XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */ 241 XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
240 XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */ 242 XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */
243 { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */
241 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ 244 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */
242 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ 245 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
243 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ 246 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
244 XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ 247 XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */
245 XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ 248 XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */
246 XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ 249 XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */
250 XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */
247 { } 251 { }
248}; 252};
249 253
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 2cf681d98c0..d528c23e194 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -79,6 +79,10 @@
79#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252 79#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
80#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253 80#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
81#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254 81#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
82/* MacbookPro10,1 (unibody, June 2012) */
83#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
84#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
85#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
82 86
83#define BCM5974_DEVICE(prod) { \ 87#define BCM5974_DEVICE(prod) { \
84 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ 88 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -128,6 +132,10 @@ static const struct usb_device_id bcm5974_table[] = {
128 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI), 132 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
129 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO), 133 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
130 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS), 134 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
135 /* MacbookPro10,1 */
136 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
137 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
138 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
131 /* Terminating entry */ 139 /* Terminating entry */
132 {} 140 {}
133}; 141};
@@ -354,6 +362,18 @@ static const struct bcm5974_config bcm5974_config_table[] = {
354 { DIM_X, DIM_X / SN_COORD, -4620, 5140 }, 362 { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
355 { DIM_Y, DIM_Y / SN_COORD, -150, 6600 } 363 { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
356 }, 364 },
365 {
366 USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI,
367 USB_DEVICE_ID_APPLE_WELLSPRING7_ISO,
368 USB_DEVICE_ID_APPLE_WELLSPRING7_JIS,
369 HAS_INTEGRATED_BUTTON,
370 0x84, sizeof(struct bt_data),
371 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
372 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
373 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
374 { DIM_X, DIM_X / SN_COORD, -4750, 5280 },
375 { DIM_Y, DIM_Y / SN_COORD, -150, 6730 }
376 },
357 {} 377 {}
358}; 378};
359 379
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index d9be6eac99b..7f03d1bd916 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/io.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <mach/jornada720.h> 25#include <mach/jornada720.h>
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index a2e418cba0f..625626391f2 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -83,6 +83,8 @@ static struct iommu_ops amd_iommu_ops;
83static ATOMIC_NOTIFIER_HEAD(ppr_notifier); 83static ATOMIC_NOTIFIER_HEAD(ppr_notifier);
84int amd_iommu_max_glx_val = -1; 84int amd_iommu_max_glx_val = -1;
85 85
86static struct dma_map_ops amd_iommu_dma_ops;
87
86/* 88/*
87 * general struct to manage commands send to an IOMMU 89 * general struct to manage commands send to an IOMMU
88 */ 90 */
@@ -402,7 +404,7 @@ static void amd_iommu_stats_init(void)
402 return; 404 return;
403 405
404 de_fflush = debugfs_create_bool("fullflush", 0444, stats_dir, 406 de_fflush = debugfs_create_bool("fullflush", 0444, stats_dir,
405 (u32 *)&amd_iommu_unmap_flush); 407 &amd_iommu_unmap_flush);
406 408
407 amd_iommu_stats_add(&compl_wait); 409 amd_iommu_stats_add(&compl_wait);
408 amd_iommu_stats_add(&cnt_map_single); 410 amd_iommu_stats_add(&cnt_map_single);
@@ -2267,6 +2269,13 @@ static int device_change_notifier(struct notifier_block *nb,
2267 list_add_tail(&dma_domain->list, &iommu_pd_list); 2269 list_add_tail(&dma_domain->list, &iommu_pd_list);
2268 spin_unlock_irqrestore(&iommu_pd_list_lock, flags); 2270 spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
2269 2271
2272 dev_data = get_dev_data(dev);
2273
2274 if (!dev_data->passthrough)
2275 dev->archdata.dma_ops = &amd_iommu_dma_ops;
2276 else
2277 dev->archdata.dma_ops = &nommu_dma_ops;
2278
2270 break; 2279 break;
2271 case BUS_NOTIFY_DEL_DEVICE: 2280 case BUS_NOTIFY_DEL_DEVICE:
2272 2281
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 542024ba6db..a33612f3206 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -129,7 +129,7 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
129 to handle */ 129 to handle */
130LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings 130LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
131 we find in ACPI */ 131 we find in ACPI */
132bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ 132u32 amd_iommu_unmap_flush; /* if true, flush on every unmap */
133 133
134LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the 134LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
135 system */ 135 system */
@@ -1641,6 +1641,8 @@ static int __init amd_iommu_init(void)
1641 1641
1642 amd_iommu_init_api(); 1642 amd_iommu_init_api();
1643 1643
1644 x86_platform.iommu_shutdown = disable_iommus;
1645
1644 if (iommu_pass_through) 1646 if (iommu_pass_through)
1645 goto out; 1647 goto out;
1646 1648
@@ -1649,8 +1651,6 @@ static int __init amd_iommu_init(void)
1649 else 1651 else
1650 printk(KERN_INFO "AMD-Vi: Lazy IO/TLB flushing enabled\n"); 1652 printk(KERN_INFO "AMD-Vi: Lazy IO/TLB flushing enabled\n");
1651 1653
1652 x86_platform.iommu_shutdown = disable_iommus;
1653
1654out: 1654out:
1655 return ret; 1655 return ret;
1656 1656
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index 24355559a2a..c1b1d489817 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -652,7 +652,7 @@ extern unsigned long *amd_iommu_pd_alloc_bitmap;
652 * If true, the addresses will be flushed on unmap time, not when 652 * If true, the addresses will be flushed on unmap time, not when
653 * they are reused 653 * they are reused
654 */ 654 */
655extern bool amd_iommu_unmap_flush; 655extern u32 amd_iommu_unmap_flush;
656 656
657/* Smallest number of PASIDs supported by any IOMMU in the system */ 657/* Smallest number of PASIDs supported by any IOMMU in the system */
658extern u32 amd_iommu_max_pasids; 658extern u32 amd_iommu_max_pasids;
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index ecd679043d7..3f3d09d560e 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -550,13 +550,13 @@ static int alloc_pdir(struct smmu_as *as)
550 return 0; 550 return 0;
551 551
552 as->pte_count = devm_kzalloc(smmu->dev, 552 as->pte_count = devm_kzalloc(smmu->dev,
553 sizeof(as->pte_count[0]) * SMMU_PDIR_COUNT, GFP_KERNEL); 553 sizeof(as->pte_count[0]) * SMMU_PDIR_COUNT, GFP_ATOMIC);
554 if (!as->pte_count) { 554 if (!as->pte_count) {
555 dev_err(smmu->dev, 555 dev_err(smmu->dev,
556 "failed to allocate smmu_device PTE cunters\n"); 556 "failed to allocate smmu_device PTE cunters\n");
557 return -ENOMEM; 557 return -ENOMEM;
558 } 558 }
559 as->pdir_page = alloc_page(GFP_KERNEL | __GFP_DMA); 559 as->pdir_page = alloc_page(GFP_ATOMIC | __GFP_DMA);
560 if (!as->pdir_page) { 560 if (!as->pdir_page) {
561 dev_err(smmu->dev, 561 dev_err(smmu->dev,
562 "failed to allocate smmu_device page directory\n"); 562 "failed to allocate smmu_device page directory\n");
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
index 1a0ae4445ff..5f21f629b7a 100644
--- a/drivers/isdn/mISDN/stack.c
+++ b/drivers/isdn/mISDN/stack.c
@@ -135,8 +135,8 @@ send_layer2(struct mISDNstack *st, struct sk_buff *skb)
135 skb = NULL; 135 skb = NULL;
136 else if (*debug & DEBUG_SEND_ERR) 136 else if (*debug & DEBUG_SEND_ERR)
137 printk(KERN_DEBUG 137 printk(KERN_DEBUG
138 "%s ch%d mgr prim(%x) addr(%x) err %d\n", 138 "%s mgr prim(%x) err %d\n",
139 __func__, ch->nr, hh->prim, ch->addr, ret); 139 __func__, hh->prim, ret);
140 } 140 }
141out: 141out:
142 mutex_unlock(&st->lmutex); 142 mutex_unlock(&st->lmutex);
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index d039de8322f..b58b7a33914 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1084,6 +1084,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1084 ti->split_io = dm_rh_get_region_size(ms->rh); 1084 ti->split_io = dm_rh_get_region_size(ms->rh);
1085 ti->num_flush_requests = 1; 1085 ti->num_flush_requests = 1;
1086 ti->num_discard_requests = 1; 1086 ti->num_discard_requests = 1;
1087 ti->discard_zeroes_data_unsupported = 1;
1087 1088
1088 ms->kmirrord_wq = alloc_workqueue("kmirrord", 1089 ms->kmirrord_wq = alloc_workqueue("kmirrord",
1089 WQ_NON_REENTRANT | WQ_MEM_RECLAIM, 0); 1090 WQ_NON_REENTRANT | WQ_MEM_RECLAIM, 0);
@@ -1214,7 +1215,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1214 * We need to dec pending if this was a write. 1215 * We need to dec pending if this was a write.
1215 */ 1216 */
1216 if (rw == WRITE) { 1217 if (rw == WRITE) {
1217 if (!(bio->bi_rw & REQ_FLUSH)) 1218 if (!(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD)))
1218 dm_rh_dec(ms->rh, map_context->ll); 1219 dm_rh_dec(ms->rh, map_context->ll);
1219 return error; 1220 return error;
1220 } 1221 }
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index 7771ed21218..69732e03eb3 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -404,6 +404,9 @@ void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio)
404 return; 404 return;
405 } 405 }
406 406
407 if (bio->bi_rw & REQ_DISCARD)
408 return;
409
407 /* We must inform the log that the sync count has changed. */ 410 /* We must inform the log that the sync count has changed. */
408 log->type->set_region_sync(log, region, 0); 411 log->type->set_region_sync(log, region, 0);
409 412
@@ -524,7 +527,7 @@ void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios)
524 struct bio *bio; 527 struct bio *bio;
525 528
526 for (bio = bios->head; bio; bio = bio->bi_next) { 529 for (bio = bios->head; bio; bio = bio->bi_next) {
527 if (bio->bi_rw & REQ_FLUSH) 530 if (bio->bi_rw & (REQ_FLUSH | REQ_DISCARD))
528 continue; 531 continue;
529 rh_inc(rh, dm_rh_bio_to_region(rh, bio)); 532 rh_inc(rh, dm_rh_bio_to_region(rh, bio));
530 } 533 }
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index ce59824fb41..68694da0d21 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1245,7 +1245,10 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
1245 1245
1246 cell_release_singleton(cell, bio); 1246 cell_release_singleton(cell, bio);
1247 cell_release_singleton(cell2, bio); 1247 cell_release_singleton(cell2, bio);
1248 remap_and_issue(tc, bio, lookup_result.block); 1248 if ((!lookup_result.shared) && pool->pf.discard_passdown)
1249 remap_and_issue(tc, bio, lookup_result.block);
1250 else
1251 bio_endio(bio, 0);
1249 } 1252 }
1250 break; 1253 break;
1251 1254
@@ -2628,6 +2631,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
2628 if (tc->pool->pf.discard_enabled) { 2631 if (tc->pool->pf.discard_enabled) {
2629 ti->discards_supported = 1; 2632 ti->discards_supported = 1;
2630 ti->num_discard_requests = 1; 2633 ti->num_discard_requests = 1;
2634 ti->discard_zeroes_data_unsupported = 1;
2631 } 2635 }
2632 2636
2633 dm_put(pool_md); 2637 dm_put(pool_md);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index a4c219e3c85..d5ab4493c8b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2931,6 +2931,7 @@ offset_store(struct md_rdev *rdev, const char *buf, size_t len)
2931 * can be sane */ 2931 * can be sane */
2932 return -EBUSY; 2932 return -EBUSY;
2933 rdev->data_offset = offset; 2933 rdev->data_offset = offset;
2934 rdev->new_data_offset = offset;
2934 return len; 2935 return len;
2935} 2936}
2936 2937
@@ -3926,8 +3927,8 @@ array_state_show(struct mddev *mddev, char *page)
3926 return sprintf(page, "%s\n", array_states[st]); 3927 return sprintf(page, "%s\n", array_states[st]);
3927} 3928}
3928 3929
3929static int do_md_stop(struct mddev * mddev, int ro, int is_open); 3930static int do_md_stop(struct mddev * mddev, int ro, struct block_device *bdev);
3930static int md_set_readonly(struct mddev * mddev, int is_open); 3931static int md_set_readonly(struct mddev * mddev, struct block_device *bdev);
3931static int do_md_run(struct mddev * mddev); 3932static int do_md_run(struct mddev * mddev);
3932static int restart_array(struct mddev *mddev); 3933static int restart_array(struct mddev *mddev);
3933 3934
@@ -3943,14 +3944,14 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
3943 /* stopping an active array */ 3944 /* stopping an active array */
3944 if (atomic_read(&mddev->openers) > 0) 3945 if (atomic_read(&mddev->openers) > 0)
3945 return -EBUSY; 3946 return -EBUSY;
3946 err = do_md_stop(mddev, 0, 0); 3947 err = do_md_stop(mddev, 0, NULL);
3947 break; 3948 break;
3948 case inactive: 3949 case inactive:
3949 /* stopping an active array */ 3950 /* stopping an active array */
3950 if (mddev->pers) { 3951 if (mddev->pers) {
3951 if (atomic_read(&mddev->openers) > 0) 3952 if (atomic_read(&mddev->openers) > 0)
3952 return -EBUSY; 3953 return -EBUSY;
3953 err = do_md_stop(mddev, 2, 0); 3954 err = do_md_stop(mddev, 2, NULL);
3954 } else 3955 } else
3955 err = 0; /* already inactive */ 3956 err = 0; /* already inactive */
3956 break; 3957 break;
@@ -3958,7 +3959,7 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
3958 break; /* not supported yet */ 3959 break; /* not supported yet */
3959 case readonly: 3960 case readonly:
3960 if (mddev->pers) 3961 if (mddev->pers)
3961 err = md_set_readonly(mddev, 0); 3962 err = md_set_readonly(mddev, NULL);
3962 else { 3963 else {
3963 mddev->ro = 1; 3964 mddev->ro = 1;
3964 set_disk_ro(mddev->gendisk, 1); 3965 set_disk_ro(mddev->gendisk, 1);
@@ -3968,7 +3969,7 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
3968 case read_auto: 3969 case read_auto:
3969 if (mddev->pers) { 3970 if (mddev->pers) {
3970 if (mddev->ro == 0) 3971 if (mddev->ro == 0)
3971 err = md_set_readonly(mddev, 0); 3972 err = md_set_readonly(mddev, NULL);
3972 else if (mddev->ro == 1) 3973 else if (mddev->ro == 1)
3973 err = restart_array(mddev); 3974 err = restart_array(mddev);
3974 if (err == 0) { 3975 if (err == 0) {
@@ -5351,15 +5352,17 @@ void md_stop(struct mddev *mddev)
5351} 5352}
5352EXPORT_SYMBOL_GPL(md_stop); 5353EXPORT_SYMBOL_GPL(md_stop);
5353 5354
5354static int md_set_readonly(struct mddev *mddev, int is_open) 5355static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
5355{ 5356{
5356 int err = 0; 5357 int err = 0;
5357 mutex_lock(&mddev->open_mutex); 5358 mutex_lock(&mddev->open_mutex);
5358 if (atomic_read(&mddev->openers) > is_open) { 5359 if (atomic_read(&mddev->openers) > !!bdev) {
5359 printk("md: %s still in use.\n",mdname(mddev)); 5360 printk("md: %s still in use.\n",mdname(mddev));
5360 err = -EBUSY; 5361 err = -EBUSY;
5361 goto out; 5362 goto out;
5362 } 5363 }
5364 if (bdev)
5365 sync_blockdev(bdev);
5363 if (mddev->pers) { 5366 if (mddev->pers) {
5364 __md_stop_writes(mddev); 5367 __md_stop_writes(mddev);
5365 5368
@@ -5381,18 +5384,26 @@ out:
5381 * 0 - completely stop and dis-assemble array 5384 * 0 - completely stop and dis-assemble array
5382 * 2 - stop but do not disassemble array 5385 * 2 - stop but do not disassemble array
5383 */ 5386 */
5384static int do_md_stop(struct mddev * mddev, int mode, int is_open) 5387static int do_md_stop(struct mddev * mddev, int mode,
5388 struct block_device *bdev)
5385{ 5389{
5386 struct gendisk *disk = mddev->gendisk; 5390 struct gendisk *disk = mddev->gendisk;
5387 struct md_rdev *rdev; 5391 struct md_rdev *rdev;
5388 5392
5389 mutex_lock(&mddev->open_mutex); 5393 mutex_lock(&mddev->open_mutex);
5390 if (atomic_read(&mddev->openers) > is_open || 5394 if (atomic_read(&mddev->openers) > !!bdev ||
5391 mddev->sysfs_active) { 5395 mddev->sysfs_active) {
5392 printk("md: %s still in use.\n",mdname(mddev)); 5396 printk("md: %s still in use.\n",mdname(mddev));
5393 mutex_unlock(&mddev->open_mutex); 5397 mutex_unlock(&mddev->open_mutex);
5394 return -EBUSY; 5398 return -EBUSY;
5395 } 5399 }
5400 if (bdev)
5401 /* It is possible IO was issued on some other
5402 * open file which was closed before we took ->open_mutex.
5403 * As that was not the last close __blkdev_put will not
5404 * have called sync_blockdev, so we must.
5405 */
5406 sync_blockdev(bdev);
5396 5407
5397 if (mddev->pers) { 5408 if (mddev->pers) {
5398 if (mddev->ro) 5409 if (mddev->ro)
@@ -5466,7 +5477,7 @@ static void autorun_array(struct mddev *mddev)
5466 err = do_md_run(mddev); 5477 err = do_md_run(mddev);
5467 if (err) { 5478 if (err) {
5468 printk(KERN_WARNING "md: do_md_run() returned %d\n", err); 5479 printk(KERN_WARNING "md: do_md_run() returned %d\n", err);
5469 do_md_stop(mddev, 0, 0); 5480 do_md_stop(mddev, 0, NULL);
5470 } 5481 }
5471} 5482}
5472 5483
@@ -6481,11 +6492,11 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6481 goto done_unlock; 6492 goto done_unlock;
6482 6493
6483 case STOP_ARRAY: 6494 case STOP_ARRAY:
6484 err = do_md_stop(mddev, 0, 1); 6495 err = do_md_stop(mddev, 0, bdev);
6485 goto done_unlock; 6496 goto done_unlock;
6486 6497
6487 case STOP_ARRAY_RO: 6498 case STOP_ARRAY_RO:
6488 err = md_set_readonly(mddev, 1); 6499 err = md_set_readonly(mddev, bdev);
6489 goto done_unlock; 6500 goto done_unlock;
6490 6501
6491 case BLKROSET: 6502 case BLKROSET:
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 8c2754f835e..cacd008d686 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1818,8 +1818,14 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
1818 1818
1819 if (atomic_dec_and_test(&r1_bio->remaining)) { 1819 if (atomic_dec_and_test(&r1_bio->remaining)) {
1820 /* if we're here, all write(s) have completed, so clean up */ 1820 /* if we're here, all write(s) have completed, so clean up */
1821 md_done_sync(mddev, r1_bio->sectors, 1); 1821 int s = r1_bio->sectors;
1822 put_buf(r1_bio); 1822 if (test_bit(R1BIO_MadeGood, &r1_bio->state) ||
1823 test_bit(R1BIO_WriteError, &r1_bio->state))
1824 reschedule_retry(r1_bio);
1825 else {
1826 put_buf(r1_bio);
1827 md_done_sync(mddev, s, 1);
1828 }
1823 } 1829 }
1824} 1830}
1825 1831
@@ -2485,9 +2491,10 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
2485 */ 2491 */
2486 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { 2492 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
2487 atomic_set(&r1_bio->remaining, read_targets); 2493 atomic_set(&r1_bio->remaining, read_targets);
2488 for (i = 0; i < conf->raid_disks * 2; i++) { 2494 for (i = 0; i < conf->raid_disks * 2 && read_targets; i++) {
2489 bio = r1_bio->bios[i]; 2495 bio = r1_bio->bios[i];
2490 if (bio->bi_end_io == end_sync_read) { 2496 if (bio->bi_end_io == end_sync_read) {
2497 read_targets--;
2491 md_sync_acct(bio->bi_bdev, nr_sectors); 2498 md_sync_acct(bio->bi_bdev, nr_sectors);
2492 generic_make_request(bio); 2499 generic_make_request(bio);
2493 } 2500 }
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 00a67326c19..39eab73b01a 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -243,6 +243,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
243 if (minor == MAX_DVB_MINORS) { 243 if (minor == MAX_DVB_MINORS) {
244 kfree(dvbdevfops); 244 kfree(dvbdevfops);
245 kfree(dvbdev); 245 kfree(dvbdev);
246 up_write(&minor_rwsem);
246 mutex_unlock(&dvbdev_register_lock); 247 mutex_unlock(&dvbdev_register_lock);
247 return -EINVAL; 248 return -EINVAL;
248 } 249 }
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 342c2c8c1dd..54ee34872d1 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -232,7 +232,7 @@ MODULE_PARM_DESC(invert, "Invert the signal from the IR receiver");
232 232
233static bool txandrx; /* default = 0 */ 233static bool txandrx; /* default = 0 */
234module_param(txandrx, bool, 0444); 234module_param(txandrx, bool, 0444);
235MODULE_PARM_DESC(invert, "Allow simultaneous TX and RX"); 235MODULE_PARM_DESC(txandrx, "Allow simultaneous TX and RX");
236 236
237static unsigned int wake_sc = 0x800F040C; 237static unsigned int wake_sc = 0x800F040C;
238module_param(wake_sc, uint, 0644); 238module_param(wake_sc, uint, 0644);
@@ -1032,6 +1032,8 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1032 data->dev->tx_ir = wbcir_tx; 1032 data->dev->tx_ir = wbcir_tx;
1033 data->dev->priv = data; 1033 data->dev->priv = data;
1034 data->dev->dev.parent = &device->dev; 1034 data->dev->dev.parent = &device->dev;
1035 data->dev->timeout = MS_TO_NS(100);
1036 data->dev->allowed_protos = RC_TYPE_ALL;
1035 1037
1036 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { 1038 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
1037 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", 1039 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
diff --git a/drivers/media/video/cx231xx/cx231xx-audio.c b/drivers/media/video/cx231xx/cx231xx-audio.c
index 068f78dc5d1..b4c99c7270c 100644
--- a/drivers/media/video/cx231xx/cx231xx-audio.c
+++ b/drivers/media/video/cx231xx/cx231xx-audio.c
@@ -307,7 +307,7 @@ static int cx231xx_init_audio_isoc(struct cx231xx *dev)
307 urb->context = dev; 307 urb->context = dev;
308 urb->pipe = usb_rcvisocpipe(dev->udev, 308 urb->pipe = usb_rcvisocpipe(dev->udev,
309 dev->adev.end_point_addr); 309 dev->adev.end_point_addr);
310 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 310 urb->transfer_flags = URB_ISO_ASAP;
311 urb->transfer_buffer = dev->adev.transfer_buffer[i]; 311 urb->transfer_buffer = dev->adev.transfer_buffer[i];
312 urb->interval = 1; 312 urb->interval = 1;
313 urb->complete = cx231xx_audio_isocirq; 313 urb->complete = cx231xx_audio_isocirq;
@@ -368,7 +368,7 @@ static int cx231xx_init_audio_bulk(struct cx231xx *dev)
368 urb->context = dev; 368 urb->context = dev;
369 urb->pipe = usb_rcvbulkpipe(dev->udev, 369 urb->pipe = usb_rcvbulkpipe(dev->udev,
370 dev->adev.end_point_addr); 370 dev->adev.end_point_addr);
371 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 371 urb->transfer_flags = 0;
372 urb->transfer_buffer = dev->adev.transfer_buffer[i]; 372 urb->transfer_buffer = dev->adev.transfer_buffer[i];
373 urb->complete = cx231xx_audio_bulkirq; 373 urb->complete = cx231xx_audio_bulkirq;
374 urb->transfer_buffer_length = sb_size; 374 urb->transfer_buffer_length = sb_size;
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c
index 3d15314e1f8..ac7db52f404 100644
--- a/drivers/media/video/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/video/cx231xx/cx231xx-vbi.c
@@ -448,7 +448,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
448 return -ENOMEM; 448 return -ENOMEM;
449 } 449 }
450 dev->vbi_mode.bulk_ctl.urb[i] = urb; 450 dev->vbi_mode.bulk_ctl.urb[i] = urb;
451 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 451 urb->transfer_flags = 0;
452 452
453 dev->vbi_mode.bulk_ctl.transfer_buffer[i] = 453 dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
454 kzalloc(sb_size, GFP_KERNEL); 454 kzalloc(sb_size, GFP_KERNEL);
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 13739e002a6..080e11157e5 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -127,22 +127,37 @@ struct cx23885_board cx23885_boards[] = {
127 }, 127 },
128 [CX23885_BOARD_HAUPPAUGE_HVR1250] = { 128 [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
129 .name = "Hauppauge WinTV-HVR1250", 129 .name = "Hauppauge WinTV-HVR1250",
130 .porta = CX23885_ANALOG_VIDEO,
130 .portc = CX23885_MPEG_DVB, 131 .portc = CX23885_MPEG_DVB,
132#ifdef MT2131_NO_ANALOG_SUPPORT_YET
133 .tuner_type = TUNER_PHILIPS_TDA8290,
134 .tuner_addr = 0x42, /* 0x84 >> 1 */
135 .tuner_bus = 1,
136#endif
137 .force_bff = 1,
131 .input = {{ 138 .input = {{
139#ifdef MT2131_NO_ANALOG_SUPPORT_YET
132 .type = CX23885_VMUX_TELEVISION, 140 .type = CX23885_VMUX_TELEVISION,
133 .vmux = 0, 141 .vmux = CX25840_VIN7_CH3 |
142 CX25840_VIN5_CH2 |
143 CX25840_VIN2_CH1,
144 .amux = CX25840_AUDIO8,
134 .gpio0 = 0xff00, 145 .gpio0 = 0xff00,
135 }, { 146 }, {
136 .type = CX23885_VMUX_DEBUG, 147#endif
137 .vmux = 0,
138 .gpio0 = 0xff01,
139 }, {
140 .type = CX23885_VMUX_COMPOSITE1, 148 .type = CX23885_VMUX_COMPOSITE1,
141 .vmux = 1, 149 .vmux = CX25840_VIN7_CH3 |
150 CX25840_VIN4_CH2 |
151 CX25840_VIN6_CH1,
152 .amux = CX25840_AUDIO7,
142 .gpio0 = 0xff02, 153 .gpio0 = 0xff02,
143 }, { 154 }, {
144 .type = CX23885_VMUX_SVIDEO, 155 .type = CX23885_VMUX_SVIDEO,
145 .vmux = 2, 156 .vmux = CX25840_VIN7_CH3 |
157 CX25840_VIN4_CH2 |
158 CX25840_VIN8_CH1 |
159 CX25840_SVIDEO_ON,
160 .amux = CX25840_AUDIO7,
146 .gpio0 = 0xff02, 161 .gpio0 = 0xff02,
147 } }, 162 } },
148 }, 163 },
@@ -267,7 +282,55 @@ struct cx23885_board cx23885_boards[] = {
267 }, 282 },
268 [CX23885_BOARD_HAUPPAUGE_HVR1255] = { 283 [CX23885_BOARD_HAUPPAUGE_HVR1255] = {
269 .name = "Hauppauge WinTV-HVR1255", 284 .name = "Hauppauge WinTV-HVR1255",
285 .porta = CX23885_ANALOG_VIDEO,
286 .portc = CX23885_MPEG_DVB,
287 .tuner_type = TUNER_ABSENT,
288 .tuner_addr = 0x42, /* 0x84 >> 1 */
289 .force_bff = 1,
290 .input = {{
291 .type = CX23885_VMUX_TELEVISION,
292 .vmux = CX25840_VIN7_CH3 |
293 CX25840_VIN5_CH2 |
294 CX25840_VIN2_CH1 |
295 CX25840_DIF_ON,
296 .amux = CX25840_AUDIO8,
297 }, {
298 .type = CX23885_VMUX_COMPOSITE1,
299 .vmux = CX25840_VIN7_CH3 |
300 CX25840_VIN4_CH2 |
301 CX25840_VIN6_CH1,
302 .amux = CX25840_AUDIO7,
303 }, {
304 .type = CX23885_VMUX_SVIDEO,
305 .vmux = CX25840_VIN7_CH3 |
306 CX25840_VIN4_CH2 |
307 CX25840_VIN8_CH1 |
308 CX25840_SVIDEO_ON,
309 .amux = CX25840_AUDIO7,
310 } },
311 },
312 [CX23885_BOARD_HAUPPAUGE_HVR1255_22111] = {
313 .name = "Hauppauge WinTV-HVR1255",
314 .porta = CX23885_ANALOG_VIDEO,
270 .portc = CX23885_MPEG_DVB, 315 .portc = CX23885_MPEG_DVB,
316 .tuner_type = TUNER_ABSENT,
317 .tuner_addr = 0x42, /* 0x84 >> 1 */
318 .force_bff = 1,
319 .input = {{
320 .type = CX23885_VMUX_TELEVISION,
321 .vmux = CX25840_VIN7_CH3 |
322 CX25840_VIN5_CH2 |
323 CX25840_VIN2_CH1 |
324 CX25840_DIF_ON,
325 .amux = CX25840_AUDIO8,
326 }, {
327 .type = CX23885_VMUX_SVIDEO,
328 .vmux = CX25840_VIN7_CH3 |
329 CX25840_VIN4_CH2 |
330 CX25840_VIN8_CH1 |
331 CX25840_SVIDEO_ON,
332 .amux = CX25840_AUDIO7,
333 } },
271 }, 334 },
272 [CX23885_BOARD_HAUPPAUGE_HVR1210] = { 335 [CX23885_BOARD_HAUPPAUGE_HVR1210] = {
273 .name = "Hauppauge WinTV-HVR1210", 336 .name = "Hauppauge WinTV-HVR1210",
@@ -624,7 +687,7 @@ struct cx23885_subid cx23885_subids[] = {
624 }, { 687 }, {
625 .subvendor = 0x0070, 688 .subvendor = 0x0070,
626 .subdevice = 0x2259, 689 .subdevice = 0x2259,
627 .card = CX23885_BOARD_HAUPPAUGE_HVR1255, 690 .card = CX23885_BOARD_HAUPPAUGE_HVR1255_22111,
628 }, { 691 }, {
629 .subvendor = 0x0070, 692 .subvendor = 0x0070,
630 .subdevice = 0x2291, 693 .subdevice = 0x2291,
@@ -900,7 +963,7 @@ int cx23885_tuner_callback(void *priv, int component, int command, int arg)
900 struct cx23885_dev *dev = port->dev; 963 struct cx23885_dev *dev = port->dev;
901 u32 bitmask = 0; 964 u32 bitmask = 0;
902 965
903 if (command == XC2028_RESET_CLK) 966 if ((command == XC2028_RESET_CLK) || (command == XC2028_I2C_FLUSH))
904 return 0; 967 return 0;
905 968
906 if (command != 0) { 969 if (command != 0) {
@@ -1130,6 +1193,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
1130 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1193 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1131 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1194 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1132 case CX23885_BOARD_HAUPPAUGE_HVR1255: 1195 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1196 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1133 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1197 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1134 /* GPIO-5 RF Control: 0 = RF1 Terrestrial, 1 = RF2 Cable */ 1198 /* GPIO-5 RF Control: 0 = RF1 Terrestrial, 1 = RF2 Cable */
1135 /* GPIO-6 I2C Gate which can isolate the demod from the bus */ 1199 /* GPIO-6 I2C Gate which can isolate the demod from the bus */
@@ -1267,6 +1331,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
1267 case CX23885_BOARD_HAUPPAUGE_HVR1400: 1331 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1268 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1332 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1269 case CX23885_BOARD_HAUPPAUGE_HVR1255: 1333 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1334 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1270 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1335 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1271 /* FIXME: Implement me */ 1336 /* FIXME: Implement me */
1272 break; 1337 break;
@@ -1424,6 +1489,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1424 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1489 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1425 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1490 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1426 case CX23885_BOARD_HAUPPAUGE_HVR1255: 1491 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1492 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1427 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1493 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1428 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1494 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1429 case CX23885_BOARD_HAUPPAUGE_HVR1290: 1495 case CX23885_BOARD_HAUPPAUGE_HVR1290:
@@ -1511,6 +1577,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1511 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1577 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1512 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1578 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1513 case CX23885_BOARD_HAUPPAUGE_HVR1255: 1579 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1580 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1514 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1581 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1515 case CX23885_BOARD_COMPRO_VIDEOMATE_E800: 1582 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1516 case CX23885_BOARD_HAUPPAUGE_HVR1290: 1583 case CX23885_BOARD_HAUPPAUGE_HVR1290:
@@ -1526,10 +1593,10 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1526 */ 1593 */
1527 switch (dev->board) { 1594 switch (dev->board) {
1528 case CX23885_BOARD_TEVII_S470: 1595 case CX23885_BOARD_TEVII_S470:
1529 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1530 /* Currently only enabled for the integrated IR controller */ 1596 /* Currently only enabled for the integrated IR controller */
1531 if (!enable_885_ir) 1597 if (!enable_885_ir)
1532 break; 1598 break;
1599 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1533 case CX23885_BOARD_HAUPPAUGE_HVR1800: 1600 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1534 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 1601 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
1535 case CX23885_BOARD_HAUPPAUGE_HVR1700: 1602 case CX23885_BOARD_HAUPPAUGE_HVR1700:
@@ -1539,6 +1606,8 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1539 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 1606 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1540 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: 1607 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1541 case CX23885_BOARD_COMPRO_VIDEOMATE_E800: 1608 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1609 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1610 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1542 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1611 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1543 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1612 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1544 case CX23885_BOARD_MYGICA_X8506: 1613 case CX23885_BOARD_MYGICA_X8506:
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index a80a92c4745..cd542684ba0 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -712,6 +712,7 @@ static int dvb_register(struct cx23885_tsport *port)
712 } 712 }
713 break; 713 break;
714 case CX23885_BOARD_HAUPPAUGE_HVR1255: 714 case CX23885_BOARD_HAUPPAUGE_HVR1255:
715 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
715 i2c_bus = &dev->i2c_bus[0]; 716 i2c_bus = &dev->i2c_bus[0];
716 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 717 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
717 &hcw_s5h1411_config, 718 &hcw_s5h1411_config,
@@ -721,6 +722,11 @@ static int dvb_register(struct cx23885_tsport *port)
721 0x60, &dev->i2c_bus[1].i2c_adap, 722 0x60, &dev->i2c_bus[1].i2c_adap,
722 &hauppauge_tda18271_config); 723 &hauppauge_tda18271_config);
723 } 724 }
725
726 tda18271_attach(&dev->ts1.analog_fe,
727 0x60, &dev->i2c_bus[1].i2c_adap,
728 &hauppauge_tda18271_config);
729
724 break; 730 break;
725 case CX23885_BOARD_HAUPPAUGE_HVR1800: 731 case CX23885_BOARD_HAUPPAUGE_HVR1800:
726 i2c_bus = &dev->i2c_bus[0]; 732 i2c_bus = &dev->i2c_bus[0];
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index c654bdc7ccb..22f8e7fbd66 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -505,6 +505,9 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
505 505
506 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) || 506 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) ||
507 (dev->board == CX23885_BOARD_MPX885) || 507 (dev->board == CX23885_BOARD_MPX885) ||
508 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1250) ||
509 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) ||
510 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) ||
508 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850)) { 511 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850)) {
509 /* Configure audio routing */ 512 /* Configure audio routing */
510 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing, 513 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
@@ -1578,7 +1581,9 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
1578 1581
1579 fe = vfe->dvb.frontend; 1582 fe = vfe->dvb.frontend;
1580 1583
1581 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) 1584 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) ||
1585 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) ||
1586 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111))
1582 fe = &dev->ts1.analog_fe; 1587 fe = &dev->ts1.analog_fe;
1583 1588
1584 if (fe && fe->ops.tuner_ops.set_analog_params) { 1589 if (fe && fe->ops.tuner_ops.set_analog_params) {
@@ -1608,6 +1613,8 @@ int cx23885_set_frequency(struct file *file, void *priv,
1608 int ret; 1613 int ret;
1609 1614
1610 switch (dev->board) { 1615 switch (dev->board) {
1616 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1617 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1611 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1618 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1612 ret = cx23885_set_freq_via_ops(dev, f); 1619 ret = cx23885_set_freq_via_ops(dev, f);
1613 break; 1620 break;
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index d884784a1c8..13c37ec07ae 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -90,6 +90,7 @@
90#define CX23885_BOARD_MYGICA_X8507 33 90#define CX23885_BOARD_MYGICA_X8507 33
91#define CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL 34 91#define CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL 34
92#define CX23885_BOARD_TEVII_S471 35 92#define CX23885_BOARD_TEVII_S471 35
93#define CX23885_BOARD_HAUPPAUGE_HVR1255_22111 36
93 94
94#define GPIO_0 0x00000001 95#define GPIO_0 0x00000001
95#define GPIO_1 0x00000002 96#define GPIO_1 0x00000002
diff --git a/drivers/media/video/cx25821/cx25821-core.c b/drivers/media/video/cx25821/cx25821-core.c
index 83c1aa6b2e6..f11f6f07e91 100644
--- a/drivers/media/video/cx25821/cx25821-core.c
+++ b/drivers/media/video/cx25821/cx25821-core.c
@@ -904,9 +904,6 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
904 list_add_tail(&dev->devlist, &cx25821_devlist); 904 list_add_tail(&dev->devlist, &cx25821_devlist);
905 mutex_unlock(&cx25821_devlist_mutex); 905 mutex_unlock(&cx25821_devlist_mutex);
906 906
907 strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
908 strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
909
910 if (dev->pci->device != 0x8210) { 907 if (dev->pci->device != 0x8210) {
911 pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n", 908 pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
912 __func__, dev->pci->device); 909 __func__, dev->pci->device);
diff --git a/drivers/media/video/cx25821/cx25821.h b/drivers/media/video/cx25821/cx25821.h
index b9aa801b00a..029f2934a6d 100644
--- a/drivers/media/video/cx25821/cx25821.h
+++ b/drivers/media/video/cx25821/cx25821.h
@@ -187,7 +187,7 @@ enum port {
187}; 187};
188 188
189struct cx25821_board { 189struct cx25821_board {
190 char *name; 190 const char *name;
191 enum port porta; 191 enum port porta;
192 enum port portb; 192 enum port portb;
193 enum port portc; 193 enum port portc;
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index fc1ff69cffd..d8eac3e30a7 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -84,7 +84,7 @@ MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");
84 84
85 85
86/* ----------------------------------------------------------------------- */ 86/* ----------------------------------------------------------------------- */
87static void cx23885_std_setup(struct i2c_client *client); 87static void cx23888_std_setup(struct i2c_client *client);
88 88
89int cx25840_write(struct i2c_client *client, u16 addr, u8 value) 89int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
90{ 90{
@@ -638,10 +638,13 @@ static void cx23885_initialize(struct i2c_client *client)
638 finish_wait(&state->fw_wait, &wait); 638 finish_wait(&state->fw_wait, &wait);
639 destroy_workqueue(q); 639 destroy_workqueue(q);
640 640
641 /* Call the cx23885 specific std setup func, we no longer rely on 641 /* Call the cx23888 specific std setup func, we no longer rely on
642 * the generic cx24840 func. 642 * the generic cx24840 func.
643 */ 643 */
644 cx23885_std_setup(client); 644 if (is_cx23888(state))
645 cx23888_std_setup(client);
646 else
647 cx25840_std_setup(client);
645 648
646 /* (re)set input */ 649 /* (re)set input */
647 set_input(client, state->vid_input, state->aud_input); 650 set_input(client, state->vid_input, state->aud_input);
@@ -1103,9 +1106,23 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
1103 1106
1104 cx25840_write4(client, 0x410, 0xffff0dbf); 1107 cx25840_write4(client, 0x410, 0xffff0dbf);
1105 cx25840_write4(client, 0x414, 0x00137d03); 1108 cx25840_write4(client, 0x414, 0x00137d03);
1106 cx25840_write4(client, 0x418, 0x01008080); 1109
1110 /* on the 887, 0x418 is HSCALE_CTRL, on the 888 it is
1111 CHROMA_CTRL */
1112 if (is_cx23888(state))
1113 cx25840_write4(client, 0x418, 0x01008080);
1114 else
1115 cx25840_write4(client, 0x418, 0x01000000);
1116
1107 cx25840_write4(client, 0x41c, 0x00000000); 1117 cx25840_write4(client, 0x41c, 0x00000000);
1108 cx25840_write4(client, 0x420, 0x001c3e0f); 1118
1119 /* on the 887, 0x420 is CHROMA_CTRL, on the 888 it is
1120 CRUSH_CTRL */
1121 if (is_cx23888(state))
1122 cx25840_write4(client, 0x420, 0x001c3e0f);
1123 else
1124 cx25840_write4(client, 0x420, 0x001c8282);
1125
1109 cx25840_write4(client, 0x42c, 0x42600000); 1126 cx25840_write4(client, 0x42c, 0x42600000);
1110 cx25840_write4(client, 0x430, 0x0000039b); 1127 cx25840_write4(client, 0x430, 0x0000039b);
1111 cx25840_write4(client, 0x438, 0x00000000); 1128 cx25840_write4(client, 0x438, 0x00000000);
@@ -1233,7 +1250,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
1233 cx25840_write4(client, 0x8d0, 0x1f063870); 1250 cx25840_write4(client, 0x8d0, 0x1f063870);
1234 } 1251 }
1235 1252
1236 if (is_cx2388x(state)) { 1253 if (is_cx23888(state)) {
1237 /* HVR1850 */ 1254 /* HVR1850 */
1238 /* AUD_IO_CTRL - I2S Input, Parallel1*/ 1255 /* AUD_IO_CTRL - I2S Input, Parallel1*/
1239 /* - Channel 1 src - Parallel1 (Merlin out) */ 1256 /* - Channel 1 src - Parallel1 (Merlin out) */
@@ -1298,8 +1315,8 @@ static int set_v4lstd(struct i2c_client *client)
1298 } 1315 }
1299 cx25840_and_or(client, 0x400, ~0xf, fmt); 1316 cx25840_and_or(client, 0x400, ~0xf, fmt);
1300 cx25840_and_or(client, 0x403, ~0x3, pal_m); 1317 cx25840_and_or(client, 0x403, ~0x3, pal_m);
1301 if (is_cx2388x(state)) 1318 if (is_cx23888(state))
1302 cx23885_std_setup(client); 1319 cx23888_std_setup(client);
1303 else 1320 else
1304 cx25840_std_setup(client); 1321 cx25840_std_setup(client);
1305 if (!is_cx2583x(state)) 1322 if (!is_cx2583x(state))
@@ -1312,6 +1329,7 @@ static int set_v4lstd(struct i2c_client *client)
1312static int cx25840_s_ctrl(struct v4l2_ctrl *ctrl) 1329static int cx25840_s_ctrl(struct v4l2_ctrl *ctrl)
1313{ 1330{
1314 struct v4l2_subdev *sd = to_sd(ctrl); 1331 struct v4l2_subdev *sd = to_sd(ctrl);
1332 struct cx25840_state *state = to_state(sd);
1315 struct i2c_client *client = v4l2_get_subdevdata(sd); 1333 struct i2c_client *client = v4l2_get_subdevdata(sd);
1316 1334
1317 switch (ctrl->id) { 1335 switch (ctrl->id) {
@@ -1324,12 +1342,20 @@ static int cx25840_s_ctrl(struct v4l2_ctrl *ctrl)
1324 break; 1342 break;
1325 1343
1326 case V4L2_CID_SATURATION: 1344 case V4L2_CID_SATURATION:
1327 cx25840_write(client, 0x420, ctrl->val << 1); 1345 if (is_cx23888(state)) {
1328 cx25840_write(client, 0x421, ctrl->val << 1); 1346 cx25840_write(client, 0x418, ctrl->val << 1);
1347 cx25840_write(client, 0x419, ctrl->val << 1);
1348 } else {
1349 cx25840_write(client, 0x420, ctrl->val << 1);
1350 cx25840_write(client, 0x421, ctrl->val << 1);
1351 }
1329 break; 1352 break;
1330 1353
1331 case V4L2_CID_HUE: 1354 case V4L2_CID_HUE:
1332 cx25840_write(client, 0x422, ctrl->val); 1355 if (is_cx23888(state))
1356 cx25840_write(client, 0x41a, ctrl->val);
1357 else
1358 cx25840_write(client, 0x422, ctrl->val);
1333 break; 1359 break;
1334 1360
1335 default: 1361 default:
@@ -1354,11 +1380,21 @@ static int cx25840_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt
1354 fmt->field = V4L2_FIELD_INTERLACED; 1380 fmt->field = V4L2_FIELD_INTERLACED;
1355 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; 1381 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
1356 1382
1357 Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4; 1383 if (is_cx23888(state)) {
1358 Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4; 1384 Vsrc = (cx25840_read(client, 0x42a) & 0x3f) << 4;
1385 Vsrc |= (cx25840_read(client, 0x429) & 0xf0) >> 4;
1386 } else {
1387 Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4;
1388 Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4;
1389 }
1359 1390
1360 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; 1391 if (is_cx23888(state)) {
1361 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; 1392 Hsrc = (cx25840_read(client, 0x426) & 0x3f) << 4;
1393 Hsrc |= (cx25840_read(client, 0x425) & 0xf0) >> 4;
1394 } else {
1395 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
1396 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
1397 }
1362 1398
1363 Vlines = fmt->height + (is_50Hz ? 4 : 7); 1399 Vlines = fmt->height + (is_50Hz ? 4 : 7);
1364 1400
@@ -1782,8 +1818,8 @@ static int cx25840_s_video_routing(struct v4l2_subdev *sd,
1782 struct cx25840_state *state = to_state(sd); 1818 struct cx25840_state *state = to_state(sd);
1783 struct i2c_client *client = v4l2_get_subdevdata(sd); 1819 struct i2c_client *client = v4l2_get_subdevdata(sd);
1784 1820
1785 if (is_cx2388x(state)) 1821 if (is_cx23888(state))
1786 cx23885_std_setup(client); 1822 cx23888_std_setup(client);
1787 1823
1788 return set_input(client, input, state->aud_input); 1824 return set_input(client, input, state->aud_input);
1789} 1825}
@@ -1794,8 +1830,8 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
1794 struct cx25840_state *state = to_state(sd); 1830 struct cx25840_state *state = to_state(sd);
1795 struct i2c_client *client = v4l2_get_subdevdata(sd); 1831 struct i2c_client *client = v4l2_get_subdevdata(sd);
1796 1832
1797 if (is_cx2388x(state)) 1833 if (is_cx23888(state))
1798 cx23885_std_setup(client); 1834 cx23888_std_setup(client);
1799 return set_input(client, state->vid_input, input); 1835 return set_input(client, state->vid_input, input);
1800} 1836}
1801 1837
@@ -4939,7 +4975,7 @@ void cx23885_dif_setup(struct i2c_client *client, u32 ifHz)
4939 } 4975 }
4940} 4976}
4941 4977
4942static void cx23885_std_setup(struct i2c_client *client) 4978static void cx23888_std_setup(struct i2c_client *client)
4943{ 4979{
4944 struct cx25840_state *state = to_state(i2c_get_clientdata(client)); 4980 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
4945 v4l2_std_id std = state->std; 4981 v4l2_std_id std = state->std;
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 92da7c28b6f..862c6575c55 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -2893,7 +2893,7 @@ static void request_module_async(struct work_struct *work)
2893 2893
2894 if (dev->board.has_dvb) 2894 if (dev->board.has_dvb)
2895 request_module("em28xx-dvb"); 2895 request_module("em28xx-dvb");
2896 if (dev->board.has_ir_i2c && !disable_ir) 2896 if (dev->board.ir_codes && !disable_ir)
2897 request_module("em28xx-rc"); 2897 request_module("em28xx-rc");
2898} 2898}
2899 2899
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index 6c31e46a1fd..b9c6f17eabb 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -2070,10 +2070,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
2070 set_gamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); 2070 set_gamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma));
2071 set_redblue(gspca_dev, v4l2_ctrl_g_ctrl(sd->blue), 2071 set_redblue(gspca_dev, v4l2_ctrl_g_ctrl(sd->blue),
2072 v4l2_ctrl_g_ctrl(sd->red)); 2072 v4l2_ctrl_g_ctrl(sd->red));
2073 set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain)); 2073 if (sd->gain)
2074 set_exposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure)); 2074 set_gain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain));
2075 set_hvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), 2075 if (sd->exposure)
2076 v4l2_ctrl_g_ctrl(sd->vflip)); 2076 set_exposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure));
2077 if (sd->hflip)
2078 set_hvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip),
2079 v4l2_ctrl_g_ctrl(sd->vflip));
2077 2080
2078 reg_w1(gspca_dev, 0x1007, 0x20); 2081 reg_w1(gspca_dev, 0x1007, 0x20);
2079 reg_w1(gspca_dev, 0x1061, 0x03); 2082 reg_w1(gspca_dev, 0x1061, 0x03);
@@ -2176,7 +2179,7 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev)
2176 struct sd *sd = (struct sd *) gspca_dev; 2179 struct sd *sd = (struct sd *) gspca_dev;
2177 int avg_lum; 2180 int avg_lum;
2178 2181
2179 if (!v4l2_ctrl_g_ctrl(sd->autogain)) 2182 if (sd->autogain == NULL || !v4l2_ctrl_g_ctrl(sd->autogain))
2180 return; 2183 return;
2181 2184
2182 avg_lum = atomic_read(&sd->avg_lum); 2185 avg_lum = atomic_read(&sd->avg_lum);
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 41f9a254b24..637bde8aca2 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -83,6 +83,7 @@
83#define CSICR1_INV_DATA (1 << 3) 83#define CSICR1_INV_DATA (1 << 3)
84#define CSICR1_INV_PCLK (1 << 2) 84#define CSICR1_INV_PCLK (1 << 2)
85#define CSICR1_REDGE (1 << 1) 85#define CSICR1_REDGE (1 << 1)
86#define CSICR1_FMT_MASK (CSICR1_PACK_DIR | CSICR1_SWAP16_EN)
86 87
87#define SHIFT_STATFF_LEVEL 22 88#define SHIFT_STATFF_LEVEL 22
88#define SHIFT_RXFF_LEVEL 19 89#define SHIFT_RXFF_LEVEL 19
@@ -230,6 +231,7 @@ struct mx2_prp_cfg {
230 u32 src_pixel; 231 u32 src_pixel;
231 u32 ch1_pixel; 232 u32 ch1_pixel;
232 u32 irq_flags; 233 u32 irq_flags;
234 u32 csicr1;
233}; 235};
234 236
235/* prp resizing parameters */ 237/* prp resizing parameters */
@@ -330,6 +332,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = {
330 .ch1_pixel = 0x2ca00565, /* RGB565 */ 332 .ch1_pixel = 0x2ca00565, /* RGB565 */
331 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH1WERR | 333 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH1WERR |
332 PRP_INTR_CH1FC | PRP_INTR_LBOVF, 334 PRP_INTR_CH1FC | PRP_INTR_LBOVF,
335 .csicr1 = 0,
333 } 336 }
334 }, 337 },
335 { 338 {
@@ -343,6 +346,21 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = {
343 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR | 346 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR |
344 PRP_INTR_CH2FC | PRP_INTR_LBOVF | 347 PRP_INTR_CH2FC | PRP_INTR_LBOVF |
345 PRP_INTR_CH2OVF, 348 PRP_INTR_CH2OVF,
349 .csicr1 = CSICR1_PACK_DIR,
350 }
351 },
352 {
353 .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8,
354 .out_fmt = V4L2_PIX_FMT_YUV420,
355 .cfg = {
356 .channel = 2,
357 .in_fmt = PRP_CNTL_DATA_IN_YUV422,
358 .out_fmt = PRP_CNTL_CH2_OUT_YUV420,
359 .src_pixel = 0x22000888, /* YUV422 (YUYV) */
360 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR |
361 PRP_INTR_CH2FC | PRP_INTR_LBOVF |
362 PRP_INTR_CH2OVF,
363 .csicr1 = CSICR1_SWAP16_EN,
346 } 364 }
347 }, 365 },
348}; 366};
@@ -1015,14 +1033,14 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1015 return ret; 1033 return ret;
1016 } 1034 }
1017 1035
1036 csicr1 = (csicr1 & ~CSICR1_FMT_MASK) | pcdev->emma_prp->cfg.csicr1;
1037
1018 if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) 1038 if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
1019 csicr1 |= CSICR1_REDGE; 1039 csicr1 |= CSICR1_REDGE;
1020 if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) 1040 if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
1021 csicr1 |= CSICR1_SOF_POL; 1041 csicr1 |= CSICR1_SOF_POL;
1022 if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 1042 if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
1023 csicr1 |= CSICR1_HSYNC_POL; 1043 csicr1 |= CSICR1_HSYNC_POL;
1024 if (pcdev->platform_flags & MX2_CAMERA_SWAP16)
1025 csicr1 |= CSICR1_SWAP16_EN;
1026 if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC) 1044 if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC)
1027 csicr1 |= CSICR1_EXT_VSYNC; 1045 csicr1 |= CSICR1_EXT_VSYNC;
1028 if (pcdev->platform_flags & MX2_CAMERA_CCIR) 1046 if (pcdev->platform_flags & MX2_CAMERA_CCIR)
@@ -1033,8 +1051,6 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1033 csicr1 |= CSICR1_GCLK_MODE; 1051 csicr1 |= CSICR1_GCLK_MODE;
1034 if (pcdev->platform_flags & MX2_CAMERA_INV_DATA) 1052 if (pcdev->platform_flags & MX2_CAMERA_INV_DATA)
1035 csicr1 |= CSICR1_INV_DATA; 1053 csicr1 |= CSICR1_INV_DATA;
1036 if (pcdev->platform_flags & MX2_CAMERA_PACK_DIR_MSB)
1037 csicr1 |= CSICR1_PACK_DIR;
1038 1054
1039 pcdev->csicr1 = csicr1; 1055 pcdev->csicr1 = csicr1;
1040 1056
@@ -1109,7 +1125,8 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd,
1109 return 0; 1125 return 0;
1110 } 1126 }
1111 1127
1112 if (code == V4L2_MBUS_FMT_YUYV8_2X8) { 1128 if (code == V4L2_MBUS_FMT_YUYV8_2X8 ||
1129 code == V4L2_MBUS_FMT_UYVY8_2X8) {
1113 formats++; 1130 formats++;
1114 if (xlate) { 1131 if (xlate) {
1115 /* 1132 /*
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index 8a4935ecc65..dd91da26f1b 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -888,12 +888,12 @@ static const struct preview_update update_attrs[] = {
888 preview_config_contrast, 888 preview_config_contrast,
889 NULL, 889 NULL,
890 offsetof(struct prev_params, contrast), 890 offsetof(struct prev_params, contrast),
891 0, true, 891 0, 0, true,
892 }, /* OMAP3ISP_PREV_BRIGHTNESS */ { 892 }, /* OMAP3ISP_PREV_BRIGHTNESS */ {
893 preview_config_brightness, 893 preview_config_brightness,
894 NULL, 894 NULL,
895 offsetof(struct prev_params, brightness), 895 offsetof(struct prev_params, brightness),
896 0, true, 896 0, 0, true,
897 }, 897 },
898}; 898};
899 899
@@ -1102,7 +1102,7 @@ static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
1102 unsigned int elv = prev->crop.top + prev->crop.height - 1; 1102 unsigned int elv = prev->crop.top + prev->crop.height - 1;
1103 u32 features; 1103 u32 features;
1104 1104
1105 if (format->code == V4L2_MBUS_FMT_Y10_1X10) { 1105 if (format->code != V4L2_MBUS_FMT_Y10_1X10) {
1106 sph -= 2; 1106 sph -= 2;
1107 eph += 2; 1107 eph += 2;
1108 slv -= 2; 1108 slv -= 2;
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index c370c2d87c1..b4c679b3fb0 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -26,6 +26,7 @@
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/slab.h>
29#include <linux/ioport.h> 30#include <linux/ioport.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/mutex.h> 32#include <linux/mutex.h>
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index 35457459190..725812aa0c3 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -350,7 +350,8 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
350 if (pixm) 350 if (pixm)
351 sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); 351 sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
352 else 352 else
353 sizes[i] = size; 353 sizes[i] = max_t(u32, size, frame->payload[i]);
354
354 allocators[i] = ctx->fimc_dev->alloc_ctx; 355 allocators[i] = ctx->fimc_dev->alloc_ctx;
355 } 356 }
356 357
@@ -479,37 +480,39 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc);
479static int fimc_capture_open(struct file *file) 480static int fimc_capture_open(struct file *file)
480{ 481{
481 struct fimc_dev *fimc = video_drvdata(file); 482 struct fimc_dev *fimc = video_drvdata(file);
482 int ret = v4l2_fh_open(file); 483 int ret;
483
484 if (ret)
485 return ret;
486 484
487 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); 485 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state);
488 486
489 /* Return if the corresponding video mem2mem node is already opened. */
490 if (fimc_m2m_active(fimc)) 487 if (fimc_m2m_active(fimc))
491 return -EBUSY; 488 return -EBUSY;
492 489
493 set_bit(ST_CAPT_BUSY, &fimc->state); 490 set_bit(ST_CAPT_BUSY, &fimc->state);
494 pm_runtime_get_sync(&fimc->pdev->dev); 491 ret = pm_runtime_get_sync(&fimc->pdev->dev);
492 if (ret < 0)
493 return ret;
495 494
496 if (++fimc->vid_cap.refcnt == 1) { 495 ret = v4l2_fh_open(file);
497 ret = fimc_pipeline_initialize(&fimc->pipeline, 496 if (ret)
498 &fimc->vid_cap.vfd->entity, true); 497 return ret;
499 if (ret < 0) {
500 dev_err(&fimc->pdev->dev,
501 "Video pipeline initialization failed\n");
502 pm_runtime_put_sync(&fimc->pdev->dev);
503 fimc->vid_cap.refcnt--;
504 v4l2_fh_release(file);
505 clear_bit(ST_CAPT_BUSY, &fimc->state);
506 return ret;
507 }
508 ret = fimc_capture_ctrls_create(fimc);
509 498
510 if (!ret && !fimc->vid_cap.user_subdev_api) 499 if (++fimc->vid_cap.refcnt != 1)
511 ret = fimc_capture_set_default_format(fimc); 500 return 0;
501
502 ret = fimc_pipeline_initialize(&fimc->pipeline,
503 &fimc->vid_cap.vfd->entity, true);
504 if (ret < 0) {
505 clear_bit(ST_CAPT_BUSY, &fimc->state);
506 pm_runtime_put_sync(&fimc->pdev->dev);
507 fimc->vid_cap.refcnt--;
508 v4l2_fh_release(file);
509 return ret;
512 } 510 }
511 ret = fimc_capture_ctrls_create(fimc);
512
513 if (!ret && !fimc->vid_cap.user_subdev_api)
514 ret = fimc_capture_set_default_format(fimc);
515
513 return ret; 516 return ret;
514} 517}
515 518
@@ -818,9 +821,6 @@ static int fimc_cap_g_fmt_mplane(struct file *file, void *fh,
818 struct fimc_dev *fimc = video_drvdata(file); 821 struct fimc_dev *fimc = video_drvdata(file);
819 struct fimc_ctx *ctx = fimc->vid_cap.ctx; 822 struct fimc_ctx *ctx = fimc->vid_cap.ctx;
820 823
821 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
822 return -EINVAL;
823
824 return fimc_fill_format(&ctx->d_frame, f); 824 return fimc_fill_format(&ctx->d_frame, f);
825} 825}
826 826
@@ -833,9 +833,6 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh,
833 struct v4l2_mbus_framefmt mf; 833 struct v4l2_mbus_framefmt mf;
834 struct fimc_fmt *ffmt = NULL; 834 struct fimc_fmt *ffmt = NULL;
835 835
836 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
837 return -EINVAL;
838
839 if (pix->pixelformat == V4L2_PIX_FMT_JPEG) { 836 if (pix->pixelformat == V4L2_PIX_FMT_JPEG) {
840 fimc_capture_try_format(ctx, &pix->width, &pix->height, 837 fimc_capture_try_format(ctx, &pix->width, &pix->height,
841 NULL, &pix->pixelformat, 838 NULL, &pix->pixelformat,
@@ -887,8 +884,6 @@ static int fimc_capture_set_format(struct fimc_dev *fimc, struct v4l2_format *f)
887 struct fimc_fmt *s_fmt = NULL; 884 struct fimc_fmt *s_fmt = NULL;
888 int ret, i; 885 int ret, i;
889 886
890 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
891 return -EINVAL;
892 if (vb2_is_busy(&fimc->vid_cap.vbq)) 887 if (vb2_is_busy(&fimc->vid_cap.vbq))
893 return -EBUSY; 888 return -EBUSY;
894 889
@@ -924,10 +919,10 @@ static int fimc_capture_set_format(struct fimc_dev *fimc, struct v4l2_format *f)
924 pix->width = mf->width; 919 pix->width = mf->width;
925 pix->height = mf->height; 920 pix->height = mf->height;
926 } 921 }
922
927 fimc_adjust_mplane_format(ff->fmt, pix->width, pix->height, pix); 923 fimc_adjust_mplane_format(ff->fmt, pix->width, pix->height, pix);
928 for (i = 0; i < ff->fmt->colplanes; i++) 924 for (i = 0; i < ff->fmt->colplanes; i++)
929 ff->payload[i] = 925 ff->payload[i] = pix->plane_fmt[i].sizeimage;
930 (pix->width * pix->height * ff->fmt->depth[i]) / 8;
931 926
932 set_frame_bounds(ff, pix->width, pix->height); 927 set_frame_bounds(ff, pix->width, pix->height);
933 /* Reset the composition rectangle if not yet configured */ 928 /* Reset the composition rectangle if not yet configured */
@@ -1045,18 +1040,22 @@ static int fimc_cap_streamon(struct file *file, void *priv,
1045{ 1040{
1046 struct fimc_dev *fimc = video_drvdata(file); 1041 struct fimc_dev *fimc = video_drvdata(file);
1047 struct fimc_pipeline *p = &fimc->pipeline; 1042 struct fimc_pipeline *p = &fimc->pipeline;
1043 struct v4l2_subdev *sd = p->subdevs[IDX_SENSOR];
1048 int ret; 1044 int ret;
1049 1045
1050 if (fimc_capture_active(fimc)) 1046 if (fimc_capture_active(fimc))
1051 return -EBUSY; 1047 return -EBUSY;
1052 1048
1053 media_entity_pipeline_start(&p->subdevs[IDX_SENSOR]->entity, 1049 ret = media_entity_pipeline_start(&sd->entity, p->m_pipeline);
1054 p->m_pipeline); 1050 if (ret < 0)
1051 return ret;
1055 1052
1056 if (fimc->vid_cap.user_subdev_api) { 1053 if (fimc->vid_cap.user_subdev_api) {
1057 ret = fimc_pipeline_validate(fimc); 1054 ret = fimc_pipeline_validate(fimc);
1058 if (ret) 1055 if (ret < 0) {
1056 media_entity_pipeline_stop(&sd->entity);
1059 return ret; 1057 return ret;
1058 }
1060 } 1059 }
1061 return vb2_streamon(&fimc->vid_cap.vbq, type); 1060 return vb2_streamon(&fimc->vid_cap.vbq, type);
1062} 1061}
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 92fc5a20fb7..a4646ca1d56 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -153,7 +153,7 @@ static struct fimc_fmt fimc_formats[] = {
153 .colplanes = 2, 153 .colplanes = 2,
154 .flags = FMT_FLAGS_M2M, 154 .flags = FMT_FLAGS_M2M,
155 }, { 155 }, {
156 .name = "YUV 4:2:0 non-contiguous 2-planar, Y/CbCr", 156 .name = "YUV 4:2:0 non-contig. 2p, Y/CbCr",
157 .fourcc = V4L2_PIX_FMT_NV12M, 157 .fourcc = V4L2_PIX_FMT_NV12M,
158 .color = FIMC_FMT_YCBCR420, 158 .color = FIMC_FMT_YCBCR420,
159 .depth = { 8, 4 }, 159 .depth = { 8, 4 },
@@ -161,7 +161,7 @@ static struct fimc_fmt fimc_formats[] = {
161 .colplanes = 2, 161 .colplanes = 2,
162 .flags = FMT_FLAGS_M2M, 162 .flags = FMT_FLAGS_M2M,
163 }, { 163 }, {
164 .name = "YUV 4:2:0 non-contiguous 3-planar, Y/Cb/Cr", 164 .name = "YUV 4:2:0 non-contig. 3p, Y/Cb/Cr",
165 .fourcc = V4L2_PIX_FMT_YUV420M, 165 .fourcc = V4L2_PIX_FMT_YUV420M,
166 .color = FIMC_FMT_YCBCR420, 166 .color = FIMC_FMT_YCBCR420,
167 .depth = { 8, 2, 2 }, 167 .depth = { 8, 2, 2 },
@@ -169,7 +169,7 @@ static struct fimc_fmt fimc_formats[] = {
169 .colplanes = 3, 169 .colplanes = 3,
170 .flags = FMT_FLAGS_M2M, 170 .flags = FMT_FLAGS_M2M,
171 }, { 171 }, {
172 .name = "YUV 4:2:0 non-contiguous 2-planar, Y/CbCr, tiled", 172 .name = "YUV 4:2:0 non-contig. 2p, tiled",
173 .fourcc = V4L2_PIX_FMT_NV12MT, 173 .fourcc = V4L2_PIX_FMT_NV12MT,
174 .color = FIMC_FMT_YCBCR420, 174 .color = FIMC_FMT_YCBCR420,
175 .depth = { 8, 4 }, 175 .depth = { 8, 4 },
@@ -641,7 +641,7 @@ void fimc_ctrls_activate(struct fimc_ctx *ctx, bool active)
641 if (!ctrls->ready) 641 if (!ctrls->ready)
642 return; 642 return;
643 643
644 mutex_lock(&ctrls->handler.lock); 644 mutex_lock(ctrls->handler.lock);
645 v4l2_ctrl_activate(ctrls->rotate, active); 645 v4l2_ctrl_activate(ctrls->rotate, active);
646 v4l2_ctrl_activate(ctrls->hflip, active); 646 v4l2_ctrl_activate(ctrls->hflip, active);
647 v4l2_ctrl_activate(ctrls->vflip, active); 647 v4l2_ctrl_activate(ctrls->vflip, active);
@@ -660,7 +660,7 @@ void fimc_ctrls_activate(struct fimc_ctx *ctx, bool active)
660 ctx->hflip = 0; 660 ctx->hflip = 0;
661 ctx->vflip = 0; 661 ctx->vflip = 0;
662 } 662 }
663 mutex_unlock(&ctrls->handler.lock); 663 mutex_unlock(ctrls->handler.lock);
664} 664}
665 665
666/* Update maximum value of the alpha color control */ 666/* Update maximum value of the alpha color control */
@@ -741,8 +741,8 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
741 pix->width = width; 741 pix->width = width;
742 742
743 for (i = 0; i < pix->num_planes; ++i) { 743 for (i = 0; i < pix->num_planes; ++i) {
744 u32 bpl = pix->plane_fmt[i].bytesperline; 744 struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i];
745 u32 *sizeimage = &pix->plane_fmt[i].sizeimage; 745 u32 bpl = plane_fmt->bytesperline;
746 746
747 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width)) 747 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
748 bpl = pix->width; /* Planar */ 748 bpl = pix->width; /* Planar */
@@ -754,8 +754,9 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
754 if (i == 0) /* Same bytesperline for each plane. */ 754 if (i == 0) /* Same bytesperline for each plane. */
755 bytesperline = bpl; 755 bytesperline = bpl;
756 756
757 pix->plane_fmt[i].bytesperline = bytesperline; 757 plane_fmt->bytesperline = bytesperline;
758 *sizeimage = (pix->width * pix->height * fmt->depth[i]) / 8; 758 plane_fmt->sizeimage = max((pix->width * pix->height *
759 fmt->depth[i]) / 8, plane_fmt->sizeimage);
759 } 760 }
760} 761}
761 762
diff --git a/drivers/media/video/s5p-fimc/fimc-lite.c b/drivers/media/video/s5p-fimc/fimc-lite.c
index 400d701aef0..74ff310db30 100644
--- a/drivers/media/video/s5p-fimc/fimc-lite.c
+++ b/drivers/media/video/s5p-fimc/fimc-lite.c
@@ -451,34 +451,44 @@ static void fimc_lite_clear_event_counters(struct fimc_lite *fimc)
451static int fimc_lite_open(struct file *file) 451static int fimc_lite_open(struct file *file)
452{ 452{
453 struct fimc_lite *fimc = video_drvdata(file); 453 struct fimc_lite *fimc = video_drvdata(file);
454 int ret = v4l2_fh_open(file); 454 int ret;
455 455
456 if (ret) 456 if (mutex_lock_interruptible(&fimc->lock))
457 return ret; 457 return -ERESTARTSYS;
458 458
459 set_bit(ST_FLITE_IN_USE, &fimc->state); 459 set_bit(ST_FLITE_IN_USE, &fimc->state);
460 pm_runtime_get_sync(&fimc->pdev->dev); 460 ret = pm_runtime_get_sync(&fimc->pdev->dev);
461 if (ret < 0)
462 goto done;
461 463
462 if (++fimc->ref_count != 1 || fimc->out_path != FIMC_IO_DMA) 464 ret = v4l2_fh_open(file);
463 return ret; 465 if (ret < 0)
466 goto done;
464 467
465 ret = fimc_pipeline_initialize(&fimc->pipeline, &fimc->vfd->entity, 468 if (++fimc->ref_count == 1 && fimc->out_path == FIMC_IO_DMA) {
466 true); 469 ret = fimc_pipeline_initialize(&fimc->pipeline,
467 if (ret < 0) { 470 &fimc->vfd->entity, true);
468 v4l2_err(fimc->vfd, "Video pipeline initialization failed\n"); 471 if (ret < 0) {
469 pm_runtime_put_sync(&fimc->pdev->dev); 472 pm_runtime_put_sync(&fimc->pdev->dev);
470 fimc->ref_count--; 473 fimc->ref_count--;
471 v4l2_fh_release(file); 474 v4l2_fh_release(file);
472 clear_bit(ST_FLITE_IN_USE, &fimc->state); 475 clear_bit(ST_FLITE_IN_USE, &fimc->state);
473 } 476 }
474 477
475 fimc_lite_clear_event_counters(fimc); 478 fimc_lite_clear_event_counters(fimc);
479 }
480done:
481 mutex_unlock(&fimc->lock);
476 return ret; 482 return ret;
477} 483}
478 484
479static int fimc_lite_close(struct file *file) 485static int fimc_lite_close(struct file *file)
480{ 486{
481 struct fimc_lite *fimc = video_drvdata(file); 487 struct fimc_lite *fimc = video_drvdata(file);
488 int ret;
489
490 if (mutex_lock_interruptible(&fimc->lock))
491 return -ERESTARTSYS;
482 492
483 if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { 493 if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) {
484 clear_bit(ST_FLITE_IN_USE, &fimc->state); 494 clear_bit(ST_FLITE_IN_USE, &fimc->state);
@@ -492,20 +502,39 @@ static int fimc_lite_close(struct file *file)
492 if (fimc->ref_count == 0) 502 if (fimc->ref_count == 0)
493 vb2_queue_release(&fimc->vb_queue); 503 vb2_queue_release(&fimc->vb_queue);
494 504
495 return v4l2_fh_release(file); 505 ret = v4l2_fh_release(file);
506
507 mutex_unlock(&fimc->lock);
508 return ret;
496} 509}
497 510
498static unsigned int fimc_lite_poll(struct file *file, 511static unsigned int fimc_lite_poll(struct file *file,
499 struct poll_table_struct *wait) 512 struct poll_table_struct *wait)
500{ 513{
501 struct fimc_lite *fimc = video_drvdata(file); 514 struct fimc_lite *fimc = video_drvdata(file);
502 return vb2_poll(&fimc->vb_queue, file, wait); 515 int ret;
516
517 if (mutex_lock_interruptible(&fimc->lock))
518 return POLL_ERR;
519
520 ret = vb2_poll(&fimc->vb_queue, file, wait);
521 mutex_unlock(&fimc->lock);
522
523 return ret;
503} 524}
504 525
505static int fimc_lite_mmap(struct file *file, struct vm_area_struct *vma) 526static int fimc_lite_mmap(struct file *file, struct vm_area_struct *vma)
506{ 527{
507 struct fimc_lite *fimc = video_drvdata(file); 528 struct fimc_lite *fimc = video_drvdata(file);
508 return vb2_mmap(&fimc->vb_queue, vma); 529 int ret;
530
531 if (mutex_lock_interruptible(&fimc->lock))
532 return -ERESTARTSYS;
533
534 ret = vb2_mmap(&fimc->vb_queue, vma);
535 mutex_unlock(&fimc->lock);
536
537 return ret;
509} 538}
510 539
511static const struct v4l2_file_operations fimc_lite_fops = { 540static const struct v4l2_file_operations fimc_lite_fops = {
@@ -762,7 +791,9 @@ static int fimc_lite_streamon(struct file *file, void *priv,
762 if (fimc_lite_active(fimc)) 791 if (fimc_lite_active(fimc))
763 return -EBUSY; 792 return -EBUSY;
764 793
765 media_entity_pipeline_start(&sensor->entity, p->m_pipeline); 794 ret = media_entity_pipeline_start(&sensor->entity, p->m_pipeline);
795 if (ret < 0)
796 return ret;
766 797
767 ret = fimc_pipeline_validate(fimc); 798 ret = fimc_pipeline_validate(fimc);
768 if (ret) { 799 if (ret) {
@@ -1508,7 +1539,7 @@ static int fimc_lite_suspend(struct device *dev)
1508 return 0; 1539 return 0;
1509 1540
1510 ret = fimc_lite_stop_capture(fimc, suspend); 1541 ret = fimc_lite_stop_capture(fimc, suspend);
1511 if (ret) 1542 if (ret < 0 || !fimc_lite_active(fimc))
1512 return ret; 1543 return ret;
1513 1544
1514 return fimc_pipeline_shutdown(&fimc->pipeline); 1545 return fimc_pipeline_shutdown(&fimc->pipeline);
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c b/drivers/media/video/s5p-fimc/fimc-mdevice.c
index 6753c45631b..52cef486542 100644
--- a/drivers/media/video/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c
@@ -193,9 +193,13 @@ int __fimc_pipeline_shutdown(struct fimc_pipeline *p)
193 193
194int fimc_pipeline_shutdown(struct fimc_pipeline *p) 194int fimc_pipeline_shutdown(struct fimc_pipeline *p)
195{ 195{
196 struct media_entity *me = &p->subdevs[IDX_SENSOR]->entity; 196 struct media_entity *me;
197 int ret; 197 int ret;
198 198
199 if (!p || !p->subdevs[IDX_SENSOR])
200 return -EINVAL;
201
202 me = &p->subdevs[IDX_SENSOR]->entity;
199 mutex_lock(&me->parent->graph_mutex); 203 mutex_lock(&me->parent->graph_mutex);
200 ret = __fimc_pipeline_shutdown(p); 204 ret = __fimc_pipeline_shutdown(p);
201 mutex_unlock(&me->parent->graph_mutex); 205 mutex_unlock(&me->parent->graph_mutex);
@@ -498,12 +502,12 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd)
498 * @source: the source entity to create links to all fimc entities from 502 * @source: the source entity to create links to all fimc entities from
499 * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null 503 * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null
500 * @pad: the source entity pad index 504 * @pad: the source entity pad index
501 * @fimc_id: index of the fimc device for which link should be enabled 505 * @link_mask: bitmask of the fimc devices for which link should be enabled
502 */ 506 */
503static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, 507static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
504 struct media_entity *source, 508 struct media_entity *source,
505 struct v4l2_subdev *sensor, 509 struct v4l2_subdev *sensor,
506 int pad, int fimc_id) 510 int pad, int link_mask)
507{ 511{
508 struct fimc_sensor_info *s_info; 512 struct fimc_sensor_info *s_info;
509 struct media_entity *sink; 513 struct media_entity *sink;
@@ -520,7 +524,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
520 if (!fmd->fimc[i]->variant->has_cam_if) 524 if (!fmd->fimc[i]->variant->has_cam_if)
521 continue; 525 continue;
522 526
523 flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; 527 flags = ((1 << i) & link_mask) ? MEDIA_LNK_FL_ENABLED : 0;
524 528
525 sink = &fmd->fimc[i]->vid_cap.subdev.entity; 529 sink = &fmd->fimc[i]->vid_cap.subdev.entity;
526 ret = media_entity_create_link(source, pad, sink, 530 ret = media_entity_create_link(source, pad, sink,
@@ -552,7 +556,10 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
552 if (!fmd->fimc_lite[i]) 556 if (!fmd->fimc_lite[i])
553 continue; 557 continue;
554 558
555 flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; 559 if (link_mask & (1 << (i + FIMC_MAX_DEVS)))
560 flags = MEDIA_LNK_FL_ENABLED;
561 else
562 flags = 0;
556 563
557 sink = &fmd->fimc_lite[i]->subdev.entity; 564 sink = &fmd->fimc_lite[i]->subdev.entity;
558 ret = media_entity_create_link(source, pad, sink, 565 ret = media_entity_create_link(source, pad, sink,
@@ -614,9 +621,8 @@ static int fimc_md_create_links(struct fimc_md *fmd)
614 struct s5p_fimc_isp_info *pdata; 621 struct s5p_fimc_isp_info *pdata;
615 struct fimc_sensor_info *s_info; 622 struct fimc_sensor_info *s_info;
616 struct media_entity *source, *sink; 623 struct media_entity *source, *sink;
617 int i, pad, fimc_id = 0; 624 int i, pad, fimc_id = 0, ret = 0;
618 int ret = 0; 625 u32 flags, link_mask = 0;
619 u32 flags;
620 626
621 for (i = 0; i < fmd->num_sensors; i++) { 627 for (i = 0; i < fmd->num_sensors; i++) {
622 if (fmd->sensor[i].subdev == NULL) 628 if (fmd->sensor[i].subdev == NULL)
@@ -668,19 +674,20 @@ static int fimc_md_create_links(struct fimc_md *fmd)
668 if (source == NULL) 674 if (source == NULL)
669 continue; 675 continue;
670 676
677 link_mask = 1 << fimc_id++;
671 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, 678 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor,
672 pad, fimc_id++); 679 pad, link_mask);
673 } 680 }
674 681
675 fimc_id = 0;
676 for (i = 0; i < ARRAY_SIZE(fmd->csis); i++) { 682 for (i = 0; i < ARRAY_SIZE(fmd->csis); i++) {
677 if (fmd->csis[i].sd == NULL) 683 if (fmd->csis[i].sd == NULL)
678 continue; 684 continue;
679 source = &fmd->csis[i].sd->entity; 685 source = &fmd->csis[i].sd->entity;
680 pad = CSIS_PAD_SOURCE; 686 pad = CSIS_PAD_SOURCE;
681 687
688 link_mask = 1 << fimc_id++;
682 ret = __fimc_md_create_fimc_sink_links(fmd, source, NULL, 689 ret = __fimc_md_create_fimc_sink_links(fmd, source, NULL,
683 pad, fimc_id++); 690 pad, link_mask);
684 } 691 }
685 692
686 /* Create immutable links between each FIMC's subdev and video node */ 693 /* Create immutable links between each FIMC's subdev and video node */
@@ -734,8 +741,8 @@ static void fimc_md_put_clocks(struct fimc_md *fmd)
734} 741}
735 742
736static int __fimc_md_set_camclk(struct fimc_md *fmd, 743static int __fimc_md_set_camclk(struct fimc_md *fmd,
737 struct fimc_sensor_info *s_info, 744 struct fimc_sensor_info *s_info,
738 bool on) 745 bool on)
739{ 746{
740 struct s5p_fimc_isp_info *pdata = s_info->pdata; 747 struct s5p_fimc_isp_info *pdata = s_info->pdata;
741 struct fimc_camclk_info *camclk; 748 struct fimc_camclk_info *camclk;
@@ -744,12 +751,10 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
744 if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || fmd == NULL) 751 if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || fmd == NULL)
745 return -EINVAL; 752 return -EINVAL;
746 753
747 if (s_info->clk_on == on)
748 return 0;
749 camclk = &fmd->camclk[pdata->clk_id]; 754 camclk = &fmd->camclk[pdata->clk_id];
750 755
751 dbg("camclk %d, f: %lu, clk: %p, on: %d", 756 dbg("camclk %d, f: %lu, use_count: %d, on: %d",
752 pdata->clk_id, pdata->clk_frequency, camclk, on); 757 pdata->clk_id, pdata->clk_frequency, camclk->use_count, on);
753 758
754 if (on) { 759 if (on) {
755 if (camclk->use_count > 0 && 760 if (camclk->use_count > 0 &&
@@ -760,11 +765,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
760 clk_set_rate(camclk->clock, pdata->clk_frequency); 765 clk_set_rate(camclk->clock, pdata->clk_frequency);
761 camclk->frequency = pdata->clk_frequency; 766 camclk->frequency = pdata->clk_frequency;
762 ret = clk_enable(camclk->clock); 767 ret = clk_enable(camclk->clock);
768 dbg("Enabled camclk %d: f: %lu", pdata->clk_id,
769 clk_get_rate(camclk->clock));
763 } 770 }
764 s_info->clk_on = 1;
765 dbg("Enabled camclk %d: f: %lu", pdata->clk_id,
766 clk_get_rate(camclk->clock));
767
768 return ret; 771 return ret;
769 } 772 }
770 773
@@ -773,7 +776,6 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
773 776
774 if (--camclk->use_count == 0) { 777 if (--camclk->use_count == 0) {
775 clk_disable(camclk->clock); 778 clk_disable(camclk->clock);
776 s_info->clk_on = 0;
777 dbg("Disabled camclk %d", pdata->clk_id); 779 dbg("Disabled camclk %d", pdata->clk_id);
778 } 780 }
779 return ret; 781 return ret;
@@ -789,8 +791,6 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
789 * devices to which sensors can be attached, either directly or through 791 * devices to which sensors can be attached, either directly or through
790 * the MIPI CSI receiver. The clock is allowed here to be used by 792 * the MIPI CSI receiver. The clock is allowed here to be used by
791 * multiple sensors concurrently if they use same frequency. 793 * multiple sensors concurrently if they use same frequency.
792 * The per sensor subdev clk_on attribute helps to synchronize accesses
793 * to the sclk_cam clocks from the video and media device nodes.
794 * This function should only be called when the graph mutex is held. 794 * This function should only be called when the graph mutex is held.
795 */ 795 */
796int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) 796int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on)
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.h b/drivers/media/video/s5p-fimc/fimc-mdevice.h
index 3b8a3492a17..1f5dbaff544 100644
--- a/drivers/media/video/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/video/s5p-fimc/fimc-mdevice.h
@@ -47,7 +47,6 @@ struct fimc_camclk_info {
47 * @pdata: sensor's atrributes passed as media device's platform data 47 * @pdata: sensor's atrributes passed as media device's platform data
48 * @subdev: image sensor v4l2 subdev 48 * @subdev: image sensor v4l2 subdev
49 * @host: fimc device the sensor is currently linked to 49 * @host: fimc device the sensor is currently linked to
50 * @clk_on: sclk_cam clock's state associated with this subdev
51 * 50 *
52 * This data structure applies to image sensor and the writeback subdevs. 51 * This data structure applies to image sensor and the writeback subdevs.
53 */ 52 */
@@ -55,7 +54,6 @@ struct fimc_sensor_info {
55 struct s5p_fimc_isp_info *pdata; 54 struct s5p_fimc_isp_info *pdata;
56 struct v4l2_subdev *subdev; 55 struct v4l2_subdev *subdev;
57 struct fimc_dev *host; 56 struct fimc_dev *host;
58 bool clk_on;
59}; 57};
60 58
61/** 59/**
diff --git a/drivers/media/video/s5p-mfc/s5p_mfc_dec.c b/drivers/media/video/s5p-mfc/s5p_mfc_dec.c
index 4dd32fc8fd8..feea867f318 100644
--- a/drivers/media/video/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/video/s5p-mfc/s5p_mfc_dec.c
@@ -996,6 +996,7 @@ int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx)
996 996
997 for (i = 0; i < NUM_CTRLS; i++) { 997 for (i = 0; i < NUM_CTRLS; i++) {
998 if (IS_MFC51_PRIV(controls[i].id)) { 998 if (IS_MFC51_PRIV(controls[i].id)) {
999 memset(&cfg, 0, sizeof(struct v4l2_ctrl_config));
999 cfg.ops = &s5p_mfc_dec_ctrl_ops; 1000 cfg.ops = &s5p_mfc_dec_ctrl_ops;
1000 cfg.id = controls[i].id; 1001 cfg.id = controls[i].id;
1001 cfg.min = controls[i].minimum; 1002 cfg.min = controls[i].minimum;
diff --git a/drivers/media/video/s5p-mfc/s5p_mfc_enc.c b/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
index 03d83340e7f..158b78989b8 100644
--- a/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
@@ -1773,6 +1773,7 @@ int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)
1773 } 1773 }
1774 for (i = 0; i < NUM_CTRLS; i++) { 1774 for (i = 0; i < NUM_CTRLS; i++) {
1775 if (IS_MFC51_PRIV(controls[i].id)) { 1775 if (IS_MFC51_PRIV(controls[i].id)) {
1776 memset(&cfg, 0, sizeof(struct v4l2_ctrl_config));
1776 cfg.ops = &s5p_mfc_enc_ctrl_ops; 1777 cfg.ops = &s5p_mfc_enc_ctrl_ops;
1777 cfg.id = controls[i].id; 1778 cfg.id = controls[i].id;
1778 cfg.min = controls[i].minimum; 1779 cfg.min = controls[i].minimum;
diff --git a/drivers/media/video/smiapp/smiapp-core.c b/drivers/media/video/smiapp/smiapp-core.c
index e8c93c89265..9cf5bda35fb 100644
--- a/drivers/media/video/smiapp/smiapp-core.c
+++ b/drivers/media/video/smiapp/smiapp-core.c
@@ -31,6 +31,7 @@
31#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
34#include <linux/regulator/consumer.h> 35#include <linux/regulator/consumer.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
36#include <linux/v4l2-mediabus.h> 37#include <linux/v4l2-mediabus.h>
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 83dbb2ddff1..0cbada18f6f 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -681,6 +681,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
681 SET_VALID_IOCTL(ops, VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings); 681 SET_VALID_IOCTL(ops, VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings);
682 SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings); 682 SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings);
683 SET_VALID_IOCTL(ops, VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings); 683 SET_VALID_IOCTL(ops, VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings);
684 SET_VALID_IOCTL(ops, VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap);
684 /* yes, really vidioc_subscribe_event */ 685 /* yes, really vidioc_subscribe_event */
685 SET_VALID_IOCTL(ops, VIDIOC_DQEVENT, vidioc_subscribe_event); 686 SET_VALID_IOCTL(ops, VIDIOC_DQEVENT, vidioc_subscribe_event);
686 SET_VALID_IOCTL(ops, VIDIOC_SUBSCRIBE_EVENT, vidioc_subscribe_event); 687 SET_VALID_IOCTL(ops, VIDIOC_SUBSCRIBE_EVENT, vidioc_subscribe_event);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e129c820df7..92144ed1ad4 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -286,6 +286,7 @@ config TWL6040_CORE
286 depends on I2C=y && GENERIC_HARDIRQS 286 depends on I2C=y && GENERIC_HARDIRQS
287 select MFD_CORE 287 select MFD_CORE
288 select REGMAP_I2C 288 select REGMAP_I2C
289 select IRQ_DOMAIN
289 default n 290 default n
290 help 291 help
291 Say yes here if you want support for Texas Instruments TWL6040 audio 292 Say yes here if you want support for Texas Instruments TWL6040 audio
diff --git a/drivers/mfd/ab5500-core.h b/drivers/mfd/ab5500-core.h
deleted file mode 100644
index 63b30b17e4f..00000000000
--- a/drivers/mfd/ab5500-core.h
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * Copyright (C) 2011 ST-Ericsson
3 * License terms: GNU General Public License (GPL) version 2
4 * Shared definitions and data structures for the AB5500 MFD driver
5 */
6
7/* Read/write operation values. */
8#define AB5500_PERM_RD (0x01)
9#define AB5500_PERM_WR (0x02)
10
11/* Read/write permissions. */
12#define AB5500_PERM_RO (AB5500_PERM_RD)
13#define AB5500_PERM_RW (AB5500_PERM_RD | AB5500_PERM_WR)
14
15#define AB5500_MASK_BASE (0x60)
16#define AB5500_MASK_END (0x79)
17#define AB5500_CHIP_ID (0x20)
18
19/**
20 * struct ab5500_reg_range
21 * @first: the first address of the range
22 * @last: the last address of the range
23 * @perm: access permissions for the range
24 */
25struct ab5500_reg_range {
26 u8 first;
27 u8 last;
28 u8 perm;
29};
30
31/**
32 * struct ab5500_i2c_ranges
33 * @count: the number of ranges in the list
34 * @range: the list of register ranges
35 */
36struct ab5500_i2c_ranges {
37 u8 nranges;
38 u8 bankid;
39 const struct ab5500_reg_range *range;
40};
41
42/**
43 * struct ab5500_i2c_banks
44 * @count: the number of ranges in the list
45 * @range: the list of register ranges
46 */
47struct ab5500_i2c_banks {
48 u8 nbanks;
49 const struct ab5500_i2c_ranges *bank;
50};
51
52/**
53 * struct ab5500_bank
54 * @slave_addr: I2C slave_addr found in AB5500 specification
55 * @name: Documentation name of the bank. For reference
56 */
57struct ab5500_bank {
58 u8 slave_addr;
59 const char *name;
60};
61
62static const struct ab5500_bank bankinfo[AB5500_NUM_BANKS] = {
63 [AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP] = {
64 AB5500_ADDR_VIT_IO_I2C_CLK_TST_OTP, "VIT_IO_I2C_CLK_TST_OTP"},
65 [AB5500_BANK_VDDDIG_IO_I2C_CLK_TST] = {
66 AB5500_ADDR_VDDDIG_IO_I2C_CLK_TST, "VDDDIG_IO_I2C_CLK_TST"},
67 [AB5500_BANK_VDENC] = {AB5500_ADDR_VDENC, "VDENC"},
68 [AB5500_BANK_SIM_USBSIM] = {AB5500_ADDR_SIM_USBSIM, "SIM_USBSIM"},
69 [AB5500_BANK_LED] = {AB5500_ADDR_LED, "LED"},
70 [AB5500_BANK_ADC] = {AB5500_ADDR_ADC, "ADC"},
71 [AB5500_BANK_RTC] = {AB5500_ADDR_RTC, "RTC"},
72 [AB5500_BANK_STARTUP] = {AB5500_ADDR_STARTUP, "STARTUP"},
73 [AB5500_BANK_DBI_ECI] = {AB5500_ADDR_DBI_ECI, "DBI-ECI"},
74 [AB5500_BANK_CHG] = {AB5500_ADDR_CHG, "CHG"},
75 [AB5500_BANK_FG_BATTCOM_ACC] = {
76 AB5500_ADDR_FG_BATTCOM_ACC, "FG_BATCOM_ACC"},
77 [AB5500_BANK_USB] = {AB5500_ADDR_USB, "USB"},
78 [AB5500_BANK_IT] = {AB5500_ADDR_IT, "IT"},
79 [AB5500_BANK_VIBRA] = {AB5500_ADDR_VIBRA, "VIBRA"},
80 [AB5500_BANK_AUDIO_HEADSETUSB] = {
81 AB5500_ADDR_AUDIO_HEADSETUSB, "AUDIO_HEADSETUSB"},
82};
83
84int ab5500_get_register_interruptible_raw(struct ab5500 *ab, u8 bank, u8 reg,
85 u8 *value);
86int ab5500_mask_and_set_register_interruptible_raw(struct ab5500 *ab, u8 bank,
87 u8 reg, u8 bitmask, u8 bitvalues);
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index 3fcdab3eb8e..03df422feb7 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -49,10 +49,72 @@ static struct regmap_config mc13xxx_regmap_spi_config = {
49 .reg_bits = 7, 49 .reg_bits = 7,
50 .pad_bits = 1, 50 .pad_bits = 1,
51 .val_bits = 24, 51 .val_bits = 24,
52 .write_flag_mask = 0x80,
52 53
53 .max_register = MC13XXX_NUMREGS, 54 .max_register = MC13XXX_NUMREGS,
54 55
55 .cache_type = REGCACHE_NONE, 56 .cache_type = REGCACHE_NONE,
57 .use_single_rw = 1,
58};
59
60static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
61 void *val, size_t val_size)
62{
63 unsigned char w[4] = { *((unsigned char *) reg), 0, 0, 0};
64 unsigned char r[4];
65 unsigned char *p = val;
66 struct device *dev = context;
67 struct spi_device *spi = to_spi_device(dev);
68 struct spi_transfer t = {
69 .tx_buf = w,
70 .rx_buf = r,
71 .len = 4,
72 };
73
74 struct spi_message m;
75 int ret;
76
77 if (val_size != 3 || reg_size != 1)
78 return -ENOTSUPP;
79
80 spi_message_init(&m);
81 spi_message_add_tail(&t, &m);
82 ret = spi_sync(spi, &m);
83
84 memcpy(p, &r[1], 3);
85
86 return ret;
87}
88
89static int mc13xxx_spi_write(void *context, const void *data, size_t count)
90{
91 struct device *dev = context;
92 struct spi_device *spi = to_spi_device(dev);
93
94 if (count != 4)
95 return -ENOTSUPP;
96
97 return spi_write(spi, data, count);
98}
99
100/*
101 * We cannot use regmap-spi generic bus implementation here.
102 * The MC13783 chip will get corrupted if CS signal is deasserted
103 * and on i.Mx31 SoC (the target SoC for MC13783 PMIC) the SPI controller
104 * has the following errata (DSPhl22960):
105 * "The CSPI negates SS when the FIFO becomes empty with
106 * SSCTL= 0. Software cannot guarantee that the FIFO will not
107 * drain because of higher priority interrupts and the
108 * non-realtime characteristics of the operating system. As a
109 * result, the SS will negate before all of the data has been
110 * transferred to/from the peripheral."
111 * We workaround this by accessing the SPI controller with a
112 * single transfert.
113 */
114
115static struct regmap_bus regmap_mc13xxx_bus = {
116 .write = mc13xxx_spi_write,
117 .read = mc13xxx_spi_read,
56}; 118};
57 119
58static int mc13xxx_spi_probe(struct spi_device *spi) 120static int mc13xxx_spi_probe(struct spi_device *spi)
@@ -73,12 +135,13 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
73 135
74 dev_set_drvdata(&spi->dev, mc13xxx); 136 dev_set_drvdata(&spi->dev, mc13xxx);
75 spi->mode = SPI_MODE_0 | SPI_CS_HIGH; 137 spi->mode = SPI_MODE_0 | SPI_CS_HIGH;
76 spi->bits_per_word = 32;
77 138
78 mc13xxx->dev = &spi->dev; 139 mc13xxx->dev = &spi->dev;
79 mutex_init(&mc13xxx->lock); 140 mutex_init(&mc13xxx->lock);
80 141
81 mc13xxx->regmap = regmap_init_spi(spi, &mc13xxx_regmap_spi_config); 142 mc13xxx->regmap = regmap_init(&spi->dev, &regmap_mc13xxx_bus, &spi->dev,
143 &mc13xxx_regmap_spi_config);
144
82 if (IS_ERR(mc13xxx->regmap)) { 145 if (IS_ERR(mc13xxx->regmap)) {
83 ret = PTR_ERR(mc13xxx->regmap); 146 ret = PTR_ERR(mc13xxx->regmap);
84 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", 147 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n",
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 7e96bb22972..41088ecbb2a 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -25,6 +25,7 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/gpio.h>
28#include <plat/cpu.h> 29#include <plat/cpu.h>
29#include <plat/usb.h> 30#include <plat/usb.h>
30#include <linux/pm_runtime.h> 31#include <linux/pm_runtime.h>
@@ -500,8 +501,21 @@ static void omap_usbhs_init(struct device *dev)
500 dev_dbg(dev, "starting TI HSUSB Controller\n"); 501 dev_dbg(dev, "starting TI HSUSB Controller\n");
501 502
502 pm_runtime_get_sync(dev); 503 pm_runtime_get_sync(dev);
503 spin_lock_irqsave(&omap->lock, flags);
504 504
505 if (pdata->ehci_data->phy_reset) {
506 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
507 gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
508 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
509
510 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
511 gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
512 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
513
514 /* Hold the PHY in RESET for enough time till DIR is high */
515 udelay(10);
516 }
517
518 spin_lock_irqsave(&omap->lock, flags);
505 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); 519 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
506 dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); 520 dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
507 521
@@ -581,9 +595,39 @@ static void omap_usbhs_init(struct device *dev)
581 } 595 }
582 596
583 spin_unlock_irqrestore(&omap->lock, flags); 597 spin_unlock_irqrestore(&omap->lock, flags);
598
599 if (pdata->ehci_data->phy_reset) {
600 /* Hold the PHY in RESET for enough time till
601 * PHY is settled and ready
602 */
603 udelay(10);
604
605 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
606 gpio_set_value_cansleep
607 (pdata->ehci_data->reset_gpio_port[0], 1);
608
609 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
610 gpio_set_value_cansleep
611 (pdata->ehci_data->reset_gpio_port[1], 1);
612 }
613
584 pm_runtime_put_sync(dev); 614 pm_runtime_put_sync(dev);
585} 615}
586 616
617static void omap_usbhs_deinit(struct device *dev)
618{
619 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
620 struct usbhs_omap_platform_data *pdata = &omap->platdata;
621
622 if (pdata->ehci_data->phy_reset) {
623 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
624 gpio_free(pdata->ehci_data->reset_gpio_port[0]);
625
626 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
627 gpio_free(pdata->ehci_data->reset_gpio_port[1]);
628 }
629}
630
587 631
588/** 632/**
589 * usbhs_omap_probe - initialize TI-based HCDs 633 * usbhs_omap_probe - initialize TI-based HCDs
@@ -767,6 +811,7 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
767 goto end_probe; 811 goto end_probe;
768 812
769err_alloc: 813err_alloc:
814 omap_usbhs_deinit(&pdev->dev);
770 iounmap(omap->tll_base); 815 iounmap(omap->tll_base);
771 816
772err_tll: 817err_tll:
@@ -818,6 +863,7 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev)
818{ 863{
819 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); 864 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
820 865
866 omap_usbhs_deinit(&pdev->dev);
821 iounmap(omap->tll_base); 867 iounmap(omap->tll_base);
822 iounmap(omap->uhh_base); 868 iounmap(omap->uhh_base);
823 clk_put(omap->init_60m_fclk); 869 clk_put(omap->init_60m_fclk);
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 00c0aba7eba..c4a69f193a1 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -356,7 +356,14 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
356 } 356 }
357 } 357 }
358 358
359 ret = regmap_add_irq_chip(palmas->regmap[1], palmas->irq, 359 /* Change IRQ into clear on read mode for efficiency */
360 slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
361 addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL);
362 reg = PALMAS_INT_CTRL_INT_CLEAR;
363
364 regmap_write(palmas->regmap[slave], addr, reg);
365
366 ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
360 IRQF_ONESHOT | IRQF_TRIGGER_LOW, -1, &palmas_irq_chip, 367 IRQF_ONESHOT | IRQF_TRIGGER_LOW, -1, &palmas_irq_chip,
361 &palmas->irq_data); 368 &palmas->irq_data);
362 if (ret < 0) 369 if (ret < 0)
@@ -441,6 +448,9 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
441 goto err; 448 goto err;
442 } 449 }
443 450
451 children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata;
452 children[PALMAS_PMIC_ID].pdata_size = sizeof(*pdata->pmic_pdata);
453
444 ret = mfd_add_devices(palmas->dev, -1, 454 ret = mfd_add_devices(palmas->dev, -1,
445 children, ARRAY_SIZE(palmas_children), 455 children, ARRAY_SIZE(palmas_children),
446 NULL, regmap_irq_chip_get_base(palmas->irq_data)); 456 NULL, regmap_irq_chip_get_base(palmas->irq_data));
@@ -472,6 +482,7 @@ static const struct i2c_device_id palmas_i2c_id[] = {
472 { "twl6035", }, 482 { "twl6035", },
473 { "twl6037", }, 483 { "twl6037", },
474 { "tps65913", }, 484 { "tps65913", },
485 { /* end */ }
475}; 486};
476MODULE_DEVICE_TABLE(i2c, palmas_i2c_id); 487MODULE_DEVICE_TABLE(i2c, palmas_i2c_id);
477 488
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 7de13891e49..783fcd7365b 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -1147,7 +1147,7 @@ static int mei_pci_resume(struct device *device)
1147 err = request_threaded_irq(pdev->irq, 1147 err = request_threaded_irq(pdev->irq,
1148 NULL, 1148 NULL,
1149 mei_interrupt_thread_handler, 1149 mei_interrupt_thread_handler,
1150 0, mei_driver_name, dev); 1150 IRQF_ONESHOT, mei_driver_name, dev);
1151 else 1151 else
1152 err = request_threaded_irq(pdev->irq, 1152 err = request_threaded_irq(pdev->irq,
1153 mei_interrupt_quick_handler, 1153 mei_interrupt_quick_handler,
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 17bbacb1b4b..87b251ab6ec 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -452,9 +452,9 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
452 452
453 if (msg->activate_gru_mq_desc_gpa != 453 if (msg->activate_gru_mq_desc_gpa !=
454 part_uv->activate_gru_mq_desc_gpa) { 454 part_uv->activate_gru_mq_desc_gpa) {
455 spin_lock_irqsave(&part_uv->flags_lock, irq_flags); 455 spin_lock(&part_uv->flags_lock);
456 part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV; 456 part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;
457 spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags); 457 spin_unlock(&part_uv->flags_lock);
458 part_uv->activate_gru_mq_desc_gpa = 458 part_uv->activate_gru_mq_desc_gpa =
459 msg->activate_gru_mq_desc_gpa; 459 msg->activate_gru_mq_desc_gpa;
460 } 460 }
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
index f13e38decea..8f5dc08d659 100644
--- a/drivers/mmc/core/cd-gpio.c
+++ b/drivers/mmc/core/cd-gpio.c
@@ -50,8 +50,8 @@ int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio)
50 goto egpioreq; 50 goto egpioreq;
51 51
52 ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, 52 ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt,
53 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 53 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
54 cd->label, host); 54 IRQF_ONESHOT, cd->label, host);
55 if (ret < 0) 55 if (ret < 0)
56 goto eirqreq; 56 goto eirqreq;
57 57
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 258b203397a..4f4489aa6ba 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -717,10 +717,6 @@ static int mmc_select_powerclass(struct mmc_card *card,
717 card->ext_csd.generic_cmd6_time); 717 card->ext_csd.generic_cmd6_time);
718 } 718 }
719 719
720 if (err)
721 pr_err("%s: power class selection for ext_csd_bus_width %d"
722 " failed\n", mmc_hostname(card->host), bus_width);
723
724 return err; 720 return err;
725} 721}
726 722
@@ -1104,7 +1100,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1104 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; 1100 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
1105 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); 1101 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
1106 if (err) 1102 if (err)
1107 goto err; 1103 pr_warning("%s: power class selection to bus width %d"
1104 " failed\n", mmc_hostname(card->host),
1105 1 << bus_width);
1108 } 1106 }
1109 1107
1110 /* 1108 /*
@@ -1136,7 +1134,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1136 err = mmc_select_powerclass(card, ext_csd_bits[idx][0], 1134 err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
1137 ext_csd); 1135 ext_csd);
1138 if (err) 1136 if (err)
1139 goto err; 1137 pr_warning("%s: power class selection to "
1138 "bus width %d failed\n",
1139 mmc_hostname(card->host),
1140 1 << bus_width);
1140 1141
1141 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1142 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1142 EXT_CSD_BUS_WIDTH, 1143 EXT_CSD_BUS_WIDTH,
@@ -1164,7 +1165,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1164 err = mmc_select_powerclass(card, ext_csd_bits[idx][1], 1165 err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
1165 ext_csd); 1166 ext_csd);
1166 if (err) 1167 if (err)
1167 goto err; 1168 pr_warning("%s: power class selection to "
1169 "bus width %d ddr %d failed\n",
1170 mmc_hostname(card->host),
1171 1 << bus_width, ddr);
1168 1172
1169 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1173 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1170 EXT_CSD_BUS_WIDTH, 1174 EXT_CSD_BUS_WIDTH,
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index a05b7b444d4..a6cad5caba7 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -920,12 +920,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
920 */ 920 */
921 memset(chip->oob_poi, ~0, mtd->oobsize); 921 memset(chip->oob_poi, ~0, mtd->oobsize);
922 chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0]; 922 chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
923
924 read_page_swap_end(this, buf, mtd->writesize,
925 this->payload_virt, this->payload_phys,
926 nfc_geo->payload_size,
927 payload_virt, payload_phys);
928 } 923 }
924
925 read_page_swap_end(this, buf, mtd->writesize,
926 this->payload_virt, this->payload_phys,
927 nfc_geo->payload_size,
928 payload_virt, payload_phys);
929exit_nfc: 929exit_nfc:
930 return ret; 930 return ret;
931} 931}
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c58e6a93f44..6acc790c2fb 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -273,6 +273,26 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
273 273
274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL }; 274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
275 275
276static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
277{
278 int i;
279 u32 *t = trg;
280 const __iomem u32 *s = src;
281
282 for (i = 0; i < (size >> 2); i++)
283 *t++ = __raw_readl(s++);
284}
285
286static void memcpy32_toio(void __iomem *trg, const void *src, int size)
287{
288 int i;
289 u32 __iomem *t = trg;
290 const u32 *s = src;
291
292 for (i = 0; i < (size >> 2); i++)
293 __raw_writel(*s++, t++);
294}
295
276static int check_int_v3(struct mxc_nand_host *host) 296static int check_int_v3(struct mxc_nand_host *host)
277{ 297{
278 uint32_t tmp; 298 uint32_t tmp;
@@ -519,7 +539,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
519 539
520 wait_op_done(host, true); 540 wait_op_done(host, true);
521 541
522 memcpy_fromio(host->data_buf, host->main_area0, 16); 542 memcpy32_fromio(host->data_buf, host->main_area0, 16);
523} 543}
524 544
525/* Request the NANDFC to perform a read of the NAND device ID. */ 545/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +555,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
535 /* Wait for operation to complete */ 555 /* Wait for operation to complete */
536 wait_op_done(host, true); 556 wait_op_done(host, true);
537 557
538 memcpy_fromio(host->data_buf, host->main_area0, 16); 558 memcpy32_fromio(host->data_buf, host->main_area0, 16);
539 559
540 if (this->options & NAND_BUSWIDTH_16) { 560 if (this->options & NAND_BUSWIDTH_16) {
541 /* compress the ID info */ 561 /* compress the ID info */
@@ -797,16 +817,16 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
797 817
798 if (bfrom) { 818 if (bfrom) {
799 for (i = 0; i < n - 1; i++) 819 for (i = 0; i < n - 1; i++)
800 memcpy_fromio(d + i * j, s + i * t, j); 820 memcpy32_fromio(d + i * j, s + i * t, j);
801 821
802 /* the last section */ 822 /* the last section */
803 memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j); 823 memcpy32_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
804 } else { 824 } else {
805 for (i = 0; i < n - 1; i++) 825 for (i = 0; i < n - 1; i++)
806 memcpy_toio(&s[i * t], &d[i * j], j); 826 memcpy32_toio(&s[i * t], &d[i * j], j);
807 827
808 /* the last section */ 828 /* the last section */
809 memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j); 829 memcpy32_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
810 } 830 }
811} 831}
812 832
@@ -1070,7 +1090,8 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1070 1090
1071 host->devtype_data->send_page(mtd, NFC_OUTPUT); 1091 host->devtype_data->send_page(mtd, NFC_OUTPUT);
1072 1092
1073 memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize); 1093 memcpy32_fromio(host->data_buf, host->main_area0,
1094 mtd->writesize);
1074 copy_spare(mtd, true); 1095 copy_spare(mtd, true);
1075 break; 1096 break;
1076 1097
@@ -1086,7 +1107,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1086 break; 1107 break;
1087 1108
1088 case NAND_CMD_PAGEPROG: 1109 case NAND_CMD_PAGEPROG:
1089 memcpy_toio(host->main_area0, host->data_buf, mtd->writesize); 1110 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize);
1090 copy_spare(mtd, false); 1111 copy_spare(mtd, false);
1091 host->devtype_data->send_page(mtd, NFC_INPUT); 1112 host->devtype_data->send_page(mtd, NFC_INPUT);
1092 host->devtype_data->send_cmd(host, command, true); 1113 host->devtype_data->send_cmd(host, command, true);
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 6cc8fbfabb8..cf0cd314681 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -28,7 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
@@ -546,12 +546,6 @@ static char *get_partition_name(int i)
546 return kstrdup(buf, GFP_KERNEL); 546 return kstrdup(buf, GFP_KERNEL);
547} 547}
548 548
549static uint64_t divide(uint64_t n, uint32_t d)
550{
551 do_div(n, d);
552 return n;
553}
554
555/* 549/*
556 * Initialize the nandsim structure. 550 * Initialize the nandsim structure.
557 * 551 *
@@ -580,7 +574,7 @@ static int init_nandsim(struct mtd_info *mtd)
580 ns->geom.oobsz = mtd->oobsize; 574 ns->geom.oobsz = mtd->oobsize;
581 ns->geom.secsz = mtd->erasesize; 575 ns->geom.secsz = mtd->erasesize;
582 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; 576 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
583 ns->geom.pgnum = divide(ns->geom.totsz, ns->geom.pgsz); 577 ns->geom.pgnum = div_u64(ns->geom.totsz, ns->geom.pgsz);
584 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz; 578 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz;
585 ns->geom.secshift = ffs(ns->geom.secsz) - 1; 579 ns->geom.secshift = ffs(ns->geom.secsz) - 1;
586 ns->geom.pgshift = chip->page_shift; 580 ns->geom.pgshift = chip->page_shift;
@@ -921,7 +915,7 @@ static int setup_wear_reporting(struct mtd_info *mtd)
921 915
922 if (!rptwear) 916 if (!rptwear)
923 return 0; 917 return 0;
924 wear_eb_count = divide(mtd->size, mtd->erasesize); 918 wear_eb_count = div_u64(mtd->size, mtd->erasesize);
925 mem = wear_eb_count * sizeof(unsigned long); 919 mem = wear_eb_count * sizeof(unsigned long);
926 if (mem / sizeof(unsigned long) != wear_eb_count) { 920 if (mem / sizeof(unsigned long) != wear_eb_count) {
927 NS_ERR("Too many erase blocks for wear reporting\n"); 921 NS_ERR("Too many erase blocks for wear reporting\n");
diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c
index 3680aa251de..2cf084eb9d5 100644
--- a/drivers/net/bonding/bond_debugfs.c
+++ b/drivers/net/bonding/bond_debugfs.c
@@ -6,7 +6,7 @@
6#include "bonding.h" 6#include "bonding.h"
7#include "bond_alb.h" 7#include "bond_alb.h"
8 8
9#ifdef CONFIG_DEBUG_FS 9#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_NET_NS)
10 10
11#include <linux/debugfs.h> 11#include <linux/debugfs.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b9c2ae62166..2ee76993f05 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3227,6 +3227,12 @@ static int bond_master_netdev_event(unsigned long event,
3227 switch (event) { 3227 switch (event) {
3228 case NETDEV_CHANGENAME: 3228 case NETDEV_CHANGENAME:
3229 return bond_event_changename(event_bond); 3229 return bond_event_changename(event_bond);
3230 case NETDEV_UNREGISTER:
3231 bond_remove_proc_entry(event_bond);
3232 break;
3233 case NETDEV_REGISTER:
3234 bond_create_proc_entry(event_bond);
3235 break;
3230 default: 3236 default:
3231 break; 3237 break;
3232 } 3238 }
@@ -4411,8 +4417,6 @@ static void bond_uninit(struct net_device *bond_dev)
4411 4417
4412 bond_work_cancel_all(bond); 4418 bond_work_cancel_all(bond);
4413 4419
4414 bond_remove_proc_entry(bond);
4415
4416 bond_debug_unregister(bond); 4420 bond_debug_unregister(bond);
4417 4421
4418 __hw_addr_flush(&bond->mc_list); 4422 __hw_addr_flush(&bond->mc_list);
@@ -4814,7 +4818,6 @@ static int bond_init(struct net_device *bond_dev)
4814 4818
4815 bond_set_lockdep_class(bond_dev); 4819 bond_set_lockdep_class(bond_dev);
4816 4820
4817 bond_create_proc_entry(bond);
4818 list_add_tail(&bond->bond_list, &bn->dev_list); 4821 list_add_tail(&bond->bond_list, &bn->dev_list);
4819 4822
4820 bond_prepare_sysfs_group(bond); 4823 bond_prepare_sysfs_group(bond);
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 9cc15701101..1f78b63d5ef 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -261,7 +261,6 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
261 if ((phy_data & BMSR_LSTATUS) == 0) { 261 if ((phy_data & BMSR_LSTATUS) == 0) {
262 /* link down */ 262 /* link down */
263 netif_carrier_off(netdev); 263 netif_carrier_off(netdev);
264 netif_stop_queue(netdev);
265 hw->hibernate = true; 264 hw->hibernate = true;
266 if (atl1c_reset_mac(hw) != 0) 265 if (atl1c_reset_mac(hw) != 0)
267 if (netif_msg_hw(adapter)) 266 if (netif_msg_hw(adapter))
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 46b8b7d8163..d09c6b583d1 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -656,7 +656,7 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
656 dma_unmap_single(bp->sdev->dma_dev, mapping, 656 dma_unmap_single(bp->sdev->dma_dev, mapping,
657 RX_PKT_BUF_SZ, DMA_FROM_DEVICE); 657 RX_PKT_BUF_SZ, DMA_FROM_DEVICE);
658 dev_kfree_skb_any(skb); 658 dev_kfree_skb_any(skb);
659 skb = __netdev_alloc_skb(bp->dev, RX_PKT_BUF_SZ, GFP_ATOMIC|GFP_DMA); 659 skb = alloc_skb(RX_PKT_BUF_SZ, GFP_ATOMIC | GFP_DMA);
660 if (skb == NULL) 660 if (skb == NULL)
661 return -ENOMEM; 661 return -ENOMEM;
662 mapping = dma_map_single(bp->sdev->dma_dev, skb->data, 662 mapping = dma_map_single(bp->sdev->dma_dev, skb->data,
@@ -967,7 +967,7 @@ static netdev_tx_t b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
967 dma_unmap_single(bp->sdev->dma_dev, mapping, len, 967 dma_unmap_single(bp->sdev->dma_dev, mapping, len,
968 DMA_TO_DEVICE); 968 DMA_TO_DEVICE);
969 969
970 bounce_skb = __netdev_alloc_skb(dev, len, GFP_ATOMIC | GFP_DMA); 970 bounce_skb = alloc_skb(len, GFP_ATOMIC | GFP_DMA);
971 if (!bounce_skb) 971 if (!bounce_skb)
972 goto err_out; 972 goto err_out;
973 973
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index ac7b7448853..1fa4927a45b 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -5372,7 +5372,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
5372 int k, last; 5372 int k, last;
5373 5373
5374 if (skb == NULL) { 5374 if (skb == NULL) {
5375 j++; 5375 j = NEXT_TX_BD(j);
5376 continue; 5376 continue;
5377 } 5377 }
5378 5378
@@ -5384,8 +5384,8 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
5384 tx_buf->skb = NULL; 5384 tx_buf->skb = NULL;
5385 5385
5386 last = tx_buf->nr_frags; 5386 last = tx_buf->nr_frags;
5387 j++; 5387 j = NEXT_TX_BD(j);
5388 for (k = 0; k < last; k++, j++) { 5388 for (k = 0; k < last; k++, j = NEXT_TX_BD(j)) {
5389 tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)]; 5389 tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)];
5390 dma_unmap_page(&bp->pdev->dev, 5390 dma_unmap_page(&bp->pdev->dev,
5391 dma_unmap_addr(tx_buf, mapping), 5391 dma_unmap_addr(tx_buf, mapping),
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index c95e7b5e2b8..2c89d17cbb2 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -534,7 +534,8 @@ int cnic_unregister_driver(int ulp_type)
534 } 534 }
535 535
536 if (atomic_read(&ulp_ops->ref_count) != 0) 536 if (atomic_read(&ulp_ops->ref_count) != 0)
537 netdev_warn(dev->netdev, "Failed waiting for ref count to go to zero\n"); 537 pr_warn("%s: Failed waiting for ref count to go to zero\n",
538 __func__);
538 return 0; 539 return 0;
539 540
540out_unlock: 541out_unlock:
@@ -1053,12 +1054,13 @@ static int cnic_init_uio(struct cnic_dev *dev)
1053 1054
1054 uinfo = &udev->cnic_uinfo; 1055 uinfo = &udev->cnic_uinfo;
1055 1056
1056 uinfo->mem[0].addr = dev->netdev->base_addr; 1057 uinfo->mem[0].addr = pci_resource_start(dev->pcidev, 0);
1057 uinfo->mem[0].internal_addr = dev->regview; 1058 uinfo->mem[0].internal_addr = dev->regview;
1058 uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start;
1059 uinfo->mem[0].memtype = UIO_MEM_PHYS; 1059 uinfo->mem[0].memtype = UIO_MEM_PHYS;
1060 1060
1061 if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { 1061 if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
1062 uinfo->mem[0].size = MB_GET_CID_ADDR(TX_TSS_CID +
1063 TX_MAX_TSS_RINGS + 1);
1062 uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & 1064 uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen &
1063 PAGE_MASK; 1065 PAGE_MASK;
1064 if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) 1066 if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
@@ -1068,6 +1070,8 @@ static int cnic_init_uio(struct cnic_dev *dev)
1068 1070
1069 uinfo->name = "bnx2_cnic"; 1071 uinfo->name = "bnx2_cnic";
1070 } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { 1072 } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) {
1073 uinfo->mem[0].size = pci_resource_len(dev->pcidev, 0);
1074
1071 uinfo->mem[1].addr = (unsigned long) cp->bnx2x_def_status_blk & 1075 uinfo->mem[1].addr = (unsigned long) cp->bnx2x_def_status_blk &
1072 PAGE_MASK; 1076 PAGE_MASK;
1073 uinfo->mem[1].size = sizeof(*cp->bnx2x_def_status_blk); 1077 uinfo->mem[1].size = sizeof(*cp->bnx2x_def_status_blk);
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index f2db8fca46a..ab1d80ff079 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2063,10 +2063,9 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2063 return NETDEV_TX_OK; 2063 return NETDEV_TX_OK;
2064 } 2064 }
2065 2065
2066 /* Steal sock reference for processing TX time stamps */ 2066 if (skb->sk)
2067 swap(skb_new->sk, skb->sk); 2067 skb_set_owner_w(skb_new, skb->sk);
2068 swap(skb_new->destructor, skb->destructor); 2068 consume_skb(skb);
2069 kfree_skb(skb);
2070 skb = skb_new; 2069 skb = skb_new;
2071 } 2070 }
2072 2071
diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
index 36db4df09ae..1f063dcd8f8 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.c
+++ b/drivers/net/ethernet/intel/e1000e/82571.c
@@ -1572,6 +1572,9 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1572 ctrl = er32(CTRL); 1572 ctrl = er32(CTRL);
1573 status = er32(STATUS); 1573 status = er32(STATUS);
1574 rxcw = er32(RXCW); 1574 rxcw = er32(RXCW);
1575 /* SYNCH bit and IV bit are sticky */
1576 udelay(10);
1577 rxcw = er32(RXCW);
1575 1578
1576 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) { 1579 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1577 1580
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index 238ab2f8a5e..e3a7b07df62 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -325,24 +325,46 @@ static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
325 **/ 325 **/
326static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw) 326static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
327{ 327{
328 u16 phy_reg; 328 u16 phy_reg = 0;
329 u32 phy_id; 329 u32 phy_id = 0;
330 s32 ret_val;
331 u16 retry_count;
332
333 for (retry_count = 0; retry_count < 2; retry_count++) {
334 ret_val = e1e_rphy_locked(hw, PHY_ID1, &phy_reg);
335 if (ret_val || (phy_reg == 0xFFFF))
336 continue;
337 phy_id = (u32)(phy_reg << 16);
330 338
331 e1e_rphy_locked(hw, PHY_ID1, &phy_reg); 339 ret_val = e1e_rphy_locked(hw, PHY_ID2, &phy_reg);
332 phy_id = (u32)(phy_reg << 16); 340 if (ret_val || (phy_reg == 0xFFFF)) {
333 e1e_rphy_locked(hw, PHY_ID2, &phy_reg); 341 phy_id = 0;
334 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK); 342 continue;
343 }
344 phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
345 break;
346 }
335 347
336 if (hw->phy.id) { 348 if (hw->phy.id) {
337 if (hw->phy.id == phy_id) 349 if (hw->phy.id == phy_id)
338 return true; 350 return true;
339 } else { 351 } else if (phy_id) {
340 if ((phy_id != 0) && (phy_id != PHY_REVISION_MASK)) 352 hw->phy.id = phy_id;
341 hw->phy.id = phy_id; 353 hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
342 return true; 354 return true;
343 } 355 }
344 356
345 return false; 357 /*
358 * In case the PHY needs to be in mdio slow mode,
359 * set slow mode and try to get the PHY id again.
360 */
361 hw->phy.ops.release(hw);
362 ret_val = e1000_set_mdio_slow_mode_hv(hw);
363 if (!ret_val)
364 ret_val = e1000e_get_phy_id(hw);
365 hw->phy.ops.acquire(hw);
366
367 return !ret_val;
346} 368}
347 369
348/** 370/**
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 18ca3bcadf0..e242104ab47 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6647,6 +6647,11 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
6647 return -EINVAL; 6647 return -EINVAL;
6648 } 6648 }
6649 6649
6650 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
6651 e_err(drv, "Enable failed, SR-IOV enabled\n");
6652 return -EINVAL;
6653 }
6654
6650 /* Hardware supports up to 8 traffic classes */ 6655 /* Hardware supports up to 8 traffic classes */
6651 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs || 6656 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs ||
6652 (hw->mac.type == ixgbe_mac_82598EB && 6657 (hw->mac.type == ixgbe_mac_82598EB &&
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index f69ec4288b1..41e32257a4e 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -201,6 +201,9 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_adapter *adapter,
201 unsigned int i, eop, count = 0; 201 unsigned int i, eop, count = 0;
202 unsigned int total_bytes = 0, total_packets = 0; 202 unsigned int total_bytes = 0, total_packets = 0;
203 203
204 if (test_bit(__IXGBEVF_DOWN, &adapter->state))
205 return true;
206
204 i = tx_ring->next_to_clean; 207 i = tx_ring->next_to_clean;
205 eop = tx_ring->tx_buffer_info[i].next_to_watch; 208 eop = tx_ring->tx_buffer_info[i].next_to_watch;
206 eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop); 209 eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop);
@@ -969,8 +972,6 @@ static irqreturn_t ixgbevf_msix_clean_tx(int irq, void *data)
969 r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); 972 r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues);
970 for (i = 0; i < q_vector->txr_count; i++) { 973 for (i = 0; i < q_vector->txr_count; i++) {
971 tx_ring = &(adapter->tx_ring[r_idx]); 974 tx_ring = &(adapter->tx_ring[r_idx]);
972 tx_ring->total_bytes = 0;
973 tx_ring->total_packets = 0;
974 ixgbevf_clean_tx_irq(adapter, tx_ring); 975 ixgbevf_clean_tx_irq(adapter, tx_ring);
975 r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues, 976 r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues,
976 r_idx + 1); 977 r_idx + 1);
@@ -994,16 +995,6 @@ static irqreturn_t ixgbevf_msix_clean_rx(int irq, void *data)
994 struct ixgbe_hw *hw = &adapter->hw; 995 struct ixgbe_hw *hw = &adapter->hw;
995 struct ixgbevf_ring *rx_ring; 996 struct ixgbevf_ring *rx_ring;
996 int r_idx; 997 int r_idx;
997 int i;
998
999 r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues);
1000 for (i = 0; i < q_vector->rxr_count; i++) {
1001 rx_ring = &(adapter->rx_ring[r_idx]);
1002 rx_ring->total_bytes = 0;
1003 rx_ring->total_packets = 0;
1004 r_idx = find_next_bit(q_vector->rxr_idx, adapter->num_rx_queues,
1005 r_idx + 1);
1006 }
1007 998
1008 if (!q_vector->rxr_count) 999 if (!q_vector->rxr_count)
1009 return IRQ_HANDLED; 1000 return IRQ_HANDLED;
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
index fb8377da168..4b785e10f2e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
@@ -51,7 +51,7 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
51 desc->des3 = desc->des2 + BUF_SIZE_4KiB; 51 desc->des3 = desc->des2 + BUF_SIZE_4KiB;
52 priv->hw->desc->prepare_tx_desc(desc, 1, bmax, 52 priv->hw->desc->prepare_tx_desc(desc, 1, bmax,
53 csum); 53 csum);
54 54 wmb();
55 entry = (++priv->cur_tx) % txsize; 55 entry = (++priv->cur_tx) % txsize;
56 desc = priv->dma_tx + entry; 56 desc = priv->dma_tx + entry;
57 57
@@ -59,6 +59,7 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
59 len, DMA_TO_DEVICE); 59 len, DMA_TO_DEVICE);
60 desc->des3 = desc->des2 + BUF_SIZE_4KiB; 60 desc->des3 = desc->des2 + BUF_SIZE_4KiB;
61 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum); 61 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum);
62 wmb();
62 priv->hw->desc->set_tx_owner(desc); 63 priv->hw->desc->set_tx_owner(desc);
63 priv->tx_skbuff[entry] = NULL; 64 priv->tx_skbuff[entry] = NULL;
64 } else { 65 } else {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 51b3b68528e..ea3003edde1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1212,6 +1212,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
1212 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion); 1212 priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion);
1213 wmb(); 1213 wmb();
1214 priv->hw->desc->set_tx_owner(desc); 1214 priv->hw->desc->set_tx_owner(desc);
1215 wmb();
1215 } 1216 }
1216 1217
1217 /* Interrupt on completition only for the latest segment */ 1218 /* Interrupt on completition only for the latest segment */
@@ -1227,6 +1228,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
1227 1228
1228 /* To avoid raise condition */ 1229 /* To avoid raise condition */
1229 priv->hw->desc->set_tx_owner(first); 1230 priv->hw->desc->set_tx_owner(first);
1231 wmb();
1230 1232
1231 priv->cur_tx++; 1233 priv->cur_tx++;
1232 1234
@@ -1290,6 +1292,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
1290 } 1292 }
1291 wmb(); 1293 wmb();
1292 priv->hw->desc->set_rx_owner(p + entry); 1294 priv->hw->desc->set_rx_owner(p + entry);
1295 wmb();
1293 } 1296 }
1294} 1297}
1295 1298
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index ff16daf33ae..8d547670791 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -289,7 +289,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
289 } 289 }
290 lsr = STLSR; 290 lsr = STLSR;
291 } 291 }
292 si->last_oscr = OSCR; 292 si->last_oscr = readl_relaxed(OSCR);
293 break; 293 break;
294 294
295 case 0x04: /* Received Data Available */ 295 case 0x04: /* Received Data Available */
@@ -300,7 +300,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
300 dev->stats.rx_bytes++; 300 dev->stats.rx_bytes++;
301 async_unwrap_char(dev, &dev->stats, &si->rx_buff, STRBR); 301 async_unwrap_char(dev, &dev->stats, &si->rx_buff, STRBR);
302 } while (STLSR & LSR_DR); 302 } while (STLSR & LSR_DR);
303 si->last_oscr = OSCR; 303 si->last_oscr = readl_relaxed(OSCR);
304 break; 304 break;
305 305
306 case 0x02: /* Transmit FIFO Data Request */ 306 case 0x02: /* Transmit FIFO Data Request */
@@ -316,7 +316,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
316 /* We need to ensure that the transmitter has finished. */ 316 /* We need to ensure that the transmitter has finished. */
317 while ((STLSR & LSR_TEMT) == 0) 317 while ((STLSR & LSR_TEMT) == 0)
318 cpu_relax(); 318 cpu_relax();
319 si->last_oscr = OSCR; 319 si->last_oscr = readl_relaxed(OSCR);
320 320
321 /* 321 /*
322 * Ok, we've finished transmitting. Now enable 322 * Ok, we've finished transmitting. Now enable
@@ -370,7 +370,7 @@ static void pxa_irda_fir_dma_tx_irq(int channel, void *data)
370 370
371 while (ICSR1 & ICSR1_TBY) 371 while (ICSR1 & ICSR1_TBY)
372 cpu_relax(); 372 cpu_relax();
373 si->last_oscr = OSCR; 373 si->last_oscr = readl_relaxed(OSCR);
374 374
375 /* 375 /*
376 * HACK: It looks like the TBY bit is dropped too soon. 376 * HACK: It looks like the TBY bit is dropped too soon.
@@ -470,7 +470,7 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
470 470
471 /* stop RX DMA */ 471 /* stop RX DMA */
472 DCSR(si->rxdma) &= ~DCSR_RUN; 472 DCSR(si->rxdma) &= ~DCSR_RUN;
473 si->last_oscr = OSCR; 473 si->last_oscr = readl_relaxed(OSCR);
474 icsr0 = ICSR0; 474 icsr0 = ICSR0;
475 475
476 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) { 476 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) {
@@ -546,7 +546,7 @@ static int pxa_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
546 skb_copy_from_linear_data(skb, si->dma_tx_buff, skb->len); 546 skb_copy_from_linear_data(skb, si->dma_tx_buff, skb->len);
547 547
548 if (mtt) 548 if (mtt)
549 while ((unsigned)(OSCR - si->last_oscr)/4 < mtt) 549 while ((unsigned)(readl_relaxed(OSCR) - si->last_oscr)/4 < mtt)
550 cpu_relax(); 550 cpu_relax();
551 551
552 /* stop RX DMA, disable FICP */ 552 /* stop RX DMA, disable FICP */
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 39ea0674dcd..5c120189ec8 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -46,7 +46,13 @@ static int mdio_mux_read(struct mii_bus *bus, int phy_id, int regnum)
46 struct mdio_mux_parent_bus *pb = cb->parent; 46 struct mdio_mux_parent_bus *pb = cb->parent;
47 int r; 47 int r;
48 48
49 mutex_lock(&pb->mii_bus->mdio_lock); 49 /* In theory multiple mdio_mux could be stacked, thus creating
50 * more than a single level of nesting. But in practice,
51 * SINGLE_DEPTH_NESTING will cover the vast majority of use
52 * cases. We use it, instead of trying to handle the general
53 * case.
54 */
55 mutex_lock_nested(&pb->mii_bus->mdio_lock, SINGLE_DEPTH_NESTING);
50 r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data); 56 r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data);
51 if (r) 57 if (r)
52 goto out; 58 goto out;
@@ -71,7 +77,7 @@ static int mdio_mux_write(struct mii_bus *bus, int phy_id,
71 77
72 int r; 78 int r;
73 79
74 mutex_lock(&pb->mii_bus->mdio_lock); 80 mutex_lock_nested(&pb->mii_bus->mdio_lock, SINGLE_DEPTH_NESTING);
75 r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data); 81 r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data);
76 if (r) 82 if (r)
77 goto out; 83 goto out;
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index b01960fcfbc..a051cedd64b 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -346,6 +346,15 @@ static const struct driver_info qmi_wwan_force_int1 = {
346 .data = BIT(1), /* interface whitelist bitmap */ 346 .data = BIT(1), /* interface whitelist bitmap */
347}; 347};
348 348
349static const struct driver_info qmi_wwan_force_int2 = {
350 .description = "Qualcomm WWAN/QMI device",
351 .flags = FLAG_WWAN,
352 .bind = qmi_wwan_bind_shared,
353 .unbind = qmi_wwan_unbind_shared,
354 .manage_power = qmi_wwan_manage_power,
355 .data = BIT(2), /* interface whitelist bitmap */
356};
357
349static const struct driver_info qmi_wwan_force_int3 = { 358static const struct driver_info qmi_wwan_force_int3 = {
350 .description = "Qualcomm WWAN/QMI device", 359 .description = "Qualcomm WWAN/QMI device",
351 .flags = FLAG_WWAN, 360 .flags = FLAG_WWAN,
@@ -498,6 +507,15 @@ static const struct usb_device_id products[] = {
498 .bInterfaceProtocol = 0xff, 507 .bInterfaceProtocol = 0xff,
499 .driver_info = (unsigned long)&qmi_wwan_force_int4, 508 .driver_info = (unsigned long)&qmi_wwan_force_int4,
500 }, 509 },
510 { /* ZTE MF60 */
511 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
512 .idVendor = 0x19d2,
513 .idProduct = 0x1402,
514 .bInterfaceClass = 0xff,
515 .bInterfaceSubClass = 0xff,
516 .bInterfaceProtocol = 0xff,
517 .driver_info = (unsigned long)&qmi_wwan_force_int2,
518 },
501 { /* Sierra Wireless MC77xx in QMI mode */ 519 { /* Sierra Wireless MC77xx in QMI mode */
502 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, 520 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
503 .idVendor = 0x1199, 521 .idVendor = 0x1199,
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index f1f8bd09bd8..c8baf020c20 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -1072,7 +1072,7 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1072 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1072 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1073 /* create a bounce buffer in zone_dma on mapping failure. */ 1073 /* create a bounce buffer in zone_dma on mapping failure. */
1074 if (b43legacy_dma_mapping_error(ring, meta->dmaaddr, skb->len, 1)) { 1074 if (b43legacy_dma_mapping_error(ring, meta->dmaaddr, skb->len, 1)) {
1075 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); 1075 bounce_skb = alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA);
1076 if (!bounce_skb) { 1076 if (!bounce_skb) {
1077 ring->current_slot = old_top_slot; 1077 ring->current_slot = old_top_slot;
1078 ring->used_slots = old_used_slots; 1078 ring->used_slots = old_used_slots;
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 509301a5e7e..ff5d689e13f 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -3405,7 +3405,7 @@ il4965_remove_dynamic_key(struct il_priv *il,
3405 return 0; 3405 return 0;
3406 } 3406 }
3407 3407
3408 if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { 3408 if (il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_INVALID) {
3409 IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, 3409 IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx,
3410 key_flags); 3410 key_flags);
3411 spin_unlock_irqrestore(&il->sta_lock, flags); 3411 spin_unlock_irqrestore(&il->sta_lock, flags);
@@ -3420,7 +3420,7 @@ il4965_remove_dynamic_key(struct il_priv *il,
3420 memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); 3420 memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo));
3421 il->stations[sta_id].sta.key.key_flags = 3421 il->stations[sta_id].sta.key.key_flags =
3422 STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; 3422 STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
3423 il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; 3423 il->stations[sta_id].sta.key.key_offset = keyconf->hw_key_idx;
3424 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 3424 il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
3425 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 3425 il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
3426 3426
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index cbf2dc18341..5d4807c2b56 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -4767,14 +4767,12 @@ il_bg_watchdog(unsigned long data)
4767 return; 4767 return;
4768 4768
4769 /* monitor and check for other stuck queues */ 4769 /* monitor and check for other stuck queues */
4770 if (il_is_any_associated(il)) { 4770 for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) {
4771 for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { 4771 /* skip as we already checked the command queue */
4772 /* skip as we already checked the command queue */ 4772 if (cnt == il->cmd_queue)
4773 if (cnt == il->cmd_queue) 4773 continue;
4774 continue; 4774 if (il_check_stuck_queue(il, cnt))
4775 if (il_check_stuck_queue(il, cnt)) 4775 return;
4776 return;
4777 }
4778 } 4776 }
4779 4777
4780 mod_timer(&il->watchdog, 4778 mod_timer(&il->watchdog,
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index ce61b6fae1c..5c7fd185373 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -958,6 +958,7 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
958 case NL80211_HIDDEN_SSID_ZERO_CONTENTS: 958 case NL80211_HIDDEN_SSID_ZERO_CONTENTS:
959 /* firmware doesn't support this type of hidden SSID */ 959 /* firmware doesn't support this type of hidden SSID */
960 default: 960 default:
961 kfree(bss_cfg);
961 return -EINVAL; 962 return -EINVAL;
962 } 963 }
963 964
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index d357d1ed92f..74ecc33fdd9 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -436,8 +436,8 @@ void rt2x00usb_kick_queue(struct data_queue *queue)
436 case QID_RX: 436 case QID_RX:
437 if (!rt2x00queue_full(queue)) 437 if (!rt2x00queue_full(queue))
438 rt2x00queue_for_each_entry(queue, 438 rt2x00queue_for_each_entry(queue,
439 Q_INDEX_DONE,
440 Q_INDEX, 439 Q_INDEX,
440 Q_INDEX_DONE,
441 NULL, 441 NULL,
442 rt2x00usb_kick_rx_entry); 442 rt2x00usb_kick_rx_entry);
443 break; 443 break;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index eada3f4ef80..d9bfd49b193 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -511,22 +511,6 @@ out:
511} 511}
512EXPORT_SYMBOL(of_find_node_with_property); 512EXPORT_SYMBOL(of_find_node_with_property);
513 513
514static const struct of_device_id *of_match_compat(const struct of_device_id *matches,
515 const char *compat)
516{
517 while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
518 const char *cp = matches->compatible;
519 int len = strlen(cp);
520
521 if (len > 0 && of_compat_cmp(compat, cp, len) == 0)
522 return matches;
523
524 matches++;
525 }
526
527 return NULL;
528}
529
530/** 514/**
531 * of_match_node - Tell if an device_node has a matching of_match structure 515 * of_match_node - Tell if an device_node has a matching of_match structure
532 * @matches: array of of device match structures to search in 516 * @matches: array of of device match structures to search in
@@ -537,18 +521,9 @@ static const struct of_device_id *of_match_compat(const struct of_device_id *mat
537const struct of_device_id *of_match_node(const struct of_device_id *matches, 521const struct of_device_id *of_match_node(const struct of_device_id *matches,
538 const struct device_node *node) 522 const struct device_node *node)
539{ 523{
540 struct property *prop;
541 const char *cp;
542
543 if (!matches) 524 if (!matches)
544 return NULL; 525 return NULL;
545 526
546 of_property_for_each_string(node, "compatible", prop, cp) {
547 const struct of_device_id *match = of_match_compat(matches, cp);
548 if (match)
549 return match;
550 }
551
552 while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 527 while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
553 int match = 1; 528 int match = 1;
554 if (matches->name[0]) 529 if (matches->name[0])
@@ -557,7 +532,10 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
557 if (matches->type[0]) 532 if (matches->type[0])
558 match &= node->type 533 match &= node->type
559 && !strcmp(matches->type, node->type); 534 && !strcmp(matches->type, node->type);
560 if (match && !matches->compatible[0]) 535 if (matches->compatible[0])
536 match &= of_device_is_compatible(node,
537 matches->compatible);
538 if (match)
561 return matches; 539 return matches;
562 matches++; 540 matches++;
563 } 541 }
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 3132ea068d9..e44f8c2d239 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -317,10 +317,9 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l
317 for(; lookup->compatible != NULL; lookup++) { 317 for(; lookup->compatible != NULL; lookup++) {
318 if (!of_device_is_compatible(np, lookup->compatible)) 318 if (!of_device_is_compatible(np, lookup->compatible))
319 continue; 319 continue;
320 if (of_address_to_resource(np, 0, &res)) 320 if (!of_address_to_resource(np, 0, &res))
321 continue; 321 if (res.start != lookup->phys_addr)
322 if (res.start != lookup->phys_addr) 322 continue;
323 continue;
324 pr_debug("%s: devname=%s\n", np->full_name, lookup->name); 323 pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
325 return lookup; 324 return lookup;
326 } 325 }
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index bf0cee629b6..099f46cd8e8 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -748,6 +748,18 @@ static int pci_pm_suspend_noirq(struct device *dev)
748 748
749 pci_pm_set_unknown_state(pci_dev); 749 pci_pm_set_unknown_state(pci_dev);
750 750
751 /*
752 * Some BIOSes from ASUS have a bug: If a USB EHCI host controller's
753 * PCI COMMAND register isn't 0, the BIOS assumes that the controller
754 * hasn't been quiesced and tries to turn it off. If the controller
755 * is already in D3, this can hang or cause memory corruption.
756 *
757 * Since the value of the COMMAND register doesn't matter once the
758 * device has been suspended, we can safely set it to 0 here.
759 */
760 if (pci_dev->class == PCI_CLASS_SERIAL_USB_EHCI)
761 pci_write_config_word(pci_dev, PCI_COMMAND, 0);
762
751 return 0; 763 return 0;
752} 764}
753 765
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 77cb54a65cd..447e83472c0 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1744,11 +1744,6 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1744 if (target_state == PCI_POWER_ERROR) 1744 if (target_state == PCI_POWER_ERROR)
1745 return -EIO; 1745 return -EIO;
1746 1746
1747 /* Some devices mustn't be in D3 during system sleep */
1748 if (target_state == PCI_D3hot &&
1749 (dev->dev_flags & PCI_DEV_FLAGS_NO_D3_DURING_SLEEP))
1750 return 0;
1751
1752 pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev)); 1747 pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev));
1753 1748
1754 error = pci_set_power_state(dev, target_state); 1749 error = pci_set_power_state(dev, target_state);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 194b243a281..2a752167754 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2929,32 +2929,6 @@ static void __devinit disable_igfx_irq(struct pci_dev *dev)
2929DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq); 2929DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
2930DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq); 2930DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
2931 2931
2932/*
2933 * The Intel 6 Series/C200 Series chipset's EHCI controllers on many
2934 * ASUS motherboards will cause memory corruption or a system crash
2935 * if they are in D3 while the system is put into S3 sleep.
2936 */
2937static void __devinit asus_ehci_no_d3(struct pci_dev *dev)
2938{
2939 const char *sys_info;
2940 static const char good_Asus_board[] = "P8Z68-V";
2941
2942 if (dev->dev_flags & PCI_DEV_FLAGS_NO_D3_DURING_SLEEP)
2943 return;
2944 if (dev->subsystem_vendor != PCI_VENDOR_ID_ASUSTEK)
2945 return;
2946 sys_info = dmi_get_system_info(DMI_BOARD_NAME);
2947 if (sys_info && memcmp(sys_info, good_Asus_board,
2948 sizeof(good_Asus_board) - 1) == 0)
2949 return;
2950
2951 dev_info(&dev->dev, "broken D3 during system sleep on ASUS\n");
2952 dev->dev_flags |= PCI_DEV_FLAGS_NO_D3_DURING_SLEEP;
2953 device_set_wakeup_capable(&dev->dev, false);
2954}
2955DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1c26, asus_ehci_no_d3);
2956DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1c2d, asus_ehci_no_d3);
2957
2958static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 2932static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
2959 struct pci_fixup *end) 2933 struct pci_fixup *end)
2960{ 2934{
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c
index decb34730bc..56ab7391560 100644
--- a/drivers/pcmcia/sa1100_shannon.c
+++ b/drivers/pcmcia/sa1100_shannon.c
@@ -8,6 +8,7 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/device.h> 9#include <linux/device.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/io.h>
11 12
12#include <mach/hardware.h> 13#include <mach/hardware.h>
13#include <asm/mach-types.h> 14#include <asm/mach-types.h>
diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index dd6d93aa533..90c837f469a 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -474,7 +474,9 @@ static int __devinit imx_pinctrl_parse_groups(struct device_node *np,
474 grp->configs[j] = config & ~IMX_PAD_SION; 474 grp->configs[j] = config & ~IMX_PAD_SION;
475 } 475 }
476 476
477#ifdef DEBUG
477 IMX_PMX_DUMP(info, grp->pins, grp->mux_mode, grp->configs, grp->npins); 478 IMX_PMX_DUMP(info, grp->pins, grp->mux_mode, grp->configs, grp->npins);
479#endif
478 480
479 return 0; 481 return 0;
480} 482}
diff --git a/drivers/pinctrl/pinctrl-imx6q.c b/drivers/pinctrl/pinctrl-imx6q.c
index 7737d4d71a3..e9bf71fbedc 100644
--- a/drivers/pinctrl/pinctrl-imx6q.c
+++ b/drivers/pinctrl/pinctrl-imx6q.c
@@ -1950,6 +1950,8 @@ static struct imx_pin_reg imx6q_pin_regs[] = {
1950 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 5, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__GPIO_1_12 */ 1950 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 5, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__GPIO_1_12 */
1951 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 6, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__SJC_DONE */ 1951 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 6, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__SJC_DONE */
1952 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 7, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__ANATOP_TESTO_3 */ 1952 IMX_PIN_REG(MX6Q_PAD_SD2_DAT3, 0x0744, 0x035C, 7, 0x0000, 0), /* MX6Q_PAD_SD2_DAT3__ANATOP_TESTO_3 */
1953 IMX_PIN_REG(MX6Q_PAD_ENET_RX_ER, 0x04EC, 0x01D8, 0, 0x0000, 0), /* MX6Q_PAD_ENET_RX_ER__ANATOP_USBOTG_ID */
1954 IMX_PIN_REG(MX6Q_PAD_GPIO_1, 0x05F4, 0x0224, 3, 0x0000, 0), /* MX6Q_PAD_GPIO_1__ANATOP_USBOTG_ID */
1953}; 1955};
1954 1956
1955/* Pad names for the pinmux subsystem */ 1957/* Pad names for the pinmux subsystem */
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 4f20f8dd3d7..17f6dfd8dbf 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -694,10 +694,10 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
694static int __devinit ideapad_acpi_add(struct acpi_device *adevice) 694static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
695{ 695{
696 int ret, i; 696 int ret, i;
697 unsigned long cfg; 697 int cfg;
698 struct ideapad_private *priv; 698 struct ideapad_private *priv;
699 699
700 if (read_method_int(adevice->handle, "_CFG", (int *)&cfg)) 700 if (read_method_int(adevice->handle, "_CFG", &cfg))
701 return -ENODEV; 701 return -ENODEV;
702 702
703 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 703 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -721,7 +721,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
721 goto input_failed; 721 goto input_failed;
722 722
723 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { 723 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
724 if (test_bit(ideapad_rfk_data[i].cfgbit, &cfg)) 724 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
725 ideapad_register_rfkill(adevice, i); 725 ideapad_register_rfkill(adevice, i);
726 else 726 else
727 priv->rfk[i] = NULL; 727 priv->rfk[i] = NULL;
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 0ffdb3cde2b..9af4257d490 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -72,6 +72,7 @@
72#include <linux/string.h> 72#include <linux/string.h>
73#include <linux/tick.h> 73#include <linux/tick.h>
74#include <linux/timer.h> 74#include <linux/timer.h>
75#include <linux/dmi.h>
75#include <drm/i915_drm.h> 76#include <drm/i915_drm.h>
76#include <asm/msr.h> 77#include <asm/msr.h>
77#include <asm/processor.h> 78#include <asm/processor.h>
@@ -1485,6 +1486,24 @@ static DEFINE_PCI_DEVICE_TABLE(ips_id_table) = {
1485 1486
1486MODULE_DEVICE_TABLE(pci, ips_id_table); 1487MODULE_DEVICE_TABLE(pci, ips_id_table);
1487 1488
1489static int ips_blacklist_callback(const struct dmi_system_id *id)
1490{
1491 pr_info("Blacklisted intel_ips for %s\n", id->ident);
1492 return 1;
1493}
1494
1495static const struct dmi_system_id ips_blacklist[] = {
1496 {
1497 .callback = ips_blacklist_callback,
1498 .ident = "HP ProBook",
1499 .matches = {
1500 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1501 DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook"),
1502 },
1503 },
1504 { } /* terminating entry */
1505};
1506
1488static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id) 1507static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
1489{ 1508{
1490 u64 platform_info; 1509 u64 platform_info;
@@ -1494,6 +1513,9 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
1494 u16 htshi, trc, trc_required_mask; 1513 u16 htshi, trc, trc_required_mask;
1495 u8 tse; 1514 u8 tse;
1496 1515
1516 if (dmi_check_system(ips_blacklist))
1517 return -ENODEV;
1518
1497 ips = kzalloc(sizeof(struct ips_driver), GFP_KERNEL); 1519 ips = kzalloc(sizeof(struct ips_driver), GFP_KERNEL);
1498 if (!ips) 1520 if (!ips)
1499 return -ENOMEM; 1521 return -ENOMEM;
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 210d4ae547c..d456ff0c73b 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -973,7 +973,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
973 struct device_attribute *attr, 973 struct device_attribute *attr,
974 const char *buffer, size_t count) 974 const char *buffer, size_t count)
975{ 975{
976 unsigned long value = 0; 976 int value;
977 int ret = 0; 977 int ret = 0;
978 struct sony_nc_value *item = 978 struct sony_nc_value *item =
979 container_of(attr, struct sony_nc_value, devattr); 979 container_of(attr, struct sony_nc_value, devattr);
@@ -984,7 +984,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
984 if (count > 31) 984 if (count > 31)
985 return -EINVAL; 985 return -EINVAL;
986 986
987 if (kstrtoul(buffer, 10, &value)) 987 if (kstrtoint(buffer, 10, &value))
988 return -EINVAL; 988 return -EINVAL;
989 989
990 if (item->validate) 990 if (item->validate)
@@ -994,7 +994,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
994 return value; 994 return value;
995 995
996 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, 996 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset,
997 (int *)&value, NULL); 997 &value, NULL);
998 if (ret < 0) 998 if (ret < 0)
999 return -EIO; 999 return -EIO;
1000 1000
@@ -1010,6 +1010,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
1010struct sony_backlight_props { 1010struct sony_backlight_props {
1011 struct backlight_device *dev; 1011 struct backlight_device *dev;
1012 int handle; 1012 int handle;
1013 int cmd_base;
1013 u8 offset; 1014 u8 offset;
1014 u8 maxlvl; 1015 u8 maxlvl;
1015}; 1016};
@@ -1037,7 +1038,7 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd)
1037 struct sony_backlight_props *sdev = 1038 struct sony_backlight_props *sdev =
1038 (struct sony_backlight_props *)bl_get_data(bd); 1039 (struct sony_backlight_props *)bl_get_data(bd);
1039 1040
1040 sony_call_snc_handle(sdev->handle, 0x0200, &result); 1041 sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result);
1041 1042
1042 return (result & 0xff) - sdev->offset; 1043 return (result & 0xff) - sdev->offset;
1043} 1044}
@@ -1049,7 +1050,8 @@ static int sony_nc_update_status_ng(struct backlight_device *bd)
1049 (struct sony_backlight_props *)bl_get_data(bd); 1050 (struct sony_backlight_props *)bl_get_data(bd);
1050 1051
1051 value = bd->props.brightness + sdev->offset; 1052 value = bd->props.brightness + sdev->offset;
1052 if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result)) 1053 if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10),
1054 &result))
1053 return -EIO; 1055 return -EIO;
1054 1056
1055 return value; 1057 return value;
@@ -1172,6 +1174,11 @@ static int sony_nc_hotkeys_decode(u32 event, unsigned int handle)
1172/* 1174/*
1173 * ACPI callbacks 1175 * ACPI callbacks
1174 */ 1176 */
1177enum event_types {
1178 HOTKEY = 1,
1179 KILLSWITCH,
1180 GFX_SWITCH
1181};
1175static void sony_nc_notify(struct acpi_device *device, u32 event) 1182static void sony_nc_notify(struct acpi_device *device, u32 event)
1176{ 1183{
1177 u32 real_ev = event; 1184 u32 real_ev = event;
@@ -1196,7 +1203,7 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
1196 /* hotkey event */ 1203 /* hotkey event */
1197 case 0x0100: 1204 case 0x0100:
1198 case 0x0127: 1205 case 0x0127:
1199 ev_type = 1; 1206 ev_type = HOTKEY;
1200 real_ev = sony_nc_hotkeys_decode(event, handle); 1207 real_ev = sony_nc_hotkeys_decode(event, handle);
1201 1208
1202 if (real_ev > 0) 1209 if (real_ev > 0)
@@ -1216,7 +1223,7 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
1216 * update the rfkill device status when the 1223 * update the rfkill device status when the
1217 * switch is moved. 1224 * switch is moved.
1218 */ 1225 */
1219 ev_type = 2; 1226 ev_type = KILLSWITCH;
1220 sony_call_snc_handle(handle, 0x0100, &result); 1227 sony_call_snc_handle(handle, 0x0100, &result);
1221 real_ev = result & 0x03; 1228 real_ev = result & 0x03;
1222 1229
@@ -1226,6 +1233,24 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
1226 1233
1227 break; 1234 break;
1228 1235
1236 case 0x0128:
1237 case 0x0146:
1238 /* Hybrid GFX switching */
1239 sony_call_snc_handle(handle, 0x0000, &result);
1240 dprintk("GFX switch event received (reason: %s)\n",
1241 (result & 0x01) ?
1242 "switch change" : "unknown");
1243
1244 /* verify the switch state
1245 * 1: discrete GFX
1246 * 0: integrated GFX
1247 */
1248 sony_call_snc_handle(handle, 0x0100, &result);
1249
1250 ev_type = GFX_SWITCH;
1251 real_ev = result & 0xff;
1252 break;
1253
1229 default: 1254 default:
1230 dprintk("Unknown event 0x%x for handle 0x%x\n", 1255 dprintk("Unknown event 0x%x for handle 0x%x\n",
1231 event, handle); 1256 event, handle);
@@ -1238,7 +1263,7 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
1238 1263
1239 } else { 1264 } else {
1240 /* old style event */ 1265 /* old style event */
1241 ev_type = 1; 1266 ev_type = HOTKEY;
1242 sony_laptop_report_input_event(real_ev); 1267 sony_laptop_report_input_event(real_ev);
1243 } 1268 }
1244 1269
@@ -1893,32 +1918,33 @@ static ssize_t sony_nc_battery_care_limit_store(struct device *dev,
1893 * bits 4,5: store the limit into the EC 1918 * bits 4,5: store the limit into the EC
1894 * bits 6,7: store the limit into the battery 1919 * bits 6,7: store the limit into the battery
1895 */ 1920 */
1921 cmd = 0;
1896 1922
1897 /* 1923 if (value > 0) {
1898 * handle 0x0115 should allow storing on battery too; 1924 if (value <= 50)
1899 * handle 0x0136 same as 0x0115 + health status; 1925 cmd = 0x20;
1900 * handle 0x013f, same as 0x0136 but no storing on the battery
1901 *
1902 * Store only inside the EC for now, regardless the handle number
1903 */
1904 if (value == 0)
1905 /* disable limits */
1906 cmd = 0x0;
1907 1926
1908 else if (value <= 50) 1927 else if (value <= 80)
1909 cmd = 0x21; 1928 cmd = 0x10;
1910 1929
1911 else if (value <= 80) 1930 else if (value <= 100)
1912 cmd = 0x11; 1931 cmd = 0x30;
1913 1932
1914 else if (value <= 100) 1933 else
1915 cmd = 0x31; 1934 return -EINVAL;
1916 1935
1917 else 1936 /*
1918 return -EINVAL; 1937 * handle 0x0115 should allow storing on battery too;
1938 * handle 0x0136 same as 0x0115 + health status;
1939 * handle 0x013f, same as 0x0136 but no storing on the battery
1940 */
1941 if (bcare_ctl->handle != 0x013f)
1942 cmd = cmd | (cmd << 2);
1919 1943
1920 if (sony_call_snc_handle(bcare_ctl->handle, (cmd << 0x10) | 0x0100, 1944 cmd = (cmd | 0x1) << 0x10;
1921 &result)) 1945 }
1946
1947 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result))
1922 return -EIO; 1948 return -EIO;
1923 1949
1924 return count; 1950 return count;
@@ -2113,7 +2139,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
2113 struct device_attribute *attr, char *buffer) 2139 struct device_attribute *attr, char *buffer)
2114{ 2140{
2115 ssize_t count = 0; 2141 ssize_t count = 0;
2116 unsigned int mode = sony_nc_thermal_mode_get(); 2142 int mode = sony_nc_thermal_mode_get();
2117 2143
2118 if (mode < 0) 2144 if (mode < 0)
2119 return mode; 2145 return mode;
@@ -2472,6 +2498,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2472{ 2498{
2473 u64 offset; 2499 u64 offset;
2474 int i; 2500 int i;
2501 int lvl_table_len = 0;
2475 u8 min = 0xff, max = 0x00; 2502 u8 min = 0xff, max = 0x00;
2476 unsigned char buffer[32] = { 0 }; 2503 unsigned char buffer[32] = { 0 };
2477 2504
@@ -2480,8 +2507,6 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2480 props->maxlvl = 0xff; 2507 props->maxlvl = 0xff;
2481 2508
2482 offset = sony_find_snc_handle(handle); 2509 offset = sony_find_snc_handle(handle);
2483 if (offset < 0)
2484 return;
2485 2510
2486 /* try to read the boundaries from ACPI tables, if we fail the above 2511 /* try to read the boundaries from ACPI tables, if we fail the above
2487 * defaults should be reasonable 2512 * defaults should be reasonable
@@ -2491,11 +2516,21 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2491 if (i < 0) 2516 if (i < 0)
2492 return; 2517 return;
2493 2518
2519 switch (handle) {
2520 case 0x012f:
2521 case 0x0137:
2522 lvl_table_len = 9;
2523 break;
2524 case 0x143:
2525 lvl_table_len = 16;
2526 break;
2527 }
2528
2494 /* the buffer lists brightness levels available, brightness levels are 2529 /* the buffer lists brightness levels available, brightness levels are
2495 * from position 0 to 8 in the array, other values are used by ALS 2530 * from position 0 to 8 in the array, other values are used by ALS
2496 * control. 2531 * control.
2497 */ 2532 */
2498 for (i = 0; i < 9 && i < ARRAY_SIZE(buffer); i++) { 2533 for (i = 0; i < lvl_table_len && i < ARRAY_SIZE(buffer); i++) {
2499 2534
2500 dprintk("Brightness level: %d\n", buffer[i]); 2535 dprintk("Brightness level: %d\n", buffer[i]);
2501 2536
@@ -2520,16 +2555,24 @@ static void sony_nc_backlight_setup(void)
2520 const struct backlight_ops *ops = NULL; 2555 const struct backlight_ops *ops = NULL;
2521 struct backlight_properties props; 2556 struct backlight_properties props;
2522 2557
2523 if (sony_find_snc_handle(0x12f) != -1) { 2558 if (sony_find_snc_handle(0x12f) >= 0) {
2524 ops = &sony_backlight_ng_ops; 2559 ops = &sony_backlight_ng_ops;
2560 sony_bl_props.cmd_base = 0x0100;
2525 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props); 2561 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props);
2526 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2562 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2527 2563
2528 } else if (sony_find_snc_handle(0x137) != -1) { 2564 } else if (sony_find_snc_handle(0x137) >= 0) {
2529 ops = &sony_backlight_ng_ops; 2565 ops = &sony_backlight_ng_ops;
2566 sony_bl_props.cmd_base = 0x0100;
2530 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props); 2567 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props);
2531 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2568 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2532 2569
2570 } else if (sony_find_snc_handle(0x143) >= 0) {
2571 ops = &sony_backlight_ng_ops;
2572 sony_bl_props.cmd_base = 0x3000;
2573 sony_nc_backlight_ng_read_limits(0x143, &sony_bl_props);
2574 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2575
2533 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 2576 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
2534 &unused))) { 2577 &unused))) {
2535 ops = &sony_backlight_ops; 2578 ops = &sony_backlight_ops;
@@ -2597,6 +2640,12 @@ static int sony_nc_add(struct acpi_device *device)
2597 } 2640 }
2598 } 2641 }
2599 2642
2643 result = sony_laptop_setup_input(device);
2644 if (result) {
2645 pr_err("Unable to create input devices\n");
2646 goto outplatform;
2647 }
2648
2600 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", 2649 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON",
2601 &handle))) { 2650 &handle))) {
2602 int arg = 1; 2651 int arg = 1;
@@ -2614,12 +2663,6 @@ static int sony_nc_add(struct acpi_device *device)
2614 } 2663 }
2615 2664
2616 /* setup input devices and helper fifo */ 2665 /* setup input devices and helper fifo */
2617 result = sony_laptop_setup_input(device);
2618 if (result) {
2619 pr_err("Unable to create input devices\n");
2620 goto outsnc;
2621 }
2622
2623 if (acpi_video_backlight_support()) { 2666 if (acpi_video_backlight_support()) {
2624 pr_info("brightness ignored, must be controlled by ACPI video driver\n"); 2667 pr_info("brightness ignored, must be controlled by ACPI video driver\n");
2625 } else { 2668 } else {
@@ -2667,22 +2710,21 @@ static int sony_nc_add(struct acpi_device *device)
2667 2710
2668 return 0; 2711 return 0;
2669 2712
2670 out_sysfs: 2713out_sysfs:
2671 for (item = sony_nc_values; item->name; ++item) { 2714 for (item = sony_nc_values; item->name; ++item) {
2672 device_remove_file(&sony_pf_device->dev, &item->devattr); 2715 device_remove_file(&sony_pf_device->dev, &item->devattr);
2673 } 2716 }
2674 sony_nc_backlight_cleanup(); 2717 sony_nc_backlight_cleanup();
2675
2676 sony_laptop_remove_input();
2677
2678 outsnc:
2679 sony_nc_function_cleanup(sony_pf_device); 2718 sony_nc_function_cleanup(sony_pf_device);
2680 sony_nc_handles_cleanup(sony_pf_device); 2719 sony_nc_handles_cleanup(sony_pf_device);
2681 2720
2682 outpresent: 2721outplatform:
2722 sony_laptop_remove_input();
2723
2724outpresent:
2683 sony_pf_remove(); 2725 sony_pf_remove();
2684 2726
2685 outwalk: 2727outwalk:
2686 sony_nc_rfkill_cleanup(); 2728 sony_nc_rfkill_cleanup();
2687 return result; 2729 return result;
2688} 2730}
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 09a737c868b..8b4b3829d9e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2519,9 +2519,12 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
2519{ 2519{
2520 struct regulator_dev *rdev = regulator->rdev; 2520 struct regulator_dev *rdev = regulator->rdev;
2521 struct regulator *consumer; 2521 struct regulator *consumer;
2522 int ret, output_uV, input_uV, total_uA_load = 0; 2522 int ret, output_uV, input_uV = 0, total_uA_load = 0;
2523 unsigned int mode; 2523 unsigned int mode;
2524 2524
2525 if (rdev->supply)
2526 input_uV = regulator_get_voltage(rdev->supply);
2527
2525 mutex_lock(&rdev->mutex); 2528 mutex_lock(&rdev->mutex);
2526 2529
2527 /* 2530 /*
@@ -2554,10 +2557,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
2554 goto out; 2557 goto out;
2555 } 2558 }
2556 2559
2557 /* get input voltage */ 2560 /* No supply? Use constraint voltage */
2558 input_uV = 0;
2559 if (rdev->supply)
2560 input_uV = regulator_get_voltage(rdev->supply);
2561 if (input_uV <= 0) 2561 if (input_uV <= 0)
2562 input_uV = rdev->constraints->input_uV; 2562 input_uV = rdev->constraints->input_uV;
2563 if (input_uV <= 0) { 2563 if (input_uV <= 0) {
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 24d880e78ec..f8d818abf98 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -4,9 +4,11 @@ menu "Remoteproc drivers (EXPERIMENTAL)"
4config REMOTEPROC 4config REMOTEPROC
5 tristate 5 tristate
6 depends on EXPERIMENTAL 6 depends on EXPERIMENTAL
7 select FW_CONFIG
7 8
8config OMAP_REMOTEPROC 9config OMAP_REMOTEPROC
9 tristate "OMAP remoteproc support" 10 tristate "OMAP remoteproc support"
11 depends on EXPERIMENTAL
10 depends on ARCH_OMAP4 12 depends on ARCH_OMAP4
11 depends on OMAP_IOMMU 13 depends on OMAP_IOMMU
12 select REMOTEPROC 14 select REMOTEPROC
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 75506ec2840..f56c8ba3a86 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -188,6 +188,26 @@ static int rpmsg_uevent(struct device *dev, struct kobj_uevent_env *env)
188 rpdev->id.name); 188 rpdev->id.name);
189} 189}
190 190
191/**
192 * __ept_release() - deallocate an rpmsg endpoint
193 * @kref: the ept's reference count
194 *
195 * This function deallocates an ept, and is invoked when its @kref refcount
196 * drops to zero.
197 *
198 * Never invoke this function directly!
199 */
200static void __ept_release(struct kref *kref)
201{
202 struct rpmsg_endpoint *ept = container_of(kref, struct rpmsg_endpoint,
203 refcount);
204 /*
205 * At this point no one holds a reference to ept anymore,
206 * so we can directly free it
207 */
208 kfree(ept);
209}
210
191/* for more info, see below documentation of rpmsg_create_ept() */ 211/* for more info, see below documentation of rpmsg_create_ept() */
192static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp, 212static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
193 struct rpmsg_channel *rpdev, rpmsg_rx_cb_t cb, 213 struct rpmsg_channel *rpdev, rpmsg_rx_cb_t cb,
@@ -206,6 +226,9 @@ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
206 return NULL; 226 return NULL;
207 } 227 }
208 228
229 kref_init(&ept->refcount);
230 mutex_init(&ept->cb_lock);
231
209 ept->rpdev = rpdev; 232 ept->rpdev = rpdev;
210 ept->cb = cb; 233 ept->cb = cb;
211 ept->priv = priv; 234 ept->priv = priv;
@@ -238,7 +261,7 @@ rem_idr:
238 idr_remove(&vrp->endpoints, request); 261 idr_remove(&vrp->endpoints, request);
239free_ept: 262free_ept:
240 mutex_unlock(&vrp->endpoints_lock); 263 mutex_unlock(&vrp->endpoints_lock);
241 kfree(ept); 264 kref_put(&ept->refcount, __ept_release);
242 return NULL; 265 return NULL;
243} 266}
244 267
@@ -302,11 +325,17 @@ EXPORT_SYMBOL(rpmsg_create_ept);
302static void 325static void
303__rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept) 326__rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept)
304{ 327{
328 /* make sure new inbound messages can't find this ept anymore */
305 mutex_lock(&vrp->endpoints_lock); 329 mutex_lock(&vrp->endpoints_lock);
306 idr_remove(&vrp->endpoints, ept->addr); 330 idr_remove(&vrp->endpoints, ept->addr);
307 mutex_unlock(&vrp->endpoints_lock); 331 mutex_unlock(&vrp->endpoints_lock);
308 332
309 kfree(ept); 333 /* make sure in-flight inbound messages won't invoke cb anymore */
334 mutex_lock(&ept->cb_lock);
335 ept->cb = NULL;
336 mutex_unlock(&ept->cb_lock);
337
338 kref_put(&ept->refcount, __ept_release);
310} 339}
311 340
312/** 341/**
@@ -790,12 +819,28 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
790 819
791 /* use the dst addr to fetch the callback of the appropriate user */ 820 /* use the dst addr to fetch the callback of the appropriate user */
792 mutex_lock(&vrp->endpoints_lock); 821 mutex_lock(&vrp->endpoints_lock);
822
793 ept = idr_find(&vrp->endpoints, msg->dst); 823 ept = idr_find(&vrp->endpoints, msg->dst);
824
825 /* let's make sure no one deallocates ept while we use it */
826 if (ept)
827 kref_get(&ept->refcount);
828
794 mutex_unlock(&vrp->endpoints_lock); 829 mutex_unlock(&vrp->endpoints_lock);
795 830
796 if (ept && ept->cb) 831 if (ept) {
797 ept->cb(ept->rpdev, msg->data, msg->len, ept->priv, msg->src); 832 /* make sure ept->cb doesn't go away while we use it */
798 else 833 mutex_lock(&ept->cb_lock);
834
835 if (ept->cb)
836 ept->cb(ept->rpdev, msg->data, msg->len, ept->priv,
837 msg->src);
838
839 mutex_unlock(&ept->cb_lock);
840
841 /* farewell, ept, we don't need you anymore */
842 kref_put(&ept->refcount, __ept_release);
843 } else
799 dev_warn(dev, "msg received with no recepient\n"); 844 dev_warn(dev, "msg received with no recepient\n");
800 845
801 /* publish the real size of the buffer */ 846 /* publish the real size of the buffer */
@@ -1040,7 +1085,7 @@ static int __init rpmsg_init(void)
1040 1085
1041 return ret; 1086 return ret;
1042} 1087}
1043module_init(rpmsg_init); 1088subsys_initcall(rpmsg_init);
1044 1089
1045static void __exit rpmsg_fini(void) 1090static void __exit rpmsg_fini(void)
1046{ 1091{
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 4bcf9ca2818..370889d0489 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -17,6 +17,7 @@
17#include <linux/mfd/abx500.h> 17#include <linux/mfd/abx500.h>
18#include <linux/mfd/abx500/ab8500.h> 18#include <linux/mfd/abx500/ab8500.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/of.h>
20 21
21#define AB8500_RTC_SOFF_STAT_REG 0x00 22#define AB8500_RTC_SOFF_STAT_REG 0x00
22#define AB8500_RTC_CC_CONF_REG 0x01 23#define AB8500_RTC_CC_CONF_REG 0x01
@@ -422,7 +423,7 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
422 } 423 }
423 424
424 err = request_threaded_irq(irq, NULL, rtc_alarm_handler, 425 err = request_threaded_irq(irq, NULL, rtc_alarm_handler,
425 IRQF_NO_SUSPEND, "ab8500-rtc", rtc); 426 IRQF_NO_SUSPEND | IRQF_ONESHOT, "ab8500-rtc", rtc);
426 if (err < 0) { 427 if (err < 0) {
427 rtc_device_unregister(rtc); 428 rtc_device_unregister(rtc);
428 return err; 429 return err;
@@ -430,7 +431,6 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
430 431
431 platform_set_drvdata(pdev, rtc); 432 platform_set_drvdata(pdev, rtc);
432 433
433
434 err = ab8500_sysfs_rtc_register(&pdev->dev); 434 err = ab8500_sysfs_rtc_register(&pdev->dev);
435 if (err) { 435 if (err) {
436 dev_err(&pdev->dev, "sysfs RTC failed to register\n"); 436 dev_err(&pdev->dev, "sysfs RTC failed to register\n");
@@ -454,10 +454,16 @@ static int __devexit ab8500_rtc_remove(struct platform_device *pdev)
454 return 0; 454 return 0;
455} 455}
456 456
457static const struct of_device_id ab8500_rtc_match[] = {
458 { .compatible = "stericsson,ab8500-rtc", },
459 {}
460};
461
457static struct platform_driver ab8500_rtc_driver = { 462static struct platform_driver ab8500_rtc_driver = {
458 .driver = { 463 .driver = {
459 .name = "ab8500-rtc", 464 .name = "ab8500-rtc",
460 .owner = THIS_MODULE, 465 .owner = THIS_MODULE,
466 .of_match_table = ab8500_rtc_match,
461 }, 467 },
462 .probe = ab8500_rtc_probe, 468 .probe = ab8500_rtc_probe,
463 .remove = __devexit_p(ab8500_rtc_remove), 469 .remove = __devexit_p(ab8500_rtc_remove),
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 5e1d64ee522..e3e50d69baf 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -202,10 +202,11 @@ static irqreturn_t mxc_rtc_interrupt(int irq, void *dev_id)
202 struct platform_device *pdev = dev_id; 202 struct platform_device *pdev = dev_id;
203 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 203 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
204 void __iomem *ioaddr = pdata->ioaddr; 204 void __iomem *ioaddr = pdata->ioaddr;
205 unsigned long flags;
205 u32 status; 206 u32 status;
206 u32 events = 0; 207 u32 events = 0;
207 208
208 spin_lock_irq(&pdata->rtc->irq_lock); 209 spin_lock_irqsave(&pdata->rtc->irq_lock, flags);
209 status = readw(ioaddr + RTC_RTCISR) & readw(ioaddr + RTC_RTCIENR); 210 status = readw(ioaddr + RTC_RTCISR) & readw(ioaddr + RTC_RTCIENR);
210 /* clear interrupt sources */ 211 /* clear interrupt sources */
211 writew(status, ioaddr + RTC_RTCISR); 212 writew(status, ioaddr + RTC_RTCISR);
@@ -224,7 +225,7 @@ static irqreturn_t mxc_rtc_interrupt(int irq, void *dev_id)
224 events |= (RTC_PF | RTC_IRQF); 225 events |= (RTC_PF | RTC_IRQF);
225 226
226 rtc_update_irq(pdata->rtc, 1, events); 227 rtc_update_irq(pdata->rtc, 1, events);
227 spin_unlock_irq(&pdata->rtc->irq_lock); 228 spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
228 229
229 return IRQ_HANDLED; 230 return IRQ_HANDLED;
230} 231}
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 1f76320e545..e2785479113 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -458,12 +458,12 @@ static int __devexit spear_rtc_remove(struct platform_device *pdev)
458 clk_disable(config->clk); 458 clk_disable(config->clk);
459 clk_put(config->clk); 459 clk_put(config->clk);
460 iounmap(config->ioaddr); 460 iounmap(config->ioaddr);
461 kfree(config);
462 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 461 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
463 if (res) 462 if (res)
464 release_mem_region(res->start, resource_size(res)); 463 release_mem_region(res->start, resource_size(res));
465 platform_set_drvdata(pdev, NULL); 464 platform_set_drvdata(pdev, NULL);
466 rtc_device_unregister(config->rtc); 465 rtc_device_unregister(config->rtc);
466 kfree(config);
467 467
468 return 0; 468 return 0;
469} 469}
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 258abeabf62..c5d06fe83bb 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -510,7 +510,7 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
510 } 510 }
511 511
512 ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt, 512 ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt,
513 IRQF_TRIGGER_RISING, 513 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
514 dev_name(&rtc->dev), rtc); 514 dev_name(&rtc->dev), rtc);
515 if (ret < 0) { 515 if (ret < 0) {
516 dev_err(&pdev->dev, "IRQ is not free.\n"); 516 dev_err(&pdev->dev, "IRQ is not free.\n");
diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 532d212b6b2..393e7ce8e95 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -201,7 +201,7 @@ static void asd_get_response_tasklet(struct asd_ascb *ascb,
201 201
202 if (SAS_STATUS_BUF_SIZE >= sizeof(*resp)) { 202 if (SAS_STATUS_BUF_SIZE >= sizeof(*resp)) {
203 resp->frame_len = le16_to_cpu(*(__le16 *)(r+6)); 203 resp->frame_len = le16_to_cpu(*(__le16 *)(r+6));
204 memcpy(&resp->ending_fis[0], r+16, 24); 204 memcpy(&resp->ending_fis[0], r+16, ATA_RESP_FIS_SIZE);
205 ts->buf_valid_size = sizeof(*resp); 205 ts->buf_valid_size = sizeof(*resp);
206 } 206 }
207 } 207 }
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 0c53c28dc3d..7e77cf62029 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -350,6 +350,7 @@ struct bnx2i_hba {
350 struct pci_dev *pcidev; 350 struct pci_dev *pcidev;
351 struct net_device *netdev; 351 struct net_device *netdev;
352 void __iomem *regview; 352 void __iomem *regview;
353 resource_size_t reg_base;
353 354
354 u32 age; 355 u32 age;
355 unsigned long cnic_dev_type; 356 unsigned long cnic_dev_type;
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ece47e50228..86a12b48e47 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2724,7 +2724,6 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
2724 goto arm_cq; 2724 goto arm_cq;
2725 } 2725 }
2726 2726
2727 reg_base = ep->hba->netdev->base_addr;
2728 if ((test_bit(BNX2I_NX2_DEV_5709, &ep->hba->cnic_dev_type)) && 2727 if ((test_bit(BNX2I_NX2_DEV_5709, &ep->hba->cnic_dev_type)) &&
2729 (ep->hba->mail_queue_access == BNX2I_MQ_BIN_MODE)) { 2728 (ep->hba->mail_queue_access == BNX2I_MQ_BIN_MODE)) {
2730 config2 = REG_RD(ep->hba, BNX2_MQ_CONFIG2); 2729 config2 = REG_RD(ep->hba, BNX2_MQ_CONFIG2);
@@ -2740,7 +2739,7 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
2740 /* 5709 device in normal node and 5706/5708 devices */ 2739 /* 5709 device in normal node and 5706/5708 devices */
2741 reg_off = CTX_OFFSET + (MB_KERNEL_CTX_SIZE * cid_num); 2740 reg_off = CTX_OFFSET + (MB_KERNEL_CTX_SIZE * cid_num);
2742 2741
2743 ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 2742 ep->qp.ctx_base = ioremap_nocache(ep->hba->reg_base + reg_off,
2744 MB_KERNEL_CTX_SIZE); 2743 MB_KERNEL_CTX_SIZE);
2745 if (!ep->qp.ctx_base) 2744 if (!ep->qp.ctx_base)
2746 return -ENOMEM; 2745 return -ENOMEM;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f8d516b5316..621538b8b54 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -811,13 +811,13 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
811 bnx2i_identify_device(hba); 811 bnx2i_identify_device(hba);
812 bnx2i_setup_host_queue_size(hba, shost); 812 bnx2i_setup_host_queue_size(hba, shost);
813 813
814 hba->reg_base = pci_resource_start(hba->pcidev, 0);
814 if (test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) { 815 if (test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) {
815 hba->regview = ioremap_nocache(hba->netdev->base_addr, 816 hba->regview = pci_iomap(hba->pcidev, 0, BNX2_MQ_CONFIG2);
816 BNX2_MQ_CONFIG2);
817 if (!hba->regview) 817 if (!hba->regview)
818 goto ioreg_map_err; 818 goto ioreg_map_err;
819 } else if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) { 819 } else if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
820 hba->regview = ioremap_nocache(hba->netdev->base_addr, 4096); 820 hba->regview = pci_iomap(hba->pcidev, 0, 4096);
821 if (!hba->regview) 821 if (!hba->regview)
822 goto ioreg_map_err; 822 goto ioreg_map_err;
823 } 823 }
@@ -884,7 +884,7 @@ cid_que_err:
884 bnx2i_free_mp_bdt(hba); 884 bnx2i_free_mp_bdt(hba);
885mp_bdt_mem_err: 885mp_bdt_mem_err:
886 if (hba->regview) { 886 if (hba->regview) {
887 iounmap(hba->regview); 887 pci_iounmap(hba->pcidev, hba->regview);
888 hba->regview = NULL; 888 hba->regview = NULL;
889 } 889 }
890ioreg_map_err: 890ioreg_map_err:
@@ -910,7 +910,7 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
910 pci_dev_put(hba->pcidev); 910 pci_dev_put(hba->pcidev);
911 911
912 if (hba->regview) { 912 if (hba->regview) {
913 iounmap(hba->regview); 913 pci_iounmap(hba->pcidev, hba->regview);
914 hba->regview = NULL; 914 hba->regview = NULL;
915 } 915 }
916 bnx2i_free_mp_bdt(hba); 916 bnx2i_free_mp_bdt(hba);
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 441d88ad99a..d109cc3a17b 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -139,12 +139,12 @@ static void sas_ata_task_done(struct sas_task *task)
139 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD || 139 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD ||
140 ((stat->stat == SAM_STAT_CHECK_CONDITION && 140 ((stat->stat == SAM_STAT_CHECK_CONDITION &&
141 dev->sata_dev.command_set == ATAPI_COMMAND_SET))) { 141 dev->sata_dev.command_set == ATAPI_COMMAND_SET))) {
142 ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf); 142 memcpy(dev->sata_dev.fis, resp->ending_fis, ATA_RESP_FIS_SIZE);
143 143
144 if (!link->sactive) { 144 if (!link->sactive) {
145 qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command); 145 qc->err_mask |= ac_err_mask(dev->sata_dev.fis[2]);
146 } else { 146 } else {
147 link->eh_info.err_mask |= ac_err_mask(dev->sata_dev.tf.command); 147 link->eh_info.err_mask |= ac_err_mask(dev->sata_dev.fis[2]);
148 if (unlikely(link->eh_info.err_mask)) 148 if (unlikely(link->eh_info.err_mask))
149 qc->flags |= ATA_QCFLAG_FAILED; 149 qc->flags |= ATA_QCFLAG_FAILED;
150 } 150 }
@@ -161,8 +161,8 @@ static void sas_ata_task_done(struct sas_task *task)
161 qc->flags |= ATA_QCFLAG_FAILED; 161 qc->flags |= ATA_QCFLAG_FAILED;
162 } 162 }
163 163
164 dev->sata_dev.tf.feature = 0x04; /* status err */ 164 dev->sata_dev.fis[3] = 0x04; /* status err */
165 dev->sata_dev.tf.command = ATA_ERR; 165 dev->sata_dev.fis[2] = ATA_ERR;
166 } 166 }
167 } 167 }
168 168
@@ -269,7 +269,7 @@ static bool sas_ata_qc_fill_rtf(struct ata_queued_cmd *qc)
269{ 269{
270 struct domain_device *dev = qc->ap->private_data; 270 struct domain_device *dev = qc->ap->private_data;
271 271
272 memcpy(&qc->result_tf, &dev->sata_dev.tf, sizeof(qc->result_tf)); 272 ata_tf_from_fis(dev->sata_dev.fis, &qc->result_tf);
273 return true; 273 return true;
274} 274}
275 275
diff --git a/drivers/scsi/scsi_wait_scan.c b/drivers/scsi/scsi_wait_scan.c
index ae781487461..07273453887 100644
--- a/drivers/scsi/scsi_wait_scan.c
+++ b/drivers/scsi/scsi_wait_scan.c
@@ -22,11 +22,6 @@ static int __init wait_scan_init(void)
22 * and might not yet have reached the scsi async scanning 22 * and might not yet have reached the scsi async scanning
23 */ 23 */
24 wait_for_device_probe(); 24 wait_for_device_probe();
25 /*
26 * and then we wait for the actual asynchronous scsi scan
27 * to finish.
28 */
29 scsi_complete_async_scans();
30 return 0; 25 return 0;
31} 26}
32 27
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 9888693a18f..664f6e775d0 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1095,7 +1095,7 @@ int target_emulate_write_same(struct se_cmd *cmd)
1095 if (num_blocks != 0) 1095 if (num_blocks != 0)
1096 range = num_blocks; 1096 range = num_blocks;
1097 else 1097 else
1098 range = (dev->transport->get_blocks(dev) - lba); 1098 range = (dev->transport->get_blocks(dev) - lba) + 1;
1099 1099
1100 pr_debug("WRITE_SAME UNMAP: LBA: %llu Range: %llu\n", 1100 pr_debug("WRITE_SAME UNMAP: LBA: %llu Range: %llu\n",
1101 (unsigned long long)lba, (unsigned long long)range); 1101 (unsigned long long)lba, (unsigned long long)range);
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 85564998500..a1bcd927a9e 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -2031,7 +2031,7 @@ static int __core_scsi3_write_aptpl_to_file(
2031 if (IS_ERR(file) || !file || !file->f_dentry) { 2031 if (IS_ERR(file) || !file || !file->f_dentry) {
2032 pr_err("filp_open(%s) for APTPL metadata" 2032 pr_err("filp_open(%s) for APTPL metadata"
2033 " failed\n", path); 2033 " failed\n", path);
2034 return (PTR_ERR(file) < 0 ? PTR_ERR(file) : -ENOENT); 2034 return IS_ERR(file) ? PTR_ERR(file) : -ENOENT;
2035 } 2035 }
2036 2036
2037 iov[0].iov_base = &buf[0]; 2037 iov[0].iov_base = &buf[0];
@@ -3818,7 +3818,7 @@ int target_scsi3_emulate_pr_out(struct se_cmd *cmd)
3818 " SPC-2 reservation is held, returning" 3818 " SPC-2 reservation is held, returning"
3819 " RESERVATION_CONFLICT\n"); 3819 " RESERVATION_CONFLICT\n");
3820 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; 3820 cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
3821 ret = EINVAL; 3821 ret = -EINVAL;
3822 goto out; 3822 goto out;
3823 } 3823 }
3824 3824
@@ -3828,7 +3828,8 @@ int target_scsi3_emulate_pr_out(struct se_cmd *cmd)
3828 */ 3828 */
3829 if (!cmd->se_sess) { 3829 if (!cmd->se_sess) {
3830 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 3830 cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
3831 return -EINVAL; 3831 ret = -EINVAL;
3832 goto out;
3832 } 3833 }
3833 3834
3834 if (cmd->data_length < 24) { 3835 if (cmd->data_length < 24) {
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index f03fb9730f5..5b65f33939a 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -230,6 +230,8 @@ u32 ft_get_task_tag(struct se_cmd *se_cmd)
230{ 230{
231 struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); 231 struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
232 232
233 if (cmd->aborted)
234 return ~0;
233 return fc_seq_exch(cmd->seq)->rxid; 235 return fc_seq_exch(cmd->seq)->rxid;
234} 236}
235 237
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index ced26c8ccd5..0d2ea0c224c 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -401,7 +401,7 @@ out:
401} 401}
402 402
403#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL_RAW 403#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL_RAW
404void __init udbg_init_debug_opal(void) 404void __init udbg_init_debug_opal_raw(void)
405{ 405{
406 u32 index = CONFIG_PPC_EARLY_DEBUG_OPAL_VTERMNO; 406 u32 index = CONFIG_PPC_EARLY_DEBUG_OPAL_VTERMNO;
407 hvc_opal_privs[index] = &hvc_opal_boot_priv; 407 hvc_opal_privs[index] = &hvc_opal_boot_priv;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c17923ec6e9..d3553b5d3fc 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -53,9 +53,9 @@
53#include <linux/delay.h> 53#include <linux/delay.h>
54#include <linux/types.h> 54#include <linux/types.h>
55#include <linux/pinctrl/consumer.h> 55#include <linux/pinctrl/consumer.h>
56#include <linux/sizes.h>
56 57
57#include <asm/io.h> 58#include <asm/io.h>
58#include <asm/sizes.h>
59 59
60#define UART_NR 14 60#define UART_NR 14
61 61
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 8fd398dffce..ee469274a3f 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -500,6 +500,8 @@ retry:
500 goto retry; 500 goto retry;
501 } 501 }
502 if (!desc->reslength) { /* zero length read */ 502 if (!desc->reslength) { /* zero length read */
503 dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
504 clear_bit(WDM_READ, &desc->flags);
503 spin_unlock_irq(&desc->iuspin); 505 spin_unlock_irq(&desc->iuspin);
504 goto retry; 506 goto retry;
505 } 507 }
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 25a7422ee65..8fb484984c8 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2324,12 +2324,16 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
2324static int hub_port_reset(struct usb_hub *hub, int port1, 2324static int hub_port_reset(struct usb_hub *hub, int port1,
2325 struct usb_device *udev, unsigned int delay, bool warm); 2325 struct usb_device *udev, unsigned int delay, bool warm);
2326 2326
2327/* Is a USB 3.0 port in the Inactive state? */ 2327/* Is a USB 3.0 port in the Inactive or Complinance Mode state?
2328static bool hub_port_inactive(struct usb_hub *hub, u16 portstatus) 2328 * Port worm reset is required to recover
2329 */
2330static bool hub_port_warm_reset_required(struct usb_hub *hub, u16 portstatus)
2329{ 2331{
2330 return hub_is_superspeed(hub->hdev) && 2332 return hub_is_superspeed(hub->hdev) &&
2331 (portstatus & USB_PORT_STAT_LINK_STATE) == 2333 (((portstatus & USB_PORT_STAT_LINK_STATE) ==
2332 USB_SS_PORT_LS_SS_INACTIVE; 2334 USB_SS_PORT_LS_SS_INACTIVE) ||
2335 ((portstatus & USB_PORT_STAT_LINK_STATE) ==
2336 USB_SS_PORT_LS_COMP_MOD)) ;
2333} 2337}
2334 2338
2335static int hub_port_wait_reset(struct usb_hub *hub, int port1, 2339static int hub_port_wait_reset(struct usb_hub *hub, int port1,
@@ -2365,7 +2369,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
2365 * 2369 *
2366 * See https://bugzilla.kernel.org/show_bug.cgi?id=41752 2370 * See https://bugzilla.kernel.org/show_bug.cgi?id=41752
2367 */ 2371 */
2368 if (hub_port_inactive(hub, portstatus)) { 2372 if (hub_port_warm_reset_required(hub, portstatus)) {
2369 int ret; 2373 int ret;
2370 2374
2371 if ((portchange & USB_PORT_STAT_C_CONNECTION)) 2375 if ((portchange & USB_PORT_STAT_C_CONNECTION))
@@ -4408,9 +4412,7 @@ static void hub_events(void)
4408 /* Warm reset a USB3 protocol port if it's in 4412 /* Warm reset a USB3 protocol port if it's in
4409 * SS.Inactive state. 4413 * SS.Inactive state.
4410 */ 4414 */
4411 if (hub_is_superspeed(hub->hdev) && 4415 if (hub_port_warm_reset_required(hub, portstatus)) {
4412 (portstatus & USB_PORT_STAT_LINK_STATE)
4413 == USB_SS_PORT_LS_SS_INACTIVE) {
4414 dev_dbg(hub_dev, "warm reset port %d\n", i); 4416 dev_dbg(hub_dev, "warm reset port %d\n", i);
4415 hub_port_reset(hub, i, NULL, 4417 hub_port_reset(hub, i, NULL,
4416 HUB_BH_RESET_TIME, true); 4418 HUB_BH_RESET_TIME, true);
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 17cfb8a1131..c30435499a0 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -281,14 +281,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
281 } 281 }
282 } 282 }
283 283
284 /* Hold PHYs in reset while initializing EHCI controller */
284 if (pdata->phy_reset) { 285 if (pdata->phy_reset) {
285 if (gpio_is_valid(pdata->reset_gpio_port[0])) 286 if (gpio_is_valid(pdata->reset_gpio_port[0]))
286 gpio_request_one(pdata->reset_gpio_port[0], 287 gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
287 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
288 288
289 if (gpio_is_valid(pdata->reset_gpio_port[1])) 289 if (gpio_is_valid(pdata->reset_gpio_port[1]))
290 gpio_request_one(pdata->reset_gpio_port[1], 290 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
291 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
292 291
293 /* Hold the PHY in RESET for enough time till DIR is high */ 292 /* Hold the PHY in RESET for enough time till DIR is high */
294 udelay(10); 293 udelay(10);
@@ -330,6 +329,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
330 omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params); 329 omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
331 330
332 ehci_reset(omap_ehci); 331 ehci_reset(omap_ehci);
332 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
333 if (ret) {
334 dev_err(dev, "failed to add hcd with err %d\n", ret);
335 goto err_add_hcd;
336 }
333 337
334 if (pdata->phy_reset) { 338 if (pdata->phy_reset) {
335 /* Hold the PHY in RESET for enough time till 339 /* Hold the PHY in RESET for enough time till
@@ -344,12 +348,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
344 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); 348 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
345 } 349 }
346 350
347 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
348 if (ret) {
349 dev_err(dev, "failed to add hcd with err %d\n", ret);
350 goto err_add_hcd;
351 }
352
353 /* root ports should always stay powered */ 351 /* root ports should always stay powered */
354 ehci_port_power(omap_ehci, 1); 352 ehci_port_power(omap_ehci, 1);
355 353
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 2732ef660c5..7b01094d799 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -462,6 +462,42 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array,
462 } 462 }
463} 463}
464 464
465/* Updates Link Status for super Speed port */
466static void xhci_hub_report_link_state(u32 *status, u32 status_reg)
467{
468 u32 pls = status_reg & PORT_PLS_MASK;
469
470 /* resume state is a xHCI internal state.
471 * Do not report it to usb core.
472 */
473 if (pls == XDEV_RESUME)
474 return;
475
476 /* When the CAS bit is set then warm reset
477 * should be performed on port
478 */
479 if (status_reg & PORT_CAS) {
480 /* The CAS bit can be set while the port is
481 * in any link state.
482 * Only roothubs have CAS bit, so we
483 * pretend to be in compliance mode
484 * unless we're already in compliance
485 * or the inactive state.
486 */
487 if (pls != USB_SS_PORT_LS_COMP_MOD &&
488 pls != USB_SS_PORT_LS_SS_INACTIVE) {
489 pls = USB_SS_PORT_LS_COMP_MOD;
490 }
491 /* Return also connection bit -
492 * hub state machine resets port
493 * when this bit is set.
494 */
495 pls |= USB_PORT_STAT_CONNECTION;
496 }
497 /* update status field */
498 *status |= pls;
499}
500
465int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 501int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
466 u16 wIndex, char *buf, u16 wLength) 502 u16 wIndex, char *buf, u16 wLength)
467{ 503{
@@ -606,13 +642,9 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
606 else 642 else
607 status |= USB_PORT_STAT_POWER; 643 status |= USB_PORT_STAT_POWER;
608 } 644 }
609 /* Port Link State */ 645 /* Update Port Link State for super speed ports*/
610 if (hcd->speed == HCD_USB3) { 646 if (hcd->speed == HCD_USB3) {
611 /* resume state is a xHCI internal state. 647 xhci_hub_report_link_state(&status, temp);
612 * Do not report it to usb core.
613 */
614 if ((temp & PORT_PLS_MASK) != XDEV_RESUME)
615 status |= (temp & PORT_PLS_MASK);
616 } 648 }
617 if (bus_state->port_c_suspend & (1 << wIndex)) 649 if (bus_state->port_c_suspend & (1 << wIndex))
618 status |= 1 << USB_PORT_FEAT_C_SUSPEND; 650 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 23b4aefd103..8275645889d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -885,6 +885,17 @@ static void update_ring_for_set_deq_completion(struct xhci_hcd *xhci,
885 num_trbs_free_temp = ep_ring->num_trbs_free; 885 num_trbs_free_temp = ep_ring->num_trbs_free;
886 dequeue_temp = ep_ring->dequeue; 886 dequeue_temp = ep_ring->dequeue;
887 887
888 /* If we get two back-to-back stalls, and the first stalled transfer
889 * ends just before a link TRB, the dequeue pointer will be left on
890 * the link TRB by the code in the while loop. So we have to update
891 * the dequeue pointer one segment further, or we'll jump off
892 * the segment into la-la-land.
893 */
894 if (last_trb(xhci, ep_ring, ep_ring->deq_seg, ep_ring->dequeue)) {
895 ep_ring->deq_seg = ep_ring->deq_seg->next;
896 ep_ring->dequeue = ep_ring->deq_seg->trbs;
897 }
898
888 while (ep_ring->dequeue != dev->eps[ep_index].queued_deq_ptr) { 899 while (ep_ring->dequeue != dev->eps[ep_index].queued_deq_ptr) {
889 /* We have more usable TRBs */ 900 /* We have more usable TRBs */
890 ep_ring->num_trbs_free++; 901 ep_ring->num_trbs_free++;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index de3d6e3e57b..55c0785810c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -341,7 +341,11 @@ struct xhci_op_regs {
341#define PORT_PLC (1 << 22) 341#define PORT_PLC (1 << 22)
342/* port configure error change - port failed to configure its link partner */ 342/* port configure error change - port failed to configure its link partner */
343#define PORT_CEC (1 << 23) 343#define PORT_CEC (1 << 23)
344/* bit 24 reserved */ 344/* Cold Attach Status - xHC can set this bit to report device attached during
345 * Sx state. Warm port reset should be perfomed to clear this bit and move port
346 * to connected state.
347 */
348#define PORT_CAS (1 << 24)
345/* wake on connect (enable) */ 349/* wake on connect (enable) */
346#define PORT_WKCONN_E (1 << 25) 350#define PORT_WKCONN_E (1 << 25)
347/* wake on disconnect (enable) */ 351/* wake on disconnect (enable) */
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 81423f7361d..d47eb06fe46 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -222,14 +222,6 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
222 metro_priv->throttled = 0; 222 metro_priv->throttled = 0;
223 spin_unlock_irqrestore(&metro_priv->lock, flags); 223 spin_unlock_irqrestore(&metro_priv->lock, flags);
224 224
225 /*
226 * Force low_latency on so that our tty_push actually forces the data
227 * through, otherwise it is scheduled, and with high data rates (like
228 * with OHCI) data can get lost.
229 */
230 if (tty)
231 tty->low_latency = 1;
232
233 /* Clear the urb pipe. */ 225 /* Clear the urb pipe. */
234 usb_clear_halt(serial->dev, port->interrupt_in_urb->pipe); 226 usb_clear_halt(serial->dev, port->interrupt_in_urb->pipe);
235 227
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index adf8ce72be5..417ab1b0aa3 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -497,6 +497,15 @@ static void option_instat_callback(struct urb *urb);
497 497
498/* MediaTek products */ 498/* MediaTek products */
499#define MEDIATEK_VENDOR_ID 0x0e8d 499#define MEDIATEK_VENDOR_ID 0x0e8d
500#define MEDIATEK_PRODUCT_DC_1COM 0x00a0
501#define MEDIATEK_PRODUCT_DC_4COM 0x00a5
502#define MEDIATEK_PRODUCT_DC_5COM 0x00a4
503#define MEDIATEK_PRODUCT_7208_1COM 0x7101
504#define MEDIATEK_PRODUCT_7208_2COM 0x7102
505#define MEDIATEK_PRODUCT_FP_1COM 0x0003
506#define MEDIATEK_PRODUCT_FP_2COM 0x0023
507#define MEDIATEK_PRODUCT_FPDC_1COM 0x0043
508#define MEDIATEK_PRODUCT_FPDC_2COM 0x0033
500 509
501/* Cellient products */ 510/* Cellient products */
502#define CELLIENT_VENDOR_ID 0x2692 511#define CELLIENT_VENDOR_ID 0x2692
@@ -554,6 +563,10 @@ static const struct option_blacklist_info net_intf1_blacklist = {
554 .reserved = BIT(1), 563 .reserved = BIT(1),
555}; 564};
556 565
566static const struct option_blacklist_info net_intf2_blacklist = {
567 .reserved = BIT(2),
568};
569
557static const struct option_blacklist_info net_intf3_blacklist = { 570static const struct option_blacklist_info net_intf3_blacklist = {
558 .reserved = BIT(3), 571 .reserved = BIT(3),
559}; 572};
@@ -1099,6 +1112,8 @@ static const struct usb_device_id option_ids[] = {
1099 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1112 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
1100 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1113 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
1101 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1114 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
1115 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
1116 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1102 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 1117 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
1103 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, 1118 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
1104 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, 1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
@@ -1240,6 +1255,17 @@ static const struct usb_device_id option_ids[] = {
1240 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) }, 1255 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) },
1241 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) }, 1256 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) },
1242 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */ 1257 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */
1258 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_1COM, 0x0a, 0x00, 0x00) },
1259 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x02, 0x01) },
1260 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_5COM, 0xff, 0x00, 0x00) },
1261 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x02, 0x01) },
1262 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM, 0xff, 0x00, 0x00) },
1263 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_1COM, 0x02, 0x00, 0x00) },
1264 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7208_2COM, 0x02, 0x02, 0x01) },
1265 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_1COM, 0x0a, 0x00, 0x00) },
1266 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) },
1267 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) },
1268 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) },
1243 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, 1269 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) },
1244 { } /* Terminating entry */ 1270 { } /* Terminating entry */
1245}; 1271};
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 5066eee10cc..58bd9c27369 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -32,6 +32,7 @@
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/regulator/consumer.h> 34#include <linux/regulator/consumer.h>
35#include <linux/suspend.h>
35 36
36#include <video/omapdss.h> 37#include <video/omapdss.h>
37 38
@@ -201,6 +202,28 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
201#endif /* CONFIG_DEBUG_FS && CONFIG_OMAP2_DSS_DEBUG_SUPPORT */ 202#endif /* CONFIG_DEBUG_FS && CONFIG_OMAP2_DSS_DEBUG_SUPPORT */
202 203
203/* PLATFORM DEVICE */ 204/* PLATFORM DEVICE */
205static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d)
206{
207 DSSDBG("pm notif %lu\n", v);
208
209 switch (v) {
210 case PM_SUSPEND_PREPARE:
211 DSSDBG("suspending displays\n");
212 return dss_suspend_all_devices();
213
214 case PM_POST_SUSPEND:
215 DSSDBG("resuming displays\n");
216 return dss_resume_all_devices();
217
218 default:
219 return 0;
220 }
221}
222
223static struct notifier_block omap_dss_pm_notif_block = {
224 .notifier_call = omap_dss_pm_notif,
225};
226
204static int __init omap_dss_probe(struct platform_device *pdev) 227static int __init omap_dss_probe(struct platform_device *pdev)
205{ 228{
206 struct omap_dss_board_info *pdata = pdev->dev.platform_data; 229 struct omap_dss_board_info *pdata = pdev->dev.platform_data;
@@ -224,6 +247,8 @@ static int __init omap_dss_probe(struct platform_device *pdev)
224 else if (pdata->default_device) 247 else if (pdata->default_device)
225 core.default_display_name = pdata->default_device->name; 248 core.default_display_name = pdata->default_device->name;
226 249
250 register_pm_notifier(&omap_dss_pm_notif_block);
251
227 return 0; 252 return 0;
228 253
229err_debugfs: 254err_debugfs:
@@ -233,6 +258,8 @@ err_debugfs:
233 258
234static int omap_dss_remove(struct platform_device *pdev) 259static int omap_dss_remove(struct platform_device *pdev)
235{ 260{
261 unregister_pm_notifier(&omap_dss_pm_notif_block);
262
236 dss_uninitialize_debugfs(); 263 dss_uninitialize_debugfs();
237 264
238 dss_uninit_overlays(pdev); 265 dss_uninit_overlays(pdev);
@@ -247,25 +274,9 @@ static void omap_dss_shutdown(struct platform_device *pdev)
247 dss_disable_all_devices(); 274 dss_disable_all_devices();
248} 275}
249 276
250static int omap_dss_suspend(struct platform_device *pdev, pm_message_t state)
251{
252 DSSDBG("suspend %d\n", state.event);
253
254 return dss_suspend_all_devices();
255}
256
257static int omap_dss_resume(struct platform_device *pdev)
258{
259 DSSDBG("resume\n");
260
261 return dss_resume_all_devices();
262}
263
264static struct platform_driver omap_dss_driver = { 277static struct platform_driver omap_dss_driver = {
265 .remove = omap_dss_remove, 278 .remove = omap_dss_remove,
266 .shutdown = omap_dss_shutdown, 279 .shutdown = omap_dss_shutdown,
267 .suspend = omap_dss_suspend,
268 .resume = omap_dss_resume,
269 .driver = { 280 .driver = {
270 .name = "omapdss", 281 .name = "omapdss",
271 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index 4749ac35646..397d4eee11b 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -384,7 +384,7 @@ void dispc_runtime_put(void)
384 DSSDBG("dispc_runtime_put\n"); 384 DSSDBG("dispc_runtime_put\n");
385 385
386 r = pm_runtime_put_sync(&dispc.pdev->dev); 386 r = pm_runtime_put_sync(&dispc.pdev->dev);
387 WARN_ON(r < 0); 387 WARN_ON(r < 0 && r != -ENOSYS);
388} 388}
389 389
390static inline bool dispc_mgr_is_lcd(enum omap_channel channel) 390static inline bool dispc_mgr_is_lcd(enum omap_channel channel)
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index ca8382d346e..14ce8cc079e 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -1075,7 +1075,7 @@ void dsi_runtime_put(struct platform_device *dsidev)
1075 DSSDBG("dsi_runtime_put\n"); 1075 DSSDBG("dsi_runtime_put\n");
1076 1076
1077 r = pm_runtime_put_sync(&dsi->pdev->dev); 1077 r = pm_runtime_put_sync(&dsi->pdev->dev);
1078 WARN_ON(r < 0); 1078 WARN_ON(r < 0 && r != -ENOSYS);
1079} 1079}
1080 1080
1081/* source clock for DSI PLL. this could also be PCLKFREE */ 1081/* source clock for DSI PLL. this could also be PCLKFREE */
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 770632359a1..d2b57197b29 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -731,7 +731,7 @@ static void dss_runtime_put(void)
731 DSSDBG("dss_runtime_put\n"); 731 DSSDBG("dss_runtime_put\n");
732 732
733 r = pm_runtime_put_sync(&dss.pdev->dev); 733 r = pm_runtime_put_sync(&dss.pdev->dev);
734 WARN_ON(r < 0 && r != -EBUSY); 734 WARN_ON(r < 0 && r != -ENOSYS && r != -EBUSY);
735} 735}
736 736
737/* DEBUGFS */ 737/* DEBUGFS */
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 8195c7166d2..26a2430a702 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -138,7 +138,7 @@ static void hdmi_runtime_put(void)
138 DSSDBG("hdmi_runtime_put\n"); 138 DSSDBG("hdmi_runtime_put\n");
139 139
140 r = pm_runtime_put_sync(&hdmi.pdev->dev); 140 r = pm_runtime_put_sync(&hdmi.pdev->dev);
141 WARN_ON(r < 0); 141 WARN_ON(r < 0 && r != -ENOSYS);
142} 142}
143 143
144static int __init hdmi_init_display(struct omap_dss_device *dssdev) 144static int __init hdmi_init_display(struct omap_dss_device *dssdev)
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index 3d8c206e90e..7985fa12b9b 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -141,7 +141,7 @@ static void rfbi_runtime_put(void)
141 DSSDBG("rfbi_runtime_put\n"); 141 DSSDBG("rfbi_runtime_put\n");
142 142
143 r = pm_runtime_put_sync(&rfbi.pdev->dev); 143 r = pm_runtime_put_sync(&rfbi.pdev->dev);
144 WARN_ON(r < 0); 144 WARN_ON(r < 0 && r != -ENOSYS);
145} 145}
146 146
147void rfbi_bus_lock(void) 147void rfbi_bus_lock(void)
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 2b8973931ff..3907c8b6ecb 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -402,7 +402,7 @@ static void venc_runtime_put(void)
402 DSSDBG("venc_runtime_put\n"); 402 DSSDBG("venc_runtime_put\n");
403 403
404 r = pm_runtime_put_sync(&venc.pdev->dev); 404 r = pm_runtime_put_sync(&venc.pdev->dev);
405 WARN_ON(r < 0); 405 WARN_ON(r < 0 && r != -ENOSYS);
406} 406}
407 407
408static const struct venc_config *venc_timings_to_config( 408static const struct venc_config *venc_timings_to_config(
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index bfbc15ca38d..0908e604433 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -47,7 +47,7 @@ struct virtio_balloon
47 struct task_struct *thread; 47 struct task_struct *thread;
48 48
49 /* Waiting for host to ack the pages we released. */ 49 /* Waiting for host to ack the pages we released. */
50 struct completion acked; 50 wait_queue_head_t acked;
51 51
52 /* Number of balloon pages we've told the Host we're not using. */ 52 /* Number of balloon pages we've told the Host we're not using. */
53 unsigned int num_pages; 53 unsigned int num_pages;
@@ -89,29 +89,25 @@ static struct page *balloon_pfn_to_page(u32 pfn)
89 89
90static void balloon_ack(struct virtqueue *vq) 90static void balloon_ack(struct virtqueue *vq)
91{ 91{
92 struct virtio_balloon *vb; 92 struct virtio_balloon *vb = vq->vdev->priv;
93 unsigned int len;
94 93
95 vb = virtqueue_get_buf(vq, &len); 94 wake_up(&vb->acked);
96 if (vb)
97 complete(&vb->acked);
98} 95}
99 96
100static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) 97static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
101{ 98{
102 struct scatterlist sg; 99 struct scatterlist sg;
100 unsigned int len;
103 101
104 sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); 102 sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
105 103
106 init_completion(&vb->acked);
107
108 /* We should always be able to add one buffer to an empty queue. */ 104 /* We should always be able to add one buffer to an empty queue. */
109 if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0) 105 if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0)
110 BUG(); 106 BUG();
111 virtqueue_kick(vq); 107 virtqueue_kick(vq);
112 108
113 /* When host has read buffer, this completes via balloon_ack */ 109 /* When host has read buffer, this completes via balloon_ack */
114 wait_for_completion(&vb->acked); 110 wait_event(vb->acked, virtqueue_get_buf(vq, &len));
115} 111}
116 112
117static void set_page_pfns(u32 pfns[], struct page *page) 113static void set_page_pfns(u32 pfns[], struct page *page)
@@ -231,12 +227,8 @@ static void update_balloon_stats(struct virtio_balloon *vb)
231 */ 227 */
232static void stats_request(struct virtqueue *vq) 228static void stats_request(struct virtqueue *vq)
233{ 229{
234 struct virtio_balloon *vb; 230 struct virtio_balloon *vb = vq->vdev->priv;
235 unsigned int len;
236 231
237 vb = virtqueue_get_buf(vq, &len);
238 if (!vb)
239 return;
240 vb->need_stats_update = 1; 232 vb->need_stats_update = 1;
241 wake_up(&vb->config_change); 233 wake_up(&vb->config_change);
242} 234}
@@ -245,11 +237,14 @@ static void stats_handle_request(struct virtio_balloon *vb)
245{ 237{
246 struct virtqueue *vq; 238 struct virtqueue *vq;
247 struct scatterlist sg; 239 struct scatterlist sg;
240 unsigned int len;
248 241
249 vb->need_stats_update = 0; 242 vb->need_stats_update = 0;
250 update_balloon_stats(vb); 243 update_balloon_stats(vb);
251 244
252 vq = vb->stats_vq; 245 vq = vb->stats_vq;
246 if (!virtqueue_get_buf(vq, &len))
247 return;
253 sg_init_one(&sg, vb->stats, sizeof(vb->stats)); 248 sg_init_one(&sg, vb->stats, sizeof(vb->stats));
254 if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0) 249 if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0)
255 BUG(); 250 BUG();
@@ -358,6 +353,7 @@ static int virtballoon_probe(struct virtio_device *vdev)
358 INIT_LIST_HEAD(&vb->pages); 353 INIT_LIST_HEAD(&vb->pages);
359 vb->num_pages = 0; 354 vb->num_pages = 0;
360 init_waitqueue_head(&vb->config_change); 355 init_waitqueue_head(&vb->config_change);
356 init_waitqueue_head(&vb->acked);
361 vb->vdev = vdev; 357 vb->vdev = vdev;
362 vb->need_stats_update = 0; 358 vb->need_stats_update = 0;
363 359
diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index 54984deb856..ccd6b29e21b 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -54,10 +54,10 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
54 return -EBUSY; 54 return -EBUSY;
55 55
56 /* Activate SA1100 Watchdog timer */ 56 /* Activate SA1100 Watchdog timer */
57 OSMR3 = OSCR + pre_margin; 57 writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
58 OSSR = OSSR_M3; 58 writel_relaxed(OSSR_M3, OSSR);
59 OWER = OWER_WME; 59 writel_relaxed(OWER_WME, OWER);
60 OIER |= OIER_E3; 60 writel_relaxed(readl_relaxed(OIER) | OIER_E3, OIER);
61 return nonseekable_open(inode, file); 61 return nonseekable_open(inode, file);
62} 62}
63 63
@@ -80,7 +80,7 @@ static ssize_t sa1100dog_write(struct file *file, const char __user *data,
80{ 80{
81 if (len) 81 if (len)
82 /* Refresh OSMR3 timer. */ 82 /* Refresh OSMR3 timer. */
83 OSMR3 = OSCR + pre_margin; 83 writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
84 return len; 84 return len;
85} 85}
86 86
@@ -114,7 +114,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
114 break; 114 break;
115 115
116 case WDIOC_KEEPALIVE: 116 case WDIOC_KEEPALIVE:
117 OSMR3 = OSCR + pre_margin; 117 writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
118 ret = 0; 118 ret = 0;
119 break; 119 break;
120 120
@@ -129,7 +129,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
129 } 129 }
130 130
131 pre_margin = oscr_freq * time; 131 pre_margin = oscr_freq * time;
132 OSMR3 = OSCR + pre_margin; 132 writel_relaxed(readl_relaxed(OSCR) + pre_margin, OSMR3);
133 /*fall through*/ 133 /*fall through*/
134 134
135 case WDIOC_GETTIMEOUT: 135 case WDIOC_GETTIMEOUT:
diff --git a/fs/buffer.c b/fs/buffer.c
index 838a9cf246b..c7062c896d7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1036,6 +1036,9 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
1036static struct buffer_head * 1036static struct buffer_head *
1037__getblk_slow(struct block_device *bdev, sector_t block, int size) 1037__getblk_slow(struct block_device *bdev, sector_t block, int size)
1038{ 1038{
1039 int ret;
1040 struct buffer_head *bh;
1041
1039 /* Size must be multiple of hard sectorsize */ 1042 /* Size must be multiple of hard sectorsize */
1040 if (unlikely(size & (bdev_logical_block_size(bdev)-1) || 1043 if (unlikely(size & (bdev_logical_block_size(bdev)-1) ||
1041 (size < 512 || size > PAGE_SIZE))) { 1044 (size < 512 || size > PAGE_SIZE))) {
@@ -1048,20 +1051,21 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
1048 return NULL; 1051 return NULL;
1049 } 1052 }
1050 1053
1051 for (;;) { 1054retry:
1052 struct buffer_head * bh; 1055 bh = __find_get_block(bdev, block, size);
1053 int ret; 1056 if (bh)
1057 return bh;
1054 1058
1059 ret = grow_buffers(bdev, block, size);
1060 if (ret == 0) {
1061 free_more_memory();
1062 goto retry;
1063 } else if (ret > 0) {
1055 bh = __find_get_block(bdev, block, size); 1064 bh = __find_get_block(bdev, block, size);
1056 if (bh) 1065 if (bh)
1057 return bh; 1066 return bh;
1058
1059 ret = grow_buffers(bdev, block, size);
1060 if (ret < 0)
1061 return NULL;
1062 if (ret == 0)
1063 free_more_memory();
1064 } 1067 }
1068 return NULL;
1065} 1069}
1066 1070
1067/* 1071/*
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 5b400730c21..4ee522b3f66 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -86,7 +86,31 @@ static struct {
86#endif /* CONFIG_CIFS_WEAK_PW_HASH */ 86#endif /* CONFIG_CIFS_WEAK_PW_HASH */
87#endif /* CIFS_POSIX */ 87#endif /* CIFS_POSIX */
88 88
89/* Forward declarations */ 89#ifdef CONFIG_HIGHMEM
90/*
91 * On arches that have high memory, kmap address space is limited. By
92 * serializing the kmap operations on those arches, we ensure that we don't
93 * end up with a bunch of threads in writeback with partially mapped page
94 * arrays, stuck waiting for kmap to come back. That situation prevents
95 * progress and can deadlock.
96 */
97static DEFINE_MUTEX(cifs_kmap_mutex);
98
99static inline void
100cifs_kmap_lock(void)
101{
102 mutex_lock(&cifs_kmap_mutex);
103}
104
105static inline void
106cifs_kmap_unlock(void)
107{
108 mutex_unlock(&cifs_kmap_mutex);
109}
110#else /* !CONFIG_HIGHMEM */
111#define cifs_kmap_lock() do { ; } while(0)
112#define cifs_kmap_unlock() do { ; } while(0)
113#endif /* CONFIG_HIGHMEM */
90 114
91/* Mark as invalid, all open files on tree connections since they 115/* Mark as invalid, all open files on tree connections since they
92 were closed when session to server was lost */ 116 were closed when session to server was lost */
@@ -1503,7 +1527,9 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1503 } 1527 }
1504 1528
1505 /* marshal up the page array */ 1529 /* marshal up the page array */
1530 cifs_kmap_lock();
1506 len = rdata->marshal_iov(rdata, data_len); 1531 len = rdata->marshal_iov(rdata, data_len);
1532 cifs_kmap_unlock();
1507 data_len -= len; 1533 data_len -= len;
1508 1534
1509 /* issue the read if we have any iovecs left to fill */ 1535 /* issue the read if we have any iovecs left to fill */
@@ -2069,7 +2095,9 @@ cifs_async_writev(struct cifs_writedata *wdata)
2069 * and set the iov_len properly for each one. It may also set 2095 * and set the iov_len properly for each one. It may also set
2070 * wdata->bytes too. 2096 * wdata->bytes too.
2071 */ 2097 */
2098 cifs_kmap_lock();
2072 wdata->marshal_iov(iov, wdata); 2099 wdata->marshal_iov(iov, wdata);
2100 cifs_kmap_unlock();
2073 2101
2074 cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes); 2102 cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes);
2075 2103
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 0ae86ddf221..94b7788c318 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3445,6 +3445,18 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
3445#define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024) 3445#define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024)
3446#define CIFS_DEFAULT_NON_POSIX_WSIZE (65536) 3446#define CIFS_DEFAULT_NON_POSIX_WSIZE (65536)
3447 3447
3448/*
3449 * On hosts with high memory, we can't currently support wsize/rsize that are
3450 * larger than we can kmap at once. Cap the rsize/wsize at
3451 * LAST_PKMAP * PAGE_SIZE. We'll never be able to fill a read or write request
3452 * larger than that anyway.
3453 */
3454#ifdef CONFIG_HIGHMEM
3455#define CIFS_KMAP_SIZE_LIMIT (LAST_PKMAP * PAGE_CACHE_SIZE)
3456#else /* CONFIG_HIGHMEM */
3457#define CIFS_KMAP_SIZE_LIMIT (1<<24)
3458#endif /* CONFIG_HIGHMEM */
3459
3448static unsigned int 3460static unsigned int
3449cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info) 3461cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
3450{ 3462{
@@ -3475,6 +3487,9 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
3475 wsize = min_t(unsigned int, wsize, 3487 wsize = min_t(unsigned int, wsize,
3476 server->maxBuf - sizeof(WRITE_REQ) + 4); 3488 server->maxBuf - sizeof(WRITE_REQ) + 4);
3477 3489
3490 /* limit to the amount that we can kmap at once */
3491 wsize = min_t(unsigned int, wsize, CIFS_KMAP_SIZE_LIMIT);
3492
3478 /* hard limit of CIFS_MAX_WSIZE */ 3493 /* hard limit of CIFS_MAX_WSIZE */
3479 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); 3494 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);
3480 3495
@@ -3516,6 +3531,9 @@ cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
3516 if (!(server->capabilities & CAP_LARGE_READ_X)) 3531 if (!(server->capabilities & CAP_LARGE_READ_X))
3517 rsize = min_t(unsigned int, CIFSMaxBufSize, rsize); 3532 rsize = min_t(unsigned int, CIFSMaxBufSize, rsize);
3518 3533
3534 /* limit to the amount that we can kmap at once */
3535 rsize = min_t(unsigned int, rsize, CIFS_KMAP_SIZE_LIMIT);
3536
3519 /* hard limit of CIFS_MAX_RSIZE */ 3537 /* hard limit of CIFS_MAX_RSIZE */
3520 rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE); 3538 rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE);
3521 3539
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 0a8224d1c4c..a4217f02fab 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -86,9 +86,12 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
86 86
87 dentry = d_lookup(parent, name); 87 dentry = d_lookup(parent, name);
88 if (dentry) { 88 if (dentry) {
89 /* FIXME: check for inode number changes? */ 89 inode = dentry->d_inode;
90 if (dentry->d_inode != NULL) 90 /* update inode in place if i_ino didn't change */
91 if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
92 cifs_fattr_to_inode(inode, fattr);
91 return dentry; 93 return dentry;
94 }
92 d_drop(dentry); 95 d_drop(dentry);
93 dput(dentry); 96 dput(dentry);
94 } 97 }
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 3097ee58fd7..f25d4ea14be 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -365,16 +365,14 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov,
365 if (mid == NULL) 365 if (mid == NULL)
366 return -ENOMEM; 366 return -ENOMEM;
367 367
368 /* put it on the pending_mid_q */
369 spin_lock(&GlobalMid_Lock);
370 list_add_tail(&mid->qhead, &server->pending_mid_q);
371 spin_unlock(&GlobalMid_Lock);
372
373 rc = cifs_sign_smb2(iov, nvec, server, &mid->sequence_number); 368 rc = cifs_sign_smb2(iov, nvec, server, &mid->sequence_number);
374 if (rc) 369 if (rc) {
375 delete_mid(mid); 370 DeleteMidQEntry(mid);
371 return rc;
372 }
373
376 *ret_mid = mid; 374 *ret_mid = mid;
377 return rc; 375 return 0;
378} 376}
379 377
380/* 378/*
@@ -407,17 +405,21 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
407 mid->callback_data = cbdata; 405 mid->callback_data = cbdata;
408 mid->mid_state = MID_REQUEST_SUBMITTED; 406 mid->mid_state = MID_REQUEST_SUBMITTED;
409 407
408 /* put it on the pending_mid_q */
409 spin_lock(&GlobalMid_Lock);
410 list_add_tail(&mid->qhead, &server->pending_mid_q);
411 spin_unlock(&GlobalMid_Lock);
412
413
410 cifs_in_send_inc(server); 414 cifs_in_send_inc(server);
411 rc = smb_sendv(server, iov, nvec); 415 rc = smb_sendv(server, iov, nvec);
412 cifs_in_send_dec(server); 416 cifs_in_send_dec(server);
413 cifs_save_when_sent(mid); 417 cifs_save_when_sent(mid);
414 mutex_unlock(&server->srv_mutex); 418 mutex_unlock(&server->srv_mutex);
415 419
416 if (rc) 420 if (rc == 0)
417 goto out_err; 421 return 0;
418 422
419 return rc;
420out_err:
421 delete_mid(mid); 423 delete_mid(mid);
422 add_credits(server, 1); 424 add_credits(server, 1);
423 wake_up(&server->request_q); 425 wake_up(&server->request_q);
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 74598f67efe..1c8b5567080 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1710,7 +1710,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
1710 goto error_tgt_fput; 1710 goto error_tgt_fput;
1711 1711
1712 /* Check if EPOLLWAKEUP is allowed */ 1712 /* Check if EPOLLWAKEUP is allowed */
1713 if ((epds.events & EPOLLWAKEUP) && !capable(CAP_EPOLLWAKEUP)) 1713 if ((epds.events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
1714 epds.events &= ~EPOLLWAKEUP; 1714 epds.events &= ~EPOLLWAKEUP;
1715 1715
1716 /* 1716 /*
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c
index 49cf230554a..24a49d47e93 100644
--- a/fs/exofs/ore.c
+++ b/fs/exofs/ore.c
@@ -735,13 +735,7 @@ static int _prepare_for_striping(struct ore_io_state *ios)
735out: 735out:
736 ios->numdevs = devs_in_group; 736 ios->numdevs = devs_in_group;
737 ios->pages_consumed = cur_pg; 737 ios->pages_consumed = cur_pg;
738 if (unlikely(ret)) { 738 return ret;
739 if (length == ios->length)
740 return ret;
741 else
742 ios->length -= length;
743 }
744 return 0;
745} 739}
746 740
747int ore_create(struct ore_io_state *ios) 741int ore_create(struct ore_io_state *ios)
diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index d222c77cfa1..5f376d14fdc 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -144,26 +144,26 @@ static void _sp2d_reset(struct __stripe_pages_2d *sp2d,
144{ 144{
145 unsigned data_devs = sp2d->data_devs; 145 unsigned data_devs = sp2d->data_devs;
146 unsigned group_width = data_devs + sp2d->parity; 146 unsigned group_width = data_devs + sp2d->parity;
147 unsigned p; 147 int p, c;
148 148
149 if (!sp2d->needed) 149 if (!sp2d->needed)
150 return; 150 return;
151 151
152 for (p = 0; p < sp2d->pages_in_unit; p++) { 152 for (c = data_devs - 1; c >= 0; --c)
153 struct __1_page_stripe *_1ps = &sp2d->_1p_stripes[p]; 153 for (p = sp2d->pages_in_unit - 1; p >= 0; --p) {
154 154 struct __1_page_stripe *_1ps = &sp2d->_1p_stripes[p];
155 if (_1ps->write_count < group_width) {
156 unsigned c;
157 155
158 for (c = 0; c < data_devs; c++) 156 if (_1ps->page_is_read[c]) {
159 if (_1ps->page_is_read[c]) { 157 struct page *page = _1ps->pages[c];
160 struct page *page = _1ps->pages[c];
161 158
162 r4w->put_page(priv, page); 159 r4w->put_page(priv, page);
163 _1ps->page_is_read[c] = false; 160 _1ps->page_is_read[c] = false;
164 } 161 }
165 } 162 }
166 163
164 for (p = 0; p < sp2d->pages_in_unit; p++) {
165 struct __1_page_stripe *_1ps = &sp2d->_1p_stripes[p];
166
167 memset(_1ps->pages, 0, group_width * sizeof(*_1ps->pages)); 167 memset(_1ps->pages, 0, group_width * sizeof(*_1ps->pages));
168 _1ps->write_count = 0; 168 _1ps->write_count = 0;
169 _1ps->tx = NULL; 169 _1ps->tx = NULL;
@@ -461,16 +461,12 @@ static void _mark_read4write_pages_uptodate(struct ore_io_state *ios, int ret)
461 * ios->sp2d[p][*], xor is calculated the same way. These pages are 461 * ios->sp2d[p][*], xor is calculated the same way. These pages are
462 * allocated/freed and don't go through cache 462 * allocated/freed and don't go through cache
463 */ 463 */
464static int _read_4_write(struct ore_io_state *ios) 464static int _read_4_write_first_stripe(struct ore_io_state *ios)
465{ 465{
466 struct ore_io_state *ios_read;
467 struct ore_striping_info read_si; 466 struct ore_striping_info read_si;
468 struct __stripe_pages_2d *sp2d = ios->sp2d; 467 struct __stripe_pages_2d *sp2d = ios->sp2d;
469 u64 offset = ios->si.first_stripe_start; 468 u64 offset = ios->si.first_stripe_start;
470 u64 last_stripe_end; 469 unsigned c, p, min_p = sp2d->pages_in_unit, max_p = -1;
471 unsigned bytes_in_stripe = ios->si.bytes_in_stripe;
472 unsigned i, c, p, min_p = sp2d->pages_in_unit, max_p = -1;
473 int ret;
474 470
475 if (offset == ios->offset) /* Go to start collect $200 */ 471 if (offset == ios->offset) /* Go to start collect $200 */
476 goto read_last_stripe; 472 goto read_last_stripe;
@@ -478,6 +474,9 @@ static int _read_4_write(struct ore_io_state *ios)
478 min_p = _sp2d_min_pg(sp2d); 474 min_p = _sp2d_min_pg(sp2d);
479 max_p = _sp2d_max_pg(sp2d); 475 max_p = _sp2d_max_pg(sp2d);
480 476
477 ORE_DBGMSG("stripe_start=0x%llx ios->offset=0x%llx min_p=%d max_p=%d\n",
478 offset, ios->offset, min_p, max_p);
479
481 for (c = 0; ; c++) { 480 for (c = 0; ; c++) {
482 ore_calc_stripe_info(ios->layout, offset, 0, &read_si); 481 ore_calc_stripe_info(ios->layout, offset, 0, &read_si);
483 read_si.obj_offset += min_p * PAGE_SIZE; 482 read_si.obj_offset += min_p * PAGE_SIZE;
@@ -512,6 +511,18 @@ static int _read_4_write(struct ore_io_state *ios)
512 } 511 }
513 512
514read_last_stripe: 513read_last_stripe:
514 return 0;
515}
516
517static int _read_4_write_last_stripe(struct ore_io_state *ios)
518{
519 struct ore_striping_info read_si;
520 struct __stripe_pages_2d *sp2d = ios->sp2d;
521 u64 offset;
522 u64 last_stripe_end;
523 unsigned bytes_in_stripe = ios->si.bytes_in_stripe;
524 unsigned c, p, min_p = sp2d->pages_in_unit, max_p = -1;
525
515 offset = ios->offset + ios->length; 526 offset = ios->offset + ios->length;
516 if (offset % PAGE_SIZE) 527 if (offset % PAGE_SIZE)
517 _add_to_r4w_last_page(ios, &offset); 528 _add_to_r4w_last_page(ios, &offset);
@@ -527,15 +538,15 @@ read_last_stripe:
527 c = _dev_order(ios->layout->group_width * ios->layout->mirrors_p1, 538 c = _dev_order(ios->layout->group_width * ios->layout->mirrors_p1,
528 ios->layout->mirrors_p1, read_si.par_dev, read_si.dev); 539 ios->layout->mirrors_p1, read_si.par_dev, read_si.dev);
529 540
530 BUG_ON(ios->si.first_stripe_start + bytes_in_stripe != last_stripe_end);
531 /* unaligned IO must be within a single stripe */
532
533 if (min_p == sp2d->pages_in_unit) { 541 if (min_p == sp2d->pages_in_unit) {
534 /* Didn't do it yet */ 542 /* Didn't do it yet */
535 min_p = _sp2d_min_pg(sp2d); 543 min_p = _sp2d_min_pg(sp2d);
536 max_p = _sp2d_max_pg(sp2d); 544 max_p = _sp2d_max_pg(sp2d);
537 } 545 }
538 546
547 ORE_DBGMSG("offset=0x%llx stripe_end=0x%llx min_p=%d max_p=%d\n",
548 offset, last_stripe_end, min_p, max_p);
549
539 while (offset < last_stripe_end) { 550 while (offset < last_stripe_end) {
540 struct __1_page_stripe *_1ps = &sp2d->_1p_stripes[p]; 551 struct __1_page_stripe *_1ps = &sp2d->_1p_stripes[p];
541 552
@@ -568,6 +579,15 @@ read_last_stripe:
568 } 579 }
569 580
570read_it: 581read_it:
582 return 0;
583}
584
585static int _read_4_write_execute(struct ore_io_state *ios)
586{
587 struct ore_io_state *ios_read;
588 unsigned i;
589 int ret;
590
571 ios_read = ios->ios_read_4_write; 591 ios_read = ios->ios_read_4_write;
572 if (!ios_read) 592 if (!ios_read)
573 return 0; 593 return 0;
@@ -591,6 +611,8 @@ read_it:
591 } 611 }
592 612
593 _mark_read4write_pages_uptodate(ios_read, ret); 613 _mark_read4write_pages_uptodate(ios_read, ret);
614 ore_put_io_state(ios_read);
615 ios->ios_read_4_write = NULL; /* Might need a reuse at last stripe */
594 return 0; 616 return 0;
595} 617}
596 618
@@ -626,8 +648,11 @@ int _ore_add_parity_unit(struct ore_io_state *ios,
626 /* If first stripe, Read in all read4write pages 648 /* If first stripe, Read in all read4write pages
627 * (if needed) before we calculate the first parity. 649 * (if needed) before we calculate the first parity.
628 */ 650 */
629 _read_4_write(ios); 651 _read_4_write_first_stripe(ios);
630 } 652 }
653 if (!cur_len) /* If last stripe r4w pages of last stripe */
654 _read_4_write_last_stripe(ios);
655 _read_4_write_execute(ios);
631 656
632 for (i = 0; i < num_pages; i++) { 657 for (i = 0; i < num_pages; i++) {
633 pages[i] = _raid_page_alloc(); 658 pages[i] = _raid_page_alloc();
@@ -654,34 +679,14 @@ int _ore_add_parity_unit(struct ore_io_state *ios,
654 679
655int _ore_post_alloc_raid_stuff(struct ore_io_state *ios) 680int _ore_post_alloc_raid_stuff(struct ore_io_state *ios)
656{ 681{
657 struct ore_layout *layout = ios->layout;
658
659 if (ios->parity_pages) { 682 if (ios->parity_pages) {
683 struct ore_layout *layout = ios->layout;
660 unsigned pages_in_unit = layout->stripe_unit / PAGE_SIZE; 684 unsigned pages_in_unit = layout->stripe_unit / PAGE_SIZE;
661 unsigned stripe_size = ios->si.bytes_in_stripe;
662 u64 last_stripe, first_stripe;
663 685
664 if (_sp2d_alloc(pages_in_unit, layout->group_width, 686 if (_sp2d_alloc(pages_in_unit, layout->group_width,
665 layout->parity, &ios->sp2d)) { 687 layout->parity, &ios->sp2d)) {
666 return -ENOMEM; 688 return -ENOMEM;
667 } 689 }
668
669 /* Round io down to last full strip */
670 first_stripe = div_u64(ios->offset, stripe_size);
671 last_stripe = div_u64(ios->offset + ios->length, stripe_size);
672
673 /* If an IO spans more then a single stripe it must end at
674 * a stripe boundary. The reminder at the end is pushed into the
675 * next IO.
676 */
677 if (last_stripe != first_stripe) {
678 ios->length = last_stripe * stripe_size - ios->offset;
679
680 BUG_ON(!ios->length);
681 ios->nr_pages = (ios->length + PAGE_SIZE - 1) /
682 PAGE_SIZE;
683 ios->si.length = ios->length; /*make it consistent */
684 }
685 } 690 }
686 return 0; 691 return 0;
687} 692}
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index e34deac3f36..6ec6f9ee2fe 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -268,7 +268,6 @@ group_extend_out:
268 err = ext4_move_extents(filp, donor_filp, me.orig_start, 268 err = ext4_move_extents(filp, donor_filp, me.orig_start,
269 me.donor_start, me.len, &me.moved_len); 269 me.donor_start, me.len, &me.moved_len);
270 mnt_drop_write_file(filp); 270 mnt_drop_write_file(filp);
271 mnt_drop_write(filp->f_path.mnt);
272 271
273 if (copy_to_user((struct move_extent __user *)arg, 272 if (copy_to_user((struct move_extent __user *)arg,
274 &me, sizeof(me))) 273 &me, sizeof(me)))
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a3d81ebf6d8..0038b32cb36 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -738,22 +738,21 @@ static int
738fat_encode_fh(struct inode *inode, __u32 *fh, int *lenp, struct inode *parent) 738fat_encode_fh(struct inode *inode, __u32 *fh, int *lenp, struct inode *parent)
739{ 739{
740 int len = *lenp; 740 int len = *lenp;
741 u32 ipos_h, ipos_m, ipos_l; 741 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
742 loff_t i_pos;
742 743
743 if (len < 5) { 744 if (len < 5) {
744 *lenp = 5; 745 *lenp = 5;
745 return 255; /* no room */ 746 return 255; /* no room */
746 } 747 }
747 748
748 ipos_h = MSDOS_I(inode)->i_pos >> 8; 749 i_pos = fat_i_pos_read(sbi, inode);
749 ipos_m = (MSDOS_I(inode)->i_pos & 0xf0) << 24;
750 ipos_l = (MSDOS_I(inode)->i_pos & 0x0f) << 28;
751 *lenp = 5; 750 *lenp = 5;
752 fh[0] = inode->i_ino; 751 fh[0] = inode->i_ino;
753 fh[1] = inode->i_generation; 752 fh[1] = inode->i_generation;
754 fh[2] = ipos_h; 753 fh[2] = i_pos >> 8;
755 fh[3] = ipos_m | MSDOS_I(inode)->i_logstart; 754 fh[3] = ((i_pos & 0xf0) << 24) | MSDOS_I(inode)->i_logstart;
756 fh[4] = ipos_l; 755 fh[4] = (i_pos & 0x0f) << 28;
757 if (parent) 756 if (parent)
758 fh[4] |= MSDOS_I(parent)->i_logstart; 757 fh[4] |= MSDOS_I(parent)->i_logstart;
759 return 3; 758 return 3;
diff --git a/fs/fifo.c b/fs/fifo.c
index b1a524d798e..cf6f4345ceb 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -14,7 +14,7 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/pipe_fs_i.h> 15#include <linux/pipe_fs_i.h>
16 16
17static void wait_for_partner(struct inode* inode, unsigned int *cnt) 17static int wait_for_partner(struct inode* inode, unsigned int *cnt)
18{ 18{
19 int cur = *cnt; 19 int cur = *cnt;
20 20
@@ -23,6 +23,7 @@ static void wait_for_partner(struct inode* inode, unsigned int *cnt)
23 if (signal_pending(current)) 23 if (signal_pending(current))
24 break; 24 break;
25 } 25 }
26 return cur == *cnt ? -ERESTARTSYS : 0;
26} 27}
27 28
28static void wake_up_partner(struct inode* inode) 29static void wake_up_partner(struct inode* inode)
@@ -67,8 +68,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
67 * seen a writer */ 68 * seen a writer */
68 filp->f_version = pipe->w_counter; 69 filp->f_version = pipe->w_counter;
69 } else { 70 } else {
70 wait_for_partner(inode, &pipe->w_counter); 71 if (wait_for_partner(inode, &pipe->w_counter))
71 if(signal_pending(current))
72 goto err_rd; 72 goto err_rd;
73 } 73 }
74 } 74 }
@@ -90,8 +90,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
90 wake_up_partner(inode); 90 wake_up_partner(inode);
91 91
92 if (!pipe->readers) { 92 if (!pipe->readers) {
93 wait_for_partner(inode, &pipe->r_counter); 93 if (wait_for_partner(inode, &pipe->r_counter))
94 if (signal_pending(current))
95 goto err_wr; 94 goto err_wr;
96 } 95 }
97 break; 96 break;
diff --git a/fs/locks.c b/fs/locks.c
index 814c51d0de4..fce6238d52c 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1465,7 +1465,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1465 case F_WRLCK: 1465 case F_WRLCK:
1466 return generic_add_lease(filp, arg, flp); 1466 return generic_add_lease(filp, arg, flp);
1467 default: 1467 default:
1468 BUG(); 1468 return -EINVAL;
1469 } 1469 }
1470} 1470}
1471EXPORT_SYMBOL(generic_setlease); 1471EXPORT_SYMBOL(generic_setlease);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 9a4cbfc85d8..48253372ab1 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -484,6 +484,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
484 484
485 list_for_each_entry_safe(req, tmp, &reqs, wb_list) { 485 list_for_each_entry_safe(req, tmp, &reqs, wb_list) {
486 if (!nfs_pageio_add_request(&desc, req)) { 486 if (!nfs_pageio_add_request(&desc, req)) {
487 nfs_list_remove_request(req);
487 nfs_list_add_request(req, &failed); 488 nfs_list_add_request(req, &failed);
488 spin_lock(cinfo.lock); 489 spin_lock(cinfo.lock);
489 dreq->flags = 0; 490 dreq->flags = 0;
@@ -494,8 +495,11 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
494 } 495 }
495 nfs_pageio_complete(&desc); 496 nfs_pageio_complete(&desc);
496 497
497 while (!list_empty(&failed)) 498 while (!list_empty(&failed)) {
499 req = nfs_list_entry(failed.next);
500 nfs_list_remove_request(req);
498 nfs_unlock_and_release_request(req); 501 nfs_unlock_and_release_request(req);
502 }
499 503
500 if (put_dreq(dreq)) 504 if (put_dreq(dreq))
501 nfs_direct_write_complete(dreq, dreq->inode); 505 nfs_direct_write_complete(dreq, dreq->inode);
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index b47277baeba..f50d3e8d6f2 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -454,7 +454,10 @@ int objio_read_pagelist(struct nfs_read_data *rdata)
454 objios->ios->done = _read_done; 454 objios->ios->done = _read_done;
455 dprintk("%s: offset=0x%llx length=0x%x\n", __func__, 455 dprintk("%s: offset=0x%llx length=0x%x\n", __func__,
456 rdata->args.offset, rdata->args.count); 456 rdata->args.offset, rdata->args.count);
457 return ore_read(objios->ios); 457 ret = ore_read(objios->ios);
458 if (unlikely(ret))
459 objio_free_result(&objios->oir);
460 return ret;
458} 461}
459 462
460/* 463/*
@@ -486,8 +489,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
486 struct nfs_write_data *wdata = objios->oir.rpcdata; 489 struct nfs_write_data *wdata = objios->oir.rpcdata;
487 struct address_space *mapping = wdata->header->inode->i_mapping; 490 struct address_space *mapping = wdata->header->inode->i_mapping;
488 pgoff_t index = offset / PAGE_SIZE; 491 pgoff_t index = offset / PAGE_SIZE;
489 struct page *page = find_get_page(mapping, index); 492 struct page *page;
493 loff_t i_size = i_size_read(wdata->header->inode);
494
495 if (offset >= i_size) {
496 *uptodate = true;
497 dprintk("%s: g_zero_page index=0x%lx\n", __func__, index);
498 return ZERO_PAGE(0);
499 }
490 500
501 page = find_get_page(mapping, index);
491 if (!page) { 502 if (!page) {
492 page = find_or_create_page(mapping, index, GFP_NOFS); 503 page = find_or_create_page(mapping, index, GFP_NOFS);
493 if (unlikely(!page)) { 504 if (unlikely(!page)) {
@@ -507,8 +518,10 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
507 518
508static void __r4w_put_page(void *priv, struct page *page) 519static void __r4w_put_page(void *priv, struct page *page)
509{ 520{
510 dprintk("%s: index=0x%lx\n", __func__, page->index); 521 dprintk("%s: index=0x%lx\n", __func__,
511 page_cache_release(page); 522 (page == ZERO_PAGE(0)) ? -1UL : page->index);
523 if (ZERO_PAGE(0) != page)
524 page_cache_release(page);
512 return; 525 return;
513} 526}
514 527
@@ -539,8 +552,10 @@ int objio_write_pagelist(struct nfs_write_data *wdata, int how)
539 dprintk("%s: offset=0x%llx length=0x%x\n", __func__, 552 dprintk("%s: offset=0x%llx length=0x%x\n", __func__,
540 wdata->args.offset, wdata->args.count); 553 wdata->args.offset, wdata->args.count);
541 ret = ore_write(objios->ios); 554 ret = ore_write(objios->ios);
542 if (unlikely(ret)) 555 if (unlikely(ret)) {
556 objio_free_result(&objios->oir);
543 return ret; 557 return ret;
558 }
544 559
545 if (objios->sync) 560 if (objios->sync)
546 _write_done(objios->ios, objios); 561 _write_done(objios->ios, objios);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 906f09c7d84..06228192f64 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2860,6 +2860,8 @@ static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
2860 2860
2861 dfprintk(MOUNT, "--> nfs4_try_mount()\n"); 2861 dfprintk(MOUNT, "--> nfs4_try_mount()\n");
2862 2862
2863 mount_info->fill_super = nfs4_fill_super;
2864
2863 export_path = data->nfs_server.export_path; 2865 export_path = data->nfs_server.export_path;
2864 data->nfs_server.export_path = "/"; 2866 data->nfs_server.export_path = "/";
2865 root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info, 2867 root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 98513c8ed58..7602783d7f4 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1950,7 +1950,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1950 if (ret < 0) 1950 if (ret < 0)
1951 mlog_errno(ret); 1951 mlog_errno(ret);
1952 1952
1953 if (file->f_flags & O_SYNC) 1953 if (file && (file->f_flags & O_SYNC))
1954 handle->h_sync = 1; 1954 handle->h_sync = 1;
1955 1955
1956 ocfs2_commit_trans(osb, handle); 1956 ocfs2_commit_trans(osb, handle);
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index fbb0b478a34..d5378d02858 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -110,6 +110,7 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
110 110
111 /* prevent the page from being discarded on memory pressure */ 111 /* prevent the page from being discarded on memory pressure */
112 SetPageDirty(page); 112 SetPageDirty(page);
113 SetPageUptodate(page);
113 114
114 unlock_page(page); 115 unlock_page(page);
115 put_page(page); 116 put_page(page);
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index ef3d1ba6d99..15e2fc5aa60 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -718,8 +718,12 @@ static int fixup_free_space(struct ubifs_info *c)
718 lnum = ubifs_next_log_lnum(c, lnum); 718 lnum = ubifs_next_log_lnum(c, lnum);
719 } 719 }
720 720
721 /* Fixup the current log head */ 721 /*
722 err = fixup_leb(c, c->lhead_lnum, c->lhead_offs); 722 * Fixup the log head which contains the only a CS node at the
723 * beginning.
724 */
725 err = fixup_leb(c, c->lhead_lnum,
726 ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size));
723 if (err) 727 if (err)
724 goto out; 728 goto out;
725 729
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 9d1aeb7e273..4f33c32affe 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -1074,13 +1074,13 @@ restart:
1074 * If we couldn't get anything, give up. 1074 * If we couldn't get anything, give up.
1075 */ 1075 */
1076 if (bno_cur_lt == NULL && bno_cur_gt == NULL) { 1076 if (bno_cur_lt == NULL && bno_cur_gt == NULL) {
1077 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
1078
1077 if (!forced++) { 1079 if (!forced++) {
1078 trace_xfs_alloc_near_busy(args); 1080 trace_xfs_alloc_near_busy(args);
1079 xfs_log_force(args->mp, XFS_LOG_SYNC); 1081 xfs_log_force(args->mp, XFS_LOG_SYNC);
1080 goto restart; 1082 goto restart;
1081 } 1083 }
1082
1083 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
1084 trace_xfs_alloc_size_neither(args); 1084 trace_xfs_alloc_size_neither(args);
1085 args->agbno = NULLAGBLOCK; 1085 args->agbno = NULLAGBLOCK;
1086 return 0; 1086 return 0;
@@ -2434,13 +2434,22 @@ xfs_alloc_vextent_worker(
2434 current_restore_flags_nested(&pflags, PF_FSTRANS); 2434 current_restore_flags_nested(&pflags, PF_FSTRANS);
2435} 2435}
2436 2436
2437 2437/*
2438int /* error */ 2438 * Data allocation requests often come in with little stack to work on. Push
2439 * them off to a worker thread so there is lots of stack to use. Metadata
2440 * requests, OTOH, are generally from low stack usage paths, so avoid the
2441 * context switch overhead here.
2442 */
2443int
2439xfs_alloc_vextent( 2444xfs_alloc_vextent(
2440 xfs_alloc_arg_t *args) /* allocation argument structure */ 2445 struct xfs_alloc_arg *args)
2441{ 2446{
2442 DECLARE_COMPLETION_ONSTACK(done); 2447 DECLARE_COMPLETION_ONSTACK(done);
2443 2448
2449 if (!args->userdata)
2450 return __xfs_alloc_vextent(args);
2451
2452
2444 args->done = &done; 2453 args->done = &done;
2445 INIT_WORK_ONSTACK(&args->work, xfs_alloc_vextent_worker); 2454 INIT_WORK_ONSTACK(&args->work, xfs_alloc_vextent_worker);
2446 queue_work(xfs_alloc_wq, &args->work); 2455 queue_work(xfs_alloc_wq, &args->work);
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index a4beb421018..269b35c084d 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -989,27 +989,6 @@ xfs_buf_ioerror_alert(
989 (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length); 989 (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length);
990} 990}
991 991
992int
993xfs_bwrite(
994 struct xfs_buf *bp)
995{
996 int error;
997
998 ASSERT(xfs_buf_islocked(bp));
999
1000 bp->b_flags |= XBF_WRITE;
1001 bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q);
1002
1003 xfs_bdstrat_cb(bp);
1004
1005 error = xfs_buf_iowait(bp);
1006 if (error) {
1007 xfs_force_shutdown(bp->b_target->bt_mount,
1008 SHUTDOWN_META_IO_ERROR);
1009 }
1010 return error;
1011}
1012
1013/* 992/*
1014 * Called when we want to stop a buffer from getting written or read. 993 * Called when we want to stop a buffer from getting written or read.
1015 * We attach the EIO error, muck with its flags, and call xfs_buf_ioend 994 * We attach the EIO error, muck with its flags, and call xfs_buf_ioend
@@ -1079,14 +1058,7 @@ xfs_bioerror_relse(
1079 return EIO; 1058 return EIO;
1080} 1059}
1081 1060
1082 1061STATIC int
1083/*
1084 * All xfs metadata buffers except log state machine buffers
1085 * get this attached as their b_bdstrat callback function.
1086 * This is so that we can catch a buffer
1087 * after prematurely unpinning it to forcibly shutdown the filesystem.
1088 */
1089int
1090xfs_bdstrat_cb( 1062xfs_bdstrat_cb(
1091 struct xfs_buf *bp) 1063 struct xfs_buf *bp)
1092{ 1064{
@@ -1107,6 +1079,27 @@ xfs_bdstrat_cb(
1107 return 0; 1079 return 0;
1108} 1080}
1109 1081
1082int
1083xfs_bwrite(
1084 struct xfs_buf *bp)
1085{
1086 int error;
1087
1088 ASSERT(xfs_buf_islocked(bp));
1089
1090 bp->b_flags |= XBF_WRITE;
1091 bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q);
1092
1093 xfs_bdstrat_cb(bp);
1094
1095 error = xfs_buf_iowait(bp);
1096 if (error) {
1097 xfs_force_shutdown(bp->b_target->bt_mount,
1098 SHUTDOWN_META_IO_ERROR);
1099 }
1100 return error;
1101}
1102
1110/* 1103/*
1111 * Wrapper around bdstrat so that we can stop data from going to disk in case 1104 * Wrapper around bdstrat so that we can stop data from going to disk in case
1112 * we are shutting down the filesystem. Typically user data goes thru this 1105 * we are shutting down the filesystem. Typically user data goes thru this
@@ -1243,7 +1236,7 @@ xfs_buf_iorequest(
1243 */ 1236 */
1244 atomic_set(&bp->b_io_remaining, 1); 1237 atomic_set(&bp->b_io_remaining, 1);
1245 _xfs_buf_ioapply(bp); 1238 _xfs_buf_ioapply(bp);
1246 _xfs_buf_ioend(bp, 0); 1239 _xfs_buf_ioend(bp, 1);
1247 1240
1248 xfs_buf_rele(bp); 1241 xfs_buf_rele(bp);
1249} 1242}
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 7f1d1392ce3..79344c48008 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -180,7 +180,6 @@ extern void xfs_buf_unlock(xfs_buf_t *);
180extern int xfs_bwrite(struct xfs_buf *bp); 180extern int xfs_bwrite(struct xfs_buf *bp);
181 181
182extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); 182extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
183extern int xfs_bdstrat_cb(struct xfs_buf *);
184 183
185extern void xfs_buf_ioend(xfs_buf_t *, int); 184extern void xfs_buf_ioend(xfs_buf_t *, int);
186extern void xfs_buf_ioerror(xfs_buf_t *, int); 185extern void xfs_buf_ioerror(xfs_buf_t *, int);
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 45df2b857d4..d9e451115f9 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -954,7 +954,7 @@ xfs_buf_iodone_callbacks(
954 954
955 if (!XFS_BUF_ISSTALE(bp)) { 955 if (!XFS_BUF_ISSTALE(bp)) {
956 bp->b_flags |= XBF_WRITE | XBF_ASYNC | XBF_DONE; 956 bp->b_flags |= XBF_WRITE | XBF_ASYNC | XBF_DONE;
957 xfs_bdstrat_cb(bp); 957 xfs_buf_iorequest(bp);
958 } else { 958 } else {
959 xfs_buf_relse(bp); 959 xfs_buf_relse(bp);
960 } 960 }
diff --git a/include/asm-generic/dma-contiguous.h b/include/asm-generic/dma-contiguous.h
index c544356b374..294b1e755ab 100644
--- a/include/asm-generic/dma-contiguous.h
+++ b/include/asm-generic/dma-contiguous.h
@@ -18,7 +18,7 @@ static inline void dev_set_cma_area(struct device *dev, struct cma *cma)
18{ 18{
19 if (dev) 19 if (dev)
20 dev->cma_area = cma; 20 dev->cma_area = cma;
21 if (!dev || !dma_contiguous_default_area) 21 if (!dev && !dma_contiguous_default_area)
22 dma_contiguous_default_area = cma; 22 dma_contiguous_default_area = cma;
23} 23}
24 24
diff --git a/include/asm-generic/sizes.h b/include/asm-generic/sizes.h
index ea5d4ef8106..1dcfad9629e 100644
--- a/include/asm-generic/sizes.h
+++ b/include/asm-generic/sizes.h
@@ -1,47 +1,2 @@
1/* 1/* This is a placeholder, to be removed over time */
2 * linux/include/asm-generic/sizes.h 2#include <linux/sizes.h>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_GENERIC_SIZES_H__
9#define __ASM_GENERIC_SIZES_H__
10
11#define SZ_1 0x00000001
12#define SZ_2 0x00000002
13#define SZ_4 0x00000004
14#define SZ_8 0x00000008
15#define SZ_16 0x00000010
16#define SZ_32 0x00000020
17#define SZ_64 0x00000040
18#define SZ_128 0x00000080
19#define SZ_256 0x00000100
20#define SZ_512 0x00000200
21
22#define SZ_1K 0x00000400
23#define SZ_2K 0x00000800
24#define SZ_4K 0x00001000
25#define SZ_8K 0x00002000
26#define SZ_16K 0x00004000
27#define SZ_32K 0x00008000
28#define SZ_64K 0x00010000
29#define SZ_128K 0x00020000
30#define SZ_256K 0x00040000
31#define SZ_512K 0x00080000
32
33#define SZ_1M 0x00100000
34#define SZ_2M 0x00200000
35#define SZ_4M 0x00400000
36#define SZ_8M 0x00800000
37#define SZ_16M 0x01000000
38#define SZ_32M 0x02000000
39#define SZ_64M 0x04000000
40#define SZ_128M 0x08000000
41#define SZ_256M 0x10000000
42#define SZ_512M 0x20000000
43
44#define SZ_1G 0x40000000
45#define SZ_2G 0x80000000
46
47#endif /* __ASM_GENERIC_SIZES_H__ */
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 324fe08ea3b..6d6795d46a7 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -91,6 +91,11 @@ extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
91 unsigned long size, 91 unsigned long size,
92 unsigned long align, 92 unsigned long align,
93 unsigned long goal); 93 unsigned long goal);
94void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
95 unsigned long size,
96 unsigned long align,
97 unsigned long goal,
98 unsigned long limit);
94extern void *__alloc_bootmem_low(unsigned long size, 99extern void *__alloc_bootmem_low(unsigned long size,
95 unsigned long align, 100 unsigned long align,
96 unsigned long goal); 101 unsigned long goal);
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 68d56effc32..d10b7ed595b 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -360,11 +360,11 @@ struct cpu_vfs_cap_data {
360 360
361#define CAP_WAKE_ALARM 35 361#define CAP_WAKE_ALARM 35
362 362
363/* Allow preventing system suspends while epoll events are pending */ 363/* Allow preventing system suspends */
364 364
365#define CAP_EPOLLWAKEUP 36 365#define CAP_BLOCK_SUSPEND 36
366 366
367#define CAP_LAST_CAP CAP_EPOLLWAKEUP 367#define CAP_LAST_CAP CAP_BLOCK_SUSPEND
368 368
369#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP) 369#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
370 370
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 2521a95fa6d..44c87e731e9 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -163,16 +163,8 @@ struct ceph_connection {
163 163
164 /* connection negotiation temps */ 164 /* connection negotiation temps */
165 char in_banner[CEPH_BANNER_MAX_LEN]; 165 char in_banner[CEPH_BANNER_MAX_LEN];
166 union { 166 struct ceph_msg_connect out_connect;
167 struct { /* outgoing connection */ 167 struct ceph_msg_connect_reply in_reply;
168 struct ceph_msg_connect out_connect;
169 struct ceph_msg_connect_reply in_reply;
170 };
171 struct { /* incoming */
172 struct ceph_msg_connect in_connect;
173 struct ceph_msg_connect_reply out_reply;
174 };
175 };
176 struct ceph_entity_addr actual_peer_addr; 168 struct ceph_entity_addr actual_peer_addr;
177 169
178 /* message out temps */ 170 /* message out temps */
diff --git a/include/linux/device.h b/include/linux/device.h
index 161d96241b1..6de94151ff6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -865,8 +865,6 @@ extern int (*platform_notify_remove)(struct device *dev);
865extern struct device *get_device(struct device *dev); 865extern struct device *get_device(struct device *dev);
866extern void put_device(struct device *dev); 866extern void put_device(struct device *dev);
867 867
868extern void wait_for_device_probe(void);
869
870#ifdef CONFIG_DEVTMPFS 868#ifdef CONFIG_DEVTMPFS
871extern int devtmpfs_create_node(struct device *dev); 869extern int devtmpfs_create_node(struct device *dev);
872extern int devtmpfs_delete_node(struct device *dev); 870extern int devtmpfs_delete_node(struct device *dev);
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 6f8be328770..f4bb378ccf6 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -34,7 +34,7 @@
34 * re-allowed until epoll_wait is called again after consuming the wakeup 34 * re-allowed until epoll_wait is called again after consuming the wakeup
35 * event(s). 35 * event(s).
36 * 36 *
37 * Requires CAP_EPOLLWAKEUP 37 * Requires CAP_BLOCK_SUSPEND
38 */ 38 */
39#define EPOLLWAKEUP (1 << 29) 39#define EPOLLWAKEUP (1 << 29)
40 40
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index f07fc2d0815..2e31e8b3a19 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -22,8 +22,8 @@
22/* Gpio pin is open source */ 22/* Gpio pin is open source */
23#define GPIOF_OPEN_SOURCE (1 << 3) 23#define GPIOF_OPEN_SOURCE (1 << 3)
24 24
25#define GPIOF_EXPORT (1 << 2) 25#define GPIOF_EXPORT (1 << 4)
26#define GPIOF_EXPORT_CHANGEABLE (1 << 3) 26#define GPIOF_EXPORT_CHANGEABLE (1 << 5)
27#define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT) 27#define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
28#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE) 28#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
29 29
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index fd0dc30c9f1..cc07d2777bb 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -165,6 +165,7 @@ enum hrtimer_base_type {
165 * @lock: lock protecting the base and associated clock bases 165 * @lock: lock protecting the base and associated clock bases
166 * and timers 166 * and timers
167 * @active_bases: Bitfield to mark bases with active timers 167 * @active_bases: Bitfield to mark bases with active timers
168 * @clock_was_set: Indicates that clock was set from irq context.
168 * @expires_next: absolute time of the next event which was scheduled 169 * @expires_next: absolute time of the next event which was scheduled
169 * via clock_set_next_event() 170 * via clock_set_next_event()
170 * @hres_active: State of high resolution mode 171 * @hres_active: State of high resolution mode
@@ -177,7 +178,8 @@ enum hrtimer_base_type {
177 */ 178 */
178struct hrtimer_cpu_base { 179struct hrtimer_cpu_base {
179 raw_spinlock_t lock; 180 raw_spinlock_t lock;
180 unsigned long active_bases; 181 unsigned int active_bases;
182 unsigned int clock_was_set;
181#ifdef CONFIG_HIGH_RES_TIMERS 183#ifdef CONFIG_HIGH_RES_TIMERS
182 ktime_t expires_next; 184 ktime_t expires_next;
183 int hres_active; 185 int hres_active;
@@ -286,6 +288,8 @@ extern void hrtimer_peek_ahead_timers(void);
286# define MONOTONIC_RES_NSEC HIGH_RES_NSEC 288# define MONOTONIC_RES_NSEC HIGH_RES_NSEC
287# define KTIME_MONOTONIC_RES KTIME_HIGH_RES 289# define KTIME_MONOTONIC_RES KTIME_HIGH_RES
288 290
291extern void clock_was_set_delayed(void);
292
289#else 293#else
290 294
291# define MONOTONIC_RES_NSEC LOW_RES_NSEC 295# define MONOTONIC_RES_NSEC LOW_RES_NSEC
@@ -306,6 +310,9 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
306{ 310{
307 return 0; 311 return 0;
308} 312}
313
314static inline void clock_was_set_delayed(void) { }
315
309#endif 316#endif
310 317
311extern void clock_was_set(void); 318extern void clock_was_set(void);
@@ -320,6 +327,7 @@ extern ktime_t ktime_get(void);
320extern ktime_t ktime_get_real(void); 327extern ktime_t ktime_get_real(void);
321extern ktime_t ktime_get_boottime(void); 328extern ktime_t ktime_get_boottime(void);
322extern ktime_t ktime_get_monotonic_offset(void); 329extern ktime_t ktime_get_monotonic_offset(void);
330extern ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot);
323 331
324DECLARE_PER_CPU(struct tick_device, tick_cpu_device); 332DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
325 333
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e07f5e0c5df..604382143bc 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -377,7 +377,6 @@ extern enum system_states {
377 SYSTEM_HALT, 377 SYSTEM_HALT,
378 SYSTEM_POWER_OFF, 378 SYSTEM_POWER_OFF,
379 SYSTEM_RESTART, 379 SYSTEM_RESTART,
380 SYSTEM_SUSPEND_DISK,
381} system_state; 380} system_state;
382 381
383#define TAINT_PROPRIETARY_MODULE 0 382#define TAINT_PROPRIETARY_MODULE 0
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
index d6bd50110ec..2e7a1e032c7 100644
--- a/include/linux/kmsg_dump.h
+++ b/include/linux/kmsg_dump.h
@@ -55,12 +55,17 @@ struct kmsg_dumper {
55#ifdef CONFIG_PRINTK 55#ifdef CONFIG_PRINTK
56void kmsg_dump(enum kmsg_dump_reason reason); 56void kmsg_dump(enum kmsg_dump_reason reason);
57 57
58bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
59 char *line, size_t size, size_t *len);
60
58bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog, 61bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
59 char *line, size_t size, size_t *len); 62 char *line, size_t size, size_t *len);
60 63
61bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog, 64bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
62 char *buf, size_t size, size_t *len); 65 char *buf, size_t size, size_t *len);
63 66
67void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper);
68
64void kmsg_dump_rewind(struct kmsg_dumper *dumper); 69void kmsg_dump_rewind(struct kmsg_dumper *dumper);
65 70
66int kmsg_dump_register(struct kmsg_dumper *dumper); 71int kmsg_dump_register(struct kmsg_dumper *dumper);
@@ -71,6 +76,13 @@ static inline void kmsg_dump(enum kmsg_dump_reason reason)
71{ 76{
72} 77}
73 78
79static inline bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper,
80 bool syslog, const char *line,
81 size_t size, size_t *len)
82{
83 return false;
84}
85
74static inline bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog, 86static inline bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
75 const char *line, size_t size, size_t *len) 87 const char *line, size_t size, size_t *len)
76{ 88{
@@ -83,6 +95,10 @@ static inline bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
83 return false; 95 return false;
84} 96}
85 97
98static inline void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
99{
100}
101
86static inline void kmsg_dump_rewind(struct kmsg_dumper *dumper) 102static inline void kmsg_dump_rewind(struct kmsg_dumper *dumper)
87{ 103{
88} 104}
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index a6bb1023514..19dc455b4f3 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -50,9 +50,7 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end,
50 phys_addr_t size, phys_addr_t align, int nid); 50 phys_addr_t size, phys_addr_t align, int nid);
51phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, 51phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
52 phys_addr_t size, phys_addr_t align); 52 phys_addr_t size, phys_addr_t align);
53int memblock_free_reserved_regions(void); 53phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
54int memblock_reserve_reserved_regions(void);
55
56void memblock_allow_resize(void); 54void memblock_allow_resize(void);
57int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); 55int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
58int memblock_add(phys_addr_t base, phys_addr_t size); 56int memblock_add(phys_addr_t base, phys_addr_t size);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 2427706f78b..68c569fcbb6 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -694,7 +694,7 @@ typedef struct pglist_data {
694 range, including holes */ 694 range, including holes */
695 int node_id; 695 int node_id;
696 wait_queue_head_t kswapd_wait; 696 wait_queue_head_t kswapd_wait;
697 struct task_struct *kswapd; 697 struct task_struct *kswapd; /* Protected by lock_memory_hotplug() */
698 int kswapd_max_order; 698 int kswapd_max_order;
699 enum zone_type classzone_idx; 699 enum zone_type classzone_idx;
700} pg_data_t; 700} pg_data_t;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fefb4e19bf6..d8c379dba6a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -176,8 +176,6 @@ enum pci_dev_flags {
176 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2, 176 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
177 /* Provide indication device is assigned by a Virtual Machine Manager */ 177 /* Provide indication device is assigned by a Virtual Machine Manager */
178 PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4, 178 PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4,
179 /* Device causes system crash if in D3 during S3 sleep */
180 PCI_DEV_FLAGS_NO_D3_DURING_SLEEP = (__force pci_dev_flags_t) 8,
181}; 179};
182 180
183enum pci_irq_reroute_variant { 181enum pci_irq_reroute_variant {
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 26d1a47591f..9cac722b169 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -184,7 +184,6 @@ static inline int rcu_preempt_depth(void)
184/* Internal to kernel */ 184/* Internal to kernel */
185extern void rcu_sched_qs(int cpu); 185extern void rcu_sched_qs(int cpu);
186extern void rcu_bh_qs(int cpu); 186extern void rcu_bh_qs(int cpu);
187extern void rcu_preempt_note_context_switch(void);
188extern void rcu_check_callbacks(int cpu, int user); 187extern void rcu_check_callbacks(int cpu, int user);
189struct notifier_block; 188struct notifier_block;
190extern void rcu_idle_enter(void); 189extern void rcu_idle_enter(void);
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index 854dc4c5c27..4e56a9c69a3 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -87,6 +87,10 @@ static inline void kfree_call_rcu(struct rcu_head *head,
87 87
88#ifdef CONFIG_TINY_RCU 88#ifdef CONFIG_TINY_RCU
89 89
90static inline void rcu_preempt_note_context_switch(void)
91{
92}
93
90static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) 94static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
91{ 95{
92 *delta_jiffies = ULONG_MAX; 96 *delta_jiffies = ULONG_MAX;
@@ -95,6 +99,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
95 99
96#else /* #ifdef CONFIG_TINY_RCU */ 100#else /* #ifdef CONFIG_TINY_RCU */
97 101
102void rcu_preempt_note_context_switch(void);
98int rcu_preempt_needs_cpu(void); 103int rcu_preempt_needs_cpu(void);
99 104
100static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies) 105static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
@@ -108,6 +113,7 @@ static inline int rcu_needs_cpu(int cpu, unsigned long *delta_jiffies)
108static inline void rcu_note_context_switch(int cpu) 113static inline void rcu_note_context_switch(int cpu)
109{ 114{
110 rcu_sched_qs(cpu); 115 rcu_sched_qs(cpu);
116 rcu_preempt_note_context_switch();
111} 117}
112 118
113/* 119/*
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index a8e50e44203..82a673905ed 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -38,6 +38,8 @@
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/mod_devicetable.h> 40#include <linux/mod_devicetable.h>
41#include <linux/kref.h>
42#include <linux/mutex.h>
41 43
42/* The feature bitmap for virtio rpmsg */ 44/* The feature bitmap for virtio rpmsg */
43#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ 45#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
@@ -120,7 +122,9 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
120/** 122/**
121 * struct rpmsg_endpoint - binds a local rpmsg address to its user 123 * struct rpmsg_endpoint - binds a local rpmsg address to its user
122 * @rpdev: rpmsg channel device 124 * @rpdev: rpmsg channel device
125 * @refcount: when this drops to zero, the ept is deallocated
123 * @cb: rx callback handler 126 * @cb: rx callback handler
127 * @cb_lock: must be taken before accessing/changing @cb
124 * @addr: local rpmsg address 128 * @addr: local rpmsg address
125 * @priv: private data for the driver's use 129 * @priv: private data for the driver's use
126 * 130 *
@@ -140,7 +144,9 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
140 */ 144 */
141struct rpmsg_endpoint { 145struct rpmsg_endpoint {
142 struct rpmsg_channel *rpdev; 146 struct rpmsg_channel *rpdev;
147 struct kref refcount;
143 rpmsg_rx_cb_t cb; 148 rpmsg_rx_cb_t cb;
149 struct mutex cb_lock;
144 u32 addr; 150 u32 addr;
145 void *priv; 151 void *priv;
146}; 152};
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4059c0f33f0..4a1f493e0fe 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1871,22 +1871,12 @@ static inline void rcu_copy_process(struct task_struct *p)
1871 INIT_LIST_HEAD(&p->rcu_node_entry); 1871 INIT_LIST_HEAD(&p->rcu_node_entry);
1872} 1872}
1873 1873
1874static inline void rcu_switch_from(struct task_struct *prev)
1875{
1876 if (prev->rcu_read_lock_nesting != 0)
1877 rcu_preempt_note_context_switch();
1878}
1879
1880#else 1874#else
1881 1875
1882static inline void rcu_copy_process(struct task_struct *p) 1876static inline void rcu_copy_process(struct task_struct *p)
1883{ 1877{
1884} 1878}
1885 1879
1886static inline void rcu_switch_from(struct task_struct *prev)
1887{
1888}
1889
1890#endif 1880#endif
1891 1881
1892#ifdef CONFIG_SMP 1882#ifdef CONFIG_SMP
@@ -1909,6 +1899,14 @@ static inline int set_cpus_allowed_ptr(struct task_struct *p,
1909} 1899}
1910#endif 1900#endif
1911 1901
1902#ifdef CONFIG_NO_HZ
1903void calc_load_enter_idle(void);
1904void calc_load_exit_idle(void);
1905#else
1906static inline void calc_load_enter_idle(void) { }
1907static inline void calc_load_exit_idle(void) { }
1908#endif /* CONFIG_NO_HZ */
1909
1912#ifndef CONFIG_CPUMASK_OFFSTACK 1910#ifndef CONFIG_CPUMASK_OFFSTACK
1913static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) 1911static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1914{ 1912{
diff --git a/include/linux/sizes.h b/include/linux/sizes.h
new file mode 100644
index 00000000000..ce3e8150c17
--- /dev/null
+++ b/include/linux/sizes.h
@@ -0,0 +1,47 @@
1/*
2 * include/linux/sizes.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __LINUX_SIZES_H__
9#define __LINUX_SIZES_H__
10
11#define SZ_1 0x00000001
12#define SZ_2 0x00000002
13#define SZ_4 0x00000004
14#define SZ_8 0x00000008
15#define SZ_16 0x00000010
16#define SZ_32 0x00000020
17#define SZ_64 0x00000040
18#define SZ_128 0x00000080
19#define SZ_256 0x00000100
20#define SZ_512 0x00000200
21
22#define SZ_1K 0x00000400
23#define SZ_2K 0x00000800
24#define SZ_4K 0x00001000
25#define SZ_8K 0x00002000
26#define SZ_16K 0x00004000
27#define SZ_32K 0x00008000
28#define SZ_64K 0x00010000
29#define SZ_128K 0x00020000
30#define SZ_256K 0x00040000
31#define SZ_512K 0x00080000
32
33#define SZ_1M 0x00100000
34#define SZ_2M 0x00200000
35#define SZ_4M 0x00400000
36#define SZ_8M 0x00800000
37#define SZ_16M 0x01000000
38#define SZ_32M 0x02000000
39#define SZ_64M 0x04000000
40#define SZ_128M 0x08000000
41#define SZ_256M 0x10000000
42#define SZ_512M 0x20000000
43
44#define SZ_1G 0x40000000
45#define SZ_2G 0x80000000
46
47#endif /* __LINUX_SIZES_H__ */
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index d6146b4811c..95374d1696a 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1425,7 +1425,7 @@ static inline void ip_vs_notrack(struct sk_buff *skb)
1425 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 1425 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
1426 1426
1427 if (!ct || !nf_ct_is_untracked(ct)) { 1427 if (!ct || !nf_ct_is_untracked(ct)) {
1428 nf_reset(skb); 1428 nf_conntrack_put(skb->nfct);
1429 skb->nfct = &nf_ct_untracked_get()->ct_general; 1429 skb->nfct = &nf_ct_untracked_get()->ct_general;
1430 skb->nfctinfo = IP_CT_NEW; 1430 skb->nfctinfo = IP_CT_NEW;
1431 nf_conntrack_get(skb->nfct); 1431 nf_conntrack_get(skb->nfct);
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index a88fb693938..e1ce1048fe5 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -78,7 +78,7 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
78 struct net *net = nf_ct_net(ct); 78 struct net *net = nf_ct_net(ct);
79 struct nf_conntrack_ecache *e; 79 struct nf_conntrack_ecache *e;
80 80
81 if (net->ct.nf_conntrack_event_cb == NULL) 81 if (!rcu_access_pointer(net->ct.nf_conntrack_event_cb))
82 return; 82 return;
83 83
84 e = nf_ct_ecache_find(ct); 84 e = nf_ct_ecache_find(ct);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index f4f1c96dca7..10ce74f589c 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -163,6 +163,8 @@ enum ata_command_set {
163 ATAPI_COMMAND_SET = 1, 163 ATAPI_COMMAND_SET = 1,
164}; 164};
165 165
166#define ATA_RESP_FIS_SIZE 24
167
166struct sata_device { 168struct sata_device {
167 enum ata_command_set command_set; 169 enum ata_command_set command_set;
168 struct smp_resp rps_resp; /* report_phy_sata_resp */ 170 struct smp_resp rps_resp; /* report_phy_sata_resp */
@@ -171,7 +173,7 @@ struct sata_device {
171 173
172 struct ata_port *ap; 174 struct ata_port *ap;
173 struct ata_host ata_host; 175 struct ata_host ata_host;
174 struct ata_taskfile tf; 176 u8 fis[ATA_RESP_FIS_SIZE];
175}; 177};
176 178
177enum { 179enum {
@@ -537,7 +539,7 @@ enum exec_status {
537 */ 539 */
538struct ata_task_resp { 540struct ata_task_resp {
539 u16 frame_len; 541 u16 frame_len;
540 u8 ending_fis[24]; /* dev to host or data-in */ 542 u8 ending_fis[ATA_RESP_FIS_SIZE]; /* dev to host or data-in */
541}; 543};
542 544
543#define SAS_STATUS_BUF_SIZE 96 545#define SAS_STATUS_BUF_SIZE 96
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 1e1198546c7..ac06cc59589 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -134,10 +134,16 @@ struct scsi_cmnd {
134 134
135static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) 135static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
136{ 136{
137 struct scsi_driver **sdp;
138
137 if (!cmd->request->rq_disk) 139 if (!cmd->request->rq_disk)
138 return NULL; 140 return NULL;
139 141
140 return *(struct scsi_driver **)cmd->request->rq_disk->private_data; 142 sdp = (struct scsi_driver **)cmd->request->rq_disk->private_data;
143 if (!sdp)
144 return NULL;
145
146 return *sdp;
141} 147}
142 148
143extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 149extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
diff --git a/init/Kconfig b/init/Kconfig
index d07dcf9fc8a..b3f55f15e10 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -357,7 +357,7 @@ config AUDIT
357 357
358config AUDITSYSCALL 358config AUDITSYSCALL
359 bool "Enable system-call auditing support" 359 bool "Enable system-call auditing support"
360 depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || ARM) 360 depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT))
361 default y if SECURITY_SELINUX 361 default y if SECURITY_SELINUX
362 help 362 help
363 Enable low-overhead system-call auditing infrastructure that 363 Enable low-overhead system-call auditing infrastructure that
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2097684cf19..b303dfc7dce 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -901,13 +901,10 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
901 mutex_unlock(&cgroup_mutex); 901 mutex_unlock(&cgroup_mutex);
902 902
903 /* 903 /*
904 * We want to drop the active superblock reference from the 904 * Drop the active superblock reference that we took when we
905 * cgroup creation after all the dentry refs are gone - 905 * created the cgroup
906 * kill_sb gets mighty unhappy otherwise. Mark
907 * dentry->d_fsdata with cgroup_diput() to tell
908 * cgroup_d_release() to call deactivate_super().
909 */ 906 */
910 dentry->d_fsdata = cgroup_diput; 907 deactivate_super(cgrp->root->sb);
911 908
912 /* 909 /*
913 * if we're getting rid of the cgroup, refcount should ensure 910 * if we're getting rid of the cgroup, refcount should ensure
@@ -933,13 +930,6 @@ static int cgroup_delete(const struct dentry *d)
933 return 1; 930 return 1;
934} 931}
935 932
936static void cgroup_d_release(struct dentry *dentry)
937{
938 /* did cgroup_diput() tell me to deactivate super? */
939 if (dentry->d_fsdata == cgroup_diput)
940 deactivate_super(dentry->d_sb);
941}
942
943static void remove_dir(struct dentry *d) 933static void remove_dir(struct dentry *d)
944{ 934{
945 struct dentry *parent = dget(d->d_parent); 935 struct dentry *parent = dget(d->d_parent);
@@ -1547,7 +1537,6 @@ static int cgroup_get_rootdir(struct super_block *sb)
1547 static const struct dentry_operations cgroup_dops = { 1537 static const struct dentry_operations cgroup_dops = {
1548 .d_iput = cgroup_diput, 1538 .d_iput = cgroup_diput,
1549 .d_delete = cgroup_delete, 1539 .d_delete = cgroup_delete,
1550 .d_release = cgroup_d_release,
1551 }; 1540 };
1552 1541
1553 struct inode *inode = 1542 struct inode *inode =
@@ -3894,8 +3883,12 @@ static void css_dput_fn(struct work_struct *work)
3894{ 3883{
3895 struct cgroup_subsys_state *css = 3884 struct cgroup_subsys_state *css =
3896 container_of(work, struct cgroup_subsys_state, dput_work); 3885 container_of(work, struct cgroup_subsys_state, dput_work);
3886 struct dentry *dentry = css->cgroup->dentry;
3887 struct super_block *sb = dentry->d_sb;
3897 3888
3898 dput(css->cgroup->dentry); 3889 atomic_inc(&sb->s_active);
3890 dput(dentry);
3891 deactivate_super(sb);
3899} 3892}
3900 3893
3901static void init_cgroup_css(struct cgroup_subsys_state *css, 3894static void init_cgroup_css(struct cgroup_subsys_state *css,
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 67b847dfa2b..1f91413edb8 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -14,6 +14,7 @@
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/kmsg_dump.h>
17#include <linux/reboot.h> 18#include <linux/reboot.h>
18#include <linux/sched.h> 19#include <linux/sched.h>
19#include <linux/sysrq.h> 20#include <linux/sysrq.h>
@@ -2040,8 +2041,15 @@ static int kdb_env(int argc, const char **argv)
2040 */ 2041 */
2041static int kdb_dmesg(int argc, const char **argv) 2042static int kdb_dmesg(int argc, const char **argv)
2042{ 2043{
2043 char *syslog_data[4], *start, *end, c = '\0', *p; 2044 int diag;
2044 int diag, logging, logsize, lines = 0, adjust = 0, n; 2045 int logging;
2046 int lines = 0;
2047 int adjust = 0;
2048 int n = 0;
2049 int skip = 0;
2050 struct kmsg_dumper dumper = { .active = 1 };
2051 size_t len;
2052 char buf[201];
2045 2053
2046 if (argc > 2) 2054 if (argc > 2)
2047 return KDB_ARGCOUNT; 2055 return KDB_ARGCOUNT;
@@ -2064,22 +2072,10 @@ static int kdb_dmesg(int argc, const char **argv)
2064 kdb_set(2, setargs); 2072 kdb_set(2, setargs);
2065 } 2073 }
2066 2074
2067 /* syslog_data[0,1] physical start, end+1. syslog_data[2,3] 2075 kmsg_dump_rewind_nolock(&dumper);
2068 * logical start, end+1. */ 2076 while (kmsg_dump_get_line_nolock(&dumper, 1, NULL, 0, NULL))
2069 kdb_syslog_data(syslog_data); 2077 n++;
2070 if (syslog_data[2] == syslog_data[3]) 2078
2071 return 0;
2072 logsize = syslog_data[1] - syslog_data[0];
2073 start = syslog_data[2];
2074 end = syslog_data[3];
2075#define KDB_WRAP(p) (((p - syslog_data[0]) % logsize) + syslog_data[0])
2076 for (n = 0, p = start; p < end; ++p) {
2077 c = *KDB_WRAP(p);
2078 if (c == '\n')
2079 ++n;
2080 }
2081 if (c != '\n')
2082 ++n;
2083 if (lines < 0) { 2079 if (lines < 0) {
2084 if (adjust >= n) 2080 if (adjust >= n)
2085 kdb_printf("buffer only contains %d lines, nothing " 2081 kdb_printf("buffer only contains %d lines, nothing "
@@ -2087,21 +2083,11 @@ static int kdb_dmesg(int argc, const char **argv)
2087 else if (adjust - lines >= n) 2083 else if (adjust - lines >= n)
2088 kdb_printf("buffer only contains %d lines, last %d " 2084 kdb_printf("buffer only contains %d lines, last %d "
2089 "lines printed\n", n, n - adjust); 2085 "lines printed\n", n, n - adjust);
2090 if (adjust) { 2086 skip = adjust;
2091 for (; start < end && adjust; ++start) { 2087 lines = abs(lines);
2092 if (*KDB_WRAP(start) == '\n')
2093 --adjust;
2094 }
2095 if (start < end)
2096 ++start;
2097 }
2098 for (p = start; p < end && lines; ++p) {
2099 if (*KDB_WRAP(p) == '\n')
2100 ++lines;
2101 }
2102 end = p;
2103 } else if (lines > 0) { 2088 } else if (lines > 0) {
2104 int skip = n - (adjust + lines); 2089 skip = n - lines - adjust;
2090 lines = abs(lines);
2105 if (adjust >= n) { 2091 if (adjust >= n) {
2106 kdb_printf("buffer only contains %d lines, " 2092 kdb_printf("buffer only contains %d lines, "
2107 "nothing printed\n", n); 2093 "nothing printed\n", n);
@@ -2112,35 +2098,24 @@ static int kdb_dmesg(int argc, const char **argv)
2112 kdb_printf("buffer only contains %d lines, first " 2098 kdb_printf("buffer only contains %d lines, first "
2113 "%d lines printed\n", n, lines); 2099 "%d lines printed\n", n, lines);
2114 } 2100 }
2115 for (; start < end && skip; ++start) { 2101 } else {
2116 if (*KDB_WRAP(start) == '\n') 2102 lines = n;
2117 --skip;
2118 }
2119 for (p = start; p < end && lines; ++p) {
2120 if (*KDB_WRAP(p) == '\n')
2121 --lines;
2122 }
2123 end = p;
2124 } 2103 }
2125 /* Do a line at a time (max 200 chars) to reduce protocol overhead */ 2104
2126 c = '\n'; 2105 if (skip >= n || skip < 0)
2127 while (start != end) { 2106 return 0;
2128 char buf[201]; 2107
2129 p = buf; 2108 kmsg_dump_rewind_nolock(&dumper);
2130 if (KDB_FLAG(CMD_INTERRUPT)) 2109 while (kmsg_dump_get_line_nolock(&dumper, 1, buf, sizeof(buf), &len)) {
2131 return 0; 2110 if (skip) {
2132 while (start < end && (c = *KDB_WRAP(start)) && 2111 skip--;
2133 (p - buf) < sizeof(buf)-1) { 2112 continue;
2134 ++start;
2135 *p++ = c;
2136 if (c == '\n')
2137 break;
2138 } 2113 }
2139 *p = '\0'; 2114 if (!lines--)
2140 kdb_printf("%s", buf); 2115 break;
2116
2117 kdb_printf("%.*s\n", (int)len - 1, buf);
2141 } 2118 }
2142 if (c != '\n')
2143 kdb_printf("\n");
2144 2119
2145 return 0; 2120 return 0;
2146} 2121}
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index 47c4e56e513..392ec6a2584 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -205,7 +205,6 @@ extern char kdb_grep_string[];
205extern int kdb_grep_leading; 205extern int kdb_grep_leading;
206extern int kdb_grep_trailing; 206extern int kdb_grep_trailing;
207extern char *kdb_cmds[]; 207extern char *kdb_cmds[];
208extern void kdb_syslog_data(char *syslog_data[]);
209extern unsigned long kdb_task_state_string(const char *); 208extern unsigned long kdb_task_state_string(const char *);
210extern char kdb_task_state_char (const struct task_struct *); 209extern char kdb_task_state_char (const struct task_struct *);
211extern unsigned long kdb_task_state(const struct task_struct *p, 210extern unsigned long kdb_task_state(const struct task_struct *p,
diff --git a/kernel/fork.c b/kernel/fork.c
index ab5211b9e62..f00e319d837 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -304,12 +304,17 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
304 } 304 }
305 305
306 err = arch_dup_task_struct(tsk, orig); 306 err = arch_dup_task_struct(tsk, orig);
307 if (err)
308 goto out;
309 307
308 /*
309 * We defer looking at err, because we will need this setup
310 * for the clean up path to work correctly.
311 */
310 tsk->stack = ti; 312 tsk->stack = ti;
311
312 setup_thread_stack(tsk, orig); 313 setup_thread_stack(tsk, orig);
314
315 if (err)
316 goto out;
317
313 clear_user_return_notifier(tsk); 318 clear_user_return_notifier(tsk);
314 clear_tsk_need_resched(tsk); 319 clear_tsk_need_resched(tsk);
315 stackend = end_of_stack(tsk); 320 stackend = end_of_stack(tsk);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index ae34bf51682..6db7a5ed52b 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -657,6 +657,14 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
657 return 0; 657 return 0;
658} 658}
659 659
660static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
661{
662 ktime_t *offs_real = &base->clock_base[HRTIMER_BASE_REALTIME].offset;
663 ktime_t *offs_boot = &base->clock_base[HRTIMER_BASE_BOOTTIME].offset;
664
665 return ktime_get_update_offsets(offs_real, offs_boot);
666}
667
660/* 668/*
661 * Retrigger next event is called after clock was set 669 * Retrigger next event is called after clock was set
662 * 670 *
@@ -665,22 +673,12 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
665static void retrigger_next_event(void *arg) 673static void retrigger_next_event(void *arg)
666{ 674{
667 struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases); 675 struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
668 struct timespec realtime_offset, xtim, wtm, sleep;
669 676
670 if (!hrtimer_hres_active()) 677 if (!hrtimer_hres_active())
671 return; 678 return;
672 679
673 /* Optimized out for !HIGH_RES */
674 get_xtime_and_monotonic_and_sleep_offset(&xtim, &wtm, &sleep);
675 set_normalized_timespec(&realtime_offset, -wtm.tv_sec, -wtm.tv_nsec);
676
677 /* Adjust CLOCK_REALTIME offset */
678 raw_spin_lock(&base->lock); 680 raw_spin_lock(&base->lock);
679 base->clock_base[HRTIMER_BASE_REALTIME].offset = 681 hrtimer_update_base(base);
680 timespec_to_ktime(realtime_offset);
681 base->clock_base[HRTIMER_BASE_BOOTTIME].offset =
682 timespec_to_ktime(sleep);
683
684 hrtimer_force_reprogram(base, 0); 682 hrtimer_force_reprogram(base, 0);
685 raw_spin_unlock(&base->lock); 683 raw_spin_unlock(&base->lock);
686} 684}
@@ -710,13 +708,25 @@ static int hrtimer_switch_to_hres(void)
710 base->clock_base[i].resolution = KTIME_HIGH_RES; 708 base->clock_base[i].resolution = KTIME_HIGH_RES;
711 709
712 tick_setup_sched_timer(); 710 tick_setup_sched_timer();
713
714 /* "Retrigger" the interrupt to get things going */ 711 /* "Retrigger" the interrupt to get things going */
715 retrigger_next_event(NULL); 712 retrigger_next_event(NULL);
716 local_irq_restore(flags); 713 local_irq_restore(flags);
717 return 1; 714 return 1;
718} 715}
719 716
717/*
718 * Called from timekeeping code to reprogramm the hrtimer interrupt
719 * device. If called from the timer interrupt context we defer it to
720 * softirq context.
721 */
722void clock_was_set_delayed(void)
723{
724 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
725
726 cpu_base->clock_was_set = 1;
727 __raise_softirq_irqoff(HRTIMER_SOFTIRQ);
728}
729
720#else 730#else
721 731
722static inline int hrtimer_hres_active(void) { return 0; } 732static inline int hrtimer_hres_active(void) { return 0; }
@@ -1250,11 +1260,10 @@ void hrtimer_interrupt(struct clock_event_device *dev)
1250 cpu_base->nr_events++; 1260 cpu_base->nr_events++;
1251 dev->next_event.tv64 = KTIME_MAX; 1261 dev->next_event.tv64 = KTIME_MAX;
1252 1262
1253 entry_time = now = ktime_get(); 1263 raw_spin_lock(&cpu_base->lock);
1264 entry_time = now = hrtimer_update_base(cpu_base);
1254retry: 1265retry:
1255 expires_next.tv64 = KTIME_MAX; 1266 expires_next.tv64 = KTIME_MAX;
1256
1257 raw_spin_lock(&cpu_base->lock);
1258 /* 1267 /*
1259 * We set expires_next to KTIME_MAX here with cpu_base->lock 1268 * We set expires_next to KTIME_MAX here with cpu_base->lock
1260 * held to prevent that a timer is enqueued in our queue via 1269 * held to prevent that a timer is enqueued in our queue via
@@ -1330,8 +1339,12 @@ retry:
1330 * We need to prevent that we loop forever in the hrtimer 1339 * We need to prevent that we loop forever in the hrtimer
1331 * interrupt routine. We give it 3 attempts to avoid 1340 * interrupt routine. We give it 3 attempts to avoid
1332 * overreacting on some spurious event. 1341 * overreacting on some spurious event.
1342 *
1343 * Acquire base lock for updating the offsets and retrieving
1344 * the current time.
1333 */ 1345 */
1334 now = ktime_get(); 1346 raw_spin_lock(&cpu_base->lock);
1347 now = hrtimer_update_base(cpu_base);
1335 cpu_base->nr_retries++; 1348 cpu_base->nr_retries++;
1336 if (++retries < 3) 1349 if (++retries < 3)
1337 goto retry; 1350 goto retry;
@@ -1343,6 +1356,7 @@ retry:
1343 */ 1356 */
1344 cpu_base->nr_hangs++; 1357 cpu_base->nr_hangs++;
1345 cpu_base->hang_detected = 1; 1358 cpu_base->hang_detected = 1;
1359 raw_spin_unlock(&cpu_base->lock);
1346 delta = ktime_sub(now, entry_time); 1360 delta = ktime_sub(now, entry_time);
1347 if (delta.tv64 > cpu_base->max_hang_time.tv64) 1361 if (delta.tv64 > cpu_base->max_hang_time.tv64)
1348 cpu_base->max_hang_time = delta; 1362 cpu_base->max_hang_time = delta;
@@ -1395,6 +1409,13 @@ void hrtimer_peek_ahead_timers(void)
1395 1409
1396static void run_hrtimer_softirq(struct softirq_action *h) 1410static void run_hrtimer_softirq(struct softirq_action *h)
1397{ 1411{
1412 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
1413
1414 if (cpu_base->clock_was_set) {
1415 cpu_base->clock_was_set = 0;
1416 clock_was_set();
1417 }
1418
1398 hrtimer_peek_ahead_timers(); 1419 hrtimer_peek_ahead_timers();
1399} 1420}
1400 1421
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 8b53db38a27..238025f5472 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -27,7 +27,6 @@
27#include <linux/syscore_ops.h> 27#include <linux/syscore_ops.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/genhd.h> 29#include <linux/genhd.h>
30#include <scsi/scsi_scan.h>
31 30
32#include "power.h" 31#include "power.h"
33 32
@@ -748,13 +747,6 @@ static int software_resume(void)
748 async_synchronize_full(); 747 async_synchronize_full();
749 } 748 }
750 749
751 /*
752 * We can't depend on SCSI devices being available after loading
753 * one of their modules until scsi_complete_async_scans() is
754 * called and the resume device usually is a SCSI one.
755 */
756 scsi_complete_async_scans();
757
758 swsusp_resume_device = name_to_dev_t(resume_file); 750 swsusp_resume_device = name_to_dev_t(resume_file);
759 if (!swsusp_resume_device) { 751 if (!swsusp_resume_device) {
760 error = -ENODEV; 752 error = -ENODEV;
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 91b0fd021a9..4ed81e74f86 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -24,7 +24,6 @@
24#include <linux/console.h> 24#include <linux/console.h>
25#include <linux/cpu.h> 25#include <linux/cpu.h>
26#include <linux/freezer.h> 26#include <linux/freezer.h>
27#include <scsi/scsi_scan.h>
28 27
29#include <asm/uaccess.h> 28#include <asm/uaccess.h>
30 29
@@ -84,7 +83,6 @@ static int snapshot_open(struct inode *inode, struct file *filp)
84 * appear. 83 * appear.
85 */ 84 */
86 wait_for_device_probe(); 85 wait_for_device_probe();
87 scsi_complete_async_scans();
88 86
89 data->swap = -1; 87 data->swap = -1;
90 data->mode = O_WRONLY; 88 data->mode = O_WRONLY;
diff --git a/kernel/printk.c b/kernel/printk.c
index dba18211685..ac4bc9e7946 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -194,8 +194,10 @@ static int console_may_schedule;
194 */ 194 */
195 195
196enum log_flags { 196enum log_flags {
197 LOG_DEFAULT = 0, 197 LOG_NOCONS = 1, /* already flushed, do not print to console */
198 LOG_NOCONS = 1, /* already flushed, do not print to console */ 198 LOG_NEWLINE = 2, /* text ended with a newline */
199 LOG_PREFIX = 4, /* text started with a prefix */
200 LOG_CONT = 8, /* text is a fragment of a continuation line */
199}; 201};
200 202
201struct log { 203struct log {
@@ -217,6 +219,8 @@ static DEFINE_RAW_SPINLOCK(logbuf_lock);
217/* the next printk record to read by syslog(READ) or /proc/kmsg */ 219/* the next printk record to read by syslog(READ) or /proc/kmsg */
218static u64 syslog_seq; 220static u64 syslog_seq;
219static u32 syslog_idx; 221static u32 syslog_idx;
222static enum log_flags syslog_prev;
223static size_t syslog_partial;
220 224
221/* index and sequence number of the first record stored in the buffer */ 225/* index and sequence number of the first record stored in the buffer */
222static u64 log_first_seq; 226static u64 log_first_seq;
@@ -430,20 +434,20 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
430 ret = mutex_lock_interruptible(&user->lock); 434 ret = mutex_lock_interruptible(&user->lock);
431 if (ret) 435 if (ret)
432 return ret; 436 return ret;
433 raw_spin_lock(&logbuf_lock); 437 raw_spin_lock_irq(&logbuf_lock);
434 while (user->seq == log_next_seq) { 438 while (user->seq == log_next_seq) {
435 if (file->f_flags & O_NONBLOCK) { 439 if (file->f_flags & O_NONBLOCK) {
436 ret = -EAGAIN; 440 ret = -EAGAIN;
437 raw_spin_unlock(&logbuf_lock); 441 raw_spin_unlock_irq(&logbuf_lock);
438 goto out; 442 goto out;
439 } 443 }
440 444
441 raw_spin_unlock(&logbuf_lock); 445 raw_spin_unlock_irq(&logbuf_lock);
442 ret = wait_event_interruptible(log_wait, 446 ret = wait_event_interruptible(log_wait,
443 user->seq != log_next_seq); 447 user->seq != log_next_seq);
444 if (ret) 448 if (ret)
445 goto out; 449 goto out;
446 raw_spin_lock(&logbuf_lock); 450 raw_spin_lock_irq(&logbuf_lock);
447 } 451 }
448 452
449 if (user->seq < log_first_seq) { 453 if (user->seq < log_first_seq) {
@@ -451,7 +455,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
451 user->idx = log_first_idx; 455 user->idx = log_first_idx;
452 user->seq = log_first_seq; 456 user->seq = log_first_seq;
453 ret = -EPIPE; 457 ret = -EPIPE;
454 raw_spin_unlock(&logbuf_lock); 458 raw_spin_unlock_irq(&logbuf_lock);
455 goto out; 459 goto out;
456 } 460 }
457 461
@@ -465,7 +469,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
465 for (i = 0; i < msg->text_len; i++) { 469 for (i = 0; i < msg->text_len; i++) {
466 unsigned char c = log_text(msg)[i]; 470 unsigned char c = log_text(msg)[i];
467 471
468 if (c < ' ' || c >= 128) 472 if (c < ' ' || c >= 127 || c == '\\')
469 len += sprintf(user->buf + len, "\\x%02x", c); 473 len += sprintf(user->buf + len, "\\x%02x", c);
470 else 474 else
471 user->buf[len++] = c; 475 user->buf[len++] = c;
@@ -489,7 +493,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
489 continue; 493 continue;
490 } 494 }
491 495
492 if (c < ' ' || c >= 128) { 496 if (c < ' ' || c >= 127 || c == '\\') {
493 len += sprintf(user->buf + len, "\\x%02x", c); 497 len += sprintf(user->buf + len, "\\x%02x", c);
494 continue; 498 continue;
495 } 499 }
@@ -501,7 +505,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
501 505
502 user->idx = log_next(user->idx); 506 user->idx = log_next(user->idx);
503 user->seq++; 507 user->seq++;
504 raw_spin_unlock(&logbuf_lock); 508 raw_spin_unlock_irq(&logbuf_lock);
505 509
506 if (len > count) { 510 if (len > count) {
507 ret = -EINVAL; 511 ret = -EINVAL;
@@ -528,7 +532,7 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
528 if (offset) 532 if (offset)
529 return -ESPIPE; 533 return -ESPIPE;
530 534
531 raw_spin_lock(&logbuf_lock); 535 raw_spin_lock_irq(&logbuf_lock);
532 switch (whence) { 536 switch (whence) {
533 case SEEK_SET: 537 case SEEK_SET:
534 /* the first record */ 538 /* the first record */
@@ -552,7 +556,7 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
552 default: 556 default:
553 ret = -EINVAL; 557 ret = -EINVAL;
554 } 558 }
555 raw_spin_unlock(&logbuf_lock); 559 raw_spin_unlock_irq(&logbuf_lock);
556 return ret; 560 return ret;
557} 561}
558 562
@@ -566,14 +570,14 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
566 570
567 poll_wait(file, &log_wait, wait); 571 poll_wait(file, &log_wait, wait);
568 572
569 raw_spin_lock(&logbuf_lock); 573 raw_spin_lock_irq(&logbuf_lock);
570 if (user->seq < log_next_seq) { 574 if (user->seq < log_next_seq) {
571 /* return error when data has vanished underneath us */ 575 /* return error when data has vanished underneath us */
572 if (user->seq < log_first_seq) 576 if (user->seq < log_first_seq)
573 ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI; 577 ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI;
574 ret = POLLIN|POLLRDNORM; 578 ret = POLLIN|POLLRDNORM;
575 } 579 }
576 raw_spin_unlock(&logbuf_lock); 580 raw_spin_unlock_irq(&logbuf_lock);
577 581
578 return ret; 582 return ret;
579} 583}
@@ -597,10 +601,10 @@ static int devkmsg_open(struct inode *inode, struct file *file)
597 601
598 mutex_init(&user->lock); 602 mutex_init(&user->lock);
599 603
600 raw_spin_lock(&logbuf_lock); 604 raw_spin_lock_irq(&logbuf_lock);
601 user->idx = log_first_idx; 605 user->idx = log_first_idx;
602 user->seq = log_first_seq; 606 user->seq = log_first_seq;
603 raw_spin_unlock(&logbuf_lock); 607 raw_spin_unlock_irq(&logbuf_lock);
604 608
605 file->private_data = user; 609 file->private_data = user;
606 return 0; 610 return 0;
@@ -818,15 +822,18 @@ static size_t print_time(u64 ts, char *buf)
818static size_t print_prefix(const struct log *msg, bool syslog, char *buf) 822static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
819{ 823{
820 size_t len = 0; 824 size_t len = 0;
825 unsigned int prefix = (msg->facility << 3) | msg->level;
821 826
822 if (syslog) { 827 if (syslog) {
823 if (buf) { 828 if (buf) {
824 len += sprintf(buf, "<%u>", msg->level); 829 len += sprintf(buf, "<%u>", prefix);
825 } else { 830 } else {
826 len += 3; 831 len += 3;
827 if (msg->level > 9) 832 if (prefix > 999)
828 len++; 833 len += 3;
829 if (msg->level > 99) 834 else if (prefix > 99)
835 len += 2;
836 else if (prefix > 9)
830 len++; 837 len++;
831 } 838 }
832 } 839 }
@@ -835,13 +842,26 @@ static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
835 return len; 842 return len;
836} 843}
837 844
838static size_t msg_print_text(const struct log *msg, bool syslog, 845static size_t msg_print_text(const struct log *msg, enum log_flags prev,
839 char *buf, size_t size) 846 bool syslog, char *buf, size_t size)
840{ 847{
841 const char *text = log_text(msg); 848 const char *text = log_text(msg);
842 size_t text_size = msg->text_len; 849 size_t text_size = msg->text_len;
850 bool prefix = true;
851 bool newline = true;
843 size_t len = 0; 852 size_t len = 0;
844 853
854 if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
855 prefix = false;
856
857 if (msg->flags & LOG_CONT) {
858 if ((prev & LOG_CONT) && !(prev & LOG_NEWLINE))
859 prefix = false;
860
861 if (!(msg->flags & LOG_NEWLINE))
862 newline = false;
863 }
864
845 do { 865 do {
846 const char *next = memchr(text, '\n', text_size); 866 const char *next = memchr(text, '\n', text_size);
847 size_t text_len; 867 size_t text_len;
@@ -859,16 +879,22 @@ static size_t msg_print_text(const struct log *msg, bool syslog,
859 text_len + 1>= size - len) 879 text_len + 1>= size - len)
860 break; 880 break;
861 881
862 len += print_prefix(msg, syslog, buf + len); 882 if (prefix)
883 len += print_prefix(msg, syslog, buf + len);
863 memcpy(buf + len, text, text_len); 884 memcpy(buf + len, text, text_len);
864 len += text_len; 885 len += text_len;
865 buf[len++] = '\n'; 886 if (next || newline)
887 buf[len++] = '\n';
866 } else { 888 } else {
867 /* SYSLOG_ACTION_* buffer size only calculation */ 889 /* SYSLOG_ACTION_* buffer size only calculation */
868 len += print_prefix(msg, syslog, NULL); 890 if (prefix)
869 len += text_len + 1; 891 len += print_prefix(msg, syslog, NULL);
892 len += text_len;
893 if (next || newline)
894 len++;
870 } 895 }
871 896
897 prefix = true;
872 text = next; 898 text = next;
873 } while (text); 899 } while (text);
874 900
@@ -887,22 +913,35 @@ static int syslog_print(char __user *buf, int size)
887 913
888 while (size > 0) { 914 while (size > 0) {
889 size_t n; 915 size_t n;
916 size_t skip;
890 917
891 raw_spin_lock_irq(&logbuf_lock); 918 raw_spin_lock_irq(&logbuf_lock);
892 if (syslog_seq < log_first_seq) { 919 if (syslog_seq < log_first_seq) {
893 /* messages are gone, move to first one */ 920 /* messages are gone, move to first one */
894 syslog_seq = log_first_seq; 921 syslog_seq = log_first_seq;
895 syslog_idx = log_first_idx; 922 syslog_idx = log_first_idx;
923 syslog_prev = 0;
924 syslog_partial = 0;
896 } 925 }
897 if (syslog_seq == log_next_seq) { 926 if (syslog_seq == log_next_seq) {
898 raw_spin_unlock_irq(&logbuf_lock); 927 raw_spin_unlock_irq(&logbuf_lock);
899 break; 928 break;
900 } 929 }
930
931 skip = syslog_partial;
901 msg = log_from_idx(syslog_idx); 932 msg = log_from_idx(syslog_idx);
902 n = msg_print_text(msg, true, text, LOG_LINE_MAX); 933 n = msg_print_text(msg, syslog_prev, true, text, LOG_LINE_MAX);
903 if (n <= size) { 934 if (n - syslog_partial <= size) {
935 /* message fits into buffer, move forward */
904 syslog_idx = log_next(syslog_idx); 936 syslog_idx = log_next(syslog_idx);
905 syslog_seq++; 937 syslog_seq++;
938 syslog_prev = msg->flags;
939 n -= syslog_partial;
940 syslog_partial = 0;
941 } else if (!len){
942 /* partial read(), remember position */
943 n = size;
944 syslog_partial += n;
906 } else 945 } else
907 n = 0; 946 n = 0;
908 raw_spin_unlock_irq(&logbuf_lock); 947 raw_spin_unlock_irq(&logbuf_lock);
@@ -910,17 +949,15 @@ static int syslog_print(char __user *buf, int size)
910 if (!n) 949 if (!n)
911 break; 950 break;
912 951
913 len += n; 952 if (copy_to_user(buf, text + skip, n)) {
914 size -= n;
915 buf += n;
916 n = copy_to_user(buf - n, text, n);
917
918 if (n) {
919 len -= n;
920 if (!len) 953 if (!len)
921 len = -EFAULT; 954 len = -EFAULT;
922 break; 955 break;
923 } 956 }
957
958 len += n;
959 size -= n;
960 buf += n;
924 } 961 }
925 962
926 kfree(text); 963 kfree(text);
@@ -941,6 +978,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
941 u64 next_seq; 978 u64 next_seq;
942 u64 seq; 979 u64 seq;
943 u32 idx; 980 u32 idx;
981 enum log_flags prev;
944 982
945 if (clear_seq < log_first_seq) { 983 if (clear_seq < log_first_seq) {
946 /* messages are gone, move to first available one */ 984 /* messages are gone, move to first available one */
@@ -954,10 +992,11 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
954 */ 992 */
955 seq = clear_seq; 993 seq = clear_seq;
956 idx = clear_idx; 994 idx = clear_idx;
995 prev = 0;
957 while (seq < log_next_seq) { 996 while (seq < log_next_seq) {
958 struct log *msg = log_from_idx(idx); 997 struct log *msg = log_from_idx(idx);
959 998
960 len += msg_print_text(msg, true, NULL, 0); 999 len += msg_print_text(msg, prev, true, NULL, 0);
961 idx = log_next(idx); 1000 idx = log_next(idx);
962 seq++; 1001 seq++;
963 } 1002 }
@@ -965,10 +1004,11 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
965 /* move first record forward until length fits into the buffer */ 1004 /* move first record forward until length fits into the buffer */
966 seq = clear_seq; 1005 seq = clear_seq;
967 idx = clear_idx; 1006 idx = clear_idx;
1007 prev = 0;
968 while (len > size && seq < log_next_seq) { 1008 while (len > size && seq < log_next_seq) {
969 struct log *msg = log_from_idx(idx); 1009 struct log *msg = log_from_idx(idx);
970 1010
971 len -= msg_print_text(msg, true, NULL, 0); 1011 len -= msg_print_text(msg, prev, true, NULL, 0);
972 idx = log_next(idx); 1012 idx = log_next(idx);
973 seq++; 1013 seq++;
974 } 1014 }
@@ -977,17 +1017,19 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
977 next_seq = log_next_seq; 1017 next_seq = log_next_seq;
978 1018
979 len = 0; 1019 len = 0;
1020 prev = 0;
980 while (len >= 0 && seq < next_seq) { 1021 while (len >= 0 && seq < next_seq) {
981 struct log *msg = log_from_idx(idx); 1022 struct log *msg = log_from_idx(idx);
982 int textlen; 1023 int textlen;
983 1024
984 textlen = msg_print_text(msg, true, text, LOG_LINE_MAX); 1025 textlen = msg_print_text(msg, prev, true, text, LOG_LINE_MAX);
985 if (textlen < 0) { 1026 if (textlen < 0) {
986 len = textlen; 1027 len = textlen;
987 break; 1028 break;
988 } 1029 }
989 idx = log_next(idx); 1030 idx = log_next(idx);
990 seq++; 1031 seq++;
1032 prev = msg->flags;
991 1033
992 raw_spin_unlock_irq(&logbuf_lock); 1034 raw_spin_unlock_irq(&logbuf_lock);
993 if (copy_to_user(buf + len, text, textlen)) 1035 if (copy_to_user(buf + len, text, textlen))
@@ -1000,6 +1042,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1000 /* messages are gone, move to next one */ 1042 /* messages are gone, move to next one */
1001 seq = log_first_seq; 1043 seq = log_first_seq;
1002 idx = log_first_idx; 1044 idx = log_first_idx;
1045 prev = 0;
1003 } 1046 }
1004 } 1047 }
1005 } 1048 }
@@ -1018,7 +1061,6 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1018{ 1061{
1019 bool clear = false; 1062 bool clear = false;
1020 static int saved_console_loglevel = -1; 1063 static int saved_console_loglevel = -1;
1021 static DEFINE_MUTEX(syslog_mutex);
1022 int error; 1064 int error;
1023 1065
1024 error = check_syslog_permissions(type, from_file); 1066 error = check_syslog_permissions(type, from_file);
@@ -1045,17 +1087,11 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1045 error = -EFAULT; 1087 error = -EFAULT;
1046 goto out; 1088 goto out;
1047 } 1089 }
1048 error = mutex_lock_interruptible(&syslog_mutex);
1049 if (error)
1050 goto out;
1051 error = wait_event_interruptible(log_wait, 1090 error = wait_event_interruptible(log_wait,
1052 syslog_seq != log_next_seq); 1091 syslog_seq != log_next_seq);
1053 if (error) { 1092 if (error)
1054 mutex_unlock(&syslog_mutex);
1055 goto out; 1093 goto out;
1056 }
1057 error = syslog_print(buf, len); 1094 error = syslog_print(buf, len);
1058 mutex_unlock(&syslog_mutex);
1059 break; 1095 break;
1060 /* Read/clear last kernel messages */ 1096 /* Read/clear last kernel messages */
1061 case SYSLOG_ACTION_READ_CLEAR: 1097 case SYSLOG_ACTION_READ_CLEAR:
@@ -1111,6 +1147,8 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1111 /* messages are gone, move to first one */ 1147 /* messages are gone, move to first one */
1112 syslog_seq = log_first_seq; 1148 syslog_seq = log_first_seq;
1113 syslog_idx = log_first_idx; 1149 syslog_idx = log_first_idx;
1150 syslog_prev = 0;
1151 syslog_partial = 0;
1114 } 1152 }
1115 if (from_file) { 1153 if (from_file) {
1116 /* 1154 /*
@@ -1120,19 +1158,20 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1120 */ 1158 */
1121 error = log_next_idx - syslog_idx; 1159 error = log_next_idx - syslog_idx;
1122 } else { 1160 } else {
1123 u64 seq; 1161 u64 seq = syslog_seq;
1124 u32 idx; 1162 u32 idx = syslog_idx;
1163 enum log_flags prev = syslog_prev;
1125 1164
1126 error = 0; 1165 error = 0;
1127 seq = syslog_seq;
1128 idx = syslog_idx;
1129 while (seq < log_next_seq) { 1166 while (seq < log_next_seq) {
1130 struct log *msg = log_from_idx(idx); 1167 struct log *msg = log_from_idx(idx);
1131 1168
1132 error += msg_print_text(msg, true, NULL, 0); 1169 error += msg_print_text(msg, prev, true, NULL, 0);
1133 idx = log_next(idx); 1170 idx = log_next(idx);
1134 seq++; 1171 seq++;
1172 prev = msg->flags;
1135 } 1173 }
1174 error -= syslog_partial;
1136 } 1175 }
1137 raw_spin_unlock_irq(&logbuf_lock); 1176 raw_spin_unlock_irq(&logbuf_lock);
1138 break; 1177 break;
@@ -1153,21 +1192,6 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
1153 return do_syslog(type, buf, len, SYSLOG_FROM_CALL); 1192 return do_syslog(type, buf, len, SYSLOG_FROM_CALL);
1154} 1193}
1155 1194
1156#ifdef CONFIG_KGDB_KDB
1157/* kdb dmesg command needs access to the syslog buffer. do_syslog()
1158 * uses locks so it cannot be used during debugging. Just tell kdb
1159 * where the start and end of the physical and logical logs are. This
1160 * is equivalent to do_syslog(3).
1161 */
1162void kdb_syslog_data(char *syslog_data[4])
1163{
1164 syslog_data[0] = log_buf;
1165 syslog_data[1] = log_buf + log_buf_len;
1166 syslog_data[2] = log_buf + log_first_idx;
1167 syslog_data[3] = log_buf + log_next_idx;
1168}
1169#endif /* CONFIG_KGDB_KDB */
1170
1171static bool __read_mostly ignore_loglevel; 1195static bool __read_mostly ignore_loglevel;
1172 1196
1173static int __init ignore_loglevel_setup(char *str) 1197static int __init ignore_loglevel_setup(char *str)
@@ -1400,10 +1424,9 @@ asmlinkage int vprintk_emit(int facility, int level,
1400 static char textbuf[LOG_LINE_MAX]; 1424 static char textbuf[LOG_LINE_MAX];
1401 char *text = textbuf; 1425 char *text = textbuf;
1402 size_t text_len; 1426 size_t text_len;
1427 enum log_flags lflags = 0;
1403 unsigned long flags; 1428 unsigned long flags;
1404 int this_cpu; 1429 int this_cpu;
1405 bool newline = false;
1406 bool prefix = false;
1407 int printed_len = 0; 1430 int printed_len = 0;
1408 1431
1409 boot_delay_msec(); 1432 boot_delay_msec();
@@ -1442,7 +1465,7 @@ asmlinkage int vprintk_emit(int facility, int level,
1442 recursion_bug = 0; 1465 recursion_bug = 0;
1443 printed_len += strlen(recursion_msg); 1466 printed_len += strlen(recursion_msg);
1444 /* emit KERN_CRIT message */ 1467 /* emit KERN_CRIT message */
1445 log_store(0, 2, LOG_DEFAULT, 0, 1468 log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
1446 NULL, 0, recursion_msg, printed_len); 1469 NULL, 0, recursion_msg, printed_len);
1447 } 1470 }
1448 1471
@@ -1455,7 +1478,7 @@ asmlinkage int vprintk_emit(int facility, int level,
1455 /* mark and strip a trailing newline */ 1478 /* mark and strip a trailing newline */
1456 if (text_len && text[text_len-1] == '\n') { 1479 if (text_len && text[text_len-1] == '\n') {
1457 text_len--; 1480 text_len--;
1458 newline = true; 1481 lflags |= LOG_NEWLINE;
1459 } 1482 }
1460 1483
1461 /* strip syslog prefix and extract log level or control flags */ 1484 /* strip syslog prefix and extract log level or control flags */
@@ -1465,7 +1488,7 @@ asmlinkage int vprintk_emit(int facility, int level,
1465 if (level == -1) 1488 if (level == -1)
1466 level = text[1] - '0'; 1489 level = text[1] - '0';
1467 case 'd': /* KERN_DEFAULT */ 1490 case 'd': /* KERN_DEFAULT */
1468 prefix = true; 1491 lflags |= LOG_PREFIX;
1469 case 'c': /* KERN_CONT */ 1492 case 'c': /* KERN_CONT */
1470 text += 3; 1493 text += 3;
1471 text_len -= 3; 1494 text_len -= 3;
@@ -1475,22 +1498,20 @@ asmlinkage int vprintk_emit(int facility, int level,
1475 if (level == -1) 1498 if (level == -1)
1476 level = default_message_loglevel; 1499 level = default_message_loglevel;
1477 1500
1478 if (dict) { 1501 if (dict)
1479 prefix = true; 1502 lflags |= LOG_PREFIX|LOG_NEWLINE;
1480 newline = true;
1481 }
1482 1503
1483 if (!newline) { 1504 if (!(lflags & LOG_NEWLINE)) {
1484 /* 1505 /*
1485 * Flush the conflicting buffer. An earlier newline was missing, 1506 * Flush the conflicting buffer. An earlier newline was missing,
1486 * or another task also prints continuation lines. 1507 * or another task also prints continuation lines.
1487 */ 1508 */
1488 if (cont.len && (prefix || cont.owner != current)) 1509 if (cont.len && (lflags & LOG_PREFIX || cont.owner != current))
1489 cont_flush(); 1510 cont_flush();
1490 1511
1491 /* buffer line if possible, otherwise store it right away */ 1512 /* buffer line if possible, otherwise store it right away */
1492 if (!cont_add(facility, level, text, text_len)) 1513 if (!cont_add(facility, level, text, text_len))
1493 log_store(facility, level, LOG_DEFAULT, 0, 1514 log_store(facility, level, lflags | LOG_CONT, 0,
1494 dict, dictlen, text, text_len); 1515 dict, dictlen, text, text_len);
1495 } else { 1516 } else {
1496 bool stored = false; 1517 bool stored = false;
@@ -1502,13 +1523,13 @@ asmlinkage int vprintk_emit(int facility, int level,
1502 * flush it out and store this line separately. 1523 * flush it out and store this line separately.
1503 */ 1524 */
1504 if (cont.len && cont.owner == current) { 1525 if (cont.len && cont.owner == current) {
1505 if (!prefix) 1526 if (!(lflags & LOG_PREFIX))
1506 stored = cont_add(facility, level, text, text_len); 1527 stored = cont_add(facility, level, text, text_len);
1507 cont_flush(); 1528 cont_flush();
1508 } 1529 }
1509 1530
1510 if (!stored) 1531 if (!stored)
1511 log_store(facility, level, LOG_DEFAULT, 0, 1532 log_store(facility, level, lflags, 0,
1512 dict, dictlen, text, text_len); 1533 dict, dictlen, text, text_len);
1513 } 1534 }
1514 printed_len += text_len; 1535 printed_len += text_len;
@@ -1607,8 +1628,8 @@ static struct cont {
1607static struct log *log_from_idx(u32 idx) { return NULL; } 1628static struct log *log_from_idx(u32 idx) { return NULL; }
1608static u32 log_next(u32 idx) { return 0; } 1629static u32 log_next(u32 idx) { return 0; }
1609static void call_console_drivers(int level, const char *text, size_t len) {} 1630static void call_console_drivers(int level, const char *text, size_t len) {}
1610static size_t msg_print_text(const struct log *msg, bool syslog, 1631static size_t msg_print_text(const struct log *msg, enum log_flags prev,
1611 char *buf, size_t size) { return 0; } 1632 bool syslog, char *buf, size_t size) { return 0; }
1612static size_t cont_print_text(char *text, size_t size) { return 0; } 1633static size_t cont_print_text(char *text, size_t size) { return 0; }
1613 1634
1614#endif /* CONFIG_PRINTK */ 1635#endif /* CONFIG_PRINTK */
@@ -1884,6 +1905,7 @@ void wake_up_klogd(void)
1884/* the next printk record to write to the console */ 1905/* the next printk record to write to the console */
1885static u64 console_seq; 1906static u64 console_seq;
1886static u32 console_idx; 1907static u32 console_idx;
1908static enum log_flags console_prev;
1887 1909
1888/** 1910/**
1889 * console_unlock - unlock the console system 1911 * console_unlock - unlock the console system
@@ -1944,6 +1966,7 @@ again:
1944 /* messages are gone, move to first one */ 1966 /* messages are gone, move to first one */
1945 console_seq = log_first_seq; 1967 console_seq = log_first_seq;
1946 console_idx = log_first_idx; 1968 console_idx = log_first_idx;
1969 console_prev = 0;
1947 } 1970 }
1948skip: 1971skip:
1949 if (console_seq == log_next_seq) 1972 if (console_seq == log_next_seq)
@@ -1957,14 +1980,21 @@ skip:
1957 */ 1980 */
1958 console_idx = log_next(console_idx); 1981 console_idx = log_next(console_idx);
1959 console_seq++; 1982 console_seq++;
1983 /*
1984 * We will get here again when we register a new
1985 * CON_PRINTBUFFER console. Clear the flag so we
1986 * will properly dump everything later.
1987 */
1988 msg->flags &= ~LOG_NOCONS;
1960 goto skip; 1989 goto skip;
1961 } 1990 }
1962 1991
1963 level = msg->level; 1992 level = msg->level;
1964 len = msg_print_text(msg, false, text, sizeof(text)); 1993 len = msg_print_text(msg, console_prev, false,
1965 1994 text, sizeof(text));
1966 console_idx = log_next(console_idx); 1995 console_idx = log_next(console_idx);
1967 console_seq++; 1996 console_seq++;
1997 console_prev = msg->flags;
1968 raw_spin_unlock(&logbuf_lock); 1998 raw_spin_unlock(&logbuf_lock);
1969 1999
1970 stop_critical_timings(); /* don't trace print latency */ 2000 stop_critical_timings(); /* don't trace print latency */
@@ -2227,6 +2257,7 @@ void register_console(struct console *newcon)
2227 raw_spin_lock_irqsave(&logbuf_lock, flags); 2257 raw_spin_lock_irqsave(&logbuf_lock, flags);
2228 console_seq = syslog_seq; 2258 console_seq = syslog_seq;
2229 console_idx = syslog_idx; 2259 console_idx = syslog_idx;
2260 console_prev = syslog_prev;
2230 raw_spin_unlock_irqrestore(&logbuf_lock, flags); 2261 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
2231 /* 2262 /*
2232 * We're about to replay the log buffer. Only do this to the 2263 * We're about to replay the log buffer. Only do this to the
@@ -2479,7 +2510,7 @@ void kmsg_dump(enum kmsg_dump_reason reason)
2479} 2510}
2480 2511
2481/** 2512/**
2482 * kmsg_dump_get_line - retrieve one kmsg log line 2513 * kmsg_dump_get_line_nolock - retrieve one kmsg log line (unlocked version)
2483 * @dumper: registered kmsg dumper 2514 * @dumper: registered kmsg dumper
2484 * @syslog: include the "<4>" prefixes 2515 * @syslog: include the "<4>" prefixes
2485 * @line: buffer to copy the line to 2516 * @line: buffer to copy the line to
@@ -2494,11 +2525,12 @@ void kmsg_dump(enum kmsg_dump_reason reason)
2494 * 2525 *
2495 * A return value of FALSE indicates that there are no more records to 2526 * A return value of FALSE indicates that there are no more records to
2496 * read. 2527 * read.
2528 *
2529 * The function is similar to kmsg_dump_get_line(), but grabs no locks.
2497 */ 2530 */
2498bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog, 2531bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
2499 char *line, size_t size, size_t *len) 2532 char *line, size_t size, size_t *len)
2500{ 2533{
2501 unsigned long flags;
2502 struct log *msg; 2534 struct log *msg;
2503 size_t l = 0; 2535 size_t l = 0;
2504 bool ret = false; 2536 bool ret = false;
@@ -2506,7 +2538,6 @@ bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
2506 if (!dumper->active) 2538 if (!dumper->active)
2507 goto out; 2539 goto out;
2508 2540
2509 raw_spin_lock_irqsave(&logbuf_lock, flags);
2510 if (dumper->cur_seq < log_first_seq) { 2541 if (dumper->cur_seq < log_first_seq) {
2511 /* messages are gone, move to first available one */ 2542 /* messages are gone, move to first available one */
2512 dumper->cur_seq = log_first_seq; 2543 dumper->cur_seq = log_first_seq;
@@ -2514,24 +2545,50 @@ bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
2514 } 2545 }
2515 2546
2516 /* last entry */ 2547 /* last entry */
2517 if (dumper->cur_seq >= log_next_seq) { 2548 if (dumper->cur_seq >= log_next_seq)
2518 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
2519 goto out; 2549 goto out;
2520 }
2521 2550
2522 msg = log_from_idx(dumper->cur_idx); 2551 msg = log_from_idx(dumper->cur_idx);
2523 l = msg_print_text(msg, syslog, 2552 l = msg_print_text(msg, 0, syslog, line, size);
2524 line, size);
2525 2553
2526 dumper->cur_idx = log_next(dumper->cur_idx); 2554 dumper->cur_idx = log_next(dumper->cur_idx);
2527 dumper->cur_seq++; 2555 dumper->cur_seq++;
2528 ret = true; 2556 ret = true;
2529 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
2530out: 2557out:
2531 if (len) 2558 if (len)
2532 *len = l; 2559 *len = l;
2533 return ret; 2560 return ret;
2534} 2561}
2562
2563/**
2564 * kmsg_dump_get_line - retrieve one kmsg log line
2565 * @dumper: registered kmsg dumper
2566 * @syslog: include the "<4>" prefixes
2567 * @line: buffer to copy the line to
2568 * @size: maximum size of the buffer
2569 * @len: length of line placed into buffer
2570 *
2571 * Start at the beginning of the kmsg buffer, with the oldest kmsg
2572 * record, and copy one record into the provided buffer.
2573 *
2574 * Consecutive calls will return the next available record moving
2575 * towards the end of the buffer with the youngest messages.
2576 *
2577 * A return value of FALSE indicates that there are no more records to
2578 * read.
2579 */
2580bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
2581 char *line, size_t size, size_t *len)
2582{
2583 unsigned long flags;
2584 bool ret;
2585
2586 raw_spin_lock_irqsave(&logbuf_lock, flags);
2587 ret = kmsg_dump_get_line_nolock(dumper, syslog, line, size, len);
2588 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
2589
2590 return ret;
2591}
2535EXPORT_SYMBOL_GPL(kmsg_dump_get_line); 2592EXPORT_SYMBOL_GPL(kmsg_dump_get_line);
2536 2593
2537/** 2594/**
@@ -2561,6 +2618,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2561 u32 idx; 2618 u32 idx;
2562 u64 next_seq; 2619 u64 next_seq;
2563 u32 next_idx; 2620 u32 next_idx;
2621 enum log_flags prev;
2564 size_t l = 0; 2622 size_t l = 0;
2565 bool ret = false; 2623 bool ret = false;
2566 2624
@@ -2583,23 +2641,27 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2583 /* calculate length of entire buffer */ 2641 /* calculate length of entire buffer */
2584 seq = dumper->cur_seq; 2642 seq = dumper->cur_seq;
2585 idx = dumper->cur_idx; 2643 idx = dumper->cur_idx;
2644 prev = 0;
2586 while (seq < dumper->next_seq) { 2645 while (seq < dumper->next_seq) {
2587 struct log *msg = log_from_idx(idx); 2646 struct log *msg = log_from_idx(idx);
2588 2647
2589 l += msg_print_text(msg, true, NULL, 0); 2648 l += msg_print_text(msg, prev, true, NULL, 0);
2590 idx = log_next(idx); 2649 idx = log_next(idx);
2591 seq++; 2650 seq++;
2651 prev = msg->flags;
2592 } 2652 }
2593 2653
2594 /* move first record forward until length fits into the buffer */ 2654 /* move first record forward until length fits into the buffer */
2595 seq = dumper->cur_seq; 2655 seq = dumper->cur_seq;
2596 idx = dumper->cur_idx; 2656 idx = dumper->cur_idx;
2657 prev = 0;
2597 while (l > size && seq < dumper->next_seq) { 2658 while (l > size && seq < dumper->next_seq) {
2598 struct log *msg = log_from_idx(idx); 2659 struct log *msg = log_from_idx(idx);
2599 2660
2600 l -= msg_print_text(msg, true, NULL, 0); 2661 l -= msg_print_text(msg, prev, true, NULL, 0);
2601 idx = log_next(idx); 2662 idx = log_next(idx);
2602 seq++; 2663 seq++;
2664 prev = msg->flags;
2603 } 2665 }
2604 2666
2605 /* last message in next interation */ 2667 /* last message in next interation */
@@ -2607,14 +2669,14 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2607 next_idx = idx; 2669 next_idx = idx;
2608 2670
2609 l = 0; 2671 l = 0;
2672 prev = 0;
2610 while (seq < dumper->next_seq) { 2673 while (seq < dumper->next_seq) {
2611 struct log *msg = log_from_idx(idx); 2674 struct log *msg = log_from_idx(idx);
2612 2675
2613 l += msg_print_text(msg, syslog, 2676 l += msg_print_text(msg, prev, syslog, buf + l, size - l);
2614 buf + l, size - l);
2615
2616 idx = log_next(idx); 2677 idx = log_next(idx);
2617 seq++; 2678 seq++;
2679 prev = msg->flags;
2618 } 2680 }
2619 2681
2620 dumper->next_seq = next_seq; 2682 dumper->next_seq = next_seq;
@@ -2629,6 +2691,24 @@ out:
2629EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer); 2691EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
2630 2692
2631/** 2693/**
2694 * kmsg_dump_rewind_nolock - reset the interator (unlocked version)
2695 * @dumper: registered kmsg dumper
2696 *
2697 * Reset the dumper's iterator so that kmsg_dump_get_line() and
2698 * kmsg_dump_get_buffer() can be called again and used multiple
2699 * times within the same dumper.dump() callback.
2700 *
2701 * The function is similar to kmsg_dump_rewind(), but grabs no locks.
2702 */
2703void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
2704{
2705 dumper->cur_seq = clear_seq;
2706 dumper->cur_idx = clear_idx;
2707 dumper->next_seq = log_next_seq;
2708 dumper->next_idx = log_next_idx;
2709}
2710
2711/**
2632 * kmsg_dump_rewind - reset the interator 2712 * kmsg_dump_rewind - reset the interator
2633 * @dumper: registered kmsg dumper 2713 * @dumper: registered kmsg dumper
2634 * 2714 *
@@ -2641,10 +2721,7 @@ void kmsg_dump_rewind(struct kmsg_dumper *dumper)
2641 unsigned long flags; 2721 unsigned long flags;
2642 2722
2643 raw_spin_lock_irqsave(&logbuf_lock, flags); 2723 raw_spin_lock_irqsave(&logbuf_lock, flags);
2644 dumper->cur_seq = clear_seq; 2724 kmsg_dump_rewind_nolock(dumper);
2645 dumper->cur_idx = clear_idx;
2646 dumper->next_seq = log_next_seq;
2647 dumper->next_idx = log_next_idx;
2648 raw_spin_unlock_irqrestore(&logbuf_lock, flags); 2725 raw_spin_unlock_irqrestore(&logbuf_lock, flags);
2649} 2726}
2650EXPORT_SYMBOL_GPL(kmsg_dump_rewind); 2727EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 38ecdda3f55..4b97bba7396 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -201,6 +201,7 @@ void rcu_note_context_switch(int cpu)
201{ 201{
202 trace_rcu_utilization("Start context switch"); 202 trace_rcu_utilization("Start context switch");
203 rcu_sched_qs(cpu); 203 rcu_sched_qs(cpu);
204 rcu_preempt_note_context_switch(cpu);
204 trace_rcu_utilization("End context switch"); 205 trace_rcu_utilization("End context switch");
205} 206}
206EXPORT_SYMBOL_GPL(rcu_note_context_switch); 207EXPORT_SYMBOL_GPL(rcu_note_context_switch);
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index ea056495783..19b61ac1079 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -444,6 +444,7 @@ DECLARE_PER_CPU(char, rcu_cpu_has_work);
444/* Forward declarations for rcutree_plugin.h */ 444/* Forward declarations for rcutree_plugin.h */
445static void rcu_bootup_announce(void); 445static void rcu_bootup_announce(void);
446long rcu_batches_completed(void); 446long rcu_batches_completed(void);
447static void rcu_preempt_note_context_switch(int cpu);
447static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp); 448static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp);
448#ifdef CONFIG_HOTPLUG_CPU 449#ifdef CONFIG_HOTPLUG_CPU
449static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, 450static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp,
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 5271a020887..3e4899459f3 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -153,7 +153,7 @@ static void rcu_preempt_qs(int cpu)
153 * 153 *
154 * Caller must disable preemption. 154 * Caller must disable preemption.
155 */ 155 */
156void rcu_preempt_note_context_switch(void) 156static void rcu_preempt_note_context_switch(int cpu)
157{ 157{
158 struct task_struct *t = current; 158 struct task_struct *t = current;
159 unsigned long flags; 159 unsigned long flags;
@@ -164,7 +164,7 @@ void rcu_preempt_note_context_switch(void)
164 (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) { 164 (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) {
165 165
166 /* Possibly blocking in an RCU read-side critical section. */ 166 /* Possibly blocking in an RCU read-side critical section. */
167 rdp = __this_cpu_ptr(rcu_preempt_state.rda); 167 rdp = per_cpu_ptr(rcu_preempt_state.rda, cpu);
168 rnp = rdp->mynode; 168 rnp = rdp->mynode;
169 raw_spin_lock_irqsave(&rnp->lock, flags); 169 raw_spin_lock_irqsave(&rnp->lock, flags);
170 t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED; 170 t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED;
@@ -228,7 +228,7 @@ void rcu_preempt_note_context_switch(void)
228 * means that we continue to block the current grace period. 228 * means that we continue to block the current grace period.
229 */ 229 */
230 local_irq_save(flags); 230 local_irq_save(flags);
231 rcu_preempt_qs(smp_processor_id()); 231 rcu_preempt_qs(cpu);
232 local_irq_restore(flags); 232 local_irq_restore(flags);
233} 233}
234 234
@@ -1002,6 +1002,14 @@ void rcu_force_quiescent_state(void)
1002EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); 1002EXPORT_SYMBOL_GPL(rcu_force_quiescent_state);
1003 1003
1004/* 1004/*
1005 * Because preemptible RCU does not exist, we never have to check for
1006 * CPUs being in quiescent states.
1007 */
1008static void rcu_preempt_note_context_switch(int cpu)
1009{
1010}
1011
1012/*
1005 * Because preemptible RCU does not exist, there are never any preempted 1013 * Because preemptible RCU does not exist, there are never any preempted
1006 * RCU readers. 1014 * RCU readers.
1007 */ 1015 */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d5594a4268d..468bdd44c1b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2081,7 +2081,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
2081#endif 2081#endif
2082 2082
2083 /* Here we just switch the register state and the stack. */ 2083 /* Here we just switch the register state and the stack. */
2084 rcu_switch_from(prev);
2085 switch_to(prev, next, prev); 2084 switch_to(prev, next, prev);
2086 2085
2087 barrier(); 2086 barrier();
@@ -2161,11 +2160,73 @@ unsigned long this_cpu_load(void)
2161} 2160}
2162 2161
2163 2162
2163/*
2164 * Global load-average calculations
2165 *
2166 * We take a distributed and async approach to calculating the global load-avg
2167 * in order to minimize overhead.
2168 *
2169 * The global load average is an exponentially decaying average of nr_running +
2170 * nr_uninterruptible.
2171 *
2172 * Once every LOAD_FREQ:
2173 *
2174 * nr_active = 0;
2175 * for_each_possible_cpu(cpu)
2176 * nr_active += cpu_of(cpu)->nr_running + cpu_of(cpu)->nr_uninterruptible;
2177 *
2178 * avenrun[n] = avenrun[0] * exp_n + nr_active * (1 - exp_n)
2179 *
2180 * Due to a number of reasons the above turns in the mess below:
2181 *
2182 * - for_each_possible_cpu() is prohibitively expensive on machines with
2183 * serious number of cpus, therefore we need to take a distributed approach
2184 * to calculating nr_active.
2185 *
2186 * \Sum_i x_i(t) = \Sum_i x_i(t) - x_i(t_0) | x_i(t_0) := 0
2187 * = \Sum_i { \Sum_j=1 x_i(t_j) - x_i(t_j-1) }
2188 *
2189 * So assuming nr_active := 0 when we start out -- true per definition, we
2190 * can simply take per-cpu deltas and fold those into a global accumulate
2191 * to obtain the same result. See calc_load_fold_active().
2192 *
2193 * Furthermore, in order to avoid synchronizing all per-cpu delta folding
2194 * across the machine, we assume 10 ticks is sufficient time for every
2195 * cpu to have completed this task.
2196 *
2197 * This places an upper-bound on the IRQ-off latency of the machine. Then
2198 * again, being late doesn't loose the delta, just wrecks the sample.
2199 *
2200 * - cpu_rq()->nr_uninterruptible isn't accurately tracked per-cpu because
2201 * this would add another cross-cpu cacheline miss and atomic operation
2202 * to the wakeup path. Instead we increment on whatever cpu the task ran
2203 * when it went into uninterruptible state and decrement on whatever cpu
2204 * did the wakeup. This means that only the sum of nr_uninterruptible over
2205 * all cpus yields the correct result.
2206 *
2207 * This covers the NO_HZ=n code, for extra head-aches, see the comment below.
2208 */
2209
2164/* Variables and functions for calc_load */ 2210/* Variables and functions for calc_load */
2165static atomic_long_t calc_load_tasks; 2211static atomic_long_t calc_load_tasks;
2166static unsigned long calc_load_update; 2212static unsigned long calc_load_update;
2167unsigned long avenrun[3]; 2213unsigned long avenrun[3];
2168EXPORT_SYMBOL(avenrun); 2214EXPORT_SYMBOL(avenrun); /* should be removed */
2215
2216/**
2217 * get_avenrun - get the load average array
2218 * @loads: pointer to dest load array
2219 * @offset: offset to add
2220 * @shift: shift count to shift the result left
2221 *
2222 * These values are estimates at best, so no need for locking.
2223 */
2224void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
2225{
2226 loads[0] = (avenrun[0] + offset) << shift;
2227 loads[1] = (avenrun[1] + offset) << shift;
2228 loads[2] = (avenrun[2] + offset) << shift;
2229}
2169 2230
2170static long calc_load_fold_active(struct rq *this_rq) 2231static long calc_load_fold_active(struct rq *this_rq)
2171{ 2232{
@@ -2182,6 +2243,9 @@ static long calc_load_fold_active(struct rq *this_rq)
2182 return delta; 2243 return delta;
2183} 2244}
2184 2245
2246/*
2247 * a1 = a0 * e + a * (1 - e)
2248 */
2185static unsigned long 2249static unsigned long
2186calc_load(unsigned long load, unsigned long exp, unsigned long active) 2250calc_load(unsigned long load, unsigned long exp, unsigned long active)
2187{ 2251{
@@ -2193,30 +2257,118 @@ calc_load(unsigned long load, unsigned long exp, unsigned long active)
2193 2257
2194#ifdef CONFIG_NO_HZ 2258#ifdef CONFIG_NO_HZ
2195/* 2259/*
2196 * For NO_HZ we delay the active fold to the next LOAD_FREQ update. 2260 * Handle NO_HZ for the global load-average.
2261 *
2262 * Since the above described distributed algorithm to compute the global
2263 * load-average relies on per-cpu sampling from the tick, it is affected by
2264 * NO_HZ.
2265 *
2266 * The basic idea is to fold the nr_active delta into a global idle-delta upon
2267 * entering NO_HZ state such that we can include this as an 'extra' cpu delta
2268 * when we read the global state.
2269 *
2270 * Obviously reality has to ruin such a delightfully simple scheme:
2271 *
2272 * - When we go NO_HZ idle during the window, we can negate our sample
2273 * contribution, causing under-accounting.
2274 *
2275 * We avoid this by keeping two idle-delta counters and flipping them
2276 * when the window starts, thus separating old and new NO_HZ load.
2277 *
2278 * The only trick is the slight shift in index flip for read vs write.
2279 *
2280 * 0s 5s 10s 15s
2281 * +10 +10 +10 +10
2282 * |-|-----------|-|-----------|-|-----------|-|
2283 * r:0 0 1 1 0 0 1 1 0
2284 * w:0 1 1 0 0 1 1 0 0
2285 *
2286 * This ensures we'll fold the old idle contribution in this window while
2287 * accumlating the new one.
2288 *
2289 * - When we wake up from NO_HZ idle during the window, we push up our
2290 * contribution, since we effectively move our sample point to a known
2291 * busy state.
2292 *
2293 * This is solved by pushing the window forward, and thus skipping the
2294 * sample, for this cpu (effectively using the idle-delta for this cpu which
2295 * was in effect at the time the window opened). This also solves the issue
2296 * of having to deal with a cpu having been in NOHZ idle for multiple
2297 * LOAD_FREQ intervals.
2197 * 2298 *
2198 * When making the ILB scale, we should try to pull this in as well. 2299 * When making the ILB scale, we should try to pull this in as well.
2199 */ 2300 */
2200static atomic_long_t calc_load_tasks_idle; 2301static atomic_long_t calc_load_idle[2];
2302static int calc_load_idx;
2201 2303
2202void calc_load_account_idle(struct rq *this_rq) 2304static inline int calc_load_write_idx(void)
2203{ 2305{
2306 int idx = calc_load_idx;
2307
2308 /*
2309 * See calc_global_nohz(), if we observe the new index, we also
2310 * need to observe the new update time.
2311 */
2312 smp_rmb();
2313
2314 /*
2315 * If the folding window started, make sure we start writing in the
2316 * next idle-delta.
2317 */
2318 if (!time_before(jiffies, calc_load_update))
2319 idx++;
2320
2321 return idx & 1;
2322}
2323
2324static inline int calc_load_read_idx(void)
2325{
2326 return calc_load_idx & 1;
2327}
2328
2329void calc_load_enter_idle(void)
2330{
2331 struct rq *this_rq = this_rq();
2204 long delta; 2332 long delta;
2205 2333
2334 /*
2335 * We're going into NOHZ mode, if there's any pending delta, fold it
2336 * into the pending idle delta.
2337 */
2206 delta = calc_load_fold_active(this_rq); 2338 delta = calc_load_fold_active(this_rq);
2207 if (delta) 2339 if (delta) {
2208 atomic_long_add(delta, &calc_load_tasks_idle); 2340 int idx = calc_load_write_idx();
2341 atomic_long_add(delta, &calc_load_idle[idx]);
2342 }
2209} 2343}
2210 2344
2211static long calc_load_fold_idle(void) 2345void calc_load_exit_idle(void)
2212{ 2346{
2213 long delta = 0; 2347 struct rq *this_rq = this_rq();
2348
2349 /*
2350 * If we're still before the sample window, we're done.
2351 */
2352 if (time_before(jiffies, this_rq->calc_load_update))
2353 return;
2214 2354
2215 /* 2355 /*
2216 * Its got a race, we don't care... 2356 * We woke inside or after the sample window, this means we're already
2357 * accounted through the nohz accounting, so skip the entire deal and
2358 * sync up for the next window.
2217 */ 2359 */
2218 if (atomic_long_read(&calc_load_tasks_idle)) 2360 this_rq->calc_load_update = calc_load_update;
2219 delta = atomic_long_xchg(&calc_load_tasks_idle, 0); 2361 if (time_before(jiffies, this_rq->calc_load_update + 10))
2362 this_rq->calc_load_update += LOAD_FREQ;
2363}
2364
2365static long calc_load_fold_idle(void)
2366{
2367 int idx = calc_load_read_idx();
2368 long delta = 0;
2369
2370 if (atomic_long_read(&calc_load_idle[idx]))
2371 delta = atomic_long_xchg(&calc_load_idle[idx], 0);
2220 2372
2221 return delta; 2373 return delta;
2222} 2374}
@@ -2302,66 +2454,39 @@ static void calc_global_nohz(void)
2302{ 2454{
2303 long delta, active, n; 2455 long delta, active, n;
2304 2456
2305 /* 2457 if (!time_before(jiffies, calc_load_update + 10)) {
2306 * If we crossed a calc_load_update boundary, make sure to fold 2458 /*
2307 * any pending idle changes, the respective CPUs might have 2459 * Catch-up, fold however many we are behind still
2308 * missed the tick driven calc_load_account_active() update 2460 */
2309 * due to NO_HZ. 2461 delta = jiffies - calc_load_update - 10;
2310 */ 2462 n = 1 + (delta / LOAD_FREQ);
2311 delta = calc_load_fold_idle();
2312 if (delta)
2313 atomic_long_add(delta, &calc_load_tasks);
2314
2315 /*
2316 * It could be the one fold was all it took, we done!
2317 */
2318 if (time_before(jiffies, calc_load_update + 10))
2319 return;
2320
2321 /*
2322 * Catch-up, fold however many we are behind still
2323 */
2324 delta = jiffies - calc_load_update - 10;
2325 n = 1 + (delta / LOAD_FREQ);
2326 2463
2327 active = atomic_long_read(&calc_load_tasks); 2464 active = atomic_long_read(&calc_load_tasks);
2328 active = active > 0 ? active * FIXED_1 : 0; 2465 active = active > 0 ? active * FIXED_1 : 0;
2329 2466
2330 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n); 2467 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
2331 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n); 2468 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
2332 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n); 2469 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
2333 2470
2334 calc_load_update += n * LOAD_FREQ; 2471 calc_load_update += n * LOAD_FREQ;
2335} 2472 }
2336#else
2337void calc_load_account_idle(struct rq *this_rq)
2338{
2339}
2340 2473
2341static inline long calc_load_fold_idle(void) 2474 /*
2342{ 2475 * Flip the idle index...
2343 return 0; 2476 *
2477 * Make sure we first write the new time then flip the index, so that
2478 * calc_load_write_idx() will see the new time when it reads the new
2479 * index, this avoids a double flip messing things up.
2480 */
2481 smp_wmb();
2482 calc_load_idx++;
2344} 2483}
2484#else /* !CONFIG_NO_HZ */
2345 2485
2346static void calc_global_nohz(void) 2486static inline long calc_load_fold_idle(void) { return 0; }
2347{ 2487static inline void calc_global_nohz(void) { }
2348}
2349#endif
2350 2488
2351/** 2489#endif /* CONFIG_NO_HZ */
2352 * get_avenrun - get the load average array
2353 * @loads: pointer to dest load array
2354 * @offset: offset to add
2355 * @shift: shift count to shift the result left
2356 *
2357 * These values are estimates at best, so no need for locking.
2358 */
2359void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
2360{
2361 loads[0] = (avenrun[0] + offset) << shift;
2362 loads[1] = (avenrun[1] + offset) << shift;
2363 loads[2] = (avenrun[2] + offset) << shift;
2364}
2365 2490
2366/* 2491/*
2367 * calc_load - update the avenrun load estimates 10 ticks after the 2492 * calc_load - update the avenrun load estimates 10 ticks after the
@@ -2369,11 +2494,18 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
2369 */ 2494 */
2370void calc_global_load(unsigned long ticks) 2495void calc_global_load(unsigned long ticks)
2371{ 2496{
2372 long active; 2497 long active, delta;
2373 2498
2374 if (time_before(jiffies, calc_load_update + 10)) 2499 if (time_before(jiffies, calc_load_update + 10))
2375 return; 2500 return;
2376 2501
2502 /*
2503 * Fold the 'old' idle-delta to include all NO_HZ cpus.
2504 */
2505 delta = calc_load_fold_idle();
2506 if (delta)
2507 atomic_long_add(delta, &calc_load_tasks);
2508
2377 active = atomic_long_read(&calc_load_tasks); 2509 active = atomic_long_read(&calc_load_tasks);
2378 active = active > 0 ? active * FIXED_1 : 0; 2510 active = active > 0 ? active * FIXED_1 : 0;
2379 2511
@@ -2384,12 +2516,7 @@ void calc_global_load(unsigned long ticks)
2384 calc_load_update += LOAD_FREQ; 2516 calc_load_update += LOAD_FREQ;
2385 2517
2386 /* 2518 /*
2387 * Account one period with whatever state we found before 2519 * In case we idled for multiple LOAD_FREQ intervals, catch up in bulk.
2388 * folding in the nohz state and ageing the entire idle period.
2389 *
2390 * This avoids loosing a sample when we go idle between
2391 * calc_load_account_active() (10 ticks ago) and now and thus
2392 * under-accounting.
2393 */ 2520 */
2394 calc_global_nohz(); 2521 calc_global_nohz();
2395} 2522}
@@ -2406,7 +2533,6 @@ static void calc_load_account_active(struct rq *this_rq)
2406 return; 2533 return;
2407 2534
2408 delta = calc_load_fold_active(this_rq); 2535 delta = calc_load_fold_active(this_rq);
2409 delta += calc_load_fold_idle();
2410 if (delta) 2536 if (delta)
2411 atomic_long_add(delta, &calc_load_tasks); 2537 atomic_long_add(delta, &calc_load_tasks);
2412 2538
@@ -2414,6 +2540,10 @@ static void calc_load_account_active(struct rq *this_rq)
2414} 2540}
2415 2541
2416/* 2542/*
2543 * End of global load-average stuff
2544 */
2545
2546/*
2417 * The exact cpuload at various idx values, calculated at every tick would be 2547 * The exact cpuload at various idx values, calculated at every tick would be
2418 * load = (2^idx - 1) / 2^idx * load + 1 / 2^idx * cur_load 2548 * load = (2^idx - 1) / 2^idx * load + 1 / 2^idx * cur_load
2419 * 2549 *
diff --git a/kernel/sched/idle_task.c b/kernel/sched/idle_task.c
index b44d604b35d..b6baf370cae 100644
--- a/kernel/sched/idle_task.c
+++ b/kernel/sched/idle_task.c
@@ -25,7 +25,6 @@ static void check_preempt_curr_idle(struct rq *rq, struct task_struct *p, int fl
25static struct task_struct *pick_next_task_idle(struct rq *rq) 25static struct task_struct *pick_next_task_idle(struct rq *rq)
26{ 26{
27 schedstat_inc(rq, sched_goidle); 27 schedstat_inc(rq, sched_goidle);
28 calc_load_account_idle(rq);
29 return rq->idle; 28 return rq->idle;
30} 29}
31 30
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6d52cea7f33..55844f24435 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -942,8 +942,6 @@ static inline u64 sched_avg_period(void)
942 return (u64)sysctl_sched_time_avg * NSEC_PER_MSEC / 2; 942 return (u64)sysctl_sched_time_avg * NSEC_PER_MSEC / 2;
943} 943}
944 944
945void calc_load_account_idle(struct rq *this_rq);
946
947#ifdef CONFIG_SCHED_HRTICK 945#ifdef CONFIG_SCHED_HRTICK
948 946
949/* 947/*
diff --git a/kernel/sys.c b/kernel/sys.c
index e0c8ffc50d7..2d39a84cd85 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1788,7 +1788,6 @@ SYSCALL_DEFINE1(umask, int, mask)
1788#ifdef CONFIG_CHECKPOINT_RESTORE 1788#ifdef CONFIG_CHECKPOINT_RESTORE
1789static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) 1789static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
1790{ 1790{
1791 struct vm_area_struct *vma;
1792 struct file *exe_file; 1791 struct file *exe_file;
1793 struct dentry *dentry; 1792 struct dentry *dentry;
1794 int err; 1793 int err;
@@ -1816,13 +1815,17 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
1816 down_write(&mm->mmap_sem); 1815 down_write(&mm->mmap_sem);
1817 1816
1818 /* 1817 /*
1819 * Forbid mm->exe_file change if there are mapped other files. 1818 * Forbid mm->exe_file change if old file still mapped.
1820 */ 1819 */
1821 err = -EBUSY; 1820 err = -EBUSY;
1822 for (vma = mm->mmap; vma; vma = vma->vm_next) { 1821 if (mm->exe_file) {
1823 if (vma->vm_file && !path_equal(&vma->vm_file->f_path, 1822 struct vm_area_struct *vma;
1824 &exe_file->f_path)) 1823
1825 goto exit_unlock; 1824 for (vma = mm->mmap; vma; vma = vma->vm_next)
1825 if (vma->vm_file &&
1826 path_equal(&vma->vm_file->f_path,
1827 &mm->exe_file->f_path))
1828 goto exit_unlock;
1826 } 1829 }
1827 1830
1828 /* 1831 /*
@@ -1835,6 +1838,7 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
1835 if (test_and_set_bit(MMF_EXE_FILE_CHANGED, &mm->flags)) 1838 if (test_and_set_bit(MMF_EXE_FILE_CHANGED, &mm->flags))
1836 goto exit_unlock; 1839 goto exit_unlock;
1837 1840
1841 err = 0;
1838 set_mm_exe_file(mm, exe_file); 1842 set_mm_exe_file(mm, exe_file);
1839exit_unlock: 1843exit_unlock:
1840 up_write(&mm->mmap_sem); 1844 up_write(&mm->mmap_sem);
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 70b33abcc7b..b7fbadc5c97 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -409,7 +409,9 @@ int second_overflow(unsigned long secs)
409 time_state = TIME_DEL; 409 time_state = TIME_DEL;
410 break; 410 break;
411 case TIME_INS: 411 case TIME_INS:
412 if (secs % 86400 == 0) { 412 if (!(time_status & STA_INS))
413 time_state = TIME_OK;
414 else if (secs % 86400 == 0) {
413 leap = -1; 415 leap = -1;
414 time_state = TIME_OOP; 416 time_state = TIME_OOP;
415 time_tai++; 417 time_tai++;
@@ -418,7 +420,9 @@ int second_overflow(unsigned long secs)
418 } 420 }
419 break; 421 break;
420 case TIME_DEL: 422 case TIME_DEL:
421 if ((secs + 1) % 86400 == 0) { 423 if (!(time_status & STA_DEL))
424 time_state = TIME_OK;
425 else if ((secs + 1) % 86400 == 0) {
422 leap = 1; 426 leap = 1;
423 time_tai--; 427 time_tai--;
424 time_state = TIME_WAIT; 428 time_state = TIME_WAIT;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 86999783392..4a08472c3ca 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -406,6 +406,7 @@ static void tick_nohz_stop_sched_tick(struct tick_sched *ts)
406 */ 406 */
407 if (!ts->tick_stopped) { 407 if (!ts->tick_stopped) {
408 select_nohz_load_balancer(1); 408 select_nohz_load_balancer(1);
409 calc_load_enter_idle();
409 410
410 ts->idle_tick = hrtimer_get_expires(&ts->sched_timer); 411 ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
411 ts->tick_stopped = 1; 412 ts->tick_stopped = 1;
@@ -597,6 +598,7 @@ void tick_nohz_idle_exit(void)
597 account_idle_ticks(ticks); 598 account_idle_ticks(ticks);
598#endif 599#endif
599 600
601 calc_load_exit_idle();
600 touch_softlockup_watchdog(); 602 touch_softlockup_watchdog();
601 /* 603 /*
602 * Cancel the scheduled timer and restore the tick 604 * Cancel the scheduled timer and restore the tick
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 6f46a00a1e8..3447cfaf11e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -70,6 +70,12 @@ struct timekeeper {
70 /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ 70 /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
71 struct timespec raw_time; 71 struct timespec raw_time;
72 72
73 /* Offset clock monotonic -> clock realtime */
74 ktime_t offs_real;
75
76 /* Offset clock monotonic -> clock boottime */
77 ktime_t offs_boot;
78
73 /* Seqlock for all timekeeper values */ 79 /* Seqlock for all timekeeper values */
74 seqlock_t lock; 80 seqlock_t lock;
75}; 81};
@@ -172,6 +178,14 @@ static inline s64 timekeeping_get_ns_raw(void)
172 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 178 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
173} 179}
174 180
181static void update_rt_offset(void)
182{
183 struct timespec tmp, *wtm = &timekeeper.wall_to_monotonic;
184
185 set_normalized_timespec(&tmp, -wtm->tv_sec, -wtm->tv_nsec);
186 timekeeper.offs_real = timespec_to_ktime(tmp);
187}
188
175/* must hold write on timekeeper.lock */ 189/* must hold write on timekeeper.lock */
176static void timekeeping_update(bool clearntp) 190static void timekeeping_update(bool clearntp)
177{ 191{
@@ -179,6 +193,7 @@ static void timekeeping_update(bool clearntp)
179 timekeeper.ntp_error = 0; 193 timekeeper.ntp_error = 0;
180 ntp_clear(); 194 ntp_clear();
181 } 195 }
196 update_rt_offset();
182 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, 197 update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic,
183 timekeeper.clock, timekeeper.mult); 198 timekeeper.clock, timekeeper.mult);
184} 199}
@@ -604,6 +619,7 @@ void __init timekeeping_init(void)
604 } 619 }
605 set_normalized_timespec(&timekeeper.wall_to_monotonic, 620 set_normalized_timespec(&timekeeper.wall_to_monotonic,
606 -boot.tv_sec, -boot.tv_nsec); 621 -boot.tv_sec, -boot.tv_nsec);
622 update_rt_offset();
607 timekeeper.total_sleep_time.tv_sec = 0; 623 timekeeper.total_sleep_time.tv_sec = 0;
608 timekeeper.total_sleep_time.tv_nsec = 0; 624 timekeeper.total_sleep_time.tv_nsec = 0;
609 write_sequnlock_irqrestore(&timekeeper.lock, flags); 625 write_sequnlock_irqrestore(&timekeeper.lock, flags);
@@ -612,6 +628,12 @@ void __init timekeeping_init(void)
612/* time in seconds when suspend began */ 628/* time in seconds when suspend began */
613static struct timespec timekeeping_suspend_time; 629static struct timespec timekeeping_suspend_time;
614 630
631static void update_sleep_time(struct timespec t)
632{
633 timekeeper.total_sleep_time = t;
634 timekeeper.offs_boot = timespec_to_ktime(t);
635}
636
615/** 637/**
616 * __timekeeping_inject_sleeptime - Internal function to add sleep interval 638 * __timekeeping_inject_sleeptime - Internal function to add sleep interval
617 * @delta: pointer to a timespec delta value 639 * @delta: pointer to a timespec delta value
@@ -630,8 +652,7 @@ static void __timekeeping_inject_sleeptime(struct timespec *delta)
630 timekeeper.xtime = timespec_add(timekeeper.xtime, *delta); 652 timekeeper.xtime = timespec_add(timekeeper.xtime, *delta);
631 timekeeper.wall_to_monotonic = 653 timekeeper.wall_to_monotonic =
632 timespec_sub(timekeeper.wall_to_monotonic, *delta); 654 timespec_sub(timekeeper.wall_to_monotonic, *delta);
633 timekeeper.total_sleep_time = timespec_add( 655 update_sleep_time(timespec_add(timekeeper.total_sleep_time, *delta));
634 timekeeper.total_sleep_time, *delta);
635} 656}
636 657
637 658
@@ -696,6 +717,7 @@ static void timekeeping_resume(void)
696 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); 717 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
697 timekeeper.ntp_error = 0; 718 timekeeper.ntp_error = 0;
698 timekeeping_suspended = 0; 719 timekeeping_suspended = 0;
720 timekeeping_update(false);
699 write_sequnlock_irqrestore(&timekeeper.lock, flags); 721 write_sequnlock_irqrestore(&timekeeper.lock, flags);
700 722
701 touch_softlockup_watchdog(); 723 touch_softlockup_watchdog();
@@ -963,6 +985,8 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
963 leap = second_overflow(timekeeper.xtime.tv_sec); 985 leap = second_overflow(timekeeper.xtime.tv_sec);
964 timekeeper.xtime.tv_sec += leap; 986 timekeeper.xtime.tv_sec += leap;
965 timekeeper.wall_to_monotonic.tv_sec -= leap; 987 timekeeper.wall_to_monotonic.tv_sec -= leap;
988 if (leap)
989 clock_was_set_delayed();
966 } 990 }
967 991
968 /* Accumulate raw time */ 992 /* Accumulate raw time */
@@ -1079,6 +1103,8 @@ static void update_wall_time(void)
1079 leap = second_overflow(timekeeper.xtime.tv_sec); 1103 leap = second_overflow(timekeeper.xtime.tv_sec);
1080 timekeeper.xtime.tv_sec += leap; 1104 timekeeper.xtime.tv_sec += leap;
1081 timekeeper.wall_to_monotonic.tv_sec -= leap; 1105 timekeeper.wall_to_monotonic.tv_sec -= leap;
1106 if (leap)
1107 clock_was_set_delayed();
1082 } 1108 }
1083 1109
1084 timekeeping_update(false); 1110 timekeeping_update(false);
@@ -1246,6 +1272,40 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
1246 } while (read_seqretry(&timekeeper.lock, seq)); 1272 } while (read_seqretry(&timekeeper.lock, seq));
1247} 1273}
1248 1274
1275#ifdef CONFIG_HIGH_RES_TIMERS
1276/**
1277 * ktime_get_update_offsets - hrtimer helper
1278 * @offs_real: pointer to storage for monotonic -> realtime offset
1279 * @offs_boot: pointer to storage for monotonic -> boottime offset
1280 *
1281 * Returns current monotonic time and updates the offsets
1282 * Called from hrtimer_interupt() or retrigger_next_event()
1283 */
1284ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot)
1285{
1286 ktime_t now;
1287 unsigned int seq;
1288 u64 secs, nsecs;
1289
1290 do {
1291 seq = read_seqbegin(&timekeeper.lock);
1292
1293 secs = timekeeper.xtime.tv_sec;
1294 nsecs = timekeeper.xtime.tv_nsec;
1295 nsecs += timekeeping_get_ns();
1296 /* If arch requires, add in gettimeoffset() */
1297 nsecs += arch_gettimeoffset();
1298
1299 *offs_real = timekeeper.offs_real;
1300 *offs_boot = timekeeper.offs_boot;
1301 } while (read_seqretry(&timekeeper.lock, seq));
1302
1303 now = ktime_add_ns(ktime_set(secs, 0), nsecs);
1304 now = ktime_sub(now, *offs_real);
1305 return now;
1306}
1307#endif
1308
1249/** 1309/**
1250 * ktime_get_monotonic_offset() - get wall_to_monotonic in ktime_t format 1310 * ktime_get_monotonic_offset() - get wall_to_monotonic in ktime_t format
1251 */ 1311 */
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 1d0f6a8a0e5..f765465bffe 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1075,6 +1075,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int nr_pages, int cpu)
1075 rb_init_page(bpage->page); 1075 rb_init_page(bpage->page);
1076 1076
1077 INIT_LIST_HEAD(&cpu_buffer->reader_page->list); 1077 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
1078 INIT_LIST_HEAD(&cpu_buffer->new_pages);
1078 1079
1079 ret = rb_allocate_pages(cpu_buffer, nr_pages); 1080 ret = rb_allocate_pages(cpu_buffer, nr_pages);
1080 if (ret < 0) 1081 if (ret < 0)
@@ -1346,10 +1347,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
1346 * If something was added to this page, it was full 1347 * If something was added to this page, it was full
1347 * since it is not the tail page. So we deduct the 1348 * since it is not the tail page. So we deduct the
1348 * bytes consumed in ring buffer from here. 1349 * bytes consumed in ring buffer from here.
1349 * No need to update overruns, since this page is 1350 * Increment overrun to account for the lost events.
1350 * deleted from ring buffer and its entries are
1351 * already accounted for.
1352 */ 1351 */
1352 local_add(page_entries, &cpu_buffer->overrun);
1353 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes); 1353 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
1354 } 1354 }
1355 1355
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 518aea714d2..66ce4148913 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -78,7 +78,7 @@ static LIST_HEAD(free_entries);
78static DEFINE_SPINLOCK(free_entries_lock); 78static DEFINE_SPINLOCK(free_entries_lock);
79 79
80/* Global disable flag - will be set in case of an error */ 80/* Global disable flag - will be set in case of an error */
81static bool global_disable __read_mostly; 81static u32 global_disable __read_mostly;
82 82
83/* Global error count */ 83/* Global error count */
84static u32 error_count; 84static u32 error_count;
@@ -657,7 +657,7 @@ static int dma_debug_fs_init(void)
657 657
658 global_disable_dent = debugfs_create_bool("disabled", 0444, 658 global_disable_dent = debugfs_create_bool("disabled", 0444,
659 dma_debug_dent, 659 dma_debug_dent,
660 (u32 *)&global_disable); 660 &global_disable);
661 if (!global_disable_dent) 661 if (!global_disable_dent)
662 goto out_err; 662 goto out_err;
663 663
diff --git a/mm/bootmem.c b/mm/bootmem.c
index ec4fcb7a56c..bcb63ac48cc 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -698,7 +698,7 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
698 return ___alloc_bootmem(size, align, goal, limit); 698 return ___alloc_bootmem(size, align, goal, limit);
699} 699}
700 700
701static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat, 701void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
702 unsigned long size, unsigned long align, 702 unsigned long size, unsigned long align,
703 unsigned long goal, unsigned long limit) 703 unsigned long goal, unsigned long limit)
704{ 704{
@@ -710,6 +710,10 @@ again:
710 if (ptr) 710 if (ptr)
711 return ptr; 711 return ptr;
712 712
713 /* do not panic in alloc_bootmem_bdata() */
714 if (limit && goal + size > limit)
715 limit = 0;
716
713 ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, limit); 717 ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, limit);
714 if (ptr) 718 if (ptr)
715 return ptr; 719 return ptr;
diff --git a/mm/compaction.c b/mm/compaction.c
index 7ea259d82a9..2f42d952853 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -701,8 +701,11 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
701 if (err) { 701 if (err) {
702 putback_lru_pages(&cc->migratepages); 702 putback_lru_pages(&cc->migratepages);
703 cc->nr_migratepages = 0; 703 cc->nr_migratepages = 0;
704 if (err == -ENOMEM) {
705 ret = COMPACT_PARTIAL;
706 goto out;
707 }
704 } 708 }
705
706 } 709 }
707 710
708out: 711out:
diff --git a/mm/memblock.c b/mm/memblock.c
index d4382095f8b..5cc6731b00c 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -143,30 +143,6 @@ phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start,
143 MAX_NUMNODES); 143 MAX_NUMNODES);
144} 144}
145 145
146/*
147 * Free memblock.reserved.regions
148 */
149int __init_memblock memblock_free_reserved_regions(void)
150{
151 if (memblock.reserved.regions == memblock_reserved_init_regions)
152 return 0;
153
154 return memblock_free(__pa(memblock.reserved.regions),
155 sizeof(struct memblock_region) * memblock.reserved.max);
156}
157
158/*
159 * Reserve memblock.reserved.regions
160 */
161int __init_memblock memblock_reserve_reserved_regions(void)
162{
163 if (memblock.reserved.regions == memblock_reserved_init_regions)
164 return 0;
165
166 return memblock_reserve(__pa(memblock.reserved.regions),
167 sizeof(struct memblock_region) * memblock.reserved.max);
168}
169
170static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) 146static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
171{ 147{
172 type->total_size -= type->regions[r].size; 148 type->total_size -= type->regions[r].size;
@@ -184,6 +160,18 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
184 } 160 }
185} 161}
186 162
163phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
164 phys_addr_t *addr)
165{
166 if (memblock.reserved.regions == memblock_reserved_init_regions)
167 return 0;
168
169 *addr = __pa(memblock.reserved.regions);
170
171 return PAGE_ALIGN(sizeof(struct memblock_region) *
172 memblock.reserved.max);
173}
174
187/** 175/**
188 * memblock_double_array - double the size of the memblock regions array 176 * memblock_double_array - double the size of the memblock regions array
189 * @type: memblock type of the regions array being doubled 177 * @type: memblock type of the regions array being doubled
@@ -204,6 +192,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
204 phys_addr_t new_area_size) 192 phys_addr_t new_area_size)
205{ 193{
206 struct memblock_region *new_array, *old_array; 194 struct memblock_region *new_array, *old_array;
195 phys_addr_t old_alloc_size, new_alloc_size;
207 phys_addr_t old_size, new_size, addr; 196 phys_addr_t old_size, new_size, addr;
208 int use_slab = slab_is_available(); 197 int use_slab = slab_is_available();
209 int *in_slab; 198 int *in_slab;
@@ -217,6 +206,12 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
217 /* Calculate new doubled size */ 206 /* Calculate new doubled size */
218 old_size = type->max * sizeof(struct memblock_region); 207 old_size = type->max * sizeof(struct memblock_region);
219 new_size = old_size << 1; 208 new_size = old_size << 1;
209 /*
210 * We need to allocated new one align to PAGE_SIZE,
211 * so we can free them completely later.
212 */
213 old_alloc_size = PAGE_ALIGN(old_size);
214 new_alloc_size = PAGE_ALIGN(new_size);
220 215
221 /* Retrieve the slab flag */ 216 /* Retrieve the slab flag */
222 if (type == &memblock.memory) 217 if (type == &memblock.memory)
@@ -245,11 +240,11 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
245 240
246 addr = memblock_find_in_range(new_area_start + new_area_size, 241 addr = memblock_find_in_range(new_area_start + new_area_size,
247 memblock.current_limit, 242 memblock.current_limit,
248 new_size, sizeof(phys_addr_t)); 243 new_alloc_size, PAGE_SIZE);
249 if (!addr && new_area_size) 244 if (!addr && new_area_size)
250 addr = memblock_find_in_range(0, 245 addr = memblock_find_in_range(0,
251 min(new_area_start, memblock.current_limit), 246 min(new_area_start, memblock.current_limit),
252 new_size, sizeof(phys_addr_t)); 247 new_alloc_size, PAGE_SIZE);
253 248
254 new_array = addr ? __va(addr) : 0; 249 new_array = addr ? __va(addr) : 0;
255 } 250 }
@@ -279,13 +274,13 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
279 kfree(old_array); 274 kfree(old_array);
280 else if (old_array != memblock_memory_init_regions && 275 else if (old_array != memblock_memory_init_regions &&
281 old_array != memblock_reserved_init_regions) 276 old_array != memblock_reserved_init_regions)
282 memblock_free(__pa(old_array), old_size); 277 memblock_free(__pa(old_array), old_alloc_size);
283 278
284 /* Reserve the new array if that comes from the memblock. 279 /* Reserve the new array if that comes from the memblock.
285 * Otherwise, we needn't do it 280 * Otherwise, we needn't do it
286 */ 281 */
287 if (!use_slab) 282 if (!use_slab)
288 BUG_ON(memblock_reserve(addr, new_size)); 283 BUG_ON(memblock_reserve(addr, new_alloc_size));
289 284
290 /* Update slab flag */ 285 /* Update slab flag */
291 *in_slab = use_slab; 286 *in_slab = use_slab;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 0d7e3ec8e0f..427bb291dd0 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -618,7 +618,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
618 pgdat = hotadd_new_pgdat(nid, start); 618 pgdat = hotadd_new_pgdat(nid, start);
619 ret = -ENOMEM; 619 ret = -ENOMEM;
620 if (!pgdat) 620 if (!pgdat)
621 goto out; 621 goto error;
622 new_pgdat = 1; 622 new_pgdat = 1;
623 } 623 }
624 624
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index d23415c001b..405573010f9 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -105,27 +105,35 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
105 __free_pages_bootmem(pfn_to_page(i), 0); 105 __free_pages_bootmem(pfn_to_page(i), 0);
106} 106}
107 107
108static unsigned long __init __free_memory_core(phys_addr_t start,
109 phys_addr_t end)
110{
111 unsigned long start_pfn = PFN_UP(start);
112 unsigned long end_pfn = min_t(unsigned long,
113 PFN_DOWN(end), max_low_pfn);
114
115 if (start_pfn > end_pfn)
116 return 0;
117
118 __free_pages_memory(start_pfn, end_pfn);
119
120 return end_pfn - start_pfn;
121}
122
108unsigned long __init free_low_memory_core_early(int nodeid) 123unsigned long __init free_low_memory_core_early(int nodeid)
109{ 124{
110 unsigned long count = 0; 125 unsigned long count = 0;
111 phys_addr_t start, end; 126 phys_addr_t start, end, size;
112 u64 i; 127 u64 i;
113 128
114 /* free reserved array temporarily so that it's treated as free area */ 129 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL)
115 memblock_free_reserved_regions(); 130 count += __free_memory_core(start, end);
116 131
117 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) { 132 /* free range that is used for reserved array if we allocate it */
118 unsigned long start_pfn = PFN_UP(start); 133 size = get_allocated_memblock_reserved_regions_info(&start);
119 unsigned long end_pfn = min_t(unsigned long, 134 if (size)
120 PFN_DOWN(end), max_low_pfn); 135 count += __free_memory_core(start, start + size);
121 if (start_pfn < end_pfn) {
122 __free_pages_memory(start_pfn, end_pfn);
123 count += end_pfn - start_pfn;
124 }
125 }
126 136
127 /* put region array back? */
128 memblock_reserve_reserved_regions();
129 return count; 137 return count;
130} 138}
131 139
@@ -274,7 +282,7 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
274 return ___alloc_bootmem(size, align, goal, limit); 282 return ___alloc_bootmem(size, align, goal, limit);
275} 283}
276 284
277static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat, 285void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
278 unsigned long size, 286 unsigned long size,
279 unsigned long align, 287 unsigned long align,
280 unsigned long goal, 288 unsigned long goal,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 44030096da6..4a4f9219683 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5635,7 +5635,12 @@ static struct page *
5635__alloc_contig_migrate_alloc(struct page *page, unsigned long private, 5635__alloc_contig_migrate_alloc(struct page *page, unsigned long private,
5636 int **resultp) 5636 int **resultp)
5637{ 5637{
5638 return alloc_page(GFP_HIGHUSER_MOVABLE); 5638 gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE;
5639
5640 if (PageHighMem(page))
5641 gfp_mask |= __GFP_HIGHMEM;
5642
5643 return alloc_page(gfp_mask);
5639} 5644}
5640 5645
5641/* [start, end) must belong to a single zone. */ 5646/* [start, end) must belong to a single zone. */
diff --git a/mm/shmem.c b/mm/shmem.c
index 4ce02e0673d..bd106361be4 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -264,46 +264,55 @@ static int shmem_radix_tree_replace(struct address_space *mapping,
264} 264}
265 265
266/* 266/*
267 * Sometimes, before we decide whether to proceed or to fail, we must check
268 * that an entry was not already brought back from swap by a racing thread.
269 *
270 * Checking page is not enough: by the time a SwapCache page is locked, it
271 * might be reused, and again be SwapCache, using the same swap as before.
272 */
273static bool shmem_confirm_swap(struct address_space *mapping,
274 pgoff_t index, swp_entry_t swap)
275{
276 void *item;
277
278 rcu_read_lock();
279 item = radix_tree_lookup(&mapping->page_tree, index);
280 rcu_read_unlock();
281 return item == swp_to_radix_entry(swap);
282}
283
284/*
267 * Like add_to_page_cache_locked, but error if expected item has gone. 285 * Like add_to_page_cache_locked, but error if expected item has gone.
268 */ 286 */
269static int shmem_add_to_page_cache(struct page *page, 287static int shmem_add_to_page_cache(struct page *page,
270 struct address_space *mapping, 288 struct address_space *mapping,
271 pgoff_t index, gfp_t gfp, void *expected) 289 pgoff_t index, gfp_t gfp, void *expected)
272{ 290{
273 int error = 0; 291 int error;
274 292
275 VM_BUG_ON(!PageLocked(page)); 293 VM_BUG_ON(!PageLocked(page));
276 VM_BUG_ON(!PageSwapBacked(page)); 294 VM_BUG_ON(!PageSwapBacked(page));
277 295
296 page_cache_get(page);
297 page->mapping = mapping;
298 page->index = index;
299
300 spin_lock_irq(&mapping->tree_lock);
278 if (!expected) 301 if (!expected)
279 error = radix_tree_preload(gfp & GFP_RECLAIM_MASK); 302 error = radix_tree_insert(&mapping->page_tree, index, page);
303 else
304 error = shmem_radix_tree_replace(mapping, index, expected,
305 page);
280 if (!error) { 306 if (!error) {
281 page_cache_get(page); 307 mapping->nrpages++;
282 page->mapping = mapping; 308 __inc_zone_page_state(page, NR_FILE_PAGES);
283 page->index = index; 309 __inc_zone_page_state(page, NR_SHMEM);
284 310 spin_unlock_irq(&mapping->tree_lock);
285 spin_lock_irq(&mapping->tree_lock); 311 } else {
286 if (!expected) 312 page->mapping = NULL;
287 error = radix_tree_insert(&mapping->page_tree, 313 spin_unlock_irq(&mapping->tree_lock);
288 index, page); 314 page_cache_release(page);
289 else
290 error = shmem_radix_tree_replace(mapping, index,
291 expected, page);
292 if (!error) {
293 mapping->nrpages++;
294 __inc_zone_page_state(page, NR_FILE_PAGES);
295 __inc_zone_page_state(page, NR_SHMEM);
296 spin_unlock_irq(&mapping->tree_lock);
297 } else {
298 page->mapping = NULL;
299 spin_unlock_irq(&mapping->tree_lock);
300 page_cache_release(page);
301 }
302 if (!expected)
303 radix_tree_preload_end();
304 } 315 }
305 if (error)
306 mem_cgroup_uncharge_cache_page(page);
307 return error; 316 return error;
308} 317}
309 318
@@ -1124,9 +1133,9 @@ repeat:
1124 /* We have to do this with page locked to prevent races */ 1133 /* We have to do this with page locked to prevent races */
1125 lock_page(page); 1134 lock_page(page);
1126 if (!PageSwapCache(page) || page_private(page) != swap.val || 1135 if (!PageSwapCache(page) || page_private(page) != swap.val ||
1127 page->mapping) { 1136 !shmem_confirm_swap(mapping, index, swap)) {
1128 error = -EEXIST; /* try again */ 1137 error = -EEXIST; /* try again */
1129 goto failed; 1138 goto unlock;
1130 } 1139 }
1131 if (!PageUptodate(page)) { 1140 if (!PageUptodate(page)) {
1132 error = -EIO; 1141 error = -EIO;
@@ -1142,9 +1151,12 @@ repeat:
1142 1151
1143 error = mem_cgroup_cache_charge(page, current->mm, 1152 error = mem_cgroup_cache_charge(page, current->mm,
1144 gfp & GFP_RECLAIM_MASK); 1153 gfp & GFP_RECLAIM_MASK);
1145 if (!error) 1154 if (!error) {
1146 error = shmem_add_to_page_cache(page, mapping, index, 1155 error = shmem_add_to_page_cache(page, mapping, index,
1147 gfp, swp_to_radix_entry(swap)); 1156 gfp, swp_to_radix_entry(swap));
1157 /* We already confirmed swap, and make no allocation */
1158 VM_BUG_ON(error);
1159 }
1148 if (error) 1160 if (error)
1149 goto failed; 1161 goto failed;
1150 1162
@@ -1181,11 +1193,18 @@ repeat:
1181 __set_page_locked(page); 1193 __set_page_locked(page);
1182 error = mem_cgroup_cache_charge(page, current->mm, 1194 error = mem_cgroup_cache_charge(page, current->mm,
1183 gfp & GFP_RECLAIM_MASK); 1195 gfp & GFP_RECLAIM_MASK);
1184 if (!error)
1185 error = shmem_add_to_page_cache(page, mapping, index,
1186 gfp, NULL);
1187 if (error) 1196 if (error)
1188 goto decused; 1197 goto decused;
1198 error = radix_tree_preload(gfp & GFP_RECLAIM_MASK);
1199 if (!error) {
1200 error = shmem_add_to_page_cache(page, mapping, index,
1201 gfp, NULL);
1202 radix_tree_preload_end();
1203 }
1204 if (error) {
1205 mem_cgroup_uncharge_cache_page(page);
1206 goto decused;
1207 }
1189 lru_cache_add_anon(page); 1208 lru_cache_add_anon(page);
1190 1209
1191 spin_lock(&info->lock); 1210 spin_lock(&info->lock);
@@ -1245,14 +1264,10 @@ decused:
1245unacct: 1264unacct:
1246 shmem_unacct_blocks(info->flags, 1); 1265 shmem_unacct_blocks(info->flags, 1);
1247failed: 1266failed:
1248 if (swap.val && error != -EINVAL) { 1267 if (swap.val && error != -EINVAL &&
1249 struct page *test = find_get_page(mapping, index); 1268 !shmem_confirm_swap(mapping, index, swap))
1250 if (test && !radix_tree_exceptional_entry(test)) 1269 error = -EEXIST;
1251 page_cache_release(test); 1270unlock:
1252 /* Have another try if the entry has changed */
1253 if (test != swp_to_radix_entry(swap))
1254 error = -EEXIST;
1255 }
1256 if (page) { 1271 if (page) {
1257 unlock_page(page); 1272 unlock_page(page);
1258 page_cache_release(page); 1273 page_cache_release(page);
@@ -1264,7 +1279,7 @@ failed:
1264 spin_unlock(&info->lock); 1279 spin_unlock(&info->lock);
1265 goto repeat; 1280 goto repeat;
1266 } 1281 }
1267 if (error == -EEXIST) 1282 if (error == -EEXIST) /* from above or from radix_tree_insert */
1268 goto repeat; 1283 goto repeat;
1269 return error; 1284 return error;
1270} 1285}
@@ -1692,98 +1707,6 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
1692 return error; 1707 return error;
1693} 1708}
1694 1709
1695/*
1696 * llseek SEEK_DATA or SEEK_HOLE through the radix_tree.
1697 */
1698static pgoff_t shmem_seek_hole_data(struct address_space *mapping,
1699 pgoff_t index, pgoff_t end, int origin)
1700{
1701 struct page *page;
1702 struct pagevec pvec;
1703 pgoff_t indices[PAGEVEC_SIZE];
1704 bool done = false;
1705 int i;
1706
1707 pagevec_init(&pvec, 0);
1708 pvec.nr = 1; /* start small: we may be there already */
1709 while (!done) {
1710 pvec.nr = shmem_find_get_pages_and_swap(mapping, index,
1711 pvec.nr, pvec.pages, indices);
1712 if (!pvec.nr) {
1713 if (origin == SEEK_DATA)
1714 index = end;
1715 break;
1716 }
1717 for (i = 0; i < pvec.nr; i++, index++) {
1718 if (index < indices[i]) {
1719 if (origin == SEEK_HOLE) {
1720 done = true;
1721 break;
1722 }
1723 index = indices[i];
1724 }
1725 page = pvec.pages[i];
1726 if (page && !radix_tree_exceptional_entry(page)) {
1727 if (!PageUptodate(page))
1728 page = NULL;
1729 }
1730 if (index >= end ||
1731 (page && origin == SEEK_DATA) ||
1732 (!page && origin == SEEK_HOLE)) {
1733 done = true;
1734 break;
1735 }
1736 }
1737 shmem_deswap_pagevec(&pvec);
1738 pagevec_release(&pvec);
1739 pvec.nr = PAGEVEC_SIZE;
1740 cond_resched();
1741 }
1742 return index;
1743}
1744
1745static loff_t shmem_file_llseek(struct file *file, loff_t offset, int origin)
1746{
1747 struct address_space *mapping;
1748 struct inode *inode;
1749 pgoff_t start, end;
1750 loff_t new_offset;
1751
1752 if (origin != SEEK_DATA && origin != SEEK_HOLE)
1753 return generic_file_llseek_size(file, offset, origin,
1754 MAX_LFS_FILESIZE);
1755 mapping = file->f_mapping;
1756 inode = mapping->host;
1757 mutex_lock(&inode->i_mutex);
1758 /* We're holding i_mutex so we can access i_size directly */
1759
1760 if (offset < 0)
1761 offset = -EINVAL;
1762 else if (offset >= inode->i_size)
1763 offset = -ENXIO;
1764 else {
1765 start = offset >> PAGE_CACHE_SHIFT;
1766 end = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
1767 new_offset = shmem_seek_hole_data(mapping, start, end, origin);
1768 new_offset <<= PAGE_CACHE_SHIFT;
1769 if (new_offset > offset) {
1770 if (new_offset < inode->i_size)
1771 offset = new_offset;
1772 else if (origin == SEEK_DATA)
1773 offset = -ENXIO;
1774 else
1775 offset = inode->i_size;
1776 }
1777 }
1778
1779 if (offset >= 0 && offset != file->f_pos) {
1780 file->f_pos = offset;
1781 file->f_version = 0;
1782 }
1783 mutex_unlock(&inode->i_mutex);
1784 return offset;
1785}
1786
1787static long shmem_fallocate(struct file *file, int mode, loff_t offset, 1710static long shmem_fallocate(struct file *file, int mode, loff_t offset,
1788 loff_t len) 1711 loff_t len)
1789{ 1712{
@@ -2787,7 +2710,7 @@ static const struct address_space_operations shmem_aops = {
2787static const struct file_operations shmem_file_operations = { 2710static const struct file_operations shmem_file_operations = {
2788 .mmap = shmem_mmap, 2711 .mmap = shmem_mmap,
2789#ifdef CONFIG_TMPFS 2712#ifdef CONFIG_TMPFS
2790 .llseek = shmem_file_llseek, 2713 .llseek = generic_file_llseek,
2791 .read = do_sync_read, 2714 .read = do_sync_read,
2792 .write = do_sync_write, 2715 .write = do_sync_write,
2793 .aio_read = shmem_file_aio_read, 2716 .aio_read = shmem_file_aio_read,
diff --git a/mm/sparse.c b/mm/sparse.c
index 6a4bf9160e8..c7bb952400c 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -275,8 +275,9 @@ static unsigned long * __init
275sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, 275sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
276 unsigned long size) 276 unsigned long size)
277{ 277{
278 pg_data_t *host_pgdat; 278 unsigned long goal, limit;
279 unsigned long goal; 279 unsigned long *p;
280 int nid;
280 /* 281 /*
281 * A page may contain usemaps for other sections preventing the 282 * A page may contain usemaps for other sections preventing the
282 * page being freed and making a section unremovable while 283 * page being freed and making a section unremovable while
@@ -287,10 +288,17 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
287 * from the same section as the pgdat where possible to avoid 288 * from the same section as the pgdat where possible to avoid
288 * this problem. 289 * this problem.
289 */ 290 */
290 goal = __pa(pgdat) & PAGE_SECTION_MASK; 291 goal = __pa(pgdat) & (PAGE_SECTION_MASK << PAGE_SHIFT);
291 host_pgdat = NODE_DATA(early_pfn_to_nid(goal >> PAGE_SHIFT)); 292 limit = goal + (1UL << PA_SECTION_SHIFT);
292 return __alloc_bootmem_node_nopanic(host_pgdat, size, 293 nid = early_pfn_to_nid(goal >> PAGE_SHIFT);
293 SMP_CACHE_BYTES, goal); 294again:
295 p = ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size,
296 SMP_CACHE_BYTES, goal, limit);
297 if (!p && limit) {
298 limit = 0;
299 goto again;
300 }
301 return p;
294} 302}
295 303
296static void __init check_usemap_section_nr(int nid, unsigned long *usemap) 304static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index eeb3bc9d1d3..66e431060c0 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2688,7 +2688,10 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int order, int classzone_idx)
2688 * them before going back to sleep. 2688 * them before going back to sleep.
2689 */ 2689 */
2690 set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold); 2690 set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold);
2691 schedule(); 2691
2692 if (!kthread_should_stop())
2693 schedule();
2694
2692 set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold); 2695 set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold);
2693 } else { 2696 } else {
2694 if (remaining) 2697 if (remaining)
@@ -2955,14 +2958,17 @@ int kswapd_run(int nid)
2955} 2958}
2956 2959
2957/* 2960/*
2958 * Called by memory hotplug when all memory in a node is offlined. 2961 * Called by memory hotplug when all memory in a node is offlined. Caller must
2962 * hold lock_memory_hotplug().
2959 */ 2963 */
2960void kswapd_stop(int nid) 2964void kswapd_stop(int nid)
2961{ 2965{
2962 struct task_struct *kswapd = NODE_DATA(nid)->kswapd; 2966 struct task_struct *kswapd = NODE_DATA(nid)->kswapd;
2963 2967
2964 if (kswapd) 2968 if (kswapd) {
2965 kthread_stop(kswapd); 2969 kthread_stop(kswapd);
2970 NODE_DATA(nid)->kswapd = NULL;
2971 }
2966} 2972}
2967 2973
2968static int __init kswapd_init(void) 2974static int __init kswapd_init(void)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 6089f0cf23b..9096bcb0813 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -403,6 +403,9 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
403 break; 403 break;
404 404
405 case NETDEV_DOWN: 405 case NETDEV_DOWN:
406 if (dev->features & NETIF_F_HW_VLAN_FILTER)
407 vlan_vid_del(dev, 0);
408
406 /* Put all VLANs for this dev in the down state too. */ 409 /* Put all VLANs for this dev in the down state too. */
407 for (i = 0; i < VLAN_N_VID; i++) { 410 for (i = 0; i < VLAN_N_VID; i++) {
408 vlandev = vlan_group_get_device(grp, i); 411 vlandev = vlan_group_get_device(grp, i);
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 051f7abae66..779095ded68 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -842,6 +842,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
842 case AX25_P_NETROM: 842 case AX25_P_NETROM:
843 if (ax25_protocol_is_registered(AX25_P_NETROM)) 843 if (ax25_protocol_is_registered(AX25_P_NETROM))
844 return -ESOCKTNOSUPPORT; 844 return -ESOCKTNOSUPPORT;
845 break;
845#endif 846#endif
846#ifdef CONFIG_ROSE_MODULE 847#ifdef CONFIG_ROSE_MODULE
847 case AX25_P_ROSE: 848 case AX25_P_ROSE:
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 8bf97515a77..c5863f49913 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1351,6 +1351,7 @@ void bla_free(struct bat_priv *bat_priv)
1351 * @bat_priv: the bat priv with all the soft interface information 1351 * @bat_priv: the bat priv with all the soft interface information
1352 * @skb: the frame to be checked 1352 * @skb: the frame to be checked
1353 * @vid: the VLAN ID of the frame 1353 * @vid: the VLAN ID of the frame
1354 * @is_bcast: the packet came in a broadcast packet type.
1354 * 1355 *
1355 * bla_rx avoidance checks if: 1356 * bla_rx avoidance checks if:
1356 * * we have to race for a claim 1357 * * we have to race for a claim
@@ -1361,7 +1362,8 @@ void bla_free(struct bat_priv *bat_priv)
1361 * process the skb. 1362 * process the skb.
1362 * 1363 *
1363 */ 1364 */
1364int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) 1365int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid,
1366 bool is_bcast)
1365{ 1367{
1366 struct ethhdr *ethhdr; 1368 struct ethhdr *ethhdr;
1367 struct claim search_claim, *claim = NULL; 1369 struct claim search_claim, *claim = NULL;
@@ -1380,7 +1382,7 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1380 1382
1381 if (unlikely(atomic_read(&bat_priv->bla_num_requests))) 1383 if (unlikely(atomic_read(&bat_priv->bla_num_requests)))
1382 /* don't allow broadcasts while requests are in flight */ 1384 /* don't allow broadcasts while requests are in flight */
1383 if (is_multicast_ether_addr(ethhdr->h_dest)) 1385 if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast)
1384 goto handled; 1386 goto handled;
1385 1387
1386 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN); 1388 memcpy(search_claim.addr, ethhdr->h_source, ETH_ALEN);
@@ -1406,8 +1408,13 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid)
1406 } 1408 }
1407 1409
1408 /* if it is a broadcast ... */ 1410 /* if it is a broadcast ... */
1409 if (is_multicast_ether_addr(ethhdr->h_dest)) { 1411 if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast) {
1410 /* ... drop it. the responsible gateway is in charge. */ 1412 /* ... drop it. the responsible gateway is in charge.
1413 *
1414 * We need to check is_bcast because with the gateway
1415 * feature, broadcasts (like DHCP requests) may be sent
1416 * using a unicast packet type.
1417 */
1411 goto handled; 1418 goto handled;
1412 } else { 1419 } else {
1413 /* seems the client considers us as its best gateway. 1420 /* seems the client considers us as its best gateway.
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index e39f93acc28..dc5227b398d 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -23,7 +23,8 @@
23#define _NET_BATMAN_ADV_BLA_H_ 23#define _NET_BATMAN_ADV_BLA_H_
24 24
25#ifdef CONFIG_BATMAN_ADV_BLA 25#ifdef CONFIG_BATMAN_ADV_BLA
26int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 26int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid,
27 bool is_bcast);
27int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 28int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
28int bla_is_backbone_gw(struct sk_buff *skb, 29int bla_is_backbone_gw(struct sk_buff *skb,
29 struct orig_node *orig_node, int hdr_size); 30 struct orig_node *orig_node, int hdr_size);
@@ -41,7 +42,7 @@ void bla_free(struct bat_priv *bat_priv);
41#else /* ifdef CONFIG_BATMAN_ADV_BLA */ 42#else /* ifdef CONFIG_BATMAN_ADV_BLA */
42 43
43static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, 44static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
44 short vid) 45 short vid, bool is_bcast)
45{ 46{
46 return 0; 47 return 0;
47} 48}
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 6e2530b0204..a0ec0e4ada4 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -256,7 +256,11 @@ void interface_rx(struct net_device *soft_iface,
256 struct bat_priv *bat_priv = netdev_priv(soft_iface); 256 struct bat_priv *bat_priv = netdev_priv(soft_iface);
257 struct ethhdr *ethhdr; 257 struct ethhdr *ethhdr;
258 struct vlan_ethhdr *vhdr; 258 struct vlan_ethhdr *vhdr;
259 struct batman_header *batadv_header = (struct batman_header *)skb->data;
259 short vid __maybe_unused = -1; 260 short vid __maybe_unused = -1;
261 bool is_bcast;
262
263 is_bcast = (batadv_header->packet_type == BAT_BCAST);
260 264
261 /* check if enough space is available for pulling, and pull */ 265 /* check if enough space is available for pulling, and pull */
262 if (!pskb_may_pull(skb, hdr_size)) 266 if (!pskb_may_pull(skb, hdr_size))
@@ -302,7 +306,7 @@ void interface_rx(struct net_device *soft_iface,
302 /* Let the bridge loop avoidance check the packet. If will 306 /* Let the bridge loop avoidance check the packet. If will
303 * not handle it, we can safely push it up. 307 * not handle it, we can safely push it up.
304 */ 308 */
305 if (bla_rx(bat_priv, skb, vid)) 309 if (bla_rx(bat_priv, skb, vid, is_bcast))
306 goto out; 310 goto out;
307 311
308 netif_rx(skb); 312 netif_rx(skb);
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 554b3128960..8c83c175b03 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -561,9 +561,9 @@ static int __init caif_device_init(void)
561 561
562static void __exit caif_device_exit(void) 562static void __exit caif_device_exit(void)
563{ 563{
564 unregister_pernet_subsys(&caif_net_ops);
565 unregister_netdevice_notifier(&caif_device_notifier); 564 unregister_netdevice_notifier(&caif_device_notifier);
566 dev_remove_pack(&caif_packet_type); 565 dev_remove_pack(&caif_packet_type);
566 unregister_pernet_subsys(&caif_net_ops);
567} 567}
568 568
569module_init(caif_device_init); 569module_init(caif_device_init);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index b332c3d7605..10255e81be7 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1423,7 +1423,7 @@ static int process_connect(struct ceph_connection *con)
1423 * dropped messages. 1423 * dropped messages.
1424 */ 1424 */
1425 dout("process_connect got RESET peer seq %u\n", 1425 dout("process_connect got RESET peer seq %u\n",
1426 le32_to_cpu(con->in_connect.connect_seq)); 1426 le32_to_cpu(con->in_reply.connect_seq));
1427 pr_err("%s%lld %s connection reset\n", 1427 pr_err("%s%lld %s connection reset\n",
1428 ENTITY_NAME(con->peer_name), 1428 ENTITY_NAME(con->peer_name),
1429 ceph_pr_addr(&con->peer_addr.in_addr)); 1429 ceph_pr_addr(&con->peer_addr.in_addr));
@@ -1450,10 +1450,10 @@ static int process_connect(struct ceph_connection *con)
1450 * If we sent a smaller connect_seq than the peer has, try 1450 * If we sent a smaller connect_seq than the peer has, try
1451 * again with a larger value. 1451 * again with a larger value.
1452 */ 1452 */
1453 dout("process_connect got RETRY my seq = %u, peer_seq = %u\n", 1453 dout("process_connect got RETRY_SESSION my seq %u, peer %u\n",
1454 le32_to_cpu(con->out_connect.connect_seq), 1454 le32_to_cpu(con->out_connect.connect_seq),
1455 le32_to_cpu(con->in_connect.connect_seq)); 1455 le32_to_cpu(con->in_reply.connect_seq));
1456 con->connect_seq = le32_to_cpu(con->in_connect.connect_seq); 1456 con->connect_seq = le32_to_cpu(con->in_reply.connect_seq);
1457 ceph_con_out_kvec_reset(con); 1457 ceph_con_out_kvec_reset(con);
1458 ret = prepare_write_connect(con); 1458 ret = prepare_write_connect(con);
1459 if (ret < 0) 1459 if (ret < 0)
@@ -1468,9 +1468,9 @@ static int process_connect(struct ceph_connection *con)
1468 */ 1468 */
1469 dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n", 1469 dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n",
1470 con->peer_global_seq, 1470 con->peer_global_seq,
1471 le32_to_cpu(con->in_connect.global_seq)); 1471 le32_to_cpu(con->in_reply.global_seq));
1472 get_global_seq(con->msgr, 1472 get_global_seq(con->msgr,
1473 le32_to_cpu(con->in_connect.global_seq)); 1473 le32_to_cpu(con->in_reply.global_seq));
1474 ceph_con_out_kvec_reset(con); 1474 ceph_con_out_kvec_reset(con);
1475 ret = prepare_write_connect(con); 1475 ret = prepare_write_connect(con);
1476 if (ret < 0) 1476 if (ret < 0)
diff --git a/net/core/dev.c b/net/core/dev.c
index 84f01ba81a3..1cb0d8a6aa6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2444,8 +2444,12 @@ static void skb_update_prio(struct sk_buff *skb)
2444{ 2444{
2445 struct netprio_map *map = rcu_dereference_bh(skb->dev->priomap); 2445 struct netprio_map *map = rcu_dereference_bh(skb->dev->priomap);
2446 2446
2447 if ((!skb->priority) && (skb->sk) && map) 2447 if (!skb->priority && skb->sk && map) {
2448 skb->priority = map->priomap[skb->sk->sk_cgrp_prioidx]; 2448 unsigned int prioidx = skb->sk->sk_cgrp_prioidx;
2449
2450 if (prioidx < map->priomap_len)
2451 skb->priority = map->priomap[prioidx];
2452 }
2449} 2453}
2450#else 2454#else
2451#define skb_update_prio(skb) 2455#define skb_update_prio(skb)
@@ -6279,7 +6283,8 @@ static struct hlist_head *netdev_create_hash(void)
6279/* Initialize per network namespace state */ 6283/* Initialize per network namespace state */
6280static int __net_init netdev_init(struct net *net) 6284static int __net_init netdev_init(struct net *net)
6281{ 6285{
6282 INIT_LIST_HEAD(&net->dev_base_head); 6286 if (net != &init_net)
6287 INIT_LIST_HEAD(&net->dev_base_head);
6283 6288
6284 net->dev_name_head = netdev_create_hash(); 6289 net->dev_name_head = netdev_create_hash();
6285 if (net->dev_name_head == NULL) 6290 if (net->dev_name_head == NULL)
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index dddbacb8f28..42f1e1c7514 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -27,7 +27,9 @@ static DEFINE_MUTEX(net_mutex);
27LIST_HEAD(net_namespace_list); 27LIST_HEAD(net_namespace_list);
28EXPORT_SYMBOL_GPL(net_namespace_list); 28EXPORT_SYMBOL_GPL(net_namespace_list);
29 29
30struct net init_net; 30struct net init_net = {
31 .dev_base_head = LIST_HEAD_INIT(init_net.dev_base_head),
32};
31EXPORT_SYMBOL(init_net); 33EXPORT_SYMBOL(init_net);
32 34
33#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */ 35#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 5b8aa2fae48..b2e9caa1ad1 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -49,8 +49,9 @@ static int get_prioidx(u32 *prio)
49 return -ENOSPC; 49 return -ENOSPC;
50 } 50 }
51 set_bit(prioidx, prioidx_map); 51 set_bit(prioidx, prioidx_map);
52 if (atomic_read(&max_prioidx) < prioidx)
53 atomic_set(&max_prioidx, prioidx);
52 spin_unlock_irqrestore(&prioidx_map_lock, flags); 54 spin_unlock_irqrestore(&prioidx_map_lock, flags);
53 atomic_set(&max_prioidx, prioidx);
54 *prio = prioidx; 55 *prio = prioidx;
55 return 0; 56 return 0;
56} 57}
@@ -64,7 +65,7 @@ static void put_prioidx(u32 idx)
64 spin_unlock_irqrestore(&prioidx_map_lock, flags); 65 spin_unlock_irqrestore(&prioidx_map_lock, flags);
65} 66}
66 67
67static void extend_netdev_table(struct net_device *dev, u32 new_len) 68static int extend_netdev_table(struct net_device *dev, u32 new_len)
68{ 69{
69 size_t new_size = sizeof(struct netprio_map) + 70 size_t new_size = sizeof(struct netprio_map) +
70 ((sizeof(u32) * new_len)); 71 ((sizeof(u32) * new_len));
@@ -76,7 +77,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
76 77
77 if (!new_priomap) { 78 if (!new_priomap) {
78 pr_warn("Unable to alloc new priomap!\n"); 79 pr_warn("Unable to alloc new priomap!\n");
79 return; 80 return -ENOMEM;
80 } 81 }
81 82
82 for (i = 0; 83 for (i = 0;
@@ -89,46 +90,79 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
89 rcu_assign_pointer(dev->priomap, new_priomap); 90 rcu_assign_pointer(dev->priomap, new_priomap);
90 if (old_priomap) 91 if (old_priomap)
91 kfree_rcu(old_priomap, rcu); 92 kfree_rcu(old_priomap, rcu);
93 return 0;
92} 94}
93 95
94static void update_netdev_tables(void) 96static int write_update_netdev_table(struct net_device *dev)
95{ 97{
98 int ret = 0;
99 u32 max_len;
100 struct netprio_map *map;
101
102 rtnl_lock();
103 max_len = atomic_read(&max_prioidx) + 1;
104 map = rtnl_dereference(dev->priomap);
105 if (!map || map->priomap_len < max_len)
106 ret = extend_netdev_table(dev, max_len);
107 rtnl_unlock();
108
109 return ret;
110}
111
112static int update_netdev_tables(void)
113{
114 int ret = 0;
96 struct net_device *dev; 115 struct net_device *dev;
97 u32 max_len = atomic_read(&max_prioidx) + 1; 116 u32 max_len;
98 struct netprio_map *map; 117 struct netprio_map *map;
99 118
100 rtnl_lock(); 119 rtnl_lock();
120 max_len = atomic_read(&max_prioidx) + 1;
101 for_each_netdev(&init_net, dev) { 121 for_each_netdev(&init_net, dev) {
102 map = rtnl_dereference(dev->priomap); 122 map = rtnl_dereference(dev->priomap);
103 if ((!map) || 123 /*
104 (map->priomap_len < max_len)) 124 * don't allocate priomap if we didn't
105 extend_netdev_table(dev, max_len); 125 * change net_prio.ifpriomap (map == NULL),
126 * this will speed up skb_update_prio.
127 */
128 if (map && map->priomap_len < max_len) {
129 ret = extend_netdev_table(dev, max_len);
130 if (ret < 0)
131 break;
132 }
106 } 133 }
107 rtnl_unlock(); 134 rtnl_unlock();
135 return ret;
108} 136}
109 137
110static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp) 138static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
111{ 139{
112 struct cgroup_netprio_state *cs; 140 struct cgroup_netprio_state *cs;
113 int ret; 141 int ret = -EINVAL;
114 142
115 cs = kzalloc(sizeof(*cs), GFP_KERNEL); 143 cs = kzalloc(sizeof(*cs), GFP_KERNEL);
116 if (!cs) 144 if (!cs)
117 return ERR_PTR(-ENOMEM); 145 return ERR_PTR(-ENOMEM);
118 146
119 if (cgrp->parent && cgrp_netprio_state(cgrp->parent)->prioidx) { 147 if (cgrp->parent && cgrp_netprio_state(cgrp->parent)->prioidx)
120 kfree(cs); 148 goto out;
121 return ERR_PTR(-EINVAL);
122 }
123 149
124 ret = get_prioidx(&cs->prioidx); 150 ret = get_prioidx(&cs->prioidx);
125 if (ret != 0) { 151 if (ret < 0) {
126 pr_warn("No space in priority index array\n"); 152 pr_warn("No space in priority index array\n");
127 kfree(cs); 153 goto out;
128 return ERR_PTR(ret); 154 }
155
156 ret = update_netdev_tables();
157 if (ret < 0) {
158 put_prioidx(cs->prioidx);
159 goto out;
129 } 160 }
130 161
131 return &cs->css; 162 return &cs->css;
163out:
164 kfree(cs);
165 return ERR_PTR(ret);
132} 166}
133 167
134static void cgrp_destroy(struct cgroup *cgrp) 168static void cgrp_destroy(struct cgroup *cgrp)
@@ -141,7 +175,7 @@ static void cgrp_destroy(struct cgroup *cgrp)
141 rtnl_lock(); 175 rtnl_lock();
142 for_each_netdev(&init_net, dev) { 176 for_each_netdev(&init_net, dev) {
143 map = rtnl_dereference(dev->priomap); 177 map = rtnl_dereference(dev->priomap);
144 if (map) 178 if (map && cs->prioidx < map->priomap_len)
145 map->priomap[cs->prioidx] = 0; 179 map->priomap[cs->prioidx] = 0;
146 } 180 }
147 rtnl_unlock(); 181 rtnl_unlock();
@@ -165,7 +199,7 @@ static int read_priomap(struct cgroup *cont, struct cftype *cft,
165 rcu_read_lock(); 199 rcu_read_lock();
166 for_each_netdev_rcu(&init_net, dev) { 200 for_each_netdev_rcu(&init_net, dev) {
167 map = rcu_dereference(dev->priomap); 201 map = rcu_dereference(dev->priomap);
168 priority = map ? map->priomap[prioidx] : 0; 202 priority = (map && prioidx < map->priomap_len) ? map->priomap[prioidx] : 0;
169 cb->fill(cb, dev->name, priority); 203 cb->fill(cb, dev->name, priority);
170 } 204 }
171 rcu_read_unlock(); 205 rcu_read_unlock();
@@ -220,13 +254,17 @@ static int write_priomap(struct cgroup *cgrp, struct cftype *cft,
220 if (!dev) 254 if (!dev)
221 goto out_free_devname; 255 goto out_free_devname;
222 256
223 update_netdev_tables(); 257 ret = write_update_netdev_table(dev);
224 ret = 0; 258 if (ret < 0)
259 goto out_put_dev;
260
225 rcu_read_lock(); 261 rcu_read_lock();
226 map = rcu_dereference(dev->priomap); 262 map = rcu_dereference(dev->priomap);
227 if (map) 263 if (map)
228 map->priomap[prioidx] = priority; 264 map->priomap[prioidx] = priority;
229 rcu_read_unlock(); 265 rcu_read_unlock();
266
267out_put_dev:
230 dev_put(dev); 268 dev_put(dev);
231 269
232out_free_devname: 270out_free_devname:
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 46a3d23d259..d124306b81f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -353,7 +353,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
353 unsigned int fragsz = SKB_DATA_ALIGN(length + NET_SKB_PAD) + 353 unsigned int fragsz = SKB_DATA_ALIGN(length + NET_SKB_PAD) +
354 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 354 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
355 355
356 if (fragsz <= PAGE_SIZE && !(gfp_mask & __GFP_WAIT)) { 356 if (fragsz <= PAGE_SIZE && !(gfp_mask & (__GFP_WAIT | GFP_DMA))) {
357 void *data = netdev_alloc_frag(fragsz); 357 void *data = netdev_alloc_frag(fragsz);
358 358
359 if (likely(data)) { 359 if (likely(data)) {
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 6fbb2ad7bb6..16705611589 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -230,6 +230,12 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
230 mtu = dev->mtu; 230 mtu = dev->mtu;
231 pr_debug("name = %s, mtu = %u\n", dev->name, mtu); 231 pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
232 232
233 if (size > mtu) {
234 pr_debug("size = %Zu, mtu = %u\n", size, mtu);
235 err = -EINVAL;
236 goto out_dev;
237 }
238
233 hlen = LL_RESERVED_SPACE(dev); 239 hlen = LL_RESERVED_SPACE(dev);
234 tlen = dev->needed_tailroom; 240 tlen = dev->needed_tailroom;
235 skb = sock_alloc_send_skb(sk, hlen + tlen + size, 241 skb = sock_alloc_send_skb(sk, hlen + tlen + size,
@@ -258,12 +264,6 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
258 if (err < 0) 264 if (err < 0)
259 goto out_skb; 265 goto out_skb;
260 266
261 if (size > mtu) {
262 pr_debug("size = %Zu, mtu = %u\n", size, mtu);
263 err = -EINVAL;
264 goto out_skb;
265 }
266
267 skb->dev = dev; 267 skb->dev = dev;
268 skb->sk = sk; 268 skb->sk = sk;
269 skb->protocol = htons(ETH_P_IEEE802154); 269 skb->protocol = htons(ETH_P_IEEE802154);
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index c48adc565e9..667c1d4ca98 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1725,8 +1725,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
1725 case CIPSO_V4_TAG_LOCAL: 1725 case CIPSO_V4_TAG_LOCAL:
1726 /* This is a non-standard tag that we only allow for 1726 /* This is a non-standard tag that we only allow for
1727 * local connections, so if the incoming interface is 1727 * local connections, so if the incoming interface is
1728 * not the loopback device drop the packet. */ 1728 * not the loopback device drop the packet. Further,
1729 if (!(skb->dev->flags & IFF_LOOPBACK)) { 1729 * there is no legitimate reason for setting this from
1730 * userspace so reject it if skb is NULL. */
1731 if (skb == NULL || !(skb->dev->flags & IFF_LOOPBACK)) {
1730 err_offset = opt_iter; 1732 err_offset = opt_iter;
1731 goto validate_return_locked; 1733 goto validate_return_locked;
1732 } 1734 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index a4bb856de08..0db5d34a06b 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2174,15 +2174,13 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
2174 sdata->name, mgmt->sa, status_code); 2174 sdata->name, mgmt->sa, status_code);
2175 ieee80211_destroy_assoc_data(sdata, false); 2175 ieee80211_destroy_assoc_data(sdata, false);
2176 } else { 2176 } else {
2177 printk(KERN_DEBUG "%s: associated\n", sdata->name);
2178
2179 if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) { 2177 if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) {
2180 /* oops -- internal error -- send timeout for now */ 2178 /* oops -- internal error -- send timeout for now */
2181 ieee80211_destroy_assoc_data(sdata, true); 2179 ieee80211_destroy_assoc_data(sdata, false);
2182 sta_info_destroy_addr(sdata, mgmt->bssid);
2183 cfg80211_put_bss(*bss); 2180 cfg80211_put_bss(*bss);
2184 return RX_MGMT_CFG80211_ASSOC_TIMEOUT; 2181 return RX_MGMT_CFG80211_ASSOC_TIMEOUT;
2185 } 2182 }
2183 printk(KERN_DEBUG "%s: associated\n", sdata->name);
2186 2184
2187 /* 2185 /*
2188 * destroy assoc_data afterwards, as otherwise an idle 2186 * destroy assoc_data afterwards, as otherwise an idle
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 2d1acc6c544..f9e51ef8dfa 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -809,7 +809,7 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
809 max_rates = sband->n_bitrates; 809 max_rates = sband->n_bitrates;
810 } 810 }
811 811
812 msp = kzalloc(sizeof(struct minstrel_ht_sta), gfp); 812 msp = kzalloc(sizeof(*msp), gfp);
813 if (!msp) 813 if (!msp)
814 return NULL; 814 return NULL;
815 815
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index d43e3c122f7..84444dda194 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1521,11 +1521,12 @@ static int ip_vs_dst_event(struct notifier_block *this, unsigned long event,
1521{ 1521{
1522 struct net_device *dev = ptr; 1522 struct net_device *dev = ptr;
1523 struct net *net = dev_net(dev); 1523 struct net *net = dev_net(dev);
1524 struct netns_ipvs *ipvs = net_ipvs(net);
1524 struct ip_vs_service *svc; 1525 struct ip_vs_service *svc;
1525 struct ip_vs_dest *dest; 1526 struct ip_vs_dest *dest;
1526 unsigned int idx; 1527 unsigned int idx;
1527 1528
1528 if (event != NETDEV_UNREGISTER) 1529 if (event != NETDEV_UNREGISTER || !ipvs)
1529 return NOTIFY_DONE; 1530 return NOTIFY_DONE;
1530 IP_VS_DBG(3, "%s() dev=%s\n", __func__, dev->name); 1531 IP_VS_DBG(3, "%s() dev=%s\n", __func__, dev->name);
1531 EnterFunction(2); 1532 EnterFunction(2);
@@ -1551,7 +1552,7 @@ static int ip_vs_dst_event(struct notifier_block *this, unsigned long event,
1551 } 1552 }
1552 } 1553 }
1553 1554
1554 list_for_each_entry(dest, &net_ipvs(net)->dest_trash, n_list) { 1555 list_for_each_entry(dest, &ipvs->dest_trash, n_list) {
1555 __ip_vs_dev_reset(dest, dev); 1556 __ip_vs_dev_reset(dest, dev);
1556 } 1557 }
1557 mutex_unlock(&__ip_vs_mutex); 1558 mutex_unlock(&__ip_vs_mutex);
diff --git a/net/netfilter/xt_set.c b/net/netfilter/xt_set.c
index 035960ec5cb..c6f7db720d8 100644
--- a/net/netfilter/xt_set.c
+++ b/net/netfilter/xt_set.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/netfilter/x_tables.h> 17#include <linux/netfilter/x_tables.h>
18#include <linux/netfilter/xt_set.h> 18#include <linux/netfilter/xt_set.h>
19#include <linux/netfilter/ipset/ip_set_timeout.h>
19 20
20MODULE_LICENSE("GPL"); 21MODULE_LICENSE("GPL");
21MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); 22MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
@@ -310,7 +311,8 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par)
310 info->del_set.flags, 0, UINT_MAX); 311 info->del_set.flags, 0, UINT_MAX);
311 312
312 /* Normalize to fit into jiffies */ 313 /* Normalize to fit into jiffies */
313 if (add_opt.timeout > UINT_MAX/MSEC_PER_SEC) 314 if (add_opt.timeout != IPSET_NO_TIMEOUT &&
315 add_opt.timeout > UINT_MAX/MSEC_PER_SEC)
314 add_opt.timeout = UINT_MAX/MSEC_PER_SEC; 316 add_opt.timeout = UINT_MAX/MSEC_PER_SEC;
315 if (info->add_set.index != IPSET_INVALID_ID) 317 if (info->add_set.index != IPSET_INVALID_ID)
316 ip_set_add(info->add_set.index, skb, par, &add_opt); 318 ip_set_add(info->add_set.index, skb, par, &add_opt);
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index 17a707db40e..e06d458fc71 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -292,7 +292,7 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr,
292 292
293 pr_debug("%p\n", sk); 293 pr_debug("%p\n", sk);
294 294
295 if (llcp_sock == NULL) 295 if (llcp_sock == NULL || llcp_sock->dev == NULL)
296 return -EBADFD; 296 return -EBADFD;
297 297
298 addr->sa_family = AF_NFC; 298 addr->sa_family = AF_NFC;
diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
index 2754f098d43..bebaa43484b 100644
--- a/net/rxrpc/ar-peer.c
+++ b/net/rxrpc/ar-peer.c
@@ -229,7 +229,7 @@ found_UDP_peer:
229 return peer; 229 return peer;
230 230
231new_UDP_peer: 231new_UDP_peer:
232 _net("Rx UDP DGRAM from NEW peer %d", peer->debug_id); 232 _net("Rx UDP DGRAM from NEW peer");
233 read_unlock_bh(&rxrpc_peer_lock); 233 read_unlock_bh(&rxrpc_peer_lock);
234 _leave(" = -EBUSY [new]"); 234 _leave(" = -EBUSY [new]");
235 return ERR_PTR(-EBUSY); 235 return ERR_PTR(-EBUSY);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index a2a95aabf9c..c412ad0d030 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -331,29 +331,22 @@ static psched_time_t packet_len_2_sched_time(unsigned int len, struct netem_sche
331 return PSCHED_NS2TICKS(ticks); 331 return PSCHED_NS2TICKS(ticks);
332} 332}
333 333
334static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) 334static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
335{ 335{
336 struct sk_buff_head *list = &sch->q; 336 struct sk_buff_head *list = &sch->q;
337 psched_time_t tnext = netem_skb_cb(nskb)->time_to_send; 337 psched_time_t tnext = netem_skb_cb(nskb)->time_to_send;
338 struct sk_buff *skb; 338 struct sk_buff *skb = skb_peek_tail(list);
339
340 if (likely(skb_queue_len(list) < sch->limit)) {
341 skb = skb_peek_tail(list);
342 /* Optimize for add at tail */
343 if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send))
344 return qdisc_enqueue_tail(nskb, sch);
345 339
346 skb_queue_reverse_walk(list, skb) { 340 /* Optimize for add at tail */
347 if (tnext >= netem_skb_cb(skb)->time_to_send) 341 if (likely(!skb || tnext >= netem_skb_cb(skb)->time_to_send))
348 break; 342 return __skb_queue_tail(list, nskb);
349 }
350 343
351 __skb_queue_after(list, skb, nskb); 344 skb_queue_reverse_walk(list, skb) {
352 sch->qstats.backlog += qdisc_pkt_len(nskb); 345 if (tnext >= netem_skb_cb(skb)->time_to_send)
353 return NET_XMIT_SUCCESS; 346 break;
354 } 347 }
355 348
356 return qdisc_reshape_fail(nskb, sch); 349 __skb_queue_after(list, skb, nskb);
357} 350}
358 351
359/* 352/*
@@ -368,7 +361,6 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
368 /* We don't fill cb now as skb_unshare() may invalidate it */ 361 /* We don't fill cb now as skb_unshare() may invalidate it */
369 struct netem_skb_cb *cb; 362 struct netem_skb_cb *cb;
370 struct sk_buff *skb2; 363 struct sk_buff *skb2;
371 int ret;
372 int count = 1; 364 int count = 1;
373 365
374 /* Random duplication */ 366 /* Random duplication */
@@ -419,6 +411,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
419 skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); 411 skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
420 } 412 }
421 413
414 if (unlikely(skb_queue_len(&sch->q) >= sch->limit))
415 return qdisc_reshape_fail(skb, sch);
416
417 sch->qstats.backlog += qdisc_pkt_len(skb);
418
422 cb = netem_skb_cb(skb); 419 cb = netem_skb_cb(skb);
423 if (q->gap == 0 || /* not doing reordering */ 420 if (q->gap == 0 || /* not doing reordering */
424 q->counter < q->gap - 1 || /* inside last reordering gap */ 421 q->counter < q->gap - 1 || /* inside last reordering gap */
@@ -450,7 +447,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
450 447
451 cb->time_to_send = now + delay; 448 cb->time_to_send = now + delay;
452 ++q->counter; 449 ++q->counter;
453 ret = tfifo_enqueue(skb, sch); 450 tfifo_enqueue(skb, sch);
454 } else { 451 } else {
455 /* 452 /*
456 * Do re-ordering by putting one out of N packets at the front 453 * Do re-ordering by putting one out of N packets at the front
@@ -460,16 +457,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
460 q->counter = 0; 457 q->counter = 0;
461 458
462 __skb_queue_head(&sch->q, skb); 459 __skb_queue_head(&sch->q, skb);
463 sch->qstats.backlog += qdisc_pkt_len(skb);
464 sch->qstats.requeues++; 460 sch->qstats.requeues++;
465 ret = NET_XMIT_SUCCESS;
466 }
467
468 if (ret != NET_XMIT_SUCCESS) {
469 if (net_xmit_drop_count(ret)) {
470 sch->qstats.drops++;
471 return ret;
472 }
473 } 461 }
474 462
475 return NET_XMIT_SUCCESS; 463 return NET_XMIT_SUCCESS;
diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
index 74305c883bd..30ea4674cab 100644
--- a/net/sched/sch_sfb.c
+++ b/net/sched/sch_sfb.c
@@ -570,6 +570,8 @@ static int sfb_dump(struct Qdisc *sch, struct sk_buff *skb)
570 570
571 sch->qstats.backlog = q->qdisc->qstats.backlog; 571 sch->qstats.backlog = q->qdisc->qstats.backlog;
572 opts = nla_nest_start(skb, TCA_OPTIONS); 572 opts = nla_nest_start(skb, TCA_OPTIONS);
573 if (opts == NULL)
574 goto nla_put_failure;
573 if (nla_put(skb, TCA_SFB_PARMS, sizeof(opt), &opt)) 575 if (nla_put(skb, TCA_SFB_PARMS, sizeof(opt), &opt))
574 goto nla_put_failure; 576 goto nla_put_failure;
575 return nla_nest_end(skb, opts); 577 return nla_nest_end(skb, opts);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 80564fe0302..8b9b6790a3d 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -736,15 +736,12 @@ static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
736 736
737 epb = &ep->base; 737 epb = &ep->base;
738 738
739 if (hlist_unhashed(&epb->node))
740 return;
741
742 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); 739 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
743 740
744 head = &sctp_ep_hashtable[epb->hashent]; 741 head = &sctp_ep_hashtable[epb->hashent];
745 742
746 sctp_write_lock(&head->lock); 743 sctp_write_lock(&head->lock);
747 __hlist_del(&epb->node); 744 hlist_del_init(&epb->node);
748 sctp_write_unlock(&head->lock); 745 sctp_write_unlock(&head->lock);
749} 746}
750 747
@@ -825,7 +822,7 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
825 head = &sctp_assoc_hashtable[epb->hashent]; 822 head = &sctp_assoc_hashtable[epb->hashent];
826 823
827 sctp_write_lock(&head->lock); 824 sctp_write_lock(&head->lock);
828 __hlist_del(&epb->node); 825 hlist_del_init(&epb->node);
829 sctp_write_unlock(&head->lock); 826 sctp_write_unlock(&head->lock);
830} 827}
831 828
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index b3b8a8d813e..31c7bfcd9b5 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1231,8 +1231,14 @@ out_free:
1231 SCTP_DEBUG_PRINTK("About to exit __sctp_connect() free asoc: %p" 1231 SCTP_DEBUG_PRINTK("About to exit __sctp_connect() free asoc: %p"
1232 " kaddrs: %p err: %d\n", 1232 " kaddrs: %p err: %d\n",
1233 asoc, kaddrs, err); 1233 asoc, kaddrs, err);
1234 if (asoc) 1234 if (asoc) {
1235 /* sctp_primitive_ASSOCIATE may have added this association
1236 * To the hash table, try to unhash it, just in case, its a noop
1237 * if it wasn't hashed so we're safe
1238 */
1239 sctp_unhash_established(asoc);
1235 sctp_association_free(asoc); 1240 sctp_association_free(asoc);
1241 }
1236 return err; 1242 return err;
1237} 1243}
1238 1244
@@ -1942,8 +1948,10 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1942 goto out_unlock; 1948 goto out_unlock;
1943 1949
1944out_free: 1950out_free:
1945 if (new_asoc) 1951 if (new_asoc) {
1952 sctp_unhash_established(asoc);
1946 sctp_association_free(asoc); 1953 sctp_association_free(asoc);
1954 }
1947out_unlock: 1955out_unlock:
1948 sctp_release_sock(sk); 1956 sctp_release_sock(sk);
1949 1957
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 372ec6502aa..ffd8900a38e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2717,7 +2717,7 @@ static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
2717 ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET)) 2717 ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET))
2718 return dentry_has_perm(cred, dentry, FILE__SETATTR); 2718 return dentry_has_perm(cred, dentry, FILE__SETATTR);
2719 2719
2720 if (ia_valid & ATTR_SIZE) 2720 if (selinux_policycap_openperm && (ia_valid & ATTR_SIZE))
2721 av |= FILE__OPEN; 2721 av |= FILE__OPEN;
2722 2722
2723 return dentry_has_perm(cred, dentry, av); 2723 return dentry_has_perm(cred, dentry, av);
diff --git a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h
index b8c53723e09..df2de54a958 100644
--- a/security/selinux/include/classmap.h
+++ b/security/selinux/include/classmap.h
@@ -145,7 +145,9 @@ struct security_class_mapping secclass_map[] = {
145 "node_bind", "name_connect", NULL } }, 145 "node_bind", "name_connect", NULL } },
146 { "memprotect", { "mmap_zero", NULL } }, 146 { "memprotect", { "mmap_zero", NULL } },
147 { "peer", { "recv", NULL } }, 147 { "peer", { "recv", NULL } },
148 { "capability2", { "mac_override", "mac_admin", "syslog", NULL } }, 148 { "capability2",
149 { "mac_override", "mac_admin", "syslog", "wake_alarm", "block_suspend",
150 NULL } },
149 { "kernel_service", { "use_as_override", "create_files_as", NULL } }, 151 { "kernel_service", { "use_as_override", "create_files_as", NULL } },
150 { "tun_socket", 152 { "tun_socket",
151 { COMMON_SOCK_PERMS, NULL } }, 153 { COMMON_SOCK_PERMS, NULL } },
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index e6906901deb..0f647d22cb4 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -414,7 +414,7 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
414{ 414{
415 struct list_head *p; 415 struct list_head *p;
416 struct snd_usb_endpoint *ep; 416 struct snd_usb_endpoint *ep;
417 int ret, is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; 417 int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK;
418 418
419 mutex_lock(&chip->mutex); 419 mutex_lock(&chip->mutex);
420 420
@@ -434,16 +434,6 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
434 type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync", 434 type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync",
435 ep_num); 435 ep_num);
436 436
437 /* select the alt setting once so the endpoints become valid */
438 ret = usb_set_interface(chip->dev, alts->desc.bInterfaceNumber,
439 alts->desc.bAlternateSetting);
440 if (ret < 0) {
441 snd_printk(KERN_ERR "%s(): usb_set_interface() failed, ret = %d\n",
442 __func__, ret);
443 ep = NULL;
444 goto __exit_unlock;
445 }
446
447 ep = kzalloc(sizeof(*ep), GFP_KERNEL); 437 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
448 if (!ep) 438 if (!ep)
449 goto __exit_unlock; 439 goto __exit_unlock;
@@ -831,9 +821,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
831 if (++ep->use_count != 1) 821 if (++ep->use_count != 1)
832 return 0; 822 return 0;
833 823
834 if (snd_BUG_ON(!test_bit(EP_FLAG_ACTIVATED, &ep->flags)))
835 return -EINVAL;
836
837 /* just to be sure */ 824 /* just to be sure */
838 deactivate_urbs(ep, 0, 1); 825 deactivate_urbs(ep, 0, 1);
839 wait_clear_urbs(ep); 826 wait_clear_urbs(ep);
@@ -911,9 +898,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
911 if (snd_BUG_ON(ep->use_count == 0)) 898 if (snd_BUG_ON(ep->use_count == 0))
912 return; 899 return;
913 900
914 if (snd_BUG_ON(!test_bit(EP_FLAG_ACTIVATED, &ep->flags)))
915 return;
916
917 if (--ep->use_count == 0) { 901 if (--ep->use_count == 0) {
918 deactivate_urbs(ep, force, can_sleep); 902 deactivate_urbs(ep, force, can_sleep);
919 ep->data_subs = NULL; 903 ep->data_subs = NULL;
@@ -927,42 +911,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
927} 911}
928 912
929/** 913/**
930 * snd_usb_endpoint_activate: activate an snd_usb_endpoint
931 *
932 * @ep: the endpoint to activate
933 *
934 * If the endpoint is not currently in use, this functions will select the
935 * correct alternate interface setting for the interface of this endpoint.
936 *
937 * In case of any active users, this functions does nothing.
938 *
939 * Returns an error if usb_set_interface() failed, 0 in all other
940 * cases.
941 */
942int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep)
943{
944 if (ep->use_count != 0)
945 return 0;
946
947 if (!ep->chip->shutdown &&
948 !test_and_set_bit(EP_FLAG_ACTIVATED, &ep->flags)) {
949 int ret;
950
951 ret = usb_set_interface(ep->chip->dev, ep->iface, ep->alt_idx);
952 if (ret < 0) {
953 snd_printk(KERN_ERR "%s() usb_set_interface() failed, ret = %d\n",
954 __func__, ret);
955 clear_bit(EP_FLAG_ACTIVATED, &ep->flags);
956 return ret;
957 }
958
959 return 0;
960 }
961
962 return -EBUSY;
963}
964
965/**
966 * snd_usb_endpoint_deactivate: deactivate an snd_usb_endpoint 914 * snd_usb_endpoint_deactivate: deactivate an snd_usb_endpoint
967 * 915 *
968 * @ep: the endpoint to deactivate 916 * @ep: the endpoint to deactivate
@@ -980,24 +928,15 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
980 if (!ep) 928 if (!ep)
981 return -EINVAL; 929 return -EINVAL;
982 930
931 deactivate_urbs(ep, 1, 1);
932 wait_clear_urbs(ep);
933
983 if (ep->use_count != 0) 934 if (ep->use_count != 0)
984 return 0; 935 return 0;
985 936
986 if (!ep->chip->shutdown && 937 clear_bit(EP_FLAG_ACTIVATED, &ep->flags);
987 test_and_clear_bit(EP_FLAG_ACTIVATED, &ep->flags)) {
988 int ret;
989
990 ret = usb_set_interface(ep->chip->dev, ep->iface, 0);
991 if (ret < 0) {
992 snd_printk(KERN_ERR "%s(): usb_set_interface() failed, ret = %d\n",
993 __func__, ret);
994 return ret;
995 }
996 938
997 return 0; 939 return 0;
998 }
999
1000 return -EBUSY;
1001} 940}
1002 941
1003/** 942/**
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 54607f8c4f6..a1298f37942 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -261,19 +261,6 @@ static void stop_endpoints(struct snd_usb_substream *subs,
261 force, can_sleep, wait); 261 force, can_sleep, wait);
262} 262}
263 263
264static int activate_endpoints(struct snd_usb_substream *subs)
265{
266 if (subs->sync_endpoint) {
267 int ret;
268
269 ret = snd_usb_endpoint_activate(subs->sync_endpoint);
270 if (ret < 0)
271 return ret;
272 }
273
274 return snd_usb_endpoint_activate(subs->data_endpoint);
275}
276
277static int deactivate_endpoints(struct snd_usb_substream *subs) 264static int deactivate_endpoints(struct snd_usb_substream *subs)
278{ 265{
279 int reta, retb; 266 int reta, retb;
@@ -314,6 +301,33 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
314 if (fmt == subs->cur_audiofmt) 301 if (fmt == subs->cur_audiofmt)
315 return 0; 302 return 0;
316 303
304 /* close the old interface */
305 if (subs->interface >= 0 && subs->interface != fmt->iface) {
306 err = usb_set_interface(subs->dev, subs->interface, 0);
307 if (err < 0) {
308 snd_printk(KERN_ERR "%d:%d:%d: return to setting 0 failed (%d)\n",
309 dev->devnum, fmt->iface, fmt->altsetting, err);
310 return -EIO;
311 }
312 subs->interface = -1;
313 subs->altset_idx = 0;
314 }
315
316 /* set interface */
317 if (subs->interface != fmt->iface ||
318 subs->altset_idx != fmt->altset_idx) {
319 err = usb_set_interface(dev, fmt->iface, fmt->altsetting);
320 if (err < 0) {
321 snd_printk(KERN_ERR "%d:%d:%d: usb_set_interface failed (%d)\n",
322 dev->devnum, fmt->iface, fmt->altsetting, err);
323 return -EIO;
324 }
325 snd_printdd(KERN_INFO "setting usb interface %d:%d\n",
326 fmt->iface, fmt->altsetting);
327 subs->interface = fmt->iface;
328 subs->altset_idx = fmt->altset_idx;
329 }
330
317 subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip, 331 subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip,
318 alts, fmt->endpoint, subs->direction, 332 alts, fmt->endpoint, subs->direction,
319 SND_USB_ENDPOINT_TYPE_DATA); 333 SND_USB_ENDPOINT_TYPE_DATA);
@@ -387,7 +401,7 @@ add_sync_ep:
387 subs->data_endpoint->sync_master = subs->sync_endpoint; 401 subs->data_endpoint->sync_master = subs->sync_endpoint;
388 } 402 }
389 403
390 if ((err = snd_usb_init_pitch(subs->stream->chip, subs->interface, alts, fmt)) < 0) 404 if ((err = snd_usb_init_pitch(subs->stream->chip, fmt->iface, alts, fmt)) < 0)
391 return err; 405 return err;
392 406
393 subs->cur_audiofmt = fmt; 407 subs->cur_audiofmt = fmt;
@@ -450,7 +464,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
450 struct usb_interface *iface; 464 struct usb_interface *iface;
451 iface = usb_ifnum_to_if(subs->dev, fmt->iface); 465 iface = usb_ifnum_to_if(subs->dev, fmt->iface);
452 alts = &iface->altsetting[fmt->altset_idx]; 466 alts = &iface->altsetting[fmt->altset_idx];
453 ret = snd_usb_init_sample_rate(subs->stream->chip, subs->interface, alts, fmt, rate); 467 ret = snd_usb_init_sample_rate(subs->stream->chip, fmt->iface, alts, fmt, rate);
454 if (ret < 0) 468 if (ret < 0)
455 return ret; 469 return ret;
456 subs->cur_rate = rate; 470 subs->cur_rate = rate;
@@ -460,12 +474,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
460 mutex_lock(&subs->stream->chip->shutdown_mutex); 474 mutex_lock(&subs->stream->chip->shutdown_mutex);
461 /* format changed */ 475 /* format changed */
462 stop_endpoints(subs, 0, 0, 0); 476 stop_endpoints(subs, 0, 0, 0);
463 deactivate_endpoints(subs);
464
465 ret = activate_endpoints(subs);
466 if (ret < 0)
467 goto unlock;
468
469 ret = snd_usb_endpoint_set_params(subs->data_endpoint, hw_params, fmt, 477 ret = snd_usb_endpoint_set_params(subs->data_endpoint, hw_params, fmt,
470 subs->sync_endpoint); 478 subs->sync_endpoint);
471 if (ret < 0) 479 if (ret < 0)
@@ -500,6 +508,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
500 subs->period_bytes = 0; 508 subs->period_bytes = 0;
501 mutex_lock(&subs->stream->chip->shutdown_mutex); 509 mutex_lock(&subs->stream->chip->shutdown_mutex);
502 stop_endpoints(subs, 0, 1, 1); 510 stop_endpoints(subs, 0, 1, 1);
511 deactivate_endpoints(subs);
503 mutex_unlock(&subs->stream->chip->shutdown_mutex); 512 mutex_unlock(&subs->stream->chip->shutdown_mutex);
504 return snd_pcm_lib_free_vmalloc_buffer(substream); 513 return snd_pcm_lib_free_vmalloc_buffer(substream);
505} 514}
@@ -938,16 +947,20 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
938 947
939static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) 948static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
940{ 949{
941 int ret;
942 struct snd_usb_stream *as = snd_pcm_substream_chip(substream); 950 struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
943 struct snd_usb_substream *subs = &as->substream[direction]; 951 struct snd_usb_substream *subs = &as->substream[direction];
944 952
945 stop_endpoints(subs, 0, 0, 0); 953 stop_endpoints(subs, 0, 0, 0);
946 ret = deactivate_endpoints(subs); 954
955 if (!as->chip->shutdown && subs->interface >= 0) {
956 usb_set_interface(subs->dev, subs->interface, 0);
957 subs->interface = -1;
958 }
959
947 subs->pcm_substream = NULL; 960 subs->pcm_substream = NULL;
948 snd_usb_autosuspend(subs->stream->chip); 961 snd_usb_autosuspend(subs->stream->chip);
949 962
950 return ret; 963 return 0;
951} 964}
952 965
953/* Since a URB can handle only a single linear buffer, we must use double 966/* Since a URB can handle only a single linear buffer, we must use double
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 35ae56864e4..a1f4e366914 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -669,25 +669,26 @@ struct machine *machines__find(struct rb_root *self, pid_t pid)
669struct machine *machines__findnew(struct rb_root *self, pid_t pid) 669struct machine *machines__findnew(struct rb_root *self, pid_t pid)
670{ 670{
671 char path[PATH_MAX]; 671 char path[PATH_MAX];
672 const char *root_dir; 672 const char *root_dir = "";
673 struct machine *machine = machines__find(self, pid); 673 struct machine *machine = machines__find(self, pid);
674 674
675 if (!machine || machine->pid != pid) { 675 if (machine && (machine->pid == pid))
676 if (pid == HOST_KERNEL_ID || pid == DEFAULT_GUEST_KERNEL_ID) 676 goto out;
677 root_dir = ""; 677
678 else { 678 if ((pid != HOST_KERNEL_ID) &&
679 if (!symbol_conf.guestmount) 679 (pid != DEFAULT_GUEST_KERNEL_ID) &&
680 goto out; 680 (symbol_conf.guestmount)) {
681 sprintf(path, "%s/%d", symbol_conf.guestmount, pid); 681 sprintf(path, "%s/%d", symbol_conf.guestmount, pid);
682 if (access(path, R_OK)) { 682 if (access(path, R_OK)) {
683 pr_err("Can't access file %s\n", path); 683 pr_err("Can't access file %s\n", path);
684 goto out; 684 machine = NULL;
685 } 685 goto out;
686 root_dir = path;
687 } 686 }
688 machine = machines__add(self, pid, root_dir); 687 root_dir = path;
689 } 688 }
690 689
690 machine = machines__add(self, pid, root_dir);
691
691out: 692out:
692 return machine; 693 return machine;
693} 694}
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c3e399bcf18..56142d0fb8d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -926,7 +926,7 @@ static struct machine *
926 else 926 else
927 pid = event->ip.pid; 927 pid = event->ip.pid;
928 928
929 return perf_session__find_machine(session, pid); 929 return perf_session__findnew_machine(session, pid);
930 } 930 }
931 931
932 return perf_session__find_host_machine(session); 932 return perf_session__find_host_machine(session);
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index df2fddbf0cd..5dd3b5ec841 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -198,9 +198,8 @@ void print_trace_event(int cpu, void *data, int size)
198 record.data = data; 198 record.data = data;
199 199
200 trace_seq_init(&s); 200 trace_seq_init(&s);
201 pevent_print_event(pevent, &s, &record); 201 pevent_event_info(&s, event, &record);
202 trace_seq_do_printf(&s); 202 trace_seq_do_printf(&s);
203 printf("\n");
204} 203}
205 204
206void print_event(int cpu, void *data, int size, unsigned long long nsecs, 205void print_event(int cpu, void *data, int size, unsigned long long nsecs,
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index b1e091ae2f3..23a41a9f8db 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -334,6 +334,11 @@ static int assigned_device_enable_host_intx(struct kvm *kvm,
334} 334}
335 335
336#ifdef __KVM_HAVE_MSI 336#ifdef __KVM_HAVE_MSI
337static irqreturn_t kvm_assigned_dev_msi(int irq, void *dev_id)
338{
339 return IRQ_WAKE_THREAD;
340}
341
337static int assigned_device_enable_host_msi(struct kvm *kvm, 342static int assigned_device_enable_host_msi(struct kvm *kvm,
338 struct kvm_assigned_dev_kernel *dev) 343 struct kvm_assigned_dev_kernel *dev)
339{ 344{
@@ -346,7 +351,7 @@ static int assigned_device_enable_host_msi(struct kvm *kvm,
346 } 351 }
347 352
348 dev->host_irq = dev->dev->irq; 353 dev->host_irq = dev->dev->irq;
349 if (request_threaded_irq(dev->host_irq, NULL, 354 if (request_threaded_irq(dev->host_irq, kvm_assigned_dev_msi,
350 kvm_assigned_dev_thread_msi, 0, 355 kvm_assigned_dev_thread_msi, 0,
351 dev->irq_name, dev)) { 356 dev->irq_name, dev)) {
352 pci_disable_msi(dev->dev); 357 pci_disable_msi(dev->dev);
@@ -358,6 +363,11 @@ static int assigned_device_enable_host_msi(struct kvm *kvm,
358#endif 363#endif
359 364
360#ifdef __KVM_HAVE_MSIX 365#ifdef __KVM_HAVE_MSIX
366static irqreturn_t kvm_assigned_dev_msix(int irq, void *dev_id)
367{
368 return IRQ_WAKE_THREAD;
369}
370
361static int assigned_device_enable_host_msix(struct kvm *kvm, 371static int assigned_device_enable_host_msix(struct kvm *kvm,
362 struct kvm_assigned_dev_kernel *dev) 372 struct kvm_assigned_dev_kernel *dev)
363{ 373{
@@ -374,7 +384,8 @@ static int assigned_device_enable_host_msix(struct kvm *kvm,
374 384
375 for (i = 0; i < dev->entries_nr; i++) { 385 for (i = 0; i < dev->entries_nr; i++) {
376 r = request_threaded_irq(dev->host_msix_entries[i].vector, 386 r = request_threaded_irq(dev->host_msix_entries[i].vector,
377 NULL, kvm_assigned_dev_thread_msix, 387 kvm_assigned_dev_msix,
388 kvm_assigned_dev_thread_msix,
378 0, dev->irq_name, dev); 389 0, dev->irq_name, dev);
379 if (r) 390 if (r)
380 goto err; 391 goto err;