aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2012-01-08 06:31:24 -0500
committerIngo Molnar <mingo@elte.hu>2012-01-08 06:31:24 -0500
commit636f0c70f2557e0819b50c74e31b4a027327015e (patch)
tree3a259ef26659dac92782651440091b9f5ab1a7f7
parent675eef66e3edcab8065533edfefbcbbacb9a30d3 (diff)
parent2e885057b7f75035f0b85e02f737891482815a81 (diff)
Merge branch 'tip/perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core
-rw-r--r--Documentation/virtual/kvm/api.txt16
-rw-r--r--MAINTAINERS28
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/common/pl330.c116
-rw-r--r--arch/arm/configs/imx_v4_v5_defconfig12
-rw-r--r--arch/arm/mach-exynos/cpu.c5
-rw-r--r--arch/arm/mach-imx/Kconfig8
-rw-r--r--arch/arm/mach-imx/Makefile4
-rw-r--r--arch/arm/mach-imx/clock-imx35.c20
-rw-r--r--arch/arm/mach-imx/mach-cpuimx35.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c4
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c1
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c139
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c18
-rw-r--r--arch/arm/mm/proc-v7.S6
-rw-r--r--arch/arm/oprofile/common.c2
-rw-r--r--arch/arm/plat-mxc/cpufreq.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/uncompress.h1
-rw-r--r--arch/arm/plat-mxc/pwm.c9
-rw-r--r--arch/arm/plat-orion/gpio.c6
-rw-r--r--arch/arm/plat-samsung/include/plat/cpu-freq-core.h25
-rw-r--r--arch/ia64/include/asm/cputime.h1
-rw-r--r--arch/powerpc/include/asm/cputime.h2
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h33
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h33
-rw-r--r--arch/powerpc/kvm/book3s_hv.c2
-rw-r--r--arch/powerpc/kvm/book3s_pr.c2
-rw-r--r--arch/powerpc/kvm/e500.c1
-rw-r--r--arch/s390/include/asm/cputime.h2
-rw-r--r--arch/s390/oprofile/init.c2
-rw-r--r--arch/sh/boards/board-sh7757lcr.c16
-rw-r--r--arch/sh/oprofile/common.c4
-rw-r--r--arch/sparc/kernel/pci_sun4v.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c2
-rw-r--r--arch/x86/kernel/dumpstack_32.c8
-rw-r--r--arch/x86/kernel/dumpstack_64.c8
-rw-r--r--arch/x86/kvm/i8254.c10
-rw-r--r--arch/x86/kvm/x86.c19
-rw-r--r--arch/x86/net/bpf_jit_comp.c4
-rw-r--r--block/blk-map.c2
-rw-r--r--block/blk-tag.c13
-rw-r--r--block/cfq-iosched.c12
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c41
-rw-r--r--drivers/dma/Kconfig4
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c4
-rw-r--r--drivers/gpu/drm/i915/intel_display.c8
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c12
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c16
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c400
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.h5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c22
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c23
-rw-r--r--drivers/i2c/busses/i2c-eg20t.c22
-rw-r--r--drivers/i2c/busses/i2c-omap.c11
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c3
-rw-r--r--drivers/infiniband/core/cma.c6
-rw-r--r--drivers/infiniband/hw/mlx4/main.c6
-rw-r--r--drivers/infiniband/hw/qib/qib_file_ops.c4
-rw-r--r--drivers/input/misc/cma3000_d0x.c4
-rw-r--r--drivers/input/mouse/sentelic.c8
-rw-r--r--drivers/input/mouse/sentelic.h3
-rw-r--r--drivers/input/mouse/synaptics.c11
-rw-r--r--drivers/input/tablet/wacom_wac.c4
-rw-r--r--drivers/iommu/iommu.c2
-rw-r--r--drivers/md/bitmap.c5
-rw-r--r--drivers/md/linear.c1
-rw-r--r--drivers/md/md.c3
-rw-r--r--drivers/md/raid5.c14
-rw-r--r--drivers/media/common/tuners/mxl5007t.c3
-rw-r--r--drivers/media/common/tuners/tda18218.c2
-rw-r--r--drivers/media/rc/ati_remote.c111
-rw-r--r--drivers/media/rc/keymaps/rc-ati-x10.c96
-rw-r--r--drivers/media/rc/keymaps/rc-medion-x10.c128
-rw-r--r--drivers/media/rc/keymaps/rc-snapstream-firefly.c114
-rw-r--r--drivers/media/video/au0828/au0828-cards.c7
-rw-r--r--drivers/media/video/gspca/gspca.c6
-rw-r--r--drivers/media/video/m5mols/m5mols.h2
-rw-r--r--drivers/media/video/m5mols/m5mols_core.c22
-rw-r--r--drivers/media/video/mt9m111.c1
-rw-r--r--drivers/media/video/mt9t112.c4
-rw-r--r--drivers/media/video/omap/omap_vout.c9
-rw-r--r--drivers/media/video/omap1_camera.c1
-rw-r--r--drivers/media/video/omap24xxcam-dma.c2
-rw-r--r--drivers/media/video/omap3isp/ispccdc.c2
-rw-r--r--drivers/media/video/omap3isp/ispstat.c2
-rw-r--r--drivers/media/video/omap3isp/ispvideo.c1
-rw-r--r--drivers/media/video/ov6650.c2
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c14
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c24
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.h2
-rw-r--r--drivers/media/video/s5p-fimc/fimc-mdevice.c43
-rw-r--r--drivers/media/video/s5p-fimc/fimc-reg.c15
-rw-r--r--drivers/media/video/s5p-mfc/s5p_mfc_enc.c2
-rw-r--r--drivers/media/video/s5p-tv/mixer_video.c1
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c34
-rw-r--r--drivers/media/video/sh_mobile_csi2.c4
-rw-r--r--drivers/media/video/soc_camera.c3
-rw-r--r--drivers/mfd/ab5500-debugfs.c2
-rw-r--r--drivers/mfd/ab8500-core.c2
-rw-r--r--drivers/mfd/adp5520.c2
-rw-r--r--drivers/mfd/da903x.c3
-rw-r--r--drivers/mfd/jz4740-adc.c1
-rw-r--r--drivers/mfd/tps6586x.c2
-rw-r--r--drivers/mfd/tps65910.c2
-rw-r--r--drivers/mfd/twl-core.c16
-rw-r--r--drivers/mfd/twl4030-irq.c18
-rw-r--r--drivers/mfd/wm8994-core.c1
-rw-r--r--drivers/mmc/core/host.c11
-rw-r--r--drivers/mmc/host/mmci.c14
-rw-r--r--drivers/mmc/host/sdhci-cns3xxx.c5
-rw-r--r--drivers/mmc/host/sdhci-dove.c5
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c5
-rw-r--r--drivers/mmc/host/sdhci-of-esdhc.c5
-rw-r--r--drivers/mmc/host/sdhci-of-hlwd.c5
-rw-r--r--drivers/mmc/host/sdhci-pci.c26
-rw-r--r--drivers/mmc/host/sdhci-pltfm.c18
-rw-r--r--drivers/mmc/host/sdhci-pltfm.h6
-rw-r--r--drivers/mmc/host/sdhci-pxav2.c5
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c5
-rw-r--r--drivers/mmc/host/sdhci-s3c.c21
-rw-r--r--drivers/mmc/host/sdhci-tegra.c5
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mmc/host/vub300.c2
-rw-r--r--drivers/mtd/maps/plat-ram.c12
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c2
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c2
-rw-r--r--drivers/mtd/nand/ndfc.c2
-rw-r--r--drivers/net/ethernet/freescale/Kconfig4
-rw-r--r--drivers/net/ethernet/marvell/skge.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_cq.c1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c14
-rw-r--r--drivers/net/ethernet/ti/davinci_cpdma.c2
-rw-r--r--drivers/net/usb/asix.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c4
-rw-r--r--drivers/net/wireless/b43/pio.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c4
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c9
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c7
-rw-r--r--drivers/of/platform.c2
-rw-r--r--drivers/oprofile/oprofile_files.c7
-rw-r--r--drivers/oprofile/oprofilefs.c11
-rw-r--r--drivers/pci/ats.c1
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c30
-rw-r--r--drivers/pci/iov.c7
-rw-r--r--drivers/pci/pci.c9
-rw-r--r--drivers/rtc/interface.c44
-rw-r--r--drivers/rtc/rtc-m41t80.c9
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c4
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c5
-rw-r--r--drivers/scsi/fcoe/fcoe.c116
-rw-r--r--drivers/scsi/fcoe/fcoe_ctlr.c4
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c27
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c14
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c25
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c42
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c86
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_def.h55
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h8
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h16
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c243
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c11
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c1084
-rw-r--r--drivers/scsi/qla4xxx/ql4_version.h2
-rw-r--r--drivers/usb/dwc3/core.c2
-rw-r--r--drivers/usb/gadget/epautoconf.c3
-rw-r--r--drivers/usb/host/isp1760-if.c8
-rw-r--r--drivers/usb/musb/musb_host.c4
-rw-r--r--drivers/watchdog/coh901327_wdt.c6
-rw-r--r--drivers/watchdog/hpwdt.c5
-rw-r--r--drivers/watchdog/iTCO_wdt.c6
-rw-r--r--drivers/watchdog/sp805_wdt.c2
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c13
-rw-r--r--firmware/README.AddingFirmware3
-rw-r--r--fs/btrfs/async-thread.c3
-rw-r--r--fs/btrfs/inode.c9
-rw-r--r--fs/ceph/dir.c29
-rw-r--r--fs/cifs/connect.c4
-rw-r--r--fs/fs-writeback.c11
-rw-r--r--fs/locks.c11
-rw-r--r--fs/minix/inode.c34
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfs/nfs4proc.c24
-rw-r--r--fs/nfs/nfs4state.c33
-rw-r--r--fs/nilfs2/ioctl.c16
-rw-r--r--fs/proc/stat.c4
-rw-r--r--fs/xfs/xfs_super.c30
-rw-r--r--fs/xfs/xfs_sync.c36
-rw-r--r--fs/xfs/xfs_sync.h2
-rw-r--r--include/asm-generic/cputime.h1
-rw-r--r--include/linux/clocksource.h11
-rw-r--r--include/linux/kvm.h1
-rw-r--r--include/linux/lglock.h36
-rw-r--r--include/linux/security.h2
-rw-r--r--include/media/soc_camera.h7
-rw-r--r--include/net/dst.h1
-rw-r--r--include/net/flow.h1
-rw-r--r--include/net/ip_vs.h2
-rw-r--r--include/net/sctp/structs.h4
-rw-r--r--include/net/sock.h4
-rw-r--r--include/scsi/libfcoe.h3
-rw-r--r--include/trace/events/writeback.h15
-rw-r--r--include/xen/interface/io/xs_wire.h3
-rw-r--r--kernel/cgroup.c5
-rw-r--r--kernel/cpuset.c29
-rw-r--r--kernel/events/core.c8
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/futex.c28
-rw-r--r--kernel/hung_task.c14
-rw-r--r--kernel/ptrace.c13
-rw-r--r--kernel/sched_fair.c14
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sysctl_binary.c2
-rw-r--r--kernel/time/clockevents.c1
-rw-r--r--kernel/time/clocksource.c12
-rw-r--r--mm/filemap.c7
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/memcontrol.c3
-rw-r--r--mm/mempolicy.c11
-rw-r--r--mm/oom_kill.c2
-rw-r--r--mm/percpu.c6
-rw-r--r--mm/vmalloc.c2
-rw-r--r--net/bluetooth/hci_conn.c2
-rw-r--r--net/bluetooth/hci_core.c2
-rw-r--r--net/bluetooth/l2cap_core.c12
-rw-r--r--net/bluetooth/rfcomm/core.c1
-rw-r--r--net/bridge/br_netfilter.c8
-rw-r--r--net/core/flow.c12
-rw-r--r--net/core/net-sysfs.c7
-rw-r--r--net/core/sock.c6
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/route.c112
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/llc/af_llc.c14
-rw-r--r--net/netfilter/ipvs/ip_vs_conn.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c10
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c22
-rw-r--r--net/netfilter/xt_connbytes.c6
-rw-r--r--net/nfc/nci/core.c2
-rw-r--r--net/packet/af_packet.c12
-rw-r--r--net/sched/sch_mqprio.c2
-rw-r--r--net/sched/sch_netem.c7
-rw-r--r--net/sched/sch_qfq.c4
-rw-r--r--net/sctp/associola.c2
-rw-r--r--net/sctp/output.c8
-rw-r--r--net/sctp/outqueue.c6
-rw-r--r--net/sctp/protocol.c3
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sctp/sysctl.c13
-rw-r--r--net/sunrpc/sched.c30
-rw-r--r--net/sunrpc/xprt.c10
-rw-r--r--net/xfrm/xfrm_policy.c18
-rw-r--r--scripts/kconfig/Makefile5
-rw-r--r--scripts/recordmcount.h2
-rw-r--r--security/integrity/evm/evm_crypto.c19
-rw-r--r--security/security.c2
-rw-r--r--security/selinux/netport.c4
-rw-r--r--sound/atmel/ac97c.c4
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--virt/kvm/assigned-dev.c93
277 files changed, 3694 insertions, 1455 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 7945b0bd35e..e2a4b528736 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1100,6 +1100,15 @@ emulate them efficiently. The fields in each entry are defined as follows:
1100 eax, ebx, ecx, edx: the values returned by the cpuid instruction for 1100 eax, ebx, ecx, edx: the values returned by the cpuid instruction for
1101 this function/index combination 1101 this function/index combination
1102 1102
1103The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
1104as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
1105support. Instead it is reported via
1106
1107 ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
1108
1109if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
1110feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
1111
11034.47 KVM_PPC_GET_PVINFO 11124.47 KVM_PPC_GET_PVINFO
1104 1113
1105Capability: KVM_CAP_PPC_GET_PVINFO 1114Capability: KVM_CAP_PPC_GET_PVINFO
@@ -1151,6 +1160,13 @@ following flags are specified:
1151/* Depends on KVM_CAP_IOMMU */ 1160/* Depends on KVM_CAP_IOMMU */
1152#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 1161#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
1153 1162
1163The KVM_DEV_ASSIGN_ENABLE_IOMMU flag is a mandatory option to ensure
1164isolation of the device. Usages not specifying this flag are deprecated.
1165
1166Only PCI header type 0 devices with PCI BAR resources are supported by
1167device assignment. The user requesting this ioctl must have read/write
1168access to the PCI sysfs resource files associated with the device.
1169
11544.49 KVM_DEASSIGN_PCI_DEVICE 11704.49 KVM_DEASSIGN_PCI_DEVICE
1155 1171
1156Capability: KVM_CAP_DEVICE_DEASSIGNMENT 1172Capability: KVM_CAP_DEVICE_DEASSIGNMENT
diff --git a/MAINTAINERS b/MAINTAINERS
index b9db108f01c..62f1cd357dd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1698,11 +1698,9 @@ F: arch/x86/include/asm/tce.h
1698 1698
1699CAN NETWORK LAYER 1699CAN NETWORK LAYER
1700M: Oliver Hartkopp <socketcan@hartkopp.net> 1700M: Oliver Hartkopp <socketcan@hartkopp.net>
1701M: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
1702M: Urs Thuermann <urs.thuermann@volkswagen.de>
1703L: linux-can@vger.kernel.org 1701L: linux-can@vger.kernel.org
1704L: netdev@vger.kernel.org 1702W: http://gitorious.org/linux-can
1705W: http://developer.berlios.de/projects/socketcan/ 1703T: git git://gitorious.org/linux-can/linux-can-next.git
1706S: Maintained 1704S: Maintained
1707F: net/can/ 1705F: net/can/
1708F: include/linux/can.h 1706F: include/linux/can.h
@@ -1713,9 +1711,10 @@ F: include/linux/can/gw.h
1713 1711
1714CAN NETWORK DRIVERS 1712CAN NETWORK DRIVERS
1715M: Wolfgang Grandegger <wg@grandegger.com> 1713M: Wolfgang Grandegger <wg@grandegger.com>
1714M: Marc Kleine-Budde <mkl@pengutronix.de>
1716L: linux-can@vger.kernel.org 1715L: linux-can@vger.kernel.org
1717L: netdev@vger.kernel.org 1716W: http://gitorious.org/linux-can
1718W: http://developer.berlios.de/projects/socketcan/ 1717T: git git://gitorious.org/linux-can/linux-can-next.git
1719S: Maintained 1718S: Maintained
1720F: drivers/net/can/ 1719F: drivers/net/can/
1721F: include/linux/can/dev.h 1720F: include/linux/can/dev.h
@@ -2700,7 +2699,7 @@ FIREWIRE SUBSYSTEM
2700M: Stefan Richter <stefanr@s5r6.in-berlin.de> 2699M: Stefan Richter <stefanr@s5r6.in-berlin.de>
2701L: linux1394-devel@lists.sourceforge.net 2700L: linux1394-devel@lists.sourceforge.net
2702W: http://ieee1394.wiki.kernel.org/ 2701W: http://ieee1394.wiki.kernel.org/
2703T: git git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git 2702T: git git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git
2704S: Maintained 2703S: Maintained
2705F: drivers/firewire/ 2704F: drivers/firewire/
2706F: include/linux/firewire*.h 2705F: include/linux/firewire*.h
@@ -3101,6 +3100,7 @@ F: include/linux/hid*
3101 3100
3102HIGH-RESOLUTION TIMERS, CLOCKEVENTS, DYNTICKS 3101HIGH-RESOLUTION TIMERS, CLOCKEVENTS, DYNTICKS
3103M: Thomas Gleixner <tglx@linutronix.de> 3102M: Thomas Gleixner <tglx@linutronix.de>
3103T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
3104S: Maintained 3104S: Maintained
3105F: Documentation/timers/ 3105F: Documentation/timers/
3106F: kernel/hrtimer.c 3106F: kernel/hrtimer.c
@@ -3610,7 +3610,7 @@ F: net/irda/
3610IRQ SUBSYSTEM 3610IRQ SUBSYSTEM
3611M: Thomas Gleixner <tglx@linutronix.de> 3611M: Thomas Gleixner <tglx@linutronix.de>
3612S: Maintained 3612S: Maintained
3613T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git irq/core 3613T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
3614F: kernel/irq/ 3614F: kernel/irq/
3615 3615
3616ISAPNP 3616ISAPNP
@@ -4098,7 +4098,7 @@ F: drivers/hwmon/lm90.c
4098LOCKDEP AND LOCKSTAT 4098LOCKDEP AND LOCKSTAT
4099M: Peter Zijlstra <peterz@infradead.org> 4099M: Peter Zijlstra <peterz@infradead.org>
4100M: Ingo Molnar <mingo@redhat.com> 4100M: Ingo Molnar <mingo@redhat.com>
4101T: git git://git.kernel.org/pub/scm/linux/kernel/git/peterz/linux-2.6-lockdep.git 4101T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/locking
4102S: Maintained 4102S: Maintained
4103F: Documentation/lockdep*.txt 4103F: Documentation/lockdep*.txt
4104F: Documentation/lockstat.txt 4104F: Documentation/lockstat.txt
@@ -4280,7 +4280,9 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git
4280S: Maintained 4280S: Maintained
4281F: Documentation/dvb/ 4281F: Documentation/dvb/
4282F: Documentation/video4linux/ 4282F: Documentation/video4linux/
4283F: Documentation/DocBook/media/
4283F: drivers/media/ 4284F: drivers/media/
4285F: drivers/staging/media/
4284F: include/media/ 4286F: include/media/
4285F: include/linux/dvb/ 4287F: include/linux/dvb/
4286F: include/linux/videodev*.h 4288F: include/linux/videodev*.h
@@ -5086,6 +5088,7 @@ M: Peter Zijlstra <a.p.zijlstra@chello.nl>
5086M: Paul Mackerras <paulus@samba.org> 5088M: Paul Mackerras <paulus@samba.org>
5087M: Ingo Molnar <mingo@elte.hu> 5089M: Ingo Molnar <mingo@elte.hu>
5088M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> 5090M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
5091T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
5089S: Supported 5092S: Supported
5090F: kernel/events/* 5093F: kernel/events/*
5091F: include/linux/perf_event.h 5094F: include/linux/perf_event.h
@@ -5165,6 +5168,7 @@ F: drivers/scsi/pm8001/
5165 5168
5166POSIX CLOCKS and TIMERS 5169POSIX CLOCKS and TIMERS
5167M: Thomas Gleixner <tglx@linutronix.de> 5170M: Thomas Gleixner <tglx@linutronix.de>
5171T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
5168S: Supported 5172S: Supported
5169F: fs/timerfd.c 5173F: fs/timerfd.c
5170F: include/linux/timer* 5174F: include/linux/timer*
@@ -5680,6 +5684,7 @@ F: drivers/dma/dw_dmac.c
5680TIMEKEEPING, NTP 5684TIMEKEEPING, NTP
5681M: John Stultz <johnstul@us.ibm.com> 5685M: John Stultz <johnstul@us.ibm.com>
5682M: Thomas Gleixner <tglx@linutronix.de> 5686M: Thomas Gleixner <tglx@linutronix.de>
5687T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
5683S: Supported 5688S: Supported
5684F: include/linux/clocksource.h 5689F: include/linux/clocksource.h
5685F: include/linux/time.h 5690F: include/linux/time.h
@@ -5704,6 +5709,7 @@ F: drivers/watchdog/sc1200wdt.c
5704SCHEDULER 5709SCHEDULER
5705M: Ingo Molnar <mingo@elte.hu> 5710M: Ingo Molnar <mingo@elte.hu>
5706M: Peter Zijlstra <peterz@infradead.org> 5711M: Peter Zijlstra <peterz@infradead.org>
5712T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core
5707S: Maintained 5713S: Maintained
5708F: kernel/sched* 5714F: kernel/sched*
5709F: include/linux/sched.h 5715F: include/linux/sched.h
@@ -6631,7 +6637,7 @@ TRACING
6631M: Steven Rostedt <rostedt@goodmis.org> 6637M: Steven Rostedt <rostedt@goodmis.org>
6632M: Frederic Weisbecker <fweisbec@gmail.com> 6638M: Frederic Weisbecker <fweisbec@gmail.com>
6633M: Ingo Molnar <mingo@redhat.com> 6639M: Ingo Molnar <mingo@redhat.com>
6634T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git perf/core 6640T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
6635S: Maintained 6641S: Maintained
6636F: Documentation/trace/ftrace.txt 6642F: Documentation/trace/ftrace.txt
6637F: arch/*/*/*/ftrace.h 6643F: arch/*/*/*/ftrace.h
@@ -7381,7 +7387,7 @@ M: Thomas Gleixner <tglx@linutronix.de>
7381M: Ingo Molnar <mingo@redhat.com> 7387M: Ingo Molnar <mingo@redhat.com>
7382M: "H. Peter Anvin" <hpa@zytor.com> 7388M: "H. Peter Anvin" <hpa@zytor.com>
7383M: x86@kernel.org 7389M: x86@kernel.org
7384T: git git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git 7390T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core
7385S: Maintained 7391S: Maintained
7386F: Documentation/x86/ 7392F: Documentation/x86/
7387F: arch/x86/ 7393F: arch/x86/
diff --git a/Makefile b/Makefile
index a43733df397..adddd11c3b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 2 2PATCHLEVEL = 2
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 776d76b8cb6..b259c7c644e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1246,7 +1246,7 @@ config PL310_ERRATA_588369
1246 1246
1247config ARM_ERRATA_720789 1247config ARM_ERRATA_720789
1248 bool "ARM errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID" 1248 bool "ARM errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID"
1249 depends on CPU_V7 && SMP 1249 depends on CPU_V7
1250 help 1250 help
1251 This option enables the workaround for the 720789 Cortex-A9 (prior to 1251 This option enables the workaround for the 720789 Cortex-A9 (prior to
1252 r2p0) erratum. A faulty ASID can be sent to the other CPUs for the 1252 r2p0) erratum. A faulty ASID can be sent to the other CPUs for the
@@ -1282,7 +1282,7 @@ config ARM_ERRATA_743622
1282 1282
1283config ARM_ERRATA_751472 1283config ARM_ERRATA_751472
1284 bool "ARM errata: Interrupted ICIALLUIS may prevent completion of broadcasted operation" 1284 bool "ARM errata: Interrupted ICIALLUIS may prevent completion of broadcasted operation"
1285 depends on CPU_V7 && SMP 1285 depends on CPU_V7
1286 help 1286 help
1287 This option enables the workaround for the 751472 Cortex-A9 (prior 1287 This option enables the workaround for the 751472 Cortex-A9 (prior
1288 to r3p0) erratum. An interrupted ICIALLUIS operation may prevent the 1288 to r3p0) erratum. An interrupted ICIALLUIS operation may prevent the
diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
index f407a6b35d3..8d8df744f7a 100644
--- a/arch/arm/common/pl330.c
+++ b/arch/arm/common/pl330.c
@@ -221,17 +221,6 @@
221 */ 221 */
222#define MCODE_BUFF_PER_REQ 256 222#define MCODE_BUFF_PER_REQ 256
223 223
224/*
225 * Mark a _pl330_req as free.
226 * We do it by writing DMAEND as the first instruction
227 * because no valid request is going to have DMAEND as
228 * its first instruction to execute.
229 */
230#define MARK_FREE(req) do { \
231 _emit_END(0, (req)->mc_cpu); \
232 (req)->mc_len = 0; \
233 } while (0)
234
235/* If the _pl330_req is available to the client */ 224/* If the _pl330_req is available to the client */
236#define IS_FREE(req) (*((u8 *)((req)->mc_cpu)) == CMD_DMAEND) 225#define IS_FREE(req) (*((u8 *)((req)->mc_cpu)) == CMD_DMAEND)
237 226
@@ -301,8 +290,10 @@ struct pl330_thread {
301 struct pl330_dmac *dmac; 290 struct pl330_dmac *dmac;
302 /* Only two at a time */ 291 /* Only two at a time */
303 struct _pl330_req req[2]; 292 struct _pl330_req req[2];
304 /* Index of the last submitted request */ 293 /* Index of the last enqueued request */
305 unsigned lstenq; 294 unsigned lstenq;
295 /* Index of the last submitted request or -1 if the DMA is stopped */
296 int req_running;
306}; 297};
307 298
308enum pl330_dmac_state { 299enum pl330_dmac_state {
@@ -778,6 +769,22 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
778 writel(0, regs + DBGCMD); 769 writel(0, regs + DBGCMD);
779} 770}
780 771
772/*
773 * Mark a _pl330_req as free.
774 * We do it by writing DMAEND as the first instruction
775 * because no valid request is going to have DMAEND as
776 * its first instruction to execute.
777 */
778static void mark_free(struct pl330_thread *thrd, int idx)
779{
780 struct _pl330_req *req = &thrd->req[idx];
781
782 _emit_END(0, req->mc_cpu);
783 req->mc_len = 0;
784
785 thrd->req_running = -1;
786}
787
781static inline u32 _state(struct pl330_thread *thrd) 788static inline u32 _state(struct pl330_thread *thrd)
782{ 789{
783 void __iomem *regs = thrd->dmac->pinfo->base; 790 void __iomem *regs = thrd->dmac->pinfo->base;
@@ -836,31 +843,6 @@ static inline u32 _state(struct pl330_thread *thrd)
836 } 843 }
837} 844}
838 845
839/* If the request 'req' of thread 'thrd' is currently active */
840static inline bool _req_active(struct pl330_thread *thrd,
841 struct _pl330_req *req)
842{
843 void __iomem *regs = thrd->dmac->pinfo->base;
844 u32 buf = req->mc_bus, pc = readl(regs + CPC(thrd->id));
845
846 if (IS_FREE(req))
847 return false;
848
849 return (pc >= buf && pc <= buf + req->mc_len) ? true : false;
850}
851
852/* Returns 0 if the thread is inactive, ID of active req + 1 otherwise */
853static inline unsigned _thrd_active(struct pl330_thread *thrd)
854{
855 if (_req_active(thrd, &thrd->req[0]))
856 return 1; /* First req active */
857
858 if (_req_active(thrd, &thrd->req[1]))
859 return 2; /* Second req active */
860
861 return 0;
862}
863
864static void _stop(struct pl330_thread *thrd) 846static void _stop(struct pl330_thread *thrd)
865{ 847{
866 void __iomem *regs = thrd->dmac->pinfo->base; 848 void __iomem *regs = thrd->dmac->pinfo->base;
@@ -892,17 +874,22 @@ static bool _trigger(struct pl330_thread *thrd)
892 struct _arg_GO go; 874 struct _arg_GO go;
893 unsigned ns; 875 unsigned ns;
894 u8 insn[6] = {0, 0, 0, 0, 0, 0}; 876 u8 insn[6] = {0, 0, 0, 0, 0, 0};
877 int idx;
895 878
896 /* Return if already ACTIVE */ 879 /* Return if already ACTIVE */
897 if (_state(thrd) != PL330_STATE_STOPPED) 880 if (_state(thrd) != PL330_STATE_STOPPED)
898 return true; 881 return true;
899 882
900 if (!IS_FREE(&thrd->req[1 - thrd->lstenq])) 883 idx = 1 - thrd->lstenq;
901 req = &thrd->req[1 - thrd->lstenq]; 884 if (!IS_FREE(&thrd->req[idx]))
902 else if (!IS_FREE(&thrd->req[thrd->lstenq])) 885 req = &thrd->req[idx];
903 req = &thrd->req[thrd->lstenq]; 886 else {
904 else 887 idx = thrd->lstenq;
905 req = NULL; 888 if (!IS_FREE(&thrd->req[idx]))
889 req = &thrd->req[idx];
890 else
891 req = NULL;
892 }
906 893
907 /* Return if no request */ 894 /* Return if no request */
908 if (!req || !req->r) 895 if (!req || !req->r)
@@ -933,6 +920,8 @@ static bool _trigger(struct pl330_thread *thrd)
933 /* Only manager can execute GO */ 920 /* Only manager can execute GO */
934 _execute_DBGINSN(thrd, insn, true); 921 _execute_DBGINSN(thrd, insn, true);
935 922
923 thrd->req_running = idx;
924
936 return true; 925 return true;
937} 926}
938 927
@@ -1382,8 +1371,8 @@ static void pl330_dotask(unsigned long data)
1382 1371
1383 thrd->req[0].r = NULL; 1372 thrd->req[0].r = NULL;
1384 thrd->req[1].r = NULL; 1373 thrd->req[1].r = NULL;
1385 MARK_FREE(&thrd->req[0]); 1374 mark_free(thrd, 0);
1386 MARK_FREE(&thrd->req[1]); 1375 mark_free(thrd, 1);
1387 1376
1388 /* Clear the reset flag */ 1377 /* Clear the reset flag */
1389 pl330->dmac_tbd.reset_chan &= ~(1 << i); 1378 pl330->dmac_tbd.reset_chan &= ~(1 << i);
@@ -1461,14 +1450,12 @@ int pl330_update(const struct pl330_info *pi)
1461 1450
1462 thrd = &pl330->channels[id]; 1451 thrd = &pl330->channels[id];
1463 1452
1464 active = _thrd_active(thrd); 1453 active = thrd->req_running;
1465 if (!active) /* Aborted */ 1454 if (active == -1) /* Aborted */
1466 continue; 1455 continue;
1467 1456
1468 active -= 1;
1469
1470 rqdone = &thrd->req[active]; 1457 rqdone = &thrd->req[active];
1471 MARK_FREE(rqdone); 1458 mark_free(thrd, active);
1472 1459
1473 /* Get going again ASAP */ 1460 /* Get going again ASAP */
1474 _start(thrd); 1461 _start(thrd);
@@ -1509,7 +1496,7 @@ int pl330_chan_ctrl(void *ch_id, enum pl330_chan_op op)
1509 struct pl330_thread *thrd = ch_id; 1496 struct pl330_thread *thrd = ch_id;
1510 struct pl330_dmac *pl330; 1497 struct pl330_dmac *pl330;
1511 unsigned long flags; 1498 unsigned long flags;
1512 int ret = 0, active; 1499 int ret = 0, active = thrd->req_running;
1513 1500
1514 if (!thrd || thrd->free || thrd->dmac->state == DYING) 1501 if (!thrd || thrd->free || thrd->dmac->state == DYING)
1515 return -EINVAL; 1502 return -EINVAL;
@@ -1525,28 +1512,24 @@ int pl330_chan_ctrl(void *ch_id, enum pl330_chan_op op)
1525 1512
1526 thrd->req[0].r = NULL; 1513 thrd->req[0].r = NULL;
1527 thrd->req[1].r = NULL; 1514 thrd->req[1].r = NULL;
1528 MARK_FREE(&thrd->req[0]); 1515 mark_free(thrd, 0);
1529 MARK_FREE(&thrd->req[1]); 1516 mark_free(thrd, 1);
1530 break; 1517 break;
1531 1518
1532 case PL330_OP_ABORT: 1519 case PL330_OP_ABORT:
1533 active = _thrd_active(thrd);
1534
1535 /* Make sure the channel is stopped */ 1520 /* Make sure the channel is stopped */
1536 _stop(thrd); 1521 _stop(thrd);
1537 1522
1538 /* ABORT is only for the active req */ 1523 /* ABORT is only for the active req */
1539 if (!active) 1524 if (active == -1)
1540 break; 1525 break;
1541 1526
1542 active--;
1543
1544 thrd->req[active].r = NULL; 1527 thrd->req[active].r = NULL;
1545 MARK_FREE(&thrd->req[active]); 1528 mark_free(thrd, active);
1546 1529
1547 /* Start the next */ 1530 /* Start the next */
1548 case PL330_OP_START: 1531 case PL330_OP_START:
1549 if (!_thrd_active(thrd) && !_start(thrd)) 1532 if ((active == -1) && !_start(thrd))
1550 ret = -EIO; 1533 ret = -EIO;
1551 break; 1534 break;
1552 1535
@@ -1587,14 +1570,13 @@ int pl330_chan_status(void *ch_id, struct pl330_chanstatus *pstatus)
1587 else 1570 else
1588 pstatus->faulting = false; 1571 pstatus->faulting = false;
1589 1572
1590 active = _thrd_active(thrd); 1573 active = thrd->req_running;
1591 1574
1592 if (!active) { 1575 if (active == -1) {
1593 /* Indicate that the thread is not running */ 1576 /* Indicate that the thread is not running */
1594 pstatus->top_req = NULL; 1577 pstatus->top_req = NULL;
1595 pstatus->wait_req = NULL; 1578 pstatus->wait_req = NULL;
1596 } else { 1579 } else {
1597 active--;
1598 pstatus->top_req = thrd->req[active].r; 1580 pstatus->top_req = thrd->req[active].r;
1599 pstatus->wait_req = !IS_FREE(&thrd->req[1 - active]) 1581 pstatus->wait_req = !IS_FREE(&thrd->req[1 - active])
1600 ? thrd->req[1 - active].r : NULL; 1582 ? thrd->req[1 - active].r : NULL;
@@ -1659,9 +1641,9 @@ void *pl330_request_channel(const struct pl330_info *pi)
1659 thrd->free = false; 1641 thrd->free = false;
1660 thrd->lstenq = 1; 1642 thrd->lstenq = 1;
1661 thrd->req[0].r = NULL; 1643 thrd->req[0].r = NULL;
1662 MARK_FREE(&thrd->req[0]); 1644 mark_free(thrd, 0);
1663 thrd->req[1].r = NULL; 1645 thrd->req[1].r = NULL;
1664 MARK_FREE(&thrd->req[1]); 1646 mark_free(thrd, 1);
1665 break; 1647 break;
1666 } 1648 }
1667 } 1649 }
@@ -1767,14 +1749,14 @@ static inline void _reset_thread(struct pl330_thread *thrd)
1767 thrd->req[0].mc_bus = pl330->mcode_bus 1749 thrd->req[0].mc_bus = pl330->mcode_bus
1768 + (thrd->id * pi->mcbufsz); 1750 + (thrd->id * pi->mcbufsz);
1769 thrd->req[0].r = NULL; 1751 thrd->req[0].r = NULL;
1770 MARK_FREE(&thrd->req[0]); 1752 mark_free(thrd, 0);
1771 1753
1772 thrd->req[1].mc_cpu = thrd->req[0].mc_cpu 1754 thrd->req[1].mc_cpu = thrd->req[0].mc_cpu
1773 + pi->mcbufsz / 2; 1755 + pi->mcbufsz / 2;
1774 thrd->req[1].mc_bus = thrd->req[0].mc_bus 1756 thrd->req[1].mc_bus = thrd->req[0].mc_bus
1775 + pi->mcbufsz / 2; 1757 + pi->mcbufsz / 2;
1776 thrd->req[1].r = NULL; 1758 thrd->req[1].r = NULL;
1777 MARK_FREE(&thrd->req[1]); 1759 mark_free(thrd, 1);
1778} 1760}
1779 1761
1780static int dmac_alloc_threads(struct pl330_dmac *pl330) 1762static int dmac_alloc_threads(struct pl330_dmac *pl330)
diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
index 11a4192197c..cf497ce41df 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -18,9 +18,10 @@ CONFIG_ARCH_MXC=y
18CONFIG_ARCH_IMX_V4_V5=y 18CONFIG_ARCH_IMX_V4_V5=y
19CONFIG_ARCH_MX1ADS=y 19CONFIG_ARCH_MX1ADS=y
20CONFIG_MACH_SCB9328=y 20CONFIG_MACH_SCB9328=y
21CONFIG_MACH_APF9328=y
21CONFIG_MACH_MX21ADS=y 22CONFIG_MACH_MX21ADS=y
22CONFIG_MACH_MX25_3DS=y 23CONFIG_MACH_MX25_3DS=y
23CONFIG_MACH_EUKREA_CPUIMX25=y 24CONFIG_MACH_EUKREA_CPUIMX25SD=y
24CONFIG_MACH_MX27ADS=y 25CONFIG_MACH_MX27ADS=y
25CONFIG_MACH_PCM038=y 26CONFIG_MACH_PCM038=y
26CONFIG_MACH_CPUIMX27=y 27CONFIG_MACH_CPUIMX27=y
@@ -72,17 +73,16 @@ CONFIG_MTD_CFI_GEOMETRY=y
72CONFIG_MTD_CFI_INTELEXT=y 73CONFIG_MTD_CFI_INTELEXT=y
73CONFIG_MTD_PHYSMAP=y 74CONFIG_MTD_PHYSMAP=y
74CONFIG_MTD_NAND=y 75CONFIG_MTD_NAND=y
76CONFIG_MTD_NAND_MXC=y
75CONFIG_MTD_UBI=y 77CONFIG_MTD_UBI=y
76CONFIG_MISC_DEVICES=y 78CONFIG_MISC_DEVICES=y
77CONFIG_EEPROM_AT24=y 79CONFIG_EEPROM_AT24=y
78CONFIG_EEPROM_AT25=y 80CONFIG_EEPROM_AT25=y
79CONFIG_NETDEVICES=y 81CONFIG_NETDEVICES=y
80CONFIG_NET_ETHERNET=y
81CONFIG_SMC91X=y
82CONFIG_DM9000=y 82CONFIG_DM9000=y
83CONFIG_SMC91X=y
83CONFIG_SMC911X=y 84CONFIG_SMC911X=y
84# CONFIG_NETDEV_1000 is not set 85CONFIG_SMSC_PHY=y
85# CONFIG_NETDEV_10000 is not set
86# CONFIG_INPUT_MOUSEDEV is not set 86# CONFIG_INPUT_MOUSEDEV is not set
87CONFIG_INPUT_EVDEV=y 87CONFIG_INPUT_EVDEV=y
88# CONFIG_INPUT_KEYBOARD is not set 88# CONFIG_INPUT_KEYBOARD is not set
@@ -100,6 +100,7 @@ CONFIG_I2C_CHARDEV=y
100CONFIG_I2C_IMX=y 100CONFIG_I2C_IMX=y
101CONFIG_SPI=y 101CONFIG_SPI=y
102CONFIG_SPI_IMX=y 102CONFIG_SPI_IMX=y
103CONFIG_SPI_SPIDEV=y
103CONFIG_W1=y 104CONFIG_W1=y
104CONFIG_W1_MASTER_MXC=y 105CONFIG_W1_MASTER_MXC=y
105CONFIG_W1_SLAVE_THERM=y 106CONFIG_W1_SLAVE_THERM=y
@@ -139,6 +140,7 @@ CONFIG_MMC=y
139CONFIG_MMC_MXC=y 140CONFIG_MMC_MXC=y
140CONFIG_NEW_LEDS=y 141CONFIG_NEW_LEDS=y
141CONFIG_LEDS_CLASS=y 142CONFIG_LEDS_CLASS=y
143CONFIG_LEDS_GPIO=y
142CONFIG_LEDS_MC13783=y 144CONFIG_LEDS_MC13783=y
143CONFIG_LEDS_TRIGGERS=y 145CONFIG_LEDS_TRIGGERS=y
144CONFIG_LEDS_TRIGGER_TIMER=y 146CONFIG_LEDS_TRIGGER_TIMER=y
diff --git a/arch/arm/mach-exynos/cpu.c b/arch/arm/mach-exynos/cpu.c
index 90ec247f3b3..cc8d4bd6d0f 100644
--- a/arch/arm/mach-exynos/cpu.c
+++ b/arch/arm/mach-exynos/cpu.c
@@ -111,11 +111,6 @@ static struct map_desc exynos4_iodesc[] __initdata = {
111 .length = SZ_4K, 111 .length = SZ_4K,
112 .type = MT_DEVICE, 112 .type = MT_DEVICE,
113 }, { 113 }, {
114 .virtual = (unsigned long)S5P_VA_SROMC,
115 .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC),
116 .length = SZ_4K,
117 .type = MT_DEVICE,
118 }, {
119 .virtual = (unsigned long)S3C_VA_USB_HSPHY, 114 .virtual = (unsigned long)S3C_VA_USB_HSPHY,
120 .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY), 115 .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY),
121 .length = SZ_4K, 116 .length = SZ_4K,
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index c44aa974e79..0e6f1af260b 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -132,7 +132,7 @@ config MACH_MX25_3DS
132 select IMX_HAVE_PLATFORM_MXC_NAND 132 select IMX_HAVE_PLATFORM_MXC_NAND
133 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX 133 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
134 134
135config MACH_EUKREA_CPUIMX25 135config MACH_EUKREA_CPUIMX25SD
136 bool "Support Eukrea CPUIMX25 Platform" 136 bool "Support Eukrea CPUIMX25 Platform"
137 select SOC_IMX25 137 select SOC_IMX25
138 select IMX_HAVE_PLATFORM_FLEXCAN 138 select IMX_HAVE_PLATFORM_FLEXCAN
@@ -148,7 +148,7 @@ config MACH_EUKREA_CPUIMX25
148 148
149choice 149choice
150 prompt "Baseboard" 150 prompt "Baseboard"
151 depends on MACH_EUKREA_CPUIMX25 151 depends on MACH_EUKREA_CPUIMX25SD
152 default MACH_EUKREA_MBIMXSD25_BASEBOARD 152 default MACH_EUKREA_MBIMXSD25_BASEBOARD
153 153
154config MACH_EUKREA_MBIMXSD25_BASEBOARD 154config MACH_EUKREA_MBIMXSD25_BASEBOARD
@@ -542,7 +542,7 @@ config MACH_MX35_3DS
542 Include support for MX35PDK platform. This includes specific 542 Include support for MX35PDK platform. This includes specific
543 configurations for the board and its peripherals. 543 configurations for the board and its peripherals.
544 544
545config MACH_EUKREA_CPUIMX35 545config MACH_EUKREA_CPUIMX35SD
546 bool "Support Eukrea CPUIMX35 Platform" 546 bool "Support Eukrea CPUIMX35 Platform"
547 select SOC_IMX35 547 select SOC_IMX35
548 select IMX_HAVE_PLATFORM_FLEXCAN 548 select IMX_HAVE_PLATFORM_FLEXCAN
@@ -560,7 +560,7 @@ config MACH_EUKREA_CPUIMX35
560 560
561choice 561choice
562 prompt "Baseboard" 562 prompt "Baseboard"
563 depends on MACH_EUKREA_CPUIMX35 563 depends on MACH_EUKREA_CPUIMX35SD
564 default MACH_EUKREA_MBIMXSD35_BASEBOARD 564 default MACH_EUKREA_MBIMXSD35_BASEBOARD
565 565
566config MACH_EUKREA_MBIMXSD35_BASEBOARD 566config MACH_EUKREA_MBIMXSD35_BASEBOARD
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index aba73214c2a..d97f409ce98 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_MACH_MX21ADS) += mach-mx21ads.o
24 24
25# i.MX25 based machines 25# i.MX25 based machines
26obj-$(CONFIG_MACH_MX25_3DS) += mach-mx25_3ds.o 26obj-$(CONFIG_MACH_MX25_3DS) += mach-mx25_3ds.o
27obj-$(CONFIG_MACH_EUKREA_CPUIMX25) += mach-eukrea_cpuimx25.o 27obj-$(CONFIG_MACH_EUKREA_CPUIMX25SD) += mach-eukrea_cpuimx25.o
28obj-$(CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD) += eukrea_mbimxsd25-baseboard.o 28obj-$(CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD) += eukrea_mbimxsd25-baseboard.o
29 29
30# i.MX27 based machines 30# i.MX27 based machines
@@ -57,7 +57,7 @@ obj-$(CONFIG_MACH_BUG) += mach-bug.o
57# i.MX35 based machines 57# i.MX35 based machines
58obj-$(CONFIG_MACH_PCM043) += mach-pcm043.o 58obj-$(CONFIG_MACH_PCM043) += mach-pcm043.o
59obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o 59obj-$(CONFIG_MACH_MX35_3DS) += mach-mx35_3ds.o
60obj-$(CONFIG_MACH_EUKREA_CPUIMX35) += mach-cpuimx35.o 60obj-$(CONFIG_MACH_EUKREA_CPUIMX35SD) += mach-cpuimx35.o
61obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o 61obj-$(CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD) += eukrea_mbimxsd35-baseboard.o
62obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o 62obj-$(CONFIG_MACH_VPR200) += mach-vpr200.o
63 63
diff --git a/arch/arm/mach-imx/clock-imx35.c b/arch/arm/mach-imx/clock-imx35.c
index 8116f119517..ac8238caecb 100644
--- a/arch/arm/mach-imx/clock-imx35.c
+++ b/arch/arm/mach-imx/clock-imx35.c
@@ -507,7 +507,7 @@ static struct clk_lookup lookups[] = {
507 507
508int __init mx35_clocks_init() 508int __init mx35_clocks_init()
509{ 509{
510 unsigned int cgr2 = 3 << 26, cgr3 = 0; 510 unsigned int cgr2 = 3 << 26;
511 511
512#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) 512#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
513 cgr2 |= 3 << 16; 513 cgr2 |= 3 << 16;
@@ -521,6 +521,12 @@ int __init mx35_clocks_init()
521 __raw_writel((3 << 18), CCM_BASE + CCM_CGR0); 521 __raw_writel((3 << 18), CCM_BASE + CCM_CGR0);
522 __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16), 522 __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16),
523 CCM_BASE + CCM_CGR1); 523 CCM_BASE + CCM_CGR1);
524 __raw_writel(cgr2, CCM_BASE + CCM_CGR2);
525 __raw_writel(0, CCM_BASE + CCM_CGR3);
526
527 clk_enable(&iim_clk);
528 imx_print_silicon_rev("i.MX35", mx35_revision());
529 clk_disable(&iim_clk);
524 530
525 /* 531 /*
526 * Check if we came up in internal boot mode. If yes, we need some 532 * Check if we came up in internal boot mode. If yes, we need some
@@ -529,17 +535,11 @@ int __init mx35_clocks_init()
529 */ 535 */
530 if (!(__raw_readl(CCM_BASE + CCM_RCSR) & (3 << 10))) { 536 if (!(__raw_readl(CCM_BASE + CCM_RCSR) & (3 << 10))) {
531 /* Additionally turn on UART1, SCC, and IIM clocks */ 537 /* Additionally turn on UART1, SCC, and IIM clocks */
532 cgr2 |= 3 << 16 | 3 << 4; 538 clk_enable(&iim_clk);
533 cgr3 |= 3 << 2; 539 clk_enable(&uart1_clk);
540 clk_enable(&scc_clk);
534 } 541 }
535 542
536 __raw_writel(cgr2, CCM_BASE + CCM_CGR2);
537 __raw_writel(cgr3, CCM_BASE + CCM_CGR3);
538
539 clk_enable(&iim_clk);
540 imx_print_silicon_rev("i.MX35", mx35_revision());
541 clk_disable(&iim_clk);
542
543#ifdef CONFIG_MXC_USE_EPIT 543#ifdef CONFIG_MXC_USE_EPIT
544 epit_timer_init(&epit1_clk, 544 epit_timer_init(&epit1_clk,
545 MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1); 545 MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1);
diff --git a/arch/arm/mach-imx/mach-cpuimx35.c b/arch/arm/mach-imx/mach-cpuimx35.c
index 66af2e8f7e5..362aae78060 100644
--- a/arch/arm/mach-imx/mach-cpuimx35.c
+++ b/arch/arm/mach-imx/mach-cpuimx35.c
@@ -53,12 +53,18 @@ static const struct imxi2c_platform_data
53 .bitrate = 100000, 53 .bitrate = 100000,
54}; 54};
55 55
56#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2)
57static int tsc2007_get_pendown_state(void)
58{
59 return !gpio_get_value(TSC2007_IRQGPIO);
60}
61
56static struct tsc2007_platform_data tsc2007_info = { 62static struct tsc2007_platform_data tsc2007_info = {
57 .model = 2007, 63 .model = 2007,
58 .x_plate_ohms = 180, 64 .x_plate_ohms = 180,
65 .get_pendown_state = tsc2007_get_pendown_state,
59}; 66};
60 67
61#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2)
62static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = { 68static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
63 { 69 {
64 I2C_BOARD_INFO("pcf8563", 0x51), 70 I2C_BOARD_INFO("pcf8563", 0x51),
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 7f8915ad509..eef43e2e163 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3247,18 +3247,14 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
3247 3247
3248/* 3430ES1-only hwmods */ 3248/* 3430ES1-only hwmods */
3249static __initdata struct omap_hwmod *omap3430es1_hwmods[] = { 3249static __initdata struct omap_hwmod *omap3430es1_hwmods[] = {
3250 &omap3xxx_iva_hwmod,
3251 &omap3430es1_dss_core_hwmod, 3250 &omap3430es1_dss_core_hwmod,
3252 &omap3xxx_mailbox_hwmod,
3253 NULL 3251 NULL
3254}; 3252};
3255 3253
3256/* 3430ES2+-only hwmods */ 3254/* 3430ES2+-only hwmods */
3257static __initdata struct omap_hwmod *omap3430es2plus_hwmods[] = { 3255static __initdata struct omap_hwmod *omap3430es2plus_hwmods[] = {
3258 &omap3xxx_iva_hwmod,
3259 &omap3xxx_dss_core_hwmod, 3256 &omap3xxx_dss_core_hwmod,
3260 &omap3xxx_usbhsotg_hwmod, 3257 &omap3xxx_usbhsotg_hwmod,
3261 &omap3xxx_mailbox_hwmod,
3262 NULL 3258 NULL
3263}; 3259};
3264 3260
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index b862e9f81e3..7119b87cbfa 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -607,6 +607,7 @@ struct sys_timer ag5evm_timer = {
607 607
608MACHINE_START(AG5EVM, "ag5evm") 608MACHINE_START(AG5EVM, "ag5evm")
609 .map_io = ag5evm_map_io, 609 .map_io = ag5evm_map_io,
610 .nr_irqs = NR_IRQS_LEGACY,
610 .init_irq = sh73a0_init_irq, 611 .init_irq = sh73a0_init_irq,
611 .handle_irq = shmobile_handle_irq_gic, 612 .handle_irq = shmobile_handle_irq_gic,
612 .init_machine = ag5evm_init, 613 .init_machine = ag5evm_init,
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index bd9a78424d6..f44150b5ae4 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -33,6 +33,7 @@
33#include <linux/input/sh_keysc.h> 33#include <linux/input/sh_keysc.h>
34#include <linux/gpio_keys.h> 34#include <linux/gpio_keys.h>
35#include <linux/leds.h> 35#include <linux/leds.h>
36#include <linux/platform_data/leds-renesas-tpu.h>
36#include <linux/mmc/host.h> 37#include <linux/mmc/host.h>
37#include <linux/mmc/sh_mmcif.h> 38#include <linux/mmc/sh_mmcif.h>
38#include <linux/mfd/tmio.h> 39#include <linux/mfd/tmio.h>
@@ -56,7 +57,7 @@ static struct resource smsc9220_resources[] = {
56 .flags = IORESOURCE_MEM, 57 .flags = IORESOURCE_MEM,
57 }, 58 },
58 [1] = { 59 [1] = {
59 .start = gic_spi(33), /* PINTA2 @ PORT144 */ 60 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
60 .flags = IORESOURCE_IRQ, 61 .flags = IORESOURCE_IRQ,
61 }, 62 },
62}; 63};
@@ -157,10 +158,6 @@ static struct platform_device gpio_keys_device = {
157#define GPIO_LED(n, g) { .name = n, .gpio = g } 158#define GPIO_LED(n, g) { .name = n, .gpio = g }
158 159
159static struct gpio_led gpio_leds[] = { 160static struct gpio_led gpio_leds[] = {
160 GPIO_LED("V2513", GPIO_PORT153), /* PORT153 [TPU1T02] -> V2513 */
161 GPIO_LED("V2514", GPIO_PORT199), /* PORT199 [TPU4TO1] -> V2514 */
162 GPIO_LED("V2515", GPIO_PORT197), /* PORT197 [TPU2TO1] -> V2515 */
163 GPIO_LED("KEYLED", GPIO_PORT163), /* PORT163 [TPU3TO0] -> KEYLED */
164 GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */ 161 GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
165 GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */ 162 GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
166 GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */ 163 GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
@@ -179,6 +176,119 @@ static struct platform_device gpio_leds_device = {
179 }, 176 },
180}; 177};
181 178
179/* TPU LED */
180static struct led_renesas_tpu_config led_renesas_tpu12_pdata = {
181 .name = "V2513",
182 .pin_gpio_fn = GPIO_FN_TPU1TO2,
183 .pin_gpio = GPIO_PORT153,
184 .channel_offset = 0x90,
185 .timer_bit = 2,
186 .max_brightness = 1000,
187};
188
189static struct resource tpu12_resources[] = {
190 [0] = {
191 .name = "TPU12",
192 .start = 0xe6610090,
193 .end = 0xe66100b5,
194 .flags = IORESOURCE_MEM,
195 },
196};
197
198static struct platform_device leds_tpu12_device = {
199 .name = "leds-renesas-tpu",
200 .id = 12,
201 .dev = {
202 .platform_data = &led_renesas_tpu12_pdata,
203 },
204 .num_resources = ARRAY_SIZE(tpu12_resources),
205 .resource = tpu12_resources,
206};
207
208static struct led_renesas_tpu_config led_renesas_tpu41_pdata = {
209 .name = "V2514",
210 .pin_gpio_fn = GPIO_FN_TPU4TO1,
211 .pin_gpio = GPIO_PORT199,
212 .channel_offset = 0x50,
213 .timer_bit = 1,
214 .max_brightness = 1000,
215};
216
217static struct resource tpu41_resources[] = {
218 [0] = {
219 .name = "TPU41",
220 .start = 0xe6640050,
221 .end = 0xe6640075,
222 .flags = IORESOURCE_MEM,
223 },
224};
225
226static struct platform_device leds_tpu41_device = {
227 .name = "leds-renesas-tpu",
228 .id = 41,
229 .dev = {
230 .platform_data = &led_renesas_tpu41_pdata,
231 },
232 .num_resources = ARRAY_SIZE(tpu41_resources),
233 .resource = tpu41_resources,
234};
235
236static struct led_renesas_tpu_config led_renesas_tpu21_pdata = {
237 .name = "V2515",
238 .pin_gpio_fn = GPIO_FN_TPU2TO1,
239 .pin_gpio = GPIO_PORT197,
240 .channel_offset = 0x50,
241 .timer_bit = 1,
242 .max_brightness = 1000,
243};
244
245static struct resource tpu21_resources[] = {
246 [0] = {
247 .name = "TPU21",
248 .start = 0xe6620050,
249 .end = 0xe6620075,
250 .flags = IORESOURCE_MEM,
251 },
252};
253
254static struct platform_device leds_tpu21_device = {
255 .name = "leds-renesas-tpu",
256 .id = 21,
257 .dev = {
258 .platform_data = &led_renesas_tpu21_pdata,
259 },
260 .num_resources = ARRAY_SIZE(tpu21_resources),
261 .resource = tpu21_resources,
262};
263
264static struct led_renesas_tpu_config led_renesas_tpu30_pdata = {
265 .name = "KEYLED",
266 .pin_gpio_fn = GPIO_FN_TPU3TO0,
267 .pin_gpio = GPIO_PORT163,
268 .channel_offset = 0x10,
269 .timer_bit = 0,
270 .max_brightness = 1000,
271};
272
273static struct resource tpu30_resources[] = {
274 [0] = {
275 .name = "TPU30",
276 .start = 0xe6630010,
277 .end = 0xe6630035,
278 .flags = IORESOURCE_MEM,
279 },
280};
281
282static struct platform_device leds_tpu30_device = {
283 .name = "leds-renesas-tpu",
284 .id = 30,
285 .dev = {
286 .platform_data = &led_renesas_tpu30_pdata,
287 },
288 .num_resources = ARRAY_SIZE(tpu30_resources),
289 .resource = tpu30_resources,
290};
291
182/* MMCIF */ 292/* MMCIF */
183static struct resource mmcif_resources[] = { 293static struct resource mmcif_resources[] = {
184 [0] = { 294 [0] = {
@@ -291,6 +401,10 @@ static struct platform_device *kota2_devices[] __initdata = {
291 &keysc_device, 401 &keysc_device,
292 &gpio_keys_device, 402 &gpio_keys_device,
293 &gpio_leds_device, 403 &gpio_leds_device,
404 &leds_tpu12_device,
405 &leds_tpu41_device,
406 &leds_tpu21_device,
407 &leds_tpu30_device,
294 &mmcif_device, 408 &mmcif_device,
295 &sdhi0_device, 409 &sdhi0_device,
296 &sdhi1_device, 410 &sdhi1_device,
@@ -317,18 +431,6 @@ static void __init kota2_map_io(void)
317 shmobile_setup_console(); 431 shmobile_setup_console();
318} 432}
319 433
320#define PINTER0A 0xe69000a0
321#define PINTCR0A 0xe69000b0
322
323void __init kota2_init_irq(void)
324{
325 sh73a0_init_irq();
326
327 /* setup PINT: enable PINTA2 as active low */
328 __raw_writel(1 << 29, PINTER0A);
329 __raw_writew(2 << 10, PINTCR0A);
330}
331
332static void __init kota2_init(void) 434static void __init kota2_init(void)
333{ 435{
334 sh73a0_pinmux_init(); 436 sh73a0_pinmux_init();
@@ -447,7 +549,8 @@ struct sys_timer kota2_timer = {
447 549
448MACHINE_START(KOTA2, "kota2") 550MACHINE_START(KOTA2, "kota2")
449 .map_io = kota2_map_io, 551 .map_io = kota2_map_io,
450 .init_irq = kota2_init_irq, 552 .nr_irqs = NR_IRQS_LEGACY,
553 .init_irq = sh73a0_init_irq,
451 .handle_irq = shmobile_handle_irq_gic, 554 .handle_irq = shmobile_handle_irq_gic,
452 .init_machine = kota2_init, 555 .init_machine = kota2_init,
453 .timer = &kota2_timer, 556 .timer = &kota2_timer,
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 61a846bb30f..1370a89ca35 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -113,6 +113,12 @@ static struct clk main_clk = {
113 .ops = &main_clk_ops, 113 .ops = &main_clk_ops,
114}; 114};
115 115
116/* Divide Main clock by two */
117static struct clk main_div2_clk = {
118 .ops = &div2_clk_ops,
119 .parent = &main_clk,
120};
121
116/* PLL0, PLL1, PLL2, PLL3 */ 122/* PLL0, PLL1, PLL2, PLL3 */
117static unsigned long pll_recalc(struct clk *clk) 123static unsigned long pll_recalc(struct clk *clk)
118{ 124{
@@ -181,6 +187,7 @@ static struct clk *main_clks[] = {
181 &extal1_div2_clk, 187 &extal1_div2_clk,
182 &extal2_div2_clk, 188 &extal2_div2_clk,
183 &main_clk, 189 &main_clk,
190 &main_div2_clk,
184 &pll0_clk, 191 &pll0_clk,
185 &pll1_clk, 192 &pll1_clk,
186 &pll2_clk, 193 &pll2_clk,
@@ -243,7 +250,7 @@ static struct clk div6_clks[DIV6_NR] = {
243 [DIV6_VCK1] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR1, 0), 250 [DIV6_VCK1] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR1, 0),
244 [DIV6_VCK2] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR2, 0), 251 [DIV6_VCK2] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR2, 0),
245 [DIV6_VCK3] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR3, 0), 252 [DIV6_VCK3] = SH_CLK_DIV6(&pll1_div2_clk, VCLKCR3, 0),
246 [DIV6_ZB1] = SH_CLK_DIV6(&pll1_div2_clk, ZBCKCR, 0), 253 [DIV6_ZB1] = SH_CLK_DIV6(&pll1_div2_clk, ZBCKCR, CLK_ENABLE_ON_INIT),
247 [DIV6_FLCTL] = SH_CLK_DIV6(&pll1_div2_clk, FLCKCR, 0), 254 [DIV6_FLCTL] = SH_CLK_DIV6(&pll1_div2_clk, FLCKCR, 0),
248 [DIV6_SDHI0] = SH_CLK_DIV6(&pll1_div2_clk, SD0CKCR, 0), 255 [DIV6_SDHI0] = SH_CLK_DIV6(&pll1_div2_clk, SD0CKCR, 0),
249 [DIV6_SDHI1] = SH_CLK_DIV6(&pll1_div2_clk, SD1CKCR, 0), 256 [DIV6_SDHI1] = SH_CLK_DIV6(&pll1_div2_clk, SD1CKCR, 0),
@@ -268,6 +275,7 @@ enum { MSTP001,
268 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 275 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
269 MSTP331, MSTP329, MSTP325, MSTP323, MSTP318, 276 MSTP331, MSTP329, MSTP325, MSTP323, MSTP318,
270 MSTP314, MSTP313, MSTP312, MSTP311, 277 MSTP314, MSTP313, MSTP312, MSTP311,
278 MSTP303, MSTP302, MSTP301, MSTP300,
271 MSTP411, MSTP410, MSTP403, 279 MSTP411, MSTP410, MSTP403,
272 MSTP_NR }; 280 MSTP_NR };
273 281
@@ -301,6 +309,10 @@ static struct clk mstp_clks[MSTP_NR] = {
301 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */ 309 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */
302 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */ 310 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */
303 [MSTP311] = MSTP(&div6_clks[DIV6_SDHI2], SMSTPCR3, 11, 0), /* SDHI2 */ 311 [MSTP311] = MSTP(&div6_clks[DIV6_SDHI2], SMSTPCR3, 11, 0), /* SDHI2 */
312 [MSTP303] = MSTP(&main_div2_clk, SMSTPCR3, 3, 0), /* TPU1 */
313 [MSTP302] = MSTP(&main_div2_clk, SMSTPCR3, 2, 0), /* TPU2 */
314 [MSTP301] = MSTP(&main_div2_clk, SMSTPCR3, 1, 0), /* TPU3 */
315 [MSTP300] = MSTP(&main_div2_clk, SMSTPCR3, 0, 0), /* TPU4 */
304 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */ 316 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */
305 [MSTP410] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 10, 0), /* IIC4 */ 317 [MSTP410] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 10, 0), /* IIC4 */
306 [MSTP403] = MSTP(&r_clk, SMSTPCR4, 3, 0), /* KEYSC */ 318 [MSTP403] = MSTP(&r_clk, SMSTPCR4, 3, 0), /* KEYSC */
@@ -350,6 +362,10 @@ static struct clk_lookup lookups[] = {
350 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ 362 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */
351 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */ 363 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */
352 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP311]), /* SDHI2 */ 364 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP311]), /* SDHI2 */
365 CLKDEV_DEV_ID("leds-renesas-tpu.12", &mstp_clks[MSTP303]), /* TPU1 */
366 CLKDEV_DEV_ID("leds-renesas-tpu.21", &mstp_clks[MSTP302]), /* TPU2 */
367 CLKDEV_DEV_ID("leds-renesas-tpu.30", &mstp_clks[MSTP301]), /* TPU3 */
368 CLKDEV_DEV_ID("leds-renesas-tpu.41", &mstp_clks[MSTP300]), /* TPU4 */
353 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */ 369 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */
354 CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */ 370 CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */
355 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */ 371 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 2c559ac3814..e70a73731ea 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -363,11 +363,13 @@ __v7_setup:
363 orreq r10, r10, #1 << 6 @ set bit #6 363 orreq r10, r10, #1 << 6 @ set bit #6
364 mcreq p15, 0, r10, c15, c0, 1 @ write diagnostic register 364 mcreq p15, 0, r10, c15, c0, 1 @ write diagnostic register
365#endif 365#endif
366#ifdef CONFIG_ARM_ERRATA_751472 366#if defined(CONFIG_ARM_ERRATA_751472) && defined(CONFIG_SMP)
367 cmp r6, #0x30 @ present prior to r3p0 367 ALT_SMP(cmp r6, #0x30) @ present prior to r3p0
368 ALT_UP_B(1f)
368 mrclt p15, 0, r10, c15, c0, 1 @ read diagnostic register 369 mrclt p15, 0, r10, c15, c0, 1 @ read diagnostic register
369 orrlt r10, r10, #1 << 11 @ set bit #11 370 orrlt r10, r10, #1 << 11 @ set bit #11
370 mcrlt p15, 0, r10, c15, c0, 1 @ write diagnostic register 371 mcrlt p15, 0, r10, c15, c0, 1 @ write diagnostic register
3721:
371#endif 373#endif
372 374
3733: mov r10, #0 3753: mov r10, #0
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index c074e66ad22..4e0a371630b 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -116,7 +116,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
116 return oprofile_perf_init(ops); 116 return oprofile_perf_init(ops);
117} 117}
118 118
119void __exit oprofile_arch_exit(void) 119void oprofile_arch_exit(void)
120{ 120{
121 oprofile_perf_exit(); 121 oprofile_perf_exit();
122} 122}
diff --git a/arch/arm/plat-mxc/cpufreq.c b/arch/arm/plat-mxc/cpufreq.c
index adbff706ef6..73db34bf588 100644
--- a/arch/arm/plat-mxc/cpufreq.c
+++ b/arch/arm/plat-mxc/cpufreq.c
@@ -98,7 +98,7 @@ static int mxc_set_target(struct cpufreq_policy *policy,
98 return ret; 98 return ret;
99} 99}
100 100
101static int __init mxc_cpufreq_init(struct cpufreq_policy *policy) 101static int mxc_cpufreq_init(struct cpufreq_policy *policy)
102{ 102{
103 int ret; 103 int ret;
104 int i; 104 int i;
diff --git a/arch/arm/plat-mxc/include/mach/uncompress.h b/arch/arm/plat-mxc/include/mach/uncompress.h
index 88fd4045256..477971b0093 100644
--- a/arch/arm/plat-mxc/include/mach/uncompress.h
+++ b/arch/arm/plat-mxc/include/mach/uncompress.h
@@ -98,6 +98,7 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)
98 case MACH_TYPE_PCM043: 98 case MACH_TYPE_PCM043:
99 case MACH_TYPE_LILLY1131: 99 case MACH_TYPE_LILLY1131:
100 case MACH_TYPE_VPR200: 100 case MACH_TYPE_VPR200:
101 case MACH_TYPE_EUKREA_CPUIMX35SD:
101 uart_base = MX3X_UART1_BASE_ADDR; 102 uart_base = MX3X_UART1_BASE_ADDR;
102 break; 103 break;
103 case MACH_TYPE_MAGX_ZN5: 104 case MACH_TYPE_MAGX_ZN5:
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 845de59f07e..e032717f7d0 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -77,6 +77,15 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
77 do_div(c, period_ns); 77 do_div(c, period_ns);
78 duty_cycles = c; 78 duty_cycles = c;
79 79
80 /*
81 * according to imx pwm RM, the real period value should be
82 * PERIOD value in PWMPR plus 2.
83 */
84 if (period_cycles > 2)
85 period_cycles -= 2;
86 else
87 period_cycles = 0;
88
80 writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR); 89 writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR);
81 writel(period_cycles, pwm->mmio_base + MX3_PWMPR); 90 writel(period_cycles, pwm->mmio_base + MX3_PWMPR);
82 91
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 41ab97ebe4c..10d16088813 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -384,12 +384,16 @@ void __init orion_gpio_init(int gpio_base, int ngpio,
384 struct orion_gpio_chip *ochip; 384 struct orion_gpio_chip *ochip;
385 struct irq_chip_generic *gc; 385 struct irq_chip_generic *gc;
386 struct irq_chip_type *ct; 386 struct irq_chip_type *ct;
387 char gc_label[16];
387 388
388 if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips)) 389 if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips))
389 return; 390 return;
390 391
392 snprintf(gc_label, sizeof(gc_label), "orion_gpio%d",
393 orion_gpio_chip_count);
394
391 ochip = orion_gpio_chips + orion_gpio_chip_count; 395 ochip = orion_gpio_chips + orion_gpio_chip_count;
392 ochip->chip.label = "orion_gpio"; 396 ochip->chip.label = kstrdup(gc_label, GFP_KERNEL);
393 ochip->chip.request = orion_gpio_request; 397 ochip->chip.request = orion_gpio_request;
394 ochip->chip.direction_input = orion_gpio_direction_input; 398 ochip->chip.direction_input = orion_gpio_direction_input;
395 ochip->chip.get = orion_gpio_get; 399 ochip->chip.get = orion_gpio_get;
diff --git a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h
index dac4760c0f0..95509d8eb14 100644
--- a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h
+++ b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h
@@ -202,14 +202,6 @@ extern int s3c_plltab_register(struct cpufreq_frequency_table *plls,
202extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void); 202extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
203extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void); 203extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
204 204
205extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
206 struct s3c_cpufreq_config *cfg,
207 union s3c_iobank *iob);
208
209extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
210 struct s3c_cpufreq_config *cfg,
211 union s3c_iobank *iob);
212
213#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS 205#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS
214#define s3c_cpufreq_debugfs_call(x) x 206#define s3c_cpufreq_debugfs_call(x) x
215#else 207#else
@@ -226,6 +218,10 @@ extern void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
226extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg); 218extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
227 219
228#ifdef CONFIG_S3C2410_IOTIMING 220#ifdef CONFIG_S3C2410_IOTIMING
221extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
222 struct s3c_cpufreq_config *cfg,
223 union s3c_iobank *iob);
224
229extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg, 225extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
230 struct s3c_iotimings *iot); 226 struct s3c_iotimings *iot);
231 227
@@ -235,6 +231,7 @@ extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
235extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg, 231extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
236 struct s3c_iotimings *iot); 232 struct s3c_iotimings *iot);
237#else 233#else
234#define s3c2410_iotiming_debugfs NULL
238#define s3c2410_iotiming_calc NULL 235#define s3c2410_iotiming_calc NULL
239#define s3c2410_iotiming_get NULL 236#define s3c2410_iotiming_get NULL
240#define s3c2410_iotiming_set NULL 237#define s3c2410_iotiming_set NULL
@@ -242,8 +239,10 @@ extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
242 239
243/* S3C2412 compatible routines */ 240/* S3C2412 compatible routines */
244 241
245extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg, 242#ifdef CONFIG_S3C2412_IOTIMING
246 struct s3c_iotimings *timings); 243extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
244 struct s3c_cpufreq_config *cfg,
245 union s3c_iobank *iob);
247 246
248extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg, 247extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
249 struct s3c_iotimings *timings); 248 struct s3c_iotimings *timings);
@@ -253,6 +252,12 @@ extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
253 252
254extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg, 253extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
255 struct s3c_iotimings *iot); 254 struct s3c_iotimings *iot);
255#else
256#define s3c2412_iotiming_debugfs NULL
257#define s3c2412_iotiming_calc NULL
258#define s3c2412_iotiming_get NULL
259#define s3c2412_iotiming_set NULL
260#endif /* CONFIG_S3C2412_IOTIMING */
256 261
257#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUG 262#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUG
258#define s3c_freq_dbg(x...) printk(KERN_INFO x) 263#define s3c_freq_dbg(x...) printk(KERN_INFO x)
diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index 6073b187528..5a274af31b2 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -60,6 +60,7 @@ typedef u64 cputime64_t;
60 */ 60 */
61#define cputime_to_usecs(__ct) ((__ct) / NSEC_PER_USEC) 61#define cputime_to_usecs(__ct) ((__ct) / NSEC_PER_USEC)
62#define usecs_to_cputime(__usecs) ((__usecs) * NSEC_PER_USEC) 62#define usecs_to_cputime(__usecs) ((__usecs) * NSEC_PER_USEC)
63#define usecs_to_cputime64(__usecs) usecs_to_cputime(__usecs)
63 64
64/* 65/*
65 * Convert cputime <-> seconds 66 * Convert cputime <-> seconds
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 1cf20bdfbec..98b7c4b49c9 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -150,6 +150,8 @@ static inline cputime_t usecs_to_cputime(const unsigned long us)
150 return ct; 150 return ct;
151} 151}
152 152
153#define usecs_to_cputime64(us) usecs_to_cputime(us)
154
153/* 155/*
154 * Convert cputime <-> seconds 156 * Convert cputime <-> seconds
155 */ 157 */
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index d4df013ad77..69c7377d207 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -381,39 +381,6 @@ static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
381} 381}
382#endif 382#endif
383 383
384static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
385 unsigned long pte_index)
386{
387 unsigned long rb, va_low;
388
389 rb = (v & ~0x7fUL) << 16; /* AVA field */
390 va_low = pte_index >> 3;
391 if (v & HPTE_V_SECONDARY)
392 va_low = ~va_low;
393 /* xor vsid from AVA */
394 if (!(v & HPTE_V_1TB_SEG))
395 va_low ^= v >> 12;
396 else
397 va_low ^= v >> 24;
398 va_low &= 0x7ff;
399 if (v & HPTE_V_LARGE) {
400 rb |= 1; /* L field */
401 if (cpu_has_feature(CPU_FTR_ARCH_206) &&
402 (r & 0xff000)) {
403 /* non-16MB large page, must be 64k */
404 /* (masks depend on page size) */
405 rb |= 0x1000; /* page encoding in LP field */
406 rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */
407 rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */
408 }
409 } else {
410 /* 4kB page */
411 rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */
412 }
413 rb |= (v >> 54) & 0x300; /* B field */
414 return rb;
415}
416
417/* Magic register values loaded into r3 and r4 before the 'sc' assembly 384/* Magic register values loaded into r3 and r4 before the 'sc' assembly
418 * instruction for the OSI hypercalls */ 385 * instruction for the OSI hypercalls */
419#define OSI_SC_MAGIC_R3 0x113724FA 386#define OSI_SC_MAGIC_R3 0x113724FA
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index e43fe42b987..d0ac94f98f9 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -29,4 +29,37 @@ static inline struct kvmppc_book3s_shadow_vcpu *to_svcpu(struct kvm_vcpu *vcpu)
29 29
30#define SPAPR_TCE_SHIFT 12 30#define SPAPR_TCE_SHIFT 12
31 31
32static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
33 unsigned long pte_index)
34{
35 unsigned long rb, va_low;
36
37 rb = (v & ~0x7fUL) << 16; /* AVA field */
38 va_low = pte_index >> 3;
39 if (v & HPTE_V_SECONDARY)
40 va_low = ~va_low;
41 /* xor vsid from AVA */
42 if (!(v & HPTE_V_1TB_SEG))
43 va_low ^= v >> 12;
44 else
45 va_low ^= v >> 24;
46 va_low &= 0x7ff;
47 if (v & HPTE_V_LARGE) {
48 rb |= 1; /* L field */
49 if (cpu_has_feature(CPU_FTR_ARCH_206) &&
50 (r & 0xff000)) {
51 /* non-16MB large page, must be 64k */
52 /* (masks depend on page size) */
53 rb |= 0x1000; /* page encoding in LP field */
54 rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */
55 rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */
56 }
57 } else {
58 /* 4kB page */
59 rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */
60 }
61 rb |= (v >> 54) & 0x300; /* B field */
62 return rb;
63}
64
32#endif /* __ASM_KVM_BOOK3S_64_H__ */ 65#endif /* __ASM_KVM_BOOK3S_64_H__ */
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 0cb137a9b03..336983da9e7 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -538,7 +538,7 @@ static void kvmppc_start_thread(struct kvm_vcpu *vcpu)
538 tpaca->kvm_hstate.napping = 0; 538 tpaca->kvm_hstate.napping = 0;
539 vcpu->cpu = vc->pcpu; 539 vcpu->cpu = vc->pcpu;
540 smp_wmb(); 540 smp_wmb();
541#ifdef CONFIG_PPC_ICP_NATIVE 541#if defined(CONFIG_PPC_ICP_NATIVE) && defined(CONFIG_SMP)
542 if (vcpu->arch.ptid) { 542 if (vcpu->arch.ptid) {
543 tpaca->cpu_start = 0x80; 543 tpaca->cpu_start = 0x80;
544 wmb(); 544 wmb();
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 3c791e1eb67..e2cfb9e1e20 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -658,10 +658,12 @@ program_interrupt:
658 ulong cmd = kvmppc_get_gpr(vcpu, 3); 658 ulong cmd = kvmppc_get_gpr(vcpu, 3);
659 int i; 659 int i;
660 660
661#ifdef CONFIG_KVM_BOOK3S_64_PR
661 if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE) { 662 if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE) {
662 r = RESUME_GUEST; 663 r = RESUME_GUEST;
663 break; 664 break;
664 } 665 }
666#endif
665 667
666 run->papr_hcall.nr = cmd; 668 run->papr_hcall.nr = cmd;
667 for (i = 0; i < 9; ++i) { 669 for (i = 0; i < 9; ++i) {
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index 26d20903f2b..8c0d45a6faf 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -15,6 +15,7 @@
15#include <linux/kvm_host.h> 15#include <linux/kvm_host.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/export.h>
18 19
19#include <asm/reg.h> 20#include <asm/reg.h>
20#include <asm/cputable.h> 21#include <asm/cputable.h>
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 08143487829..b9acaaa175d 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -87,6 +87,8 @@ usecs_to_cputime(const unsigned int m)
87 return (cputime_t) m * 4096; 87 return (cputime_t) m * 4096;
88} 88}
89 89
90#define usecs_to_cputime64(m) usecs_to_cputime(m)
91
90/* 92/*
91 * Convert cputime to milliseconds and back. 93 * Convert cputime to milliseconds and back.
92 */ 94 */
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index 6cf2286d040..2297be406c6 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -123,7 +123,7 @@ static ssize_t hwsampler_write(struct file *file, char const __user *buf,
123 return -EINVAL; 123 return -EINVAL;
124 124
125 retval = oprofilefs_ulong_from_user(&val, buf, count); 125 retval = oprofilefs_ulong_from_user(&val, buf, count);
126 if (retval) 126 if (retval <= 0)
127 return retval; 127 return retval;
128 128
129 if (val != 0 && val != 1) 129 if (val != 0 && val != 1)
diff --git a/arch/sh/boards/board-sh7757lcr.c b/arch/sh/boards/board-sh7757lcr.c
index ec8c84c14b1..895e337c79b 100644
--- a/arch/sh/boards/board-sh7757lcr.c
+++ b/arch/sh/boards/board-sh7757lcr.c
@@ -50,9 +50,9 @@ static struct platform_device heartbeat_device = {
50#define GBECONT 0xffc10100 50#define GBECONT 0xffc10100
51#define GBECONT_RMII1 BIT(17) 51#define GBECONT_RMII1 BIT(17)
52#define GBECONT_RMII0 BIT(16) 52#define GBECONT_RMII0 BIT(16)
53static void sh7757_eth_set_mdio_gate(unsigned long addr) 53static void sh7757_eth_set_mdio_gate(void *addr)
54{ 54{
55 if ((addr & 0x00000fff) < 0x0800) 55 if (((unsigned long)addr & 0x00000fff) < 0x0800)
56 writel(readl(GBECONT) | GBECONT_RMII0, GBECONT); 56 writel(readl(GBECONT) | GBECONT_RMII0, GBECONT);
57 else 57 else
58 writel(readl(GBECONT) | GBECONT_RMII1, GBECONT); 58 writel(readl(GBECONT) | GBECONT_RMII1, GBECONT);
@@ -116,9 +116,9 @@ static struct platform_device sh7757_eth1_device = {
116 }, 116 },
117}; 117};
118 118
119static void sh7757_eth_giga_set_mdio_gate(unsigned long addr) 119static void sh7757_eth_giga_set_mdio_gate(void *addr)
120{ 120{
121 if ((addr & 0x00000fff) < 0x0800) { 121 if (((unsigned long)addr & 0x00000fff) < 0x0800) {
122 gpio_set_value(GPIO_PTT4, 1); 122 gpio_set_value(GPIO_PTT4, 1);
123 writel(readl(GBECONT) & ~GBECONT_RMII0, GBECONT); 123 writel(readl(GBECONT) & ~GBECONT_RMII0, GBECONT);
124 } else { 124 } else {
@@ -210,8 +210,12 @@ static struct resource sh_mmcif_resources[] = {
210}; 210};
211 211
212static struct sh_mmcif_dma sh7757lcr_mmcif_dma = { 212static struct sh_mmcif_dma sh7757lcr_mmcif_dma = {
213 .chan_priv_tx = SHDMA_SLAVE_MMCIF_TX, 213 .chan_priv_tx = {
214 .chan_priv_rx = SHDMA_SLAVE_MMCIF_RX, 214 .slave_id = SHDMA_SLAVE_MMCIF_TX,
215 },
216 .chan_priv_rx = {
217 .slave_id = SHDMA_SLAVE_MMCIF_RX,
218 }
215}; 219};
216 220
217static struct sh_mmcif_plat_data sh_mmcif_plat = { 221static struct sh_mmcif_plat_data sh_mmcif_plat = {
diff --git a/arch/sh/oprofile/common.c b/arch/sh/oprofile/common.c
index b4c2d2b946d..e4dd5d5a111 100644
--- a/arch/sh/oprofile/common.c
+++ b/arch/sh/oprofile/common.c
@@ -49,7 +49,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
49 return oprofile_perf_init(ops); 49 return oprofile_perf_init(ops);
50} 50}
51 51
52void __exit oprofile_arch_exit(void) 52void oprofile_arch_exit(void)
53{ 53{
54 oprofile_perf_exit(); 54 oprofile_perf_exit();
55 kfree(sh_pmu_op_name); 55 kfree(sh_pmu_op_name);
@@ -60,5 +60,5 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
60 ops->backtrace = sh_backtrace; 60 ops->backtrace = sh_backtrace;
61 return -ENODEV; 61 return -ENODEV;
62} 62}
63void __exit oprofile_arch_exit(void) {} 63void oprofile_arch_exit(void) {}
64#endif /* CONFIG_HW_PERF_EVENTS */ 64#endif /* CONFIG_HW_PERF_EVENTS */
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index b272cda35a0..af5755d20fb 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -849,10 +849,10 @@ static int pci_sun4v_msiq_build_irq(struct pci_pbm_info *pbm,
849 if (!irq) 849 if (!irq)
850 return -ENOMEM; 850 return -ENOMEM;
851 851
852 if (pci_sun4v_msiq_setstate(pbm->devhandle, msiqid, HV_MSIQSTATE_IDLE))
853 return -EINVAL;
854 if (pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_VALID)) 852 if (pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_VALID))
855 return -EINVAL; 853 return -EINVAL;
854 if (pci_sun4v_msiq_setstate(pbm->devhandle, msiqid, HV_MSIQSTATE_IDLE))
855 return -EINVAL;
856 856
857 return irq; 857 return irq;
858} 858}
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index cbfaaa2475e..3bd37bdf1b8 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1165,7 +1165,7 @@ again:
1165 */ 1165 */
1166 c = &unconstrained; 1166 c = &unconstrained;
1167 } else if (intel_try_alt_er(event, orig_idx)) { 1167 } else if (intel_try_alt_er(event, orig_idx)) {
1168 raw_spin_unlock(&era->lock); 1168 raw_spin_unlock_irqrestore(&era->lock, flags);
1169 goto again; 1169 goto again;
1170 } 1170 }
1171 raw_spin_unlock_irqrestore(&era->lock, flags); 1171 raw_spin_unlock_irqrestore(&era->lock, flags);
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 3b97a80ce32..c99f9ed013d 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -116,16 +116,16 @@ void show_registers(struct pt_regs *regs)
116 for (i = 0; i < code_len; i++, ip++) { 116 for (i = 0; i < code_len; i++, ip++) {
117 if (ip < (u8 *)PAGE_OFFSET || 117 if (ip < (u8 *)PAGE_OFFSET ||
118 probe_kernel_address(ip, c)) { 118 probe_kernel_address(ip, c)) {
119 printk(" Bad EIP value."); 119 printk(KERN_CONT " Bad EIP value.");
120 break; 120 break;
121 } 121 }
122 if (ip == (u8 *)regs->ip) 122 if (ip == (u8 *)regs->ip)
123 printk("<%02x> ", c); 123 printk(KERN_CONT "<%02x> ", c);
124 else 124 else
125 printk("%02x ", c); 125 printk(KERN_CONT "%02x ", c);
126 } 126 }
127 } 127 }
128 printk("\n"); 128 printk(KERN_CONT "\n");
129} 129}
130 130
131int is_valid_bugaddr(unsigned long ip) 131int is_valid_bugaddr(unsigned long ip)
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 19853ad8afc..6d728d9284b 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -284,16 +284,16 @@ void show_registers(struct pt_regs *regs)
284 for (i = 0; i < code_len; i++, ip++) { 284 for (i = 0; i < code_len; i++, ip++) {
285 if (ip < (u8 *)PAGE_OFFSET || 285 if (ip < (u8 *)PAGE_OFFSET ||
286 probe_kernel_address(ip, c)) { 286 probe_kernel_address(ip, c)) {
287 printk(" Bad RIP value."); 287 printk(KERN_CONT " Bad RIP value.");
288 break; 288 break;
289 } 289 }
290 if (ip == (u8 *)regs->ip) 290 if (ip == (u8 *)regs->ip)
291 printk("<%02x> ", c); 291 printk(KERN_CONT "<%02x> ", c);
292 else 292 else
293 printk("%02x ", c); 293 printk(KERN_CONT "%02x ", c);
294 } 294 }
295 } 295 }
296 printk("\n"); 296 printk(KERN_CONT "\n");
297} 297}
298 298
299int is_valid_bugaddr(unsigned long ip) 299int is_valid_bugaddr(unsigned long ip)
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 76e3f1cd036..405f2620392 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -338,11 +338,15 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
338 return HRTIMER_NORESTART; 338 return HRTIMER_NORESTART;
339} 339}
340 340
341static void create_pit_timer(struct kvm_kpit_state *ps, u32 val, int is_period) 341static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
342{ 342{
343 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
343 struct kvm_timer *pt = &ps->pit_timer; 344 struct kvm_timer *pt = &ps->pit_timer;
344 s64 interval; 345 s64 interval;
345 346
347 if (!irqchip_in_kernel(kvm))
348 return;
349
346 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ); 350 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ);
347 351
348 pr_debug("create pit timer, interval is %llu nsec\n", interval); 352 pr_debug("create pit timer, interval is %llu nsec\n", interval);
@@ -394,13 +398,13 @@ static void pit_load_count(struct kvm *kvm, int channel, u32 val)
394 /* FIXME: enhance mode 4 precision */ 398 /* FIXME: enhance mode 4 precision */
395 case 4: 399 case 4:
396 if (!(ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)) { 400 if (!(ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)) {
397 create_pit_timer(ps, val, 0); 401 create_pit_timer(kvm, val, 0);
398 } 402 }
399 break; 403 break;
400 case 2: 404 case 2:
401 case 3: 405 case 3:
402 if (!(ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)){ 406 if (!(ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)){
403 create_pit_timer(ps, val, 1); 407 create_pit_timer(kvm, val, 1);
404 } 408 }
405 break; 409 break;
406 default: 410 default:
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c38efd7b792..4c938da2ba0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -602,7 +602,6 @@ static void update_cpuid(struct kvm_vcpu *vcpu)
602{ 602{
603 struct kvm_cpuid_entry2 *best; 603 struct kvm_cpuid_entry2 *best;
604 struct kvm_lapic *apic = vcpu->arch.apic; 604 struct kvm_lapic *apic = vcpu->arch.apic;
605 u32 timer_mode_mask;
606 605
607 best = kvm_find_cpuid_entry(vcpu, 1, 0); 606 best = kvm_find_cpuid_entry(vcpu, 1, 0);
608 if (!best) 607 if (!best)
@@ -615,15 +614,12 @@ static void update_cpuid(struct kvm_vcpu *vcpu)
615 best->ecx |= bit(X86_FEATURE_OSXSAVE); 614 best->ecx |= bit(X86_FEATURE_OSXSAVE);
616 } 615 }
617 616
618 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && 617 if (apic) {
619 best->function == 0x1) { 618 if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
620 best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER); 619 apic->lapic_timer.timer_mode_mask = 3 << 17;
621 timer_mode_mask = 3 << 17; 620 else
622 } else 621 apic->lapic_timer.timer_mode_mask = 1 << 17;
623 timer_mode_mask = 1 << 17; 622 }
624
625 if (apic)
626 apic->lapic_timer.timer_mode_mask = timer_mode_mask;
627} 623}
628 624
629int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) 625int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
@@ -2135,6 +2131,9 @@ int kvm_dev_ioctl_check_extension(long ext)
2135 case KVM_CAP_TSC_CONTROL: 2131 case KVM_CAP_TSC_CONTROL:
2136 r = kvm_has_tsc_control; 2132 r = kvm_has_tsc_control;
2137 break; 2133 break;
2134 case KVM_CAP_TSC_DEADLINE_TIMER:
2135 r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
2136 break;
2138 default: 2137 default:
2139 r = 0; 2138 r = 0;
2140 break; 2139 break;
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index bfab3fa10ed..7b65f752c5f 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -568,8 +568,8 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
568 break; 568 break;
569 } 569 }
570 if (filter[i].jt != 0) { 570 if (filter[i].jt != 0) {
571 if (filter[i].jf) 571 if (filter[i].jf && f_offset)
572 t_offset += is_near(f_offset) ? 2 : 6; 572 t_offset += is_near(f_offset) ? 2 : 5;
573 EMIT_COND_JMP(t_op, t_offset); 573 EMIT_COND_JMP(t_op, t_offset);
574 if (filter[i].jf) 574 if (filter[i].jf)
575 EMIT_JMP(f_offset); 575 EMIT_JMP(f_offset);
diff --git a/block/blk-map.c b/block/blk-map.c
index 164cd005970..623e1cd4cff 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -311,7 +311,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
311 if (IS_ERR(bio)) 311 if (IS_ERR(bio))
312 return PTR_ERR(bio); 312 return PTR_ERR(bio);
313 313
314 if (rq_data_dir(rq) == WRITE) 314 if (!reading)
315 bio->bi_rw |= REQ_WRITE; 315 bio->bi_rw |= REQ_WRITE;
316 316
317 if (do_copy) 317 if (do_copy)
diff --git a/block/blk-tag.c b/block/blk-tag.c
index e74d6d13838..4af6f5cc116 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -282,18 +282,9 @@ EXPORT_SYMBOL(blk_queue_resize_tags);
282void blk_queue_end_tag(struct request_queue *q, struct request *rq) 282void blk_queue_end_tag(struct request_queue *q, struct request *rq)
283{ 283{
284 struct blk_queue_tag *bqt = q->queue_tags; 284 struct blk_queue_tag *bqt = q->queue_tags;
285 int tag = rq->tag; 285 unsigned tag = rq->tag; /* negative tags invalid */
286 286
287 BUG_ON(tag == -1); 287 BUG_ON(tag >= bqt->real_max_depth);
288
289 if (unlikely(tag >= bqt->max_depth)) {
290 /*
291 * This can happen after tag depth has been reduced.
292 * But tag shouldn't be larger than real_max_depth.
293 */
294 WARN_ON(tag >= bqt->real_max_depth);
295 return;
296 }
297 288
298 list_del_init(&rq->queuelist); 289 list_del_init(&rq->queuelist);
299 rq->cmd_flags &= ~REQ_QUEUED; 290 rq->cmd_flags &= ~REQ_QUEUED;
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 4c12869fcf7..3548705b04e 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1655,6 +1655,8 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
1655 struct request *next) 1655 struct request *next)
1656{ 1656{
1657 struct cfq_queue *cfqq = RQ_CFQQ(rq); 1657 struct cfq_queue *cfqq = RQ_CFQQ(rq);
1658 struct cfq_data *cfqd = q->elevator->elevator_data;
1659
1658 /* 1660 /*
1659 * reposition in fifo if next is older than rq 1661 * reposition in fifo if next is older than rq
1660 */ 1662 */
@@ -1669,6 +1671,16 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
1669 cfq_remove_request(next); 1671 cfq_remove_request(next);
1670 cfq_blkiocg_update_io_merged_stats(&(RQ_CFQG(rq))->blkg, 1672 cfq_blkiocg_update_io_merged_stats(&(RQ_CFQG(rq))->blkg,
1671 rq_data_dir(next), rq_is_sync(next)); 1673 rq_data_dir(next), rq_is_sync(next));
1674
1675 cfqq = RQ_CFQQ(next);
1676 /*
1677 * all requests of this queue are merged to other queues, delete it
1678 * from the service tree. If it's the active_queue,
1679 * cfq_dispatch_requests() will choose to expire it or do idle
1680 */
1681 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list) &&
1682 cfqq != cfqd->active_queue)
1683 cfq_del_cfqq_rr(cfqd, cfqq);
1672} 1684}
1673 1685
1674static int cfq_allow_merge(struct request_queue *q, struct request *rq, 1686static int cfq_allow_merge(struct request_queue *q, struct request *rq,
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 6bdedd7cca2..cf047c406d9 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -820,7 +820,7 @@ config PATA_PLATFORM
820 820
821config PATA_OF_PLATFORM 821config PATA_OF_PLATFORM
822 tristate "OpenFirmware platform device PATA support" 822 tristate "OpenFirmware platform device PATA support"
823 depends on PATA_PLATFORM && OF 823 depends on PATA_PLATFORM && OF && OF_IRQ
824 help 824 help
825 This option enables support for generic directly connected ATA 825 This option enables support for generic directly connected ATA
826 devices commonly found on embedded systems with OpenFirmware 826 devices commonly found on embedded systems with OpenFirmware
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index c2917ffad2c..34767a6d7f4 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -139,6 +139,8 @@
139#define IPMI_WDOG_SET_TIMER 0x24 139#define IPMI_WDOG_SET_TIMER 0x24
140#define IPMI_WDOG_GET_TIMER 0x25 140#define IPMI_WDOG_GET_TIMER 0x25
141 141
142#define IPMI_WDOG_TIMER_NOT_INIT_RESP 0x80
143
142/* These are here until the real ones get into the watchdog.h interface. */ 144/* These are here until the real ones get into the watchdog.h interface. */
143#ifndef WDIOC_GETTIMEOUT 145#ifndef WDIOC_GETTIMEOUT
144#define WDIOC_GETTIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 20, int) 146#define WDIOC_GETTIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 20, int)
@@ -596,6 +598,7 @@ static int ipmi_heartbeat(void)
596 struct kernel_ipmi_msg msg; 598 struct kernel_ipmi_msg msg;
597 int rv; 599 int rv;
598 struct ipmi_system_interface_addr addr; 600 struct ipmi_system_interface_addr addr;
601 int timeout_retries = 0;
599 602
600 if (ipmi_ignore_heartbeat) 603 if (ipmi_ignore_heartbeat)
601 return 0; 604 return 0;
@@ -616,6 +619,7 @@ static int ipmi_heartbeat(void)
616 619
617 mutex_lock(&heartbeat_lock); 620 mutex_lock(&heartbeat_lock);
618 621
622restart:
619 atomic_set(&heartbeat_tofree, 2); 623 atomic_set(&heartbeat_tofree, 2);
620 624
621 /* 625 /*
@@ -653,7 +657,33 @@ static int ipmi_heartbeat(void)
653 /* Wait for the heartbeat to be sent. */ 657 /* Wait for the heartbeat to be sent. */
654 wait_for_completion(&heartbeat_wait); 658 wait_for_completion(&heartbeat_wait);
655 659
656 if (heartbeat_recv_msg.msg.data[0] != 0) { 660 if (heartbeat_recv_msg.msg.data[0] == IPMI_WDOG_TIMER_NOT_INIT_RESP) {
661 timeout_retries++;
662 if (timeout_retries > 3) {
663 printk(KERN_ERR PFX ": Unable to restore the IPMI"
664 " watchdog's settings, giving up.\n");
665 rv = -EIO;
666 goto out_unlock;
667 }
668
669 /*
670 * The timer was not initialized, that means the BMC was
671 * probably reset and lost the watchdog information. Attempt
672 * to restore the timer's info. Note that we still hold
673 * the heartbeat lock, to keep a heartbeat from happening
674 * in this process, so must say no heartbeat to avoid a
675 * deadlock on this mutex.
676 */
677 rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
678 if (rv) {
679 printk(KERN_ERR PFX ": Unable to send the command to"
680 " set the watchdog's settings, giving up.\n");
681 goto out_unlock;
682 }
683
684 /* We might need a new heartbeat, so do it now */
685 goto restart;
686 } else if (heartbeat_recv_msg.msg.data[0] != 0) {
657 /* 687 /*
658 * Got an error in the heartbeat response. It was already 688 * Got an error in the heartbeat response. It was already
659 * reported in ipmi_wdog_msg_handler, but we should return 689 * reported in ipmi_wdog_msg_handler, but we should return
@@ -662,6 +692,7 @@ static int ipmi_heartbeat(void)
662 rv = -EINVAL; 692 rv = -EINVAL;
663 } 693 }
664 694
695out_unlock:
665 mutex_unlock(&heartbeat_lock); 696 mutex_unlock(&heartbeat_lock);
666 697
667 return rv; 698 return rv;
@@ -922,11 +953,15 @@ static struct miscdevice ipmi_wdog_miscdev = {
922static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg, 953static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg,
923 void *handler_data) 954 void *handler_data)
924{ 955{
925 if (msg->msg.data[0] != 0) { 956 if (msg->msg.cmd == IPMI_WDOG_RESET_TIMER &&
957 msg->msg.data[0] == IPMI_WDOG_TIMER_NOT_INIT_RESP)
958 printk(KERN_INFO PFX "response: The IPMI controller appears"
959 " to have been reset, will attempt to reinitialize"
960 " the watchdog timer\n");
961 else if (msg->msg.data[0] != 0)
926 printk(KERN_ERR PFX "response: Error %x on cmd %x\n", 962 printk(KERN_ERR PFX "response: Error %x on cmd %x\n",
927 msg->msg.data[0], 963 msg->msg.data[0],
928 msg->msg.cmd); 964 msg->msg.cmd);
929 }
930 965
931 ipmi_free_recv_msg(msg); 966 ipmi_free_recv_msg(msg);
932} 967}
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ab8f469f5cf..5a99bb3f255 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -124,7 +124,7 @@ config MV_XOR
124 124
125config MX3_IPU 125config MX3_IPU
126 bool "MX3x Image Processing Unit support" 126 bool "MX3x Image Processing Unit support"
127 depends on ARCH_MX3 127 depends on SOC_IMX31 || SOC_IMX35
128 select DMA_ENGINE 128 select DMA_ENGINE
129 default y 129 default y
130 help 130 help
@@ -216,7 +216,7 @@ config PCH_DMA
216 216
217config IMX_SDMA 217config IMX_SDMA
218 tristate "i.MX SDMA support" 218 tristate "i.MX SDMA support"
219 depends on ARCH_MX25 || ARCH_MX3 || ARCH_MX5 219 depends on ARCH_MX25 || SOC_IMX31 || SOC_IMX35 || ARCH_MX5
220 select DMA_ENGINE 220 select DMA_ENGINE
221 help 221 help
222 Support the i.MX SDMA engine. This engine is integrated into 222 Support the i.MX SDMA engine. This engine is integrated into
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index c681dc149d2..b9da8900ae4 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -756,9 +756,9 @@ intel_enable_semaphores(struct drm_device *dev)
756 if (i915_semaphores >= 0) 756 if (i915_semaphores >= 0)
757 return i915_semaphores; 757 return i915_semaphores;
758 758
759 /* Enable semaphores on SNB when IO remapping is off */ 759 /* Disable semaphores on SNB */
760 if (INTEL_INFO(dev)->gen == 6) 760 if (INTEL_INFO(dev)->gen == 6)
761 return !intel_iommu_enabled; 761 return 0;
762 762
763 return 1; 763 return 1;
764} 764}
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d809b038ca8..daa5743ccbd 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7922,13 +7922,11 @@ static bool intel_enable_rc6(struct drm_device *dev)
7922 return 0; 7922 return 0;
7923 7923
7924 /* 7924 /*
7925 * Enable rc6 on Sandybridge if DMA remapping is disabled 7925 * Disable rc6 on Sandybridge
7926 */ 7926 */
7927 if (INTEL_INFO(dev)->gen == 6) { 7927 if (INTEL_INFO(dev)->gen == 6) {
7928 DRM_DEBUG_DRIVER("Sandybridge: intel_iommu_enabled %s -- RC6 %sabled\n", 7928 DRM_DEBUG_DRIVER("Sandybridge: RC6 disabled\n");
7929 intel_iommu_enabled ? "true" : "false", 7929 return 0;
7930 !intel_iommu_enabled ? "en" : "dis");
7931 return !intel_iommu_enabled;
7932 } 7930 }
7933 DRM_DEBUG_DRIVER("RC6 enabled\n"); 7931 DRM_DEBUG_DRIVER("RC6 enabled\n");
7934 return 1; 7932 return 1;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 5e00d1670aa..92c9628c572 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3276,6 +3276,18 @@ int evergreen_init(struct radeon_device *rdev)
3276 rdev->accel_working = false; 3276 rdev->accel_working = false;
3277 } 3277 }
3278 } 3278 }
3279
3280 /* Don't start up if the MC ucode is missing on BTC parts.
3281 * The default clocks and voltages before the MC ucode
3282 * is loaded are not suffient for advanced operations.
3283 */
3284 if (ASIC_IS_DCE5(rdev)) {
3285 if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) {
3286 DRM_ERROR("radeon: MC ucode required for NI+.\n");
3287 return -EINVAL;
3288 }
3289 }
3290
3279 return 0; 3291 return 0;
3280} 3292}
3281 3293
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index d24baf30efc..5082d17d14d 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2560,7 +2560,11 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
2560 2560
2561 rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; 2561 rdev->pm.current_power_state_index = rdev->pm.default_power_state_index;
2562 rdev->pm.current_clock_mode_index = 0; 2562 rdev->pm.current_clock_mode_index = 0;
2563 rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage; 2563 if (rdev->pm.default_power_state_index >= 0)
2564 rdev->pm.current_vddc =
2565 rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage;
2566 else
2567 rdev->pm.current_vddc = 0;
2564} 2568}
2565 2569
2566void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable) 2570void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 8cca91a93bd..dc279706ca7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -390,6 +390,11 @@ extern int vmw_context_check(struct vmw_private *dev_priv,
390 struct ttm_object_file *tfile, 390 struct ttm_object_file *tfile,
391 int id, 391 int id,
392 struct vmw_resource **p_res); 392 struct vmw_resource **p_res);
393extern int vmw_user_lookup_handle(struct vmw_private *dev_priv,
394 struct ttm_object_file *tfile,
395 uint32_t handle,
396 struct vmw_surface **out_surf,
397 struct vmw_dma_buffer **out_buf);
393extern void vmw_surface_res_free(struct vmw_resource *res); 398extern void vmw_surface_res_free(struct vmw_resource *res);
394extern int vmw_surface_init(struct vmw_private *dev_priv, 399extern int vmw_surface_init(struct vmw_private *dev_priv,
395 struct vmw_surface *srf, 400 struct vmw_surface *srf,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
index 03bbc2a6f9a..a0c2f12b1e1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
@@ -33,6 +33,7 @@ bool vmw_fifo_have_3d(struct vmw_private *dev_priv)
33{ 33{
34 __le32 __iomem *fifo_mem = dev_priv->mmio_virt; 34 __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
35 uint32_t fifo_min, hwversion; 35 uint32_t fifo_min, hwversion;
36 const struct vmw_fifo_state *fifo = &dev_priv->fifo;
36 37
37 if (!(dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO)) 38 if (!(dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO))
38 return false; 39 return false;
@@ -41,7 +42,12 @@ bool vmw_fifo_have_3d(struct vmw_private *dev_priv)
41 if (fifo_min <= SVGA_FIFO_3D_HWVERSION * sizeof(unsigned int)) 42 if (fifo_min <= SVGA_FIFO_3D_HWVERSION * sizeof(unsigned int))
42 return false; 43 return false;
43 44
44 hwversion = ioread32(fifo_mem + SVGA_FIFO_3D_HWVERSION); 45 hwversion = ioread32(fifo_mem +
46 ((fifo->capabilities &
47 SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ?
48 SVGA_FIFO_3D_HWVERSION_REVISED :
49 SVGA_FIFO_3D_HWVERSION));
50
45 if (hwversion == 0) 51 if (hwversion == 0)
46 return false; 52 return false;
47 53
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index 5ff561d4e0b..66917c6c381 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -58,8 +58,14 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
58 case DRM_VMW_PARAM_FIFO_HW_VERSION: 58 case DRM_VMW_PARAM_FIFO_HW_VERSION:
59 { 59 {
60 __le32 __iomem *fifo_mem = dev_priv->mmio_virt; 60 __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
61 61 const struct vmw_fifo_state *fifo = &dev_priv->fifo;
62 param->value = ioread32(fifo_mem + SVGA_FIFO_3D_HWVERSION); 62
63 param->value =
64 ioread32(fifo_mem +
65 ((fifo->capabilities &
66 SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ?
67 SVGA_FIFO_3D_HWVERSION_REVISED :
68 SVGA_FIFO_3D_HWVERSION));
63 break; 69 break;
64 } 70 }
65 default: 71 default:
@@ -166,13 +172,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
166 ret = -EINVAL; 172 ret = -EINVAL;
167 goto out_no_fb; 173 goto out_no_fb;
168 } 174 }
169
170 vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj)); 175 vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj));
171 if (!vfb->dmabuf) {
172 DRM_ERROR("Framebuffer not dmabuf backed.\n");
173 ret = -EINVAL;
174 goto out_no_fb;
175 }
176 176
177 ret = ttm_read_lock(&vmaster->lock, true); 177 ret = ttm_read_lock(&vmaster->lock, true);
178 if (unlikely(ret != 0)) 178 if (unlikely(ret != 0))
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 37d40545ed7..f94b33ae221 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -31,6 +31,44 @@
31/* Might need a hrtimer here? */ 31/* Might need a hrtimer here? */
32#define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1) 32#define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1)
33 33
34
35struct vmw_clip_rect {
36 int x1, x2, y1, y2;
37};
38
39/**
40 * Clip @num_rects number of @rects against @clip storing the
41 * results in @out_rects and the number of passed rects in @out_num.
42 */
43void vmw_clip_cliprects(struct drm_clip_rect *rects,
44 int num_rects,
45 struct vmw_clip_rect clip,
46 SVGASignedRect *out_rects,
47 int *out_num)
48{
49 int i, k;
50
51 for (i = 0, k = 0; i < num_rects; i++) {
52 int x1 = max_t(int, clip.x1, rects[i].x1);
53 int y1 = max_t(int, clip.y1, rects[i].y1);
54 int x2 = min_t(int, clip.x2, rects[i].x2);
55 int y2 = min_t(int, clip.y2, rects[i].y2);
56
57 if (x1 >= x2)
58 continue;
59 if (y1 >= y2)
60 continue;
61
62 out_rects[k].left = x1;
63 out_rects[k].top = y1;
64 out_rects[k].right = x2;
65 out_rects[k].bottom = y2;
66 k++;
67 }
68
69 *out_num = k;
70}
71
34void vmw_display_unit_cleanup(struct vmw_display_unit *du) 72void vmw_display_unit_cleanup(struct vmw_display_unit *du)
35{ 73{
36 if (du->cursor_surface) 74 if (du->cursor_surface)
@@ -82,6 +120,43 @@ int vmw_cursor_update_image(struct vmw_private *dev_priv,
82 return 0; 120 return 0;
83} 121}
84 122
123int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
124 struct vmw_dma_buffer *dmabuf,
125 u32 width, u32 height,
126 u32 hotspotX, u32 hotspotY)
127{
128 struct ttm_bo_kmap_obj map;
129 unsigned long kmap_offset;
130 unsigned long kmap_num;
131 void *virtual;
132 bool dummy;
133 int ret;
134
135 kmap_offset = 0;
136 kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT;
137
138 ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0);
139 if (unlikely(ret != 0)) {
140 DRM_ERROR("reserve failed\n");
141 return -EINVAL;
142 }
143
144 ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map);
145 if (unlikely(ret != 0))
146 goto err_unreserve;
147
148 virtual = ttm_kmap_obj_virtual(&map, &dummy);
149 ret = vmw_cursor_update_image(dev_priv, virtual, width, height,
150 hotspotX, hotspotY);
151
152 ttm_bo_kunmap(&map);
153err_unreserve:
154 ttm_bo_unreserve(&dmabuf->base);
155
156 return ret;
157}
158
159
85void vmw_cursor_update_position(struct vmw_private *dev_priv, 160void vmw_cursor_update_position(struct vmw_private *dev_priv,
86 bool show, int x, int y) 161 bool show, int x, int y)
87{ 162{
@@ -110,24 +185,21 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
110 return -EINVAL; 185 return -EINVAL;
111 186
112 if (handle) { 187 if (handle) {
113 ret = vmw_user_surface_lookup_handle(dev_priv, tfile, 188 ret = vmw_user_lookup_handle(dev_priv, tfile,
114 handle, &surface); 189 handle, &surface, &dmabuf);
115 if (!ret) { 190 if (ret) {
116 if (!surface->snooper.image) { 191 DRM_ERROR("failed to find surface or dmabuf: %i\n", ret);
117 DRM_ERROR("surface not suitable for cursor\n"); 192 return -EINVAL;
118 vmw_surface_unreference(&surface);
119 return -EINVAL;
120 }
121 } else {
122 ret = vmw_user_dmabuf_lookup(tfile,
123 handle, &dmabuf);
124 if (ret) {
125 DRM_ERROR("failed to find surface or dmabuf: %i\n", ret);
126 return -EINVAL;
127 }
128 } 193 }
129 } 194 }
130 195
196 /* need to do this before taking down old image */
197 if (surface && !surface->snooper.image) {
198 DRM_ERROR("surface not suitable for cursor\n");
199 vmw_surface_unreference(&surface);
200 return -EINVAL;
201 }
202
131 /* takedown old cursor */ 203 /* takedown old cursor */
132 if (du->cursor_surface) { 204 if (du->cursor_surface) {
133 du->cursor_surface->snooper.crtc = NULL; 205 du->cursor_surface->snooper.crtc = NULL;
@@ -146,36 +218,11 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
146 vmw_cursor_update_image(dev_priv, surface->snooper.image, 218 vmw_cursor_update_image(dev_priv, surface->snooper.image,
147 64, 64, du->hotspot_x, du->hotspot_y); 219 64, 64, du->hotspot_x, du->hotspot_y);
148 } else if (dmabuf) { 220 } else if (dmabuf) {
149 struct ttm_bo_kmap_obj map;
150 unsigned long kmap_offset;
151 unsigned long kmap_num;
152 void *virtual;
153 bool dummy;
154
155 /* vmw_user_surface_lookup takes one reference */ 221 /* vmw_user_surface_lookup takes one reference */
156 du->cursor_dmabuf = dmabuf; 222 du->cursor_dmabuf = dmabuf;
157 223
158 kmap_offset = 0; 224 ret = vmw_cursor_update_dmabuf(dev_priv, dmabuf, width, height,
159 kmap_num = (64*64*4) >> PAGE_SHIFT; 225 du->hotspot_x, du->hotspot_y);
160
161 ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0);
162 if (unlikely(ret != 0)) {
163 DRM_ERROR("reserve failed\n");
164 return -EINVAL;
165 }
166
167 ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map);
168 if (unlikely(ret != 0))
169 goto err_unreserve;
170
171 virtual = ttm_kmap_obj_virtual(&map, &dummy);
172 vmw_cursor_update_image(dev_priv, virtual, 64, 64,
173 du->hotspot_x, du->hotspot_y);
174
175 ttm_bo_kunmap(&map);
176err_unreserve:
177 ttm_bo_unreserve(&dmabuf->base);
178
179 } else { 226 } else {
180 vmw_cursor_update_position(dev_priv, false, 0, 0); 227 vmw_cursor_update_position(dev_priv, false, 0, 0);
181 return 0; 228 return 0;
@@ -377,8 +424,9 @@ static int do_surface_dirty_sou(struct vmw_private *dev_priv,
377 struct drm_clip_rect *clips, 424 struct drm_clip_rect *clips,
378 unsigned num_clips, int inc) 425 unsigned num_clips, int inc)
379{ 426{
380 struct drm_clip_rect *clips_ptr;
381 struct vmw_display_unit *units[VMWGFX_NUM_DISPLAY_UNITS]; 427 struct vmw_display_unit *units[VMWGFX_NUM_DISPLAY_UNITS];
428 struct drm_clip_rect *clips_ptr;
429 struct drm_clip_rect *tmp;
382 struct drm_crtc *crtc; 430 struct drm_crtc *crtc;
383 size_t fifo_size; 431 size_t fifo_size;
384 int i, num_units; 432 int i, num_units;
@@ -391,7 +439,6 @@ static int do_surface_dirty_sou(struct vmw_private *dev_priv,
391 } *cmd; 439 } *cmd;
392 SVGASignedRect *blits; 440 SVGASignedRect *blits;
393 441
394
395 num_units = 0; 442 num_units = 0;
396 list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, 443 list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list,
397 head) { 444 head) {
@@ -402,13 +449,24 @@ static int do_surface_dirty_sou(struct vmw_private *dev_priv,
402 449
403 BUG_ON(!clips || !num_clips); 450 BUG_ON(!clips || !num_clips);
404 451
452 tmp = kzalloc(sizeof(*tmp) * num_clips, GFP_KERNEL);
453 if (unlikely(tmp == NULL)) {
454 DRM_ERROR("Temporary cliprect memory alloc failed.\n");
455 return -ENOMEM;
456 }
457
405 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num_clips; 458 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num_clips;
406 cmd = kzalloc(fifo_size, GFP_KERNEL); 459 cmd = kzalloc(fifo_size, GFP_KERNEL);
407 if (unlikely(cmd == NULL)) { 460 if (unlikely(cmd == NULL)) {
408 DRM_ERROR("Temporary fifo memory alloc failed.\n"); 461 DRM_ERROR("Temporary fifo memory alloc failed.\n");
409 return -ENOMEM; 462 ret = -ENOMEM;
463 goto out_free_tmp;
410 } 464 }
411 465
466 /* setup blits pointer */
467 blits = (SVGASignedRect *)&cmd[1];
468
469 /* initial clip region */
412 left = clips->x1; 470 left = clips->x1;
413 right = clips->x2; 471 right = clips->x2;
414 top = clips->y1; 472 top = clips->y1;
@@ -434,45 +492,60 @@ static int do_surface_dirty_sou(struct vmw_private *dev_priv,
434 cmd->body.srcRect.bottom = bottom; 492 cmd->body.srcRect.bottom = bottom;
435 493
436 clips_ptr = clips; 494 clips_ptr = clips;
437 blits = (SVGASignedRect *)&cmd[1];
438 for (i = 0; i < num_clips; i++, clips_ptr += inc) { 495 for (i = 0; i < num_clips; i++, clips_ptr += inc) {
439 blits[i].left = clips_ptr->x1 - left; 496 tmp[i].x1 = clips_ptr->x1 - left;
440 blits[i].right = clips_ptr->x2 - left; 497 tmp[i].x2 = clips_ptr->x2 - left;
441 blits[i].top = clips_ptr->y1 - top; 498 tmp[i].y1 = clips_ptr->y1 - top;
442 blits[i].bottom = clips_ptr->y2 - top; 499 tmp[i].y2 = clips_ptr->y2 - top;
443 } 500 }
444 501
445 /* do per unit writing, reuse fifo for each */ 502 /* do per unit writing, reuse fifo for each */
446 for (i = 0; i < num_units; i++) { 503 for (i = 0; i < num_units; i++) {
447 struct vmw_display_unit *unit = units[i]; 504 struct vmw_display_unit *unit = units[i];
448 int clip_x1 = left - unit->crtc.x; 505 struct vmw_clip_rect clip;
449 int clip_y1 = top - unit->crtc.y; 506 int num;
450 int clip_x2 = right - unit->crtc.x; 507
451 int clip_y2 = bottom - unit->crtc.y; 508 clip.x1 = left - unit->crtc.x;
509 clip.y1 = top - unit->crtc.y;
510 clip.x2 = right - unit->crtc.x;
511 clip.y2 = bottom - unit->crtc.y;
452 512
453 /* skip any crtcs that misses the clip region */ 513 /* skip any crtcs that misses the clip region */
454 if (clip_x1 >= unit->crtc.mode.hdisplay || 514 if (clip.x1 >= unit->crtc.mode.hdisplay ||
455 clip_y1 >= unit->crtc.mode.vdisplay || 515 clip.y1 >= unit->crtc.mode.vdisplay ||
456 clip_x2 <= 0 || clip_y2 <= 0) 516 clip.x2 <= 0 || clip.y2 <= 0)
457 continue; 517 continue;
458 518
519 /*
520 * In order for the clip rects to be correctly scaled
521 * the src and dest rects needs to be the same size.
522 */
523 cmd->body.destRect.left = clip.x1;
524 cmd->body.destRect.right = clip.x2;
525 cmd->body.destRect.top = clip.y1;
526 cmd->body.destRect.bottom = clip.y2;
527
528 /* create a clip rect of the crtc in dest coords */
529 clip.x2 = unit->crtc.mode.hdisplay - clip.x1;
530 clip.y2 = unit->crtc.mode.vdisplay - clip.y1;
531 clip.x1 = 0 - clip.x1;
532 clip.y1 = 0 - clip.y1;
533
459 /* need to reset sid as it is changed by execbuf */ 534 /* need to reset sid as it is changed by execbuf */
460 cmd->body.srcImage.sid = cpu_to_le32(framebuffer->user_handle); 535 cmd->body.srcImage.sid = cpu_to_le32(framebuffer->user_handle);
461
462 cmd->body.destScreenId = unit->unit; 536 cmd->body.destScreenId = unit->unit;
463 537
464 /* 538 /* clip and write blits to cmd stream */
465 * The blit command is a lot more resilient then the 539 vmw_clip_cliprects(tmp, num_clips, clip, blits, &num);
466 * readback command when it comes to clip rects. So its
467 * okay to go out of bounds.
468 */
469 540
470 cmd->body.destRect.left = clip_x1; 541 /* if no cliprects hit skip this */
471 cmd->body.destRect.right = clip_x2; 542 if (num == 0)
472 cmd->body.destRect.top = clip_y1; 543 continue;
473 cmd->body.destRect.bottom = clip_y2;
474 544
475 545
546 /* recalculate package length */
547 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num;
548 cmd->header.size = cpu_to_le32(fifo_size - sizeof(cmd->header));
476 ret = vmw_execbuf_process(file_priv, dev_priv, NULL, cmd, 549 ret = vmw_execbuf_process(file_priv, dev_priv, NULL, cmd,
477 fifo_size, 0, NULL); 550 fifo_size, 0, NULL);
478 551
@@ -480,7 +553,10 @@ static int do_surface_dirty_sou(struct vmw_private *dev_priv,
480 break; 553 break;
481 } 554 }
482 555
556
483 kfree(cmd); 557 kfree(cmd);
558out_free_tmp:
559 kfree(tmp);
484 560
485 return ret; 561 return ret;
486} 562}
@@ -556,6 +632,10 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
556 * Sanity checks. 632 * Sanity checks.
557 */ 633 */
558 634
635 /* Surface must be marked as a scanout. */
636 if (unlikely(!surface->scanout))
637 return -EINVAL;
638
559 if (unlikely(surface->mip_levels[0] != 1 || 639 if (unlikely(surface->mip_levels[0] != 1 ||
560 surface->num_sizes != 1 || 640 surface->num_sizes != 1 ||
561 surface->sizes[0].width < mode_cmd->width || 641 surface->sizes[0].width < mode_cmd->width ||
@@ -782,6 +862,7 @@ static int do_dmabuf_dirty_sou(struct drm_file *file_priv,
782 int clip_y1 = clips_ptr->y1 - unit->crtc.y; 862 int clip_y1 = clips_ptr->y1 - unit->crtc.y;
783 int clip_x2 = clips_ptr->x2 - unit->crtc.x; 863 int clip_x2 = clips_ptr->x2 - unit->crtc.x;
784 int clip_y2 = clips_ptr->y2 - unit->crtc.y; 864 int clip_y2 = clips_ptr->y2 - unit->crtc.y;
865 int move_x, move_y;
785 866
786 /* skip any crtcs that misses the clip region */ 867 /* skip any crtcs that misses the clip region */
787 if (clip_x1 >= unit->crtc.mode.hdisplay || 868 if (clip_x1 >= unit->crtc.mode.hdisplay ||
@@ -789,12 +870,21 @@ static int do_dmabuf_dirty_sou(struct drm_file *file_priv,
789 clip_x2 <= 0 || clip_y2 <= 0) 870 clip_x2 <= 0 || clip_y2 <= 0)
790 continue; 871 continue;
791 872
873 /* clip size to crtc size */
874 clip_x2 = min_t(int, clip_x2, unit->crtc.mode.hdisplay);
875 clip_y2 = min_t(int, clip_y2, unit->crtc.mode.vdisplay);
876
877 /* translate both src and dest to bring clip into screen */
878 move_x = min_t(int, clip_x1, 0);
879 move_y = min_t(int, clip_y1, 0);
880
881 /* actual translate done here */
792 blits[hit_num].header = SVGA_CMD_BLIT_GMRFB_TO_SCREEN; 882 blits[hit_num].header = SVGA_CMD_BLIT_GMRFB_TO_SCREEN;
793 blits[hit_num].body.destScreenId = unit->unit; 883 blits[hit_num].body.destScreenId = unit->unit;
794 blits[hit_num].body.srcOrigin.x = clips_ptr->x1; 884 blits[hit_num].body.srcOrigin.x = clips_ptr->x1 - move_x;
795 blits[hit_num].body.srcOrigin.y = clips_ptr->y1; 885 blits[hit_num].body.srcOrigin.y = clips_ptr->y1 - move_y;
796 blits[hit_num].body.destRect.left = clip_x1; 886 blits[hit_num].body.destRect.left = clip_x1 - move_x;
797 blits[hit_num].body.destRect.top = clip_y1; 887 blits[hit_num].body.destRect.top = clip_y1 - move_y;
798 blits[hit_num].body.destRect.right = clip_x2; 888 blits[hit_num].body.destRect.right = clip_x2;
799 blits[hit_num].body.destRect.bottom = clip_y2; 889 blits[hit_num].body.destRect.bottom = clip_y2;
800 hit_num++; 890 hit_num++;
@@ -1003,7 +1093,6 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
1003 struct vmw_surface *surface = NULL; 1093 struct vmw_surface *surface = NULL;
1004 struct vmw_dma_buffer *bo = NULL; 1094 struct vmw_dma_buffer *bo = NULL;
1005 struct ttm_base_object *user_obj; 1095 struct ttm_base_object *user_obj;
1006 u64 required_size;
1007 int ret; 1096 int ret;
1008 1097
1009 /** 1098 /**
@@ -1012,8 +1101,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
1012 * requested framebuffer. 1101 * requested framebuffer.
1013 */ 1102 */
1014 1103
1015 required_size = mode_cmd->pitch * mode_cmd->height; 1104 if (!vmw_kms_validate_mode_vram(dev_priv,
1016 if (unlikely(required_size > (u64) dev_priv->vram_size)) { 1105 mode_cmd->pitch,
1106 mode_cmd->height)) {
1017 DRM_ERROR("VRAM size is too small for requested mode.\n"); 1107 DRM_ERROR("VRAM size is too small for requested mode.\n");
1018 return ERR_PTR(-ENOMEM); 1108 return ERR_PTR(-ENOMEM);
1019 } 1109 }
@@ -1033,46 +1123,29 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
1033 return ERR_PTR(-ENOENT); 1123 return ERR_PTR(-ENOENT);
1034 } 1124 }
1035 1125
1036 /** 1126 /* returns either a dmabuf or surface */
1037 * End conditioned code. 1127 ret = vmw_user_lookup_handle(dev_priv, tfile,
1038 */ 1128 mode_cmd->handle,
1039 1129 &surface, &bo);
1040 ret = vmw_user_surface_lookup_handle(dev_priv, tfile,
1041 mode_cmd->handle, &surface);
1042 if (ret) 1130 if (ret)
1043 goto try_dmabuf; 1131 goto err_out;
1044 1132
1045 if (!surface->scanout) 1133 /* Create the new framebuffer depending one what we got back */
1046 goto err_not_scanout; 1134 if (bo)
1047 1135 ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb,
1048 ret = vmw_kms_new_framebuffer_surface(dev_priv, file_priv, surface, 1136 mode_cmd);
1049 &vfb, mode_cmd); 1137 else if (surface)
1050 1138 ret = vmw_kms_new_framebuffer_surface(dev_priv, file_priv,
1051 /* vmw_user_surface_lookup takes one ref so does new_fb */ 1139 surface, &vfb, mode_cmd);
1052 vmw_surface_unreference(&surface); 1140 else
1053 1141 BUG();
1054 if (ret) {
1055 DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
1056 ttm_base_object_unref(&user_obj);
1057 return ERR_PTR(ret);
1058 } else
1059 vfb->user_obj = user_obj;
1060 return &vfb->base;
1061
1062try_dmabuf:
1063 DRM_INFO("%s: trying buffer\n", __func__);
1064
1065 ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo);
1066 if (ret) {
1067 DRM_ERROR("failed to find buffer: %i\n", ret);
1068 return ERR_PTR(-ENOENT);
1069 }
1070
1071 ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb,
1072 mode_cmd);
1073 1142
1074 /* vmw_user_dmabuf_lookup takes one ref so does new_fb */ 1143err_out:
1075 vmw_dmabuf_unreference(&bo); 1144 /* vmw_user_lookup_handle takes one ref so does new_fb */
1145 if (bo)
1146 vmw_dmabuf_unreference(&bo);
1147 if (surface)
1148 vmw_surface_unreference(&surface);
1076 1149
1077 if (ret) { 1150 if (ret) {
1078 DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); 1151 DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
@@ -1082,14 +1155,6 @@ try_dmabuf:
1082 vfb->user_obj = user_obj; 1155 vfb->user_obj = user_obj;
1083 1156
1084 return &vfb->base; 1157 return &vfb->base;
1085
1086err_not_scanout:
1087 DRM_ERROR("surface not marked as scanout\n");
1088 /* vmw_user_surface_lookup takes one ref */
1089 vmw_surface_unreference(&surface);
1090 ttm_base_object_unref(&user_obj);
1091
1092 return ERR_PTR(-EINVAL);
1093} 1158}
1094 1159
1095static struct drm_mode_config_funcs vmw_kms_funcs = { 1160static struct drm_mode_config_funcs vmw_kms_funcs = {
@@ -1106,10 +1171,12 @@ int vmw_kms_present(struct vmw_private *dev_priv,
1106 uint32_t num_clips) 1171 uint32_t num_clips)
1107{ 1172{
1108 struct vmw_display_unit *units[VMWGFX_NUM_DISPLAY_UNITS]; 1173 struct vmw_display_unit *units[VMWGFX_NUM_DISPLAY_UNITS];
1174 struct drm_clip_rect *tmp;
1109 struct drm_crtc *crtc; 1175 struct drm_crtc *crtc;
1110 size_t fifo_size; 1176 size_t fifo_size;
1111 int i, k, num_units; 1177 int i, k, num_units;
1112 int ret = 0; /* silence warning */ 1178 int ret = 0; /* silence warning */
1179 int left, right, top, bottom;
1113 1180
1114 struct { 1181 struct {
1115 SVGA3dCmdHeader header; 1182 SVGA3dCmdHeader header;
@@ -1127,60 +1194,95 @@ int vmw_kms_present(struct vmw_private *dev_priv,
1127 BUG_ON(surface == NULL); 1194 BUG_ON(surface == NULL);
1128 BUG_ON(!clips || !num_clips); 1195 BUG_ON(!clips || !num_clips);
1129 1196
1197 tmp = kzalloc(sizeof(*tmp) * num_clips, GFP_KERNEL);
1198 if (unlikely(tmp == NULL)) {
1199 DRM_ERROR("Temporary cliprect memory alloc failed.\n");
1200 return -ENOMEM;
1201 }
1202
1130 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num_clips; 1203 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num_clips;
1131 cmd = kmalloc(fifo_size, GFP_KERNEL); 1204 cmd = kmalloc(fifo_size, GFP_KERNEL);
1132 if (unlikely(cmd == NULL)) { 1205 if (unlikely(cmd == NULL)) {
1133 DRM_ERROR("Failed to allocate temporary fifo memory.\n"); 1206 DRM_ERROR("Failed to allocate temporary fifo memory.\n");
1134 return -ENOMEM; 1207 ret = -ENOMEM;
1208 goto out_free_tmp;
1209 }
1210
1211 left = clips->x;
1212 right = clips->x + clips->w;
1213 top = clips->y;
1214 bottom = clips->y + clips->h;
1215
1216 for (i = 1; i < num_clips; i++) {
1217 left = min_t(int, left, (int)clips[i].x);
1218 right = max_t(int, right, (int)clips[i].x + clips[i].w);
1219 top = min_t(int, top, (int)clips[i].y);
1220 bottom = max_t(int, bottom, (int)clips[i].y + clips[i].h);
1135 } 1221 }
1136 1222
1137 /* only need to do this once */ 1223 /* only need to do this once */
1138 memset(cmd, 0, fifo_size); 1224 memset(cmd, 0, fifo_size);
1139 cmd->header.id = cpu_to_le32(SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN); 1225 cmd->header.id = cpu_to_le32(SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN);
1140 cmd->header.size = cpu_to_le32(fifo_size - sizeof(cmd->header));
1141
1142 cmd->body.srcRect.left = 0;
1143 cmd->body.srcRect.right = surface->sizes[0].width;
1144 cmd->body.srcRect.top = 0;
1145 cmd->body.srcRect.bottom = surface->sizes[0].height;
1146 1226
1147 blits = (SVGASignedRect *)&cmd[1]; 1227 blits = (SVGASignedRect *)&cmd[1];
1228
1229 cmd->body.srcRect.left = left;
1230 cmd->body.srcRect.right = right;
1231 cmd->body.srcRect.top = top;
1232 cmd->body.srcRect.bottom = bottom;
1233
1148 for (i = 0; i < num_clips; i++) { 1234 for (i = 0; i < num_clips; i++) {
1149 blits[i].left = clips[i].x; 1235 tmp[i].x1 = clips[i].x - left;
1150 blits[i].right = clips[i].x + clips[i].w; 1236 tmp[i].x2 = clips[i].x + clips[i].w - left;
1151 blits[i].top = clips[i].y; 1237 tmp[i].y1 = clips[i].y - top;
1152 blits[i].bottom = clips[i].y + clips[i].h; 1238 tmp[i].y2 = clips[i].y + clips[i].h - top;
1153 } 1239 }
1154 1240
1155 for (k = 0; k < num_units; k++) { 1241 for (k = 0; k < num_units; k++) {
1156 struct vmw_display_unit *unit = units[k]; 1242 struct vmw_display_unit *unit = units[k];
1157 int clip_x1 = destX - unit->crtc.x; 1243 struct vmw_clip_rect clip;
1158 int clip_y1 = destY - unit->crtc.y; 1244 int num;
1159 int clip_x2 = clip_x1 + surface->sizes[0].width; 1245
1160 int clip_y2 = clip_y1 + surface->sizes[0].height; 1246 clip.x1 = left + destX - unit->crtc.x;
1247 clip.y1 = top + destY - unit->crtc.y;
1248 clip.x2 = right + destX - unit->crtc.x;
1249 clip.y2 = bottom + destY - unit->crtc.y;
1161 1250
1162 /* skip any crtcs that misses the clip region */ 1251 /* skip any crtcs that misses the clip region */
1163 if (clip_x1 >= unit->crtc.mode.hdisplay || 1252 if (clip.x1 >= unit->crtc.mode.hdisplay ||
1164 clip_y1 >= unit->crtc.mode.vdisplay || 1253 clip.y1 >= unit->crtc.mode.vdisplay ||
1165 clip_x2 <= 0 || clip_y2 <= 0) 1254 clip.x2 <= 0 || clip.y2 <= 0)
1166 continue; 1255 continue;
1167 1256
1257 /*
1258 * In order for the clip rects to be correctly scaled
1259 * the src and dest rects needs to be the same size.
1260 */
1261 cmd->body.destRect.left = clip.x1;
1262 cmd->body.destRect.right = clip.x2;
1263 cmd->body.destRect.top = clip.y1;
1264 cmd->body.destRect.bottom = clip.y2;
1265
1266 /* create a clip rect of the crtc in dest coords */
1267 clip.x2 = unit->crtc.mode.hdisplay - clip.x1;
1268 clip.y2 = unit->crtc.mode.vdisplay - clip.y1;
1269 clip.x1 = 0 - clip.x1;
1270 clip.y1 = 0 - clip.y1;
1271
1168 /* need to reset sid as it is changed by execbuf */ 1272 /* need to reset sid as it is changed by execbuf */
1169 cmd->body.srcImage.sid = sid; 1273 cmd->body.srcImage.sid = sid;
1170
1171 cmd->body.destScreenId = unit->unit; 1274 cmd->body.destScreenId = unit->unit;
1172 1275
1173 /* 1276 /* clip and write blits to cmd stream */
1174 * The blit command is a lot more resilient then the 1277 vmw_clip_cliprects(tmp, num_clips, clip, blits, &num);
1175 * readback command when it comes to clip rects. So its
1176 * okay to go out of bounds.
1177 */
1178 1278
1179 cmd->body.destRect.left = clip_x1; 1279 /* if no cliprects hit skip this */
1180 cmd->body.destRect.right = clip_x2; 1280 if (num == 0)
1181 cmd->body.destRect.top = clip_y1; 1281 continue;
1182 cmd->body.destRect.bottom = clip_y2;
1183 1282
1283 /* recalculate package length */
1284 fifo_size = sizeof(*cmd) + sizeof(SVGASignedRect) * num;
1285 cmd->header.size = cpu_to_le32(fifo_size - sizeof(cmd->header));
1184 ret = vmw_execbuf_process(file_priv, dev_priv, NULL, cmd, 1286 ret = vmw_execbuf_process(file_priv, dev_priv, NULL, cmd,
1185 fifo_size, 0, NULL); 1287 fifo_size, 0, NULL);
1186 1288
@@ -1189,6 +1291,8 @@ int vmw_kms_present(struct vmw_private *dev_priv,
1189 } 1291 }
1190 1292
1191 kfree(cmd); 1293 kfree(cmd);
1294out_free_tmp:
1295 kfree(tmp);
1192 1296
1193 return ret; 1297 return ret;
1194} 1298}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index af8e6e5bd96..e1cb8556355 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -62,9 +62,14 @@ struct vmw_framebuffer {
62int vmw_cursor_update_image(struct vmw_private *dev_priv, 62int vmw_cursor_update_image(struct vmw_private *dev_priv,
63 u32 *image, u32 width, u32 height, 63 u32 *image, u32 width, u32 height,
64 u32 hotspotX, u32 hotspotY); 64 u32 hotspotX, u32 hotspotY);
65int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
66 struct vmw_dma_buffer *dmabuf,
67 u32 width, u32 height,
68 u32 hotspotX, u32 hotspotY);
65void vmw_cursor_update_position(struct vmw_private *dev_priv, 69void vmw_cursor_update_position(struct vmw_private *dev_priv,
66 bool show, int x, int y); 70 bool show, int x, int y);
67 71
72
68/** 73/**
69 * Base class display unit. 74 * Base class display unit.
70 * 75 *
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 90c5e392849..8f8dbd43c33 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -74,9 +74,10 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
74{ 74{
75 struct vmw_legacy_display *lds = dev_priv->ldu_priv; 75 struct vmw_legacy_display *lds = dev_priv->ldu_priv;
76 struct vmw_legacy_display_unit *entry; 76 struct vmw_legacy_display_unit *entry;
77 struct vmw_display_unit *du = NULL;
77 struct drm_framebuffer *fb = NULL; 78 struct drm_framebuffer *fb = NULL;
78 struct drm_crtc *crtc = NULL; 79 struct drm_crtc *crtc = NULL;
79 int i = 0; 80 int i = 0, ret;
80 81
81 /* If there is no display topology the host just assumes 82 /* If there is no display topology the host just assumes
82 * that the guest will set the same layout as the host. 83 * that the guest will set the same layout as the host.
@@ -129,6 +130,25 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
129 130
130 lds->last_num_active = lds->num_active; 131 lds->last_num_active = lds->num_active;
131 132
133
134 /* Find the first du with a cursor. */
135 list_for_each_entry(entry, &lds->active, active) {
136 du = &entry->base;
137
138 if (!du->cursor_dmabuf)
139 continue;
140
141 ret = vmw_cursor_update_dmabuf(dev_priv,
142 du->cursor_dmabuf,
143 64, 64,
144 du->hotspot_x,
145 du->hotspot_y);
146 if (ret == 0)
147 break;
148
149 DRM_ERROR("Could not update cursor image\n");
150 }
151
132 return 0; 152 return 0;
133} 153}
134 154
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 86c5e4cceb3..1c7f09e2681 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -1190,6 +1190,29 @@ void vmw_resource_unreserve(struct list_head *list)
1190 write_unlock(lock); 1190 write_unlock(lock);
1191} 1191}
1192 1192
1193/**
1194 * Helper function that looks either a surface or dmabuf.
1195 *
1196 * The pointer this pointed at by out_surf and out_buf needs to be null.
1197 */
1198int vmw_user_lookup_handle(struct vmw_private *dev_priv,
1199 struct ttm_object_file *tfile,
1200 uint32_t handle,
1201 struct vmw_surface **out_surf,
1202 struct vmw_dma_buffer **out_buf)
1203{
1204 int ret;
1205
1206 BUG_ON(*out_surf || *out_buf);
1207
1208 ret = vmw_user_surface_lookup_handle(dev_priv, tfile, handle, out_surf);
1209 if (!ret)
1210 return 0;
1211
1212 ret = vmw_user_dmabuf_lookup(tfile, handle, out_buf);
1213 return ret;
1214}
1215
1193 1216
1194int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv, 1217int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv,
1195 struct ttm_object_file *tfile, 1218 struct ttm_object_file *tfile,
diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index 8cebef49aea..18936ac9d51 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -893,6 +893,13 @@ static int __devinit pch_i2c_probe(struct pci_dev *pdev,
893 /* Set the number of I2C channel instance */ 893 /* Set the number of I2C channel instance */
894 adap_info->ch_num = id->driver_data; 894 adap_info->ch_num = id->driver_data;
895 895
896 ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED,
897 KBUILD_MODNAME, adap_info);
898 if (ret) {
899 pch_pci_err(pdev, "request_irq FAILED\n");
900 goto err_request_irq;
901 }
902
896 for (i = 0; i < adap_info->ch_num; i++) { 903 for (i = 0; i < adap_info->ch_num; i++) {
897 pch_adap = &adap_info->pch_data[i].pch_adapter; 904 pch_adap = &adap_info->pch_data[i].pch_adapter;
898 adap_info->pch_i2c_suspended = false; 905 adap_info->pch_i2c_suspended = false;
@@ -910,28 +917,23 @@ static int __devinit pch_i2c_probe(struct pci_dev *pdev,
910 917
911 pch_adap->dev.parent = &pdev->dev; 918 pch_adap->dev.parent = &pdev->dev;
912 919
920 pch_i2c_init(&adap_info->pch_data[i]);
913 ret = i2c_add_adapter(pch_adap); 921 ret = i2c_add_adapter(pch_adap);
914 if (ret) { 922 if (ret) {
915 pch_pci_err(pdev, "i2c_add_adapter[ch:%d] FAILED\n", i); 923 pch_pci_err(pdev, "i2c_add_adapter[ch:%d] FAILED\n", i);
916 goto err_i2c_add_adapter; 924 goto err_add_adapter;
917 } 925 }
918
919 pch_i2c_init(&adap_info->pch_data[i]);
920 }
921 ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED,
922 KBUILD_MODNAME, adap_info);
923 if (ret) {
924 pch_pci_err(pdev, "request_irq FAILED\n");
925 goto err_i2c_add_adapter;
926 } 926 }
927 927
928 pci_set_drvdata(pdev, adap_info); 928 pci_set_drvdata(pdev, adap_info);
929 pch_pci_dbg(pdev, "returns %d.\n", ret); 929 pch_pci_dbg(pdev, "returns %d.\n", ret);
930 return 0; 930 return 0;
931 931
932err_i2c_add_adapter: 932err_add_adapter:
933 for (j = 0; j < i; j++) 933 for (j = 0; j < i; j++)
934 i2c_del_adapter(&adap_info->pch_data[j].pch_adapter); 934 i2c_del_adapter(&adap_info->pch_data[j].pch_adapter);
935 free_irq(pdev->irq, adap_info);
936err_request_irq:
935 pci_iounmap(pdev, base_addr); 937 pci_iounmap(pdev, base_addr);
936err_pci_iomap: 938err_pci_iomap:
937 pci_release_regions(pdev); 939 pci_release_regions(pdev);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index a43d0023446..fa23faa20f0 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1047,13 +1047,14 @@ omap_i2c_probe(struct platform_device *pdev)
1047 * size. This is to ensure that we can handle the status on int 1047 * size. This is to ensure that we can handle the status on int
1048 * call back latencies. 1048 * call back latencies.
1049 */ 1049 */
1050 if (dev->rev >= OMAP_I2C_REV_ON_3530_4430) { 1050
1051 dev->fifo_size = 0; 1051 dev->fifo_size = (dev->fifo_size / 2);
1052
1053 if (dev->rev >= OMAP_I2C_REV_ON_3530_4430)
1052 dev->b_hw = 0; /* Disable hardware fixes */ 1054 dev->b_hw = 0; /* Disable hardware fixes */
1053 } else { 1055 else
1054 dev->fifo_size = (dev->fifo_size / 2);
1055 dev->b_hw = 1; /* Enable hardware fixes */ 1056 dev->b_hw = 1; /* Enable hardware fixes */
1056 } 1057
1057 /* calculate wakeup latency constraint for MPU */ 1058 /* calculate wakeup latency constraint for MPU */
1058 if (dev->set_mpu_wkup_lat != NULL) 1059 if (dev->set_mpu_wkup_lat != NULL)
1059 dev->latency = (1000000 * dev->fifo_size) / 1060 dev->latency = (1000000 * dev->fifo_size) /
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 2754cef86a0..4c171808168 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -534,6 +534,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
534 534
535 /* first, try busy waiting briefly */ 535 /* first, try busy waiting briefly */
536 do { 536 do {
537 cpu_relax();
537 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 538 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
538 } while ((iicstat & S3C2410_IICSTAT_START) && --spins); 539 } while ((iicstat & S3C2410_IICSTAT_START) && --spins);
539 540
@@ -786,7 +787,7 @@ static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
786#else 787#else
787static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) 788static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
788{ 789{
789 return -EINVAL; 790 return 0;
790} 791}
791 792
792static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c) 793static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 75ff821c0af..d0d4aa9f480 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2513,6 +2513,9 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
2513 2513
2514 req.private_data_len = sizeof(struct cma_hdr) + 2514 req.private_data_len = sizeof(struct cma_hdr) +
2515 conn_param->private_data_len; 2515 conn_param->private_data_len;
2516 if (req.private_data_len < conn_param->private_data_len)
2517 return -EINVAL;
2518
2516 req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC); 2519 req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
2517 if (!req.private_data) 2520 if (!req.private_data)
2518 return -ENOMEM; 2521 return -ENOMEM;
@@ -2562,6 +2565,9 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
2562 memset(&req, 0, sizeof req); 2565 memset(&req, 0, sizeof req);
2563 offset = cma_user_data_offset(id_priv->id.ps); 2566 offset = cma_user_data_offset(id_priv->id.ps);
2564 req.private_data_len = offset + conn_param->private_data_len; 2567 req.private_data_len = offset + conn_param->private_data_len;
2568 if (req.private_data_len < conn_param->private_data_len)
2569 return -EINVAL;
2570
2565 private_data = kzalloc(req.private_data_len, GFP_ATOMIC); 2571 private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
2566 if (!private_data) 2572 if (!private_data)
2567 return -ENOMEM; 2573 return -ENOMEM;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 77f3dbc0aaa..18836cdf1e1 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1244,7 +1244,8 @@ err_reg:
1244 1244
1245err_counter: 1245err_counter:
1246 for (; i; --i) 1246 for (; i; --i)
1247 mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]); 1247 if (ibdev->counters[i - 1] != -1)
1248 mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]);
1248 1249
1249err_map: 1250err_map:
1250 iounmap(ibdev->uar_map); 1251 iounmap(ibdev->uar_map);
@@ -1275,7 +1276,8 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
1275 } 1276 }
1276 iounmap(ibdev->uar_map); 1277 iounmap(ibdev->uar_map);
1277 for (p = 0; p < ibdev->num_ports; ++p) 1278 for (p = 0; p < ibdev->num_ports; ++p)
1278 mlx4_counter_free(ibdev->dev, ibdev->counters[p]); 1279 if (ibdev->counters[p] != -1)
1280 mlx4_counter_free(ibdev->dev, ibdev->counters[p]);
1279 mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB) 1281 mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB)
1280 mlx4_CLOSE_PORT(dev, p); 1282 mlx4_CLOSE_PORT(dev, p);
1281 1283
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index 574600ef5b4..a7403248d83 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -1285,7 +1285,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt,
1285 strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); 1285 strlcpy(rcd->comm, current->comm, sizeof(rcd->comm));
1286 ctxt_fp(fp) = rcd; 1286 ctxt_fp(fp) = rcd;
1287 qib_stats.sps_ctxts++; 1287 qib_stats.sps_ctxts++;
1288 dd->freectxts++; 1288 dd->freectxts--;
1289 ret = 0; 1289 ret = 0;
1290 goto bail; 1290 goto bail;
1291 1291
@@ -1794,7 +1794,7 @@ static int qib_close(struct inode *in, struct file *fp)
1794 if (dd->pageshadow) 1794 if (dd->pageshadow)
1795 unlock_expected_tids(rcd); 1795 unlock_expected_tids(rcd);
1796 qib_stats.sps_ctxts--; 1796 qib_stats.sps_ctxts--;
1797 dd->freectxts--; 1797 dd->freectxts++;
1798 } 1798 }
1799 1799
1800 mutex_unlock(&qib_mutex); 1800 mutex_unlock(&qib_mutex);
diff --git a/drivers/input/misc/cma3000_d0x.c b/drivers/input/misc/cma3000_d0x.c
index 80793f1608e..06517e60e50 100644
--- a/drivers/input/misc/cma3000_d0x.c
+++ b/drivers/input/misc/cma3000_d0x.c
@@ -115,8 +115,8 @@ static void decode_mg(struct cma3000_accl_data *data, int *datax,
115static irqreturn_t cma3000_thread_irq(int irq, void *dev_id) 115static irqreturn_t cma3000_thread_irq(int irq, void *dev_id)
116{ 116{
117 struct cma3000_accl_data *data = dev_id; 117 struct cma3000_accl_data *data = dev_id;
118 int datax, datay, dataz; 118 int datax, datay, dataz, intr_status;
119 u8 ctrl, mode, range, intr_status; 119 u8 ctrl, mode, range;
120 120
121 intr_status = CMA3000_READ(data, CMA3000_INTSTATUS, "interrupt status"); 121 intr_status = CMA3000_READ(data, CMA3000_INTSTATUS, "interrupt status");
122 if (intr_status < 0) 122 if (intr_status < 0)
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index c5b12d2e955..86d6f39178b 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -2,7 +2,7 @@
2 * Finger Sensing Pad PS/2 mouse driver. 2 * Finger Sensing Pad PS/2 mouse driver.
3 * 3 *
4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
5 * Copyright (C) 2005-2010 Tai-hwa Liang, Sentelic Corporation. 5 * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -162,7 +162,7 @@ static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
162 ps2_sendbyte(ps2dev, v, FSP_CMD_TIMEOUT2); 162 ps2_sendbyte(ps2dev, v, FSP_CMD_TIMEOUT2);
163 163
164 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0) 164 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
165 return -1; 165 goto out;
166 166
167 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) { 167 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) {
168 /* inversion is required */ 168 /* inversion is required */
@@ -261,7 +261,7 @@ static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val)
261 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2); 261 ps2_sendbyte(ps2dev, 0x88, FSP_CMD_TIMEOUT2);
262 262
263 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0) 263 if (ps2_sendbyte(ps2dev, 0xf3, FSP_CMD_TIMEOUT) < 0)
264 return -1; 264 goto out;
265 265
266 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) { 266 if ((v = fsp_test_invert_cmd(reg_val)) != reg_val) {
267 ps2_sendbyte(ps2dev, 0x47, FSP_CMD_TIMEOUT2); 267 ps2_sendbyte(ps2dev, 0x47, FSP_CMD_TIMEOUT2);
@@ -309,7 +309,7 @@ static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
309 }; 309 };
310 int val; 310 int val;
311 311
312 if (fsp_reg_read(psmouse, FSP_REG_TMOD_STATUS1, &val) == -1) 312 if (fsp_reg_read(psmouse, FSP_REG_TMOD_STATUS, &val) == -1)
313 return -EIO; 313 return -EIO;
314 314
315 *btn = buttons[(val & 0x30) >> 4]; 315 *btn = buttons[(val & 0x30) >> 4];
diff --git a/drivers/input/mouse/sentelic.h b/drivers/input/mouse/sentelic.h
index ed1395ac7b8..2e4af24f8c1 100644
--- a/drivers/input/mouse/sentelic.h
+++ b/drivers/input/mouse/sentelic.h
@@ -2,7 +2,7 @@
2 * Finger Sensing Pad PS/2 mouse driver. 2 * Finger Sensing Pad PS/2 mouse driver.
3 * 3 *
4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd.
5 * Copyright (C) 2005-2009 Tai-hwa Liang, Sentelic Corporation. 5 * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -33,6 +33,7 @@
33/* Finger-sensing Pad control registers */ 33/* Finger-sensing Pad control registers */
34#define FSP_REG_SYSCTL1 0x10 34#define FSP_REG_SYSCTL1 0x10
35#define FSP_BIT_EN_REG_CLK BIT(5) 35#define FSP_BIT_EN_REG_CLK BIT(5)
36#define FSP_REG_TMOD_STATUS 0x20
36#define FSP_REG_OPC_QDOWN 0x31 37#define FSP_REG_OPC_QDOWN 0x31
37#define FSP_BIT_EN_OPC_TAG BIT(7) 38#define FSP_BIT_EN_OPC_TAG BIT(7)
38#define FSP_REG_OPTZ_XLO 0x34 39#define FSP_REG_OPTZ_XLO 0x34
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index c080b828e5d..a6dcd18e9ad 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/delay.h>
27#include <linux/dmi.h> 28#include <linux/dmi.h>
28#include <linux/input/mt.h> 29#include <linux/input/mt.h>
29#include <linux/serio.h> 30#include <linux/serio.h>
@@ -1220,6 +1221,16 @@ static int synaptics_reconnect(struct psmouse *psmouse)
1220 1221
1221 do { 1222 do {
1222 psmouse_reset(psmouse); 1223 psmouse_reset(psmouse);
1224 if (retry) {
1225 /*
1226 * On some boxes, right after resuming, the touchpad
1227 * needs some time to finish initializing (I assume
1228 * it needs time to calibrate) and start responding
1229 * to Synaptics-specific queries, so let's wait a
1230 * bit.
1231 */
1232 ssleep(1);
1233 }
1223 error = synaptics_detect(psmouse, 0); 1234 error = synaptics_detect(psmouse, 0);
1224 } while (error && ++retry < 3); 1235 } while (error && ++retry < 3);
1225 1236
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index da0d8761e77..2ee47d01a3b 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1470,6 +1470,9 @@ static const struct wacom_features wacom_features_0xE3 =
1470static const struct wacom_features wacom_features_0xE6 = 1470static const struct wacom_features wacom_features_0xE6 =
1471 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255, 1471 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
1472 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1472 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1473static const struct wacom_features wacom_features_0xEC =
1474 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1475 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1473static const struct wacom_features wacom_features_0x47 = 1476static const struct wacom_features wacom_features_0x47 =
1474 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 1477 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1475 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1478 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -1611,6 +1614,7 @@ const struct usb_device_id wacom_ids[] = {
1611 { USB_DEVICE_WACOM(0xE2) }, 1614 { USB_DEVICE_WACOM(0xE2) },
1612 { USB_DEVICE_WACOM(0xE3) }, 1615 { USB_DEVICE_WACOM(0xE3) },
1613 { USB_DEVICE_WACOM(0xE6) }, 1616 { USB_DEVICE_WACOM(0xE6) },
1617 { USB_DEVICE_WACOM(0xEC) },
1614 { USB_DEVICE_WACOM(0x47) }, 1618 { USB_DEVICE_WACOM(0x47) },
1615 { USB_DEVICE_LENOVO(0x6004) }, 1619 { USB_DEVICE_LENOVO(0x6004) },
1616 { } 1620 { }
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 2fb2963df55..5b5fa5cdaa3 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -90,7 +90,7 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
90 if (bus == NULL || bus->iommu_ops == NULL) 90 if (bus == NULL || bus->iommu_ops == NULL)
91 return NULL; 91 return NULL;
92 92
93 domain = kmalloc(sizeof(*domain), GFP_KERNEL); 93 domain = kzalloc(sizeof(*domain), GFP_KERNEL);
94 if (!domain) 94 if (!domain)
95 return NULL; 95 return NULL;
96 96
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index b6907118283..6d03774b176 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1393,9 +1393,6 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1393 atomic_read(&bitmap->behind_writes), 1393 atomic_read(&bitmap->behind_writes),
1394 bitmap->mddev->bitmap_info.max_write_behind); 1394 bitmap->mddev->bitmap_info.max_write_behind);
1395 } 1395 }
1396 if (bitmap->mddev->degraded)
1397 /* Never clear bits or update events_cleared when degraded */
1398 success = 0;
1399 1396
1400 while (sectors) { 1397 while (sectors) {
1401 sector_t blocks; 1398 sector_t blocks;
@@ -1409,7 +1406,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1409 return; 1406 return;
1410 } 1407 }
1411 1408
1412 if (success && 1409 if (success && !bitmap->mddev->degraded &&
1413 bitmap->events_cleared < bitmap->mddev->events) { 1410 bitmap->events_cleared < bitmap->mddev->events) {
1414 bitmap->events_cleared = bitmap->mddev->events; 1411 bitmap->events_cleared = bitmap->mddev->events;
1415 bitmap->need_sync = 1; 1412 bitmap->need_sync = 1;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index c3273efd08c..627456542fb 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -230,6 +230,7 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
230 return -EINVAL; 230 return -EINVAL;
231 231
232 rdev->raid_disk = rdev->saved_raid_disk; 232 rdev->raid_disk = rdev->saved_raid_disk;
233 rdev->saved_raid_disk = -1;
233 234
234 newconf = linear_conf(mddev,mddev->raid_disks+1); 235 newconf = linear_conf(mddev,mddev->raid_disks+1);
235 236
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ee981737edf..f47f1f8ac44 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7360,8 +7360,7 @@ static int remove_and_add_spares(struct mddev *mddev)
7360 spares++; 7360 spares++;
7361 md_new_event(mddev); 7361 md_new_event(mddev);
7362 set_bit(MD_CHANGE_DEVS, &mddev->flags); 7362 set_bit(MD_CHANGE_DEVS, &mddev->flags);
7363 } else 7363 }
7364 break;
7365 } 7364 }
7366 } 7365 }
7367 } 7366 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 31670f8d6b6..858fdbb7eb0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3065,11 +3065,17 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
3065 } 3065 }
3066 } else if (test_bit(In_sync, &rdev->flags)) 3066 } else if (test_bit(In_sync, &rdev->flags))
3067 set_bit(R5_Insync, &dev->flags); 3067 set_bit(R5_Insync, &dev->flags);
3068 else { 3068 else if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
3069 /* in sync if before recovery_offset */ 3069 /* in sync if before recovery_offset */
3070 if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset) 3070 set_bit(R5_Insync, &dev->flags);
3071 set_bit(R5_Insync, &dev->flags); 3071 else if (test_bit(R5_UPTODATE, &dev->flags) &&
3072 } 3072 test_bit(R5_Expanded, &dev->flags))
3073 /* If we've reshaped into here, we assume it is Insync.
3074 * We will shortly update recovery_offset to make
3075 * it official.
3076 */
3077 set_bit(R5_Insync, &dev->flags);
3078
3073 if (rdev && test_bit(R5_WriteError, &dev->flags)) { 3079 if (rdev && test_bit(R5_WriteError, &dev->flags)) {
3074 clear_bit(R5_Insync, &dev->flags); 3080 clear_bit(R5_Insync, &dev->flags);
3075 if (!test_bit(Faulty, &rdev->flags)) { 3081 if (!test_bit(Faulty, &rdev->flags)) {
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c
index 7eb1bf75cd0..5d02221e99d 100644
--- a/drivers/media/common/tuners/mxl5007t.c
+++ b/drivers/media/common/tuners/mxl5007t.c
@@ -488,9 +488,10 @@ static int mxl5007t_write_regs(struct mxl5007t_state *state,
488 488
489static int mxl5007t_read_reg(struct mxl5007t_state *state, u8 reg, u8 *val) 489static int mxl5007t_read_reg(struct mxl5007t_state *state, u8 reg, u8 *val)
490{ 490{
491 u8 buf[2] = { 0xfb, reg };
491 struct i2c_msg msg[] = { 492 struct i2c_msg msg[] = {
492 { .addr = state->i2c_props.addr, .flags = 0, 493 { .addr = state->i2c_props.addr, .flags = 0,
493 .buf = &reg, .len = 1 }, 494 .buf = buf, .len = 2 },
494 { .addr = state->i2c_props.addr, .flags = I2C_M_RD, 495 { .addr = state->i2c_props.addr, .flags = I2C_M_RD,
495 .buf = val, .len = 1 }, 496 .buf = val, .len = 1 },
496 }; 497 };
diff --git a/drivers/media/common/tuners/tda18218.c b/drivers/media/common/tuners/tda18218.c
index aacfe2387e2..4fc29730a12 100644
--- a/drivers/media/common/tuners/tda18218.c
+++ b/drivers/media/common/tuners/tda18218.c
@@ -141,7 +141,7 @@ static int tda18218_set_params(struct dvb_frontend *fe,
141 switch (params->u.ofdm.bandwidth) { 141 switch (params->u.ofdm.bandwidth) {
142 case BANDWIDTH_6_MHZ: 142 case BANDWIDTH_6_MHZ:
143 LP_Fc = 0; 143 LP_Fc = 0;
144 LO_Frac = params->frequency + 4000000; 144 LO_Frac = params->frequency + 3000000;
145 break; 145 break;
146 case BANDWIDTH_7_MHZ: 146 case BANDWIDTH_7_MHZ:
147 LP_Fc = 1; 147 LP_Fc = 1;
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 303f22ea04c..01bb8daf4b0 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -189,7 +189,7 @@ struct ati_remote {
189 dma_addr_t inbuf_dma; 189 dma_addr_t inbuf_dma;
190 dma_addr_t outbuf_dma; 190 dma_addr_t outbuf_dma;
191 191
192 unsigned char old_data[2]; /* Detect duplicate events */ 192 unsigned char old_data; /* Detect duplicate events */
193 unsigned long old_jiffies; 193 unsigned long old_jiffies;
194 unsigned long acc_jiffies; /* handle acceleration */ 194 unsigned long acc_jiffies; /* handle acceleration */
195 unsigned long first_jiffies; 195 unsigned long first_jiffies;
@@ -221,35 +221,35 @@ struct ati_remote {
221/* Translation table from hardware messages to input events. */ 221/* Translation table from hardware messages to input events. */
222static const struct { 222static const struct {
223 short kind; 223 short kind;
224 unsigned char data1, data2; 224 unsigned char data;
225 int type; 225 int type;
226 unsigned int code; 226 unsigned int code;
227 int value; 227 int value;
228} ati_remote_tbl[] = { 228} ati_remote_tbl[] = {
229 /* Directional control pad axes */ 229 /* Directional control pad axes */
230 {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ 230 {KIND_ACCEL, 0x70, EV_REL, REL_X, -1}, /* left */
231 {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ 231 {KIND_ACCEL, 0x71, EV_REL, REL_X, 1}, /* right */
232 {KIND_ACCEL, 0x37, 0x72, EV_REL, REL_Y, -1}, /* up */ 232 {KIND_ACCEL, 0x72, EV_REL, REL_Y, -1}, /* up */
233 {KIND_ACCEL, 0x38, 0x73, EV_REL, REL_Y, 1}, /* down */ 233 {KIND_ACCEL, 0x73, EV_REL, REL_Y, 1}, /* down */
234 /* Directional control pad diagonals */ 234 /* Directional control pad diagonals */
235 {KIND_LU, 0x39, 0x74, EV_REL, 0, 0}, /* left up */ 235 {KIND_LU, 0x74, EV_REL, 0, 0}, /* left up */
236 {KIND_RU, 0x3a, 0x75, EV_REL, 0, 0}, /* right up */ 236 {KIND_RU, 0x75, EV_REL, 0, 0}, /* right up */
237 {KIND_LD, 0x3c, 0x77, EV_REL, 0, 0}, /* left down */ 237 {KIND_LD, 0x77, EV_REL, 0, 0}, /* left down */
238 {KIND_RD, 0x3b, 0x76, EV_REL, 0, 0}, /* right down */ 238 {KIND_RD, 0x76, EV_REL, 0, 0}, /* right down */
239 239
240 /* "Mouse button" buttons */ 240 /* "Mouse button" buttons */
241 {KIND_LITERAL, 0x3d, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */ 241 {KIND_LITERAL, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */
242 {KIND_LITERAL, 0x3e, 0x79, EV_KEY, BTN_LEFT, 0}, /* left btn up */ 242 {KIND_LITERAL, 0x79, EV_KEY, BTN_LEFT, 0}, /* left btn up */
243 {KIND_LITERAL, 0x41, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */ 243 {KIND_LITERAL, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */
244 {KIND_LITERAL, 0x42, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */ 244 {KIND_LITERAL, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */
245 245
246 /* Artificial "doubleclick" events are generated by the hardware. 246 /* Artificial "doubleclick" events are generated by the hardware.
247 * They are mapped to the "side" and "extra" mouse buttons here. */ 247 * They are mapped to the "side" and "extra" mouse buttons here. */
248 {KIND_FILTERED, 0x3f, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */ 248 {KIND_FILTERED, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */
249 {KIND_FILTERED, 0x43, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */ 249 {KIND_FILTERED, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */
250 250
251 /* Non-mouse events are handled by rc-core */ 251 /* Non-mouse events are handled by rc-core */
252 {KIND_END, 0x00, 0x00, EV_MAX + 1, 0, 0} 252 {KIND_END, 0x00, EV_MAX + 1, 0, 0}
253}; 253};
254 254
255/* Local function prototypes */ 255/* Local function prototypes */
@@ -397,25 +397,6 @@ static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigne
397} 397}
398 398
399/* 399/*
400 * ati_remote_event_lookup
401 */
402static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2)
403{
404 int i;
405
406 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) {
407 /*
408 * Decide if the table entry matches the remote input.
409 */
410 if (ati_remote_tbl[i].data1 == d1 &&
411 ati_remote_tbl[i].data2 == d2)
412 return i;
413
414 }
415 return -1;
416}
417
418/*
419 * ati_remote_compute_accel 400 * ati_remote_compute_accel
420 * 401 *
421 * Implements acceleration curve for directional control pad 402 * Implements acceleration curve for directional control pad
@@ -463,7 +444,15 @@ static void ati_remote_input_report(struct urb *urb)
463 int index = -1; 444 int index = -1;
464 int acc; 445 int acc;
465 int remote_num; 446 int remote_num;
466 unsigned char scancode[2]; 447 unsigned char scancode;
448 int i;
449
450 /*
451 * data[0] = 0x14
452 * data[1] = data[2] + data[3] + 0xd5 (a checksum byte)
453 * data[2] = the key code (with toggle bit in MSB with some models)
454 * data[3] = channel << 4 (the low 4 bits must be zero)
455 */
467 456
468 /* Deal with strange looking inputs */ 457 /* Deal with strange looking inputs */
469 if ( (urb->actual_length != 4) || (data[0] != 0x14) || 458 if ( (urb->actual_length != 4) || (data[0] != 0x14) ||
@@ -472,6 +461,13 @@ static void ati_remote_input_report(struct urb *urb)
472 return; 461 return;
473 } 462 }
474 463
464 if (data[1] != ((data[2] + data[3] + 0xd5) & 0xff)) {
465 dbginfo(&ati_remote->interface->dev,
466 "wrong checksum in input: %02x %02x %02x %02x\n",
467 data[0], data[1], data[2], data[3]);
468 return;
469 }
470
475 /* Mask unwanted remote channels. */ 471 /* Mask unwanted remote channels. */
476 /* note: remote_num is 0-based, channel 1 on remote == 0 here */ 472 /* note: remote_num is 0-based, channel 1 on remote == 0 here */
477 remote_num = (data[3] >> 4) & 0x0f; 473 remote_num = (data[3] >> 4) & 0x0f;
@@ -482,31 +478,30 @@ static void ati_remote_input_report(struct urb *urb)
482 return; 478 return;
483 } 479 }
484 480
485 scancode[0] = (((data[1] - ((remote_num + 1) << 4)) & 0xf0) | (data[1] & 0x0f));
486
487 /* 481 /*
488 * Some devices (e.g. SnapStream Firefly) use 8080 as toggle code, 482 * MSB is a toggle code, though only used by some devices
489 * so we have to clear them. The first bit is a bit tricky as the 483 * (e.g. SnapStream Firefly)
490 * "non-toggled" state depends on remote_num, so we xor it with the
491 * second bit which is only used for toggle.
492 */ 484 */
493 scancode[0] ^= (data[2] & 0x80); 485 scancode = data[2] & 0x7f;
494
495 scancode[1] = data[2] & ~0x80;
496 486
497 /* Look up event code index in mouse translation table. */ 487 /* Look up event code index in the mouse translation table. */
498 index = ati_remote_event_lookup(remote_num, scancode[0], scancode[1]); 488 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) {
489 if (scancode == ati_remote_tbl[i].data) {
490 index = i;
491 break;
492 }
493 }
499 494
500 if (index >= 0) { 495 if (index >= 0) {
501 dbginfo(&ati_remote->interface->dev, 496 dbginfo(&ati_remote->interface->dev,
502 "channel 0x%02x; mouse data %02x,%02x; index %d; keycode %d\n", 497 "channel 0x%02x; mouse data %02x; index %d; keycode %d\n",
503 remote_num, data[1], data[2], index, ati_remote_tbl[index].code); 498 remote_num, data[2], index, ati_remote_tbl[index].code);
504 if (!dev) 499 if (!dev)
505 return; /* no mouse device */ 500 return; /* no mouse device */
506 } else 501 } else
507 dbginfo(&ati_remote->interface->dev, 502 dbginfo(&ati_remote->interface->dev,
508 "channel 0x%02x; key data %02x,%02x, scancode %02x,%02x\n", 503 "channel 0x%02x; key data %02x, scancode %02x\n",
509 remote_num, data[1], data[2], scancode[0], scancode[1]); 504 remote_num, data[2], scancode);
510 505
511 506
512 if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) { 507 if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) {
@@ -523,8 +518,7 @@ static void ati_remote_input_report(struct urb *urb)
523 unsigned long now = jiffies; 518 unsigned long now = jiffies;
524 519
525 /* Filter duplicate events which happen "too close" together. */ 520 /* Filter duplicate events which happen "too close" together. */
526 if (ati_remote->old_data[0] == data[1] && 521 if (ati_remote->old_data == data[2] &&
527 ati_remote->old_data[1] == data[2] &&
528 time_before(now, ati_remote->old_jiffies + 522 time_before(now, ati_remote->old_jiffies +
529 msecs_to_jiffies(repeat_filter))) { 523 msecs_to_jiffies(repeat_filter))) {
530 ati_remote->repeat_count++; 524 ati_remote->repeat_count++;
@@ -533,8 +527,7 @@ static void ati_remote_input_report(struct urb *urb)
533 ati_remote->first_jiffies = now; 527 ati_remote->first_jiffies = now;
534 } 528 }
535 529
536 ati_remote->old_data[0] = data[1]; 530 ati_remote->old_data = data[2];
537 ati_remote->old_data[1] = data[2];
538 ati_remote->old_jiffies = now; 531 ati_remote->old_jiffies = now;
539 532
540 /* Ensure we skip at least the 4 first duplicate events (generated 533 /* Ensure we skip at least the 4 first duplicate events (generated
@@ -549,14 +542,13 @@ static void ati_remote_input_report(struct urb *urb)
549 542
550 if (index < 0) { 543 if (index < 0) {
551 /* Not a mouse event, hand it to rc-core. */ 544 /* Not a mouse event, hand it to rc-core. */
552 u32 rc_code = (scancode[0] << 8) | scancode[1];
553 545
554 /* 546 /*
555 * We don't use the rc-core repeat handling yet as 547 * We don't use the rc-core repeat handling yet as
556 * it would cause ghost repeats which would be a 548 * it would cause ghost repeats which would be a
557 * regression for this driver. 549 * regression for this driver.
558 */ 550 */
559 rc_keydown_notimeout(ati_remote->rdev, rc_code, 551 rc_keydown_notimeout(ati_remote->rdev, scancode,
560 data[2]); 552 data[2]);
561 rc_keyup(ati_remote->rdev); 553 rc_keyup(ati_remote->rdev);
562 return; 554 return;
@@ -607,8 +599,7 @@ static void ati_remote_input_report(struct urb *urb)
607 input_sync(dev); 599 input_sync(dev);
608 600
609 ati_remote->old_jiffies = jiffies; 601 ati_remote->old_jiffies = jiffies;
610 ati_remote->old_data[0] = data[1]; 602 ati_remote->old_data = data[2];
611 ati_remote->old_data[1] = data[2];
612 } 603 }
613} 604}
614 605
diff --git a/drivers/media/rc/keymaps/rc-ati-x10.c b/drivers/media/rc/keymaps/rc-ati-x10.c
index e1b8b2605c4..81506440ede 100644
--- a/drivers/media/rc/keymaps/rc-ati-x10.c
+++ b/drivers/media/rc/keymaps/rc-ati-x10.c
@@ -27,55 +27,55 @@
27#include <media/rc-map.h> 27#include <media/rc-map.h>
28 28
29static struct rc_map_table ati_x10[] = { 29static struct rc_map_table ati_x10[] = {
30 { 0xd20d, KEY_1 }, 30 { 0x0d, KEY_1 },
31 { 0xd30e, KEY_2 }, 31 { 0x0e, KEY_2 },
32 { 0xd40f, KEY_3 }, 32 { 0x0f, KEY_3 },
33 { 0xd510, KEY_4 }, 33 { 0x10, KEY_4 },
34 { 0xd611, KEY_5 }, 34 { 0x11, KEY_5 },
35 { 0xd712, KEY_6 }, 35 { 0x12, KEY_6 },
36 { 0xd813, KEY_7 }, 36 { 0x13, KEY_7 },
37 { 0xd914, KEY_8 }, 37 { 0x14, KEY_8 },
38 { 0xda15, KEY_9 }, 38 { 0x15, KEY_9 },
39 { 0xdc17, KEY_0 }, 39 { 0x17, KEY_0 },
40 { 0xc500, KEY_A }, 40 { 0x00, KEY_A },
41 { 0xc601, KEY_B }, 41 { 0x01, KEY_B },
42 { 0xde19, KEY_C }, 42 { 0x19, KEY_C },
43 { 0xe01b, KEY_D }, 43 { 0x1b, KEY_D },
44 { 0xe621, KEY_E }, 44 { 0x21, KEY_E },
45 { 0xe823, KEY_F }, 45 { 0x23, KEY_F },
46 46
47 { 0xdd18, KEY_KPENTER }, /* "check" */ 47 { 0x18, KEY_KPENTER }, /* "check" */
48 { 0xdb16, KEY_MENU }, /* "menu" */ 48 { 0x16, KEY_MENU }, /* "menu" */
49 { 0xc702, KEY_POWER }, /* Power */ 49 { 0x02, KEY_POWER }, /* Power */
50 { 0xc803, KEY_TV }, /* TV */ 50 { 0x03, KEY_TV }, /* TV */
51 { 0xc904, KEY_DVD }, /* DVD */ 51 { 0x04, KEY_DVD }, /* DVD */
52 { 0xca05, KEY_WWW }, /* WEB */ 52 { 0x05, KEY_WWW }, /* WEB */
53 { 0xcb06, KEY_BOOKMARKS }, /* "book" */ 53 { 0x06, KEY_BOOKMARKS }, /* "book" */
54 { 0xcc07, KEY_EDIT }, /* "hand" */ 54 { 0x07, KEY_EDIT }, /* "hand" */
55 { 0xe11c, KEY_COFFEE }, /* "timer" */ 55 { 0x1c, KEY_COFFEE }, /* "timer" */
56 { 0xe520, KEY_FRONT }, /* "max" */ 56 { 0x20, KEY_FRONT }, /* "max" */
57 { 0xe21d, KEY_LEFT }, /* left */ 57 { 0x1d, KEY_LEFT }, /* left */
58 { 0xe41f, KEY_RIGHT }, /* right */ 58 { 0x1f, KEY_RIGHT }, /* right */
59 { 0xe722, KEY_DOWN }, /* down */ 59 { 0x22, KEY_DOWN }, /* down */
60 { 0xdf1a, KEY_UP }, /* up */ 60 { 0x1a, KEY_UP }, /* up */
61 { 0xe31e, KEY_OK }, /* "OK" */ 61 { 0x1e, KEY_OK }, /* "OK" */
62 { 0xce09, KEY_VOLUMEDOWN }, /* VOL + */ 62 { 0x09, KEY_VOLUMEDOWN }, /* VOL + */
63 { 0xcd08, KEY_VOLUMEUP }, /* VOL - */ 63 { 0x08, KEY_VOLUMEUP }, /* VOL - */
64 { 0xcf0a, KEY_MUTE }, /* MUTE */ 64 { 0x0a, KEY_MUTE }, /* MUTE */
65 { 0xd00b, KEY_CHANNELUP }, /* CH + */ 65 { 0x0b, KEY_CHANNELUP }, /* CH + */
66 { 0xd10c, KEY_CHANNELDOWN },/* CH - */ 66 { 0x0c, KEY_CHANNELDOWN },/* CH - */
67 { 0xec27, KEY_RECORD }, /* ( o) red */ 67 { 0x27, KEY_RECORD }, /* ( o) red */
68 { 0xea25, KEY_PLAY }, /* ( >) */ 68 { 0x25, KEY_PLAY }, /* ( >) */
69 { 0xe924, KEY_REWIND }, /* (<<) */ 69 { 0x24, KEY_REWIND }, /* (<<) */
70 { 0xeb26, KEY_FORWARD }, /* (>>) */ 70 { 0x26, KEY_FORWARD }, /* (>>) */
71 { 0xed28, KEY_STOP }, /* ([]) */ 71 { 0x28, KEY_STOP }, /* ([]) */
72 { 0xee29, KEY_PAUSE }, /* ('') */ 72 { 0x29, KEY_PAUSE }, /* ('') */
73 { 0xf02b, KEY_PREVIOUS }, /* (<-) */ 73 { 0x2b, KEY_PREVIOUS }, /* (<-) */
74 { 0xef2a, KEY_NEXT }, /* (>+) */ 74 { 0x2a, KEY_NEXT }, /* (>+) */
75 { 0xf22d, KEY_INFO }, /* PLAYING */ 75 { 0x2d, KEY_INFO }, /* PLAYING */
76 { 0xf32e, KEY_HOME }, /* TOP */ 76 { 0x2e, KEY_HOME }, /* TOP */
77 { 0xf42f, KEY_END }, /* END */ 77 { 0x2f, KEY_END }, /* END */
78 { 0xf530, KEY_SELECT }, /* SELECT */ 78 { 0x30, KEY_SELECT }, /* SELECT */
79}; 79};
80 80
81static struct rc_map_list ati_x10_map = { 81static struct rc_map_list ati_x10_map = {
diff --git a/drivers/media/rc/keymaps/rc-medion-x10.c b/drivers/media/rc/keymaps/rc-medion-x10.c
index 09e2cc01d11..479cdb89781 100644
--- a/drivers/media/rc/keymaps/rc-medion-x10.c
+++ b/drivers/media/rc/keymaps/rc-medion-x10.c
@@ -25,70 +25,70 @@
25#include <media/rc-map.h> 25#include <media/rc-map.h>
26 26
27static struct rc_map_table medion_x10[] = { 27static struct rc_map_table medion_x10[] = {
28 { 0xf12c, KEY_TV }, /* TV */ 28 { 0x2c, KEY_TV }, /* TV */
29 { 0xf22d, KEY_VCR }, /* VCR */ 29 { 0x2d, KEY_VCR }, /* VCR */
30 { 0xc904, KEY_DVD }, /* DVD */ 30 { 0x04, KEY_DVD }, /* DVD */
31 { 0xcb06, KEY_AUDIO }, /* MUSIC */ 31 { 0x06, KEY_AUDIO }, /* MUSIC */
32 32
33 { 0xf32e, KEY_RADIO }, /* RADIO */ 33 { 0x2e, KEY_RADIO }, /* RADIO */
34 { 0xca05, KEY_DIRECTORY }, /* PHOTO */ 34 { 0x05, KEY_DIRECTORY }, /* PHOTO */
35 { 0xf42f, KEY_INFO }, /* TV-PREVIEW */ 35 { 0x2f, KEY_INFO }, /* TV-PREVIEW */
36 { 0xf530, KEY_LIST }, /* CHANNEL-LST */ 36 { 0x30, KEY_LIST }, /* CHANNEL-LST */
37 37
38 { 0xe01b, KEY_SETUP }, /* SETUP */ 38 { 0x1b, KEY_SETUP }, /* SETUP */
39 { 0xf631, KEY_VIDEO }, /* VIDEO DESKTOP */ 39 { 0x31, KEY_VIDEO }, /* VIDEO DESKTOP */
40 40
41 { 0xcd08, KEY_VOLUMEDOWN }, /* VOL - */ 41 { 0x08, KEY_VOLUMEDOWN }, /* VOL - */
42 { 0xce09, KEY_VOLUMEUP }, /* VOL + */ 42 { 0x09, KEY_VOLUMEUP }, /* VOL + */
43 { 0xd00b, KEY_CHANNELUP }, /* CHAN + */ 43 { 0x0b, KEY_CHANNELUP }, /* CHAN + */
44 { 0xd10c, KEY_CHANNELDOWN }, /* CHAN - */ 44 { 0x0c, KEY_CHANNELDOWN }, /* CHAN - */
45 { 0xc500, KEY_MUTE }, /* MUTE */ 45 { 0x00, KEY_MUTE }, /* MUTE */
46 46
47 { 0xf732, KEY_RED }, /* red */ 47 { 0x32, KEY_RED }, /* red */
48 { 0xf833, KEY_GREEN }, /* green */ 48 { 0x33, KEY_GREEN }, /* green */
49 { 0xf934, KEY_YELLOW }, /* yellow */ 49 { 0x34, KEY_YELLOW }, /* yellow */
50 { 0xfa35, KEY_BLUE }, /* blue */ 50 { 0x35, KEY_BLUE }, /* blue */
51 { 0xdb16, KEY_TEXT }, /* TXT */ 51 { 0x16, KEY_TEXT }, /* TXT */
52 52
53 { 0xd20d, KEY_1 }, 53 { 0x0d, KEY_1 },
54 { 0xd30e, KEY_2 }, 54 { 0x0e, KEY_2 },
55 { 0xd40f, KEY_3 }, 55 { 0x0f, KEY_3 },
56 { 0xd510, KEY_4 }, 56 { 0x10, KEY_4 },
57 { 0xd611, KEY_5 }, 57 { 0x11, KEY_5 },
58 { 0xd712, KEY_6 }, 58 { 0x12, KEY_6 },
59 { 0xd813, KEY_7 }, 59 { 0x13, KEY_7 },
60 { 0xd914, KEY_8 }, 60 { 0x14, KEY_8 },
61 { 0xda15, KEY_9 }, 61 { 0x15, KEY_9 },
62 { 0xdc17, KEY_0 }, 62 { 0x17, KEY_0 },
63 { 0xe11c, KEY_SEARCH }, /* TV/RAD, CH SRC */ 63 { 0x1c, KEY_SEARCH }, /* TV/RAD, CH SRC */
64 { 0xe520, KEY_DELETE }, /* DELETE */ 64 { 0x20, KEY_DELETE }, /* DELETE */
65 65
66 { 0xfb36, KEY_KEYBOARD }, /* RENAME */ 66 { 0x36, KEY_KEYBOARD }, /* RENAME */
67 { 0xdd18, KEY_SCREEN }, /* SNAPSHOT */ 67 { 0x18, KEY_SCREEN }, /* SNAPSHOT */
68 68
69 { 0xdf1a, KEY_UP }, /* up */ 69 { 0x1a, KEY_UP }, /* up */
70 { 0xe722, KEY_DOWN }, /* down */ 70 { 0x22, KEY_DOWN }, /* down */
71 { 0xe21d, KEY_LEFT }, /* left */ 71 { 0x1d, KEY_LEFT }, /* left */
72 { 0xe41f, KEY_RIGHT }, /* right */ 72 { 0x1f, KEY_RIGHT }, /* right */
73 { 0xe31e, KEY_OK }, /* OK */ 73 { 0x1e, KEY_OK }, /* OK */
74 74
75 { 0xfc37, KEY_SELECT }, /* ACQUIRE IMAGE */ 75 { 0x37, KEY_SELECT }, /* ACQUIRE IMAGE */
76 { 0xfd38, KEY_EDIT }, /* EDIT IMAGE */ 76 { 0x38, KEY_EDIT }, /* EDIT IMAGE */
77 77
78 { 0xe924, KEY_REWIND }, /* rewind (<<) */ 78 { 0x24, KEY_REWIND }, /* rewind (<<) */
79 { 0xea25, KEY_PLAY }, /* play ( >) */ 79 { 0x25, KEY_PLAY }, /* play ( >) */
80 { 0xeb26, KEY_FORWARD }, /* forward (>>) */ 80 { 0x26, KEY_FORWARD }, /* forward (>>) */
81 { 0xec27, KEY_RECORD }, /* record ( o) */ 81 { 0x27, KEY_RECORD }, /* record ( o) */
82 { 0xed28, KEY_STOP }, /* stop ([]) */ 82 { 0x28, KEY_STOP }, /* stop ([]) */
83 { 0xee29, KEY_PAUSE }, /* pause ('') */ 83 { 0x29, KEY_PAUSE }, /* pause ('') */
84 84
85 { 0xe621, KEY_PREVIOUS }, /* prev */ 85 { 0x21, KEY_PREVIOUS }, /* prev */
86 { 0xfe39, KEY_SWITCHVIDEOMODE }, /* F SCR */ 86 { 0x39, KEY_SWITCHVIDEOMODE }, /* F SCR */
87 { 0xe823, KEY_NEXT }, /* next */ 87 { 0x23, KEY_NEXT }, /* next */
88 { 0xde19, KEY_MENU }, /* MENU */ 88 { 0x19, KEY_MENU }, /* MENU */
89 { 0xff3a, KEY_LANGUAGE }, /* AUDIO */ 89 { 0x3a, KEY_LANGUAGE }, /* AUDIO */
90 90
91 { 0xc702, KEY_POWER }, /* POWER */ 91 { 0x02, KEY_POWER }, /* POWER */
92}; 92};
93 93
94static struct rc_map_list medion_x10_map = { 94static struct rc_map_list medion_x10_map = {
diff --git a/drivers/media/rc/keymaps/rc-snapstream-firefly.c b/drivers/media/rc/keymaps/rc-snapstream-firefly.c
index ef146520931..c7f33ec719b 100644
--- a/drivers/media/rc/keymaps/rc-snapstream-firefly.c
+++ b/drivers/media/rc/keymaps/rc-snapstream-firefly.c
@@ -22,63 +22,63 @@
22#include <media/rc-map.h> 22#include <media/rc-map.h>
23 23
24static struct rc_map_table snapstream_firefly[] = { 24static struct rc_map_table snapstream_firefly[] = {
25 { 0xf12c, KEY_ZOOM }, /* Maximize */ 25 { 0x2c, KEY_ZOOM }, /* Maximize */
26 { 0xc702, KEY_CLOSE }, 26 { 0x02, KEY_CLOSE },
27 27
28 { 0xd20d, KEY_1 }, 28 { 0x0d, KEY_1 },
29 { 0xd30e, KEY_2 }, 29 { 0x0e, KEY_2 },
30 { 0xd40f, KEY_3 }, 30 { 0x0f, KEY_3 },
31 { 0xd510, KEY_4 }, 31 { 0x10, KEY_4 },
32 { 0xd611, KEY_5 }, 32 { 0x11, KEY_5 },
33 { 0xd712, KEY_6 }, 33 { 0x12, KEY_6 },
34 { 0xd813, KEY_7 }, 34 { 0x13, KEY_7 },
35 { 0xd914, KEY_8 }, 35 { 0x14, KEY_8 },
36 { 0xda15, KEY_9 }, 36 { 0x15, KEY_9 },
37 { 0xdc17, KEY_0 }, 37 { 0x17, KEY_0 },
38 { 0xdb16, KEY_BACK }, 38 { 0x16, KEY_BACK },
39 { 0xdd18, KEY_KPENTER }, /* ent */ 39 { 0x18, KEY_KPENTER }, /* ent */
40 40
41 { 0xce09, KEY_VOLUMEUP }, 41 { 0x09, KEY_VOLUMEUP },
42 { 0xcd08, KEY_VOLUMEDOWN }, 42 { 0x08, KEY_VOLUMEDOWN },
43 { 0xcf0a, KEY_MUTE }, 43 { 0x0a, KEY_MUTE },
44 { 0xd00b, KEY_CHANNELUP }, 44 { 0x0b, KEY_CHANNELUP },
45 { 0xd10c, KEY_CHANNELDOWN }, 45 { 0x0c, KEY_CHANNELDOWN },
46 { 0xc500, KEY_VENDOR }, /* firefly */ 46 { 0x00, KEY_VENDOR }, /* firefly */
47 47
48 { 0xf32e, KEY_INFO }, 48 { 0x2e, KEY_INFO },
49 { 0xf42f, KEY_OPTION }, 49 { 0x2f, KEY_OPTION },
50 50
51 { 0xe21d, KEY_LEFT }, 51 { 0x1d, KEY_LEFT },
52 { 0xe41f, KEY_RIGHT }, 52 { 0x1f, KEY_RIGHT },
53 { 0xe722, KEY_DOWN }, 53 { 0x22, KEY_DOWN },
54 { 0xdf1a, KEY_UP }, 54 { 0x1a, KEY_UP },
55 { 0xe31e, KEY_OK }, 55 { 0x1e, KEY_OK },
56 56
57 { 0xe11c, KEY_MENU }, 57 { 0x1c, KEY_MENU },
58 { 0xe520, KEY_EXIT }, 58 { 0x20, KEY_EXIT },
59 59
60 { 0xec27, KEY_RECORD }, 60 { 0x27, KEY_RECORD },
61 { 0xea25, KEY_PLAY }, 61 { 0x25, KEY_PLAY },
62 { 0xed28, KEY_STOP }, 62 { 0x28, KEY_STOP },
63 { 0xe924, KEY_REWIND }, 63 { 0x24, KEY_REWIND },
64 { 0xeb26, KEY_FORWARD }, 64 { 0x26, KEY_FORWARD },
65 { 0xee29, KEY_PAUSE }, 65 { 0x29, KEY_PAUSE },
66 { 0xf02b, KEY_PREVIOUS }, 66 { 0x2b, KEY_PREVIOUS },
67 { 0xef2a, KEY_NEXT }, 67 { 0x2a, KEY_NEXT },
68 68
69 { 0xcb06, KEY_AUDIO }, /* Music */ 69 { 0x06, KEY_AUDIO }, /* Music */
70 { 0xca05, KEY_IMAGES }, /* Photos */ 70 { 0x05, KEY_IMAGES }, /* Photos */
71 { 0xc904, KEY_DVD }, 71 { 0x04, KEY_DVD },
72 { 0xc803, KEY_TV }, 72 { 0x03, KEY_TV },
73 { 0xcc07, KEY_VIDEO }, 73 { 0x07, KEY_VIDEO },
74 74
75 { 0xc601, KEY_HELP }, 75 { 0x01, KEY_HELP },
76 { 0xf22d, KEY_MODE }, /* Mouse */ 76 { 0x2d, KEY_MODE }, /* Mouse */
77 77
78 { 0xde19, KEY_A }, 78 { 0x19, KEY_A },
79 { 0xe01b, KEY_B }, 79 { 0x1b, KEY_B },
80 { 0xe621, KEY_C }, 80 { 0x21, KEY_C },
81 { 0xe823, KEY_D }, 81 { 0x23, KEY_D },
82}; 82};
83 83
84static struct rc_map_list snapstream_firefly_map = { 84static struct rc_map_list snapstream_firefly_map = {
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c
index 39fc923fc46..1c6015a04f9 100644
--- a/drivers/media/video/au0828/au0828-cards.c
+++ b/drivers/media/video/au0828/au0828-cards.c
@@ -162,11 +162,14 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
162 switch (tv.model) { 162 switch (tv.model) {
163 case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */ 163 case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
164 case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */ 164 case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
165 case 72101: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
166 case 72201: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
165 case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ 167 case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
166 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ 168 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
167 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ 169 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
168 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ 170 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
169 case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */ 171 case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
172 case 72261: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
170 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */ 173 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */
171 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ 174 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
172 break; 175 break;
@@ -324,6 +327,10 @@ struct usb_device_id au0828_usb_id_table[] = {
324 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, 327 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
325 { USB_DEVICE(0x2040, 0x8200), 328 { USB_DEVICE(0x2040, 0x8200),
326 .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY }, 329 .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
330 { USB_DEVICE(0x2040, 0x7260),
331 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
332 { USB_DEVICE(0x2040, 0x7213),
333 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
327 { }, 334 { },
328}; 335};
329 336
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 881e04c7ffe..2ca10dfec91 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -838,13 +838,13 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
838 gspca_dev->usb_err = 0; 838 gspca_dev->usb_err = 0;
839 839
840 /* do the specific subdriver stuff before endpoint selection */ 840 /* do the specific subdriver stuff before endpoint selection */
841 gspca_dev->alt = 0; 841 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
842 gspca_dev->alt = gspca_dev->cam.bulk ? intf->num_altsetting : 0;
842 if (gspca_dev->sd_desc->isoc_init) { 843 if (gspca_dev->sd_desc->isoc_init) {
843 ret = gspca_dev->sd_desc->isoc_init(gspca_dev); 844 ret = gspca_dev->sd_desc->isoc_init(gspca_dev);
844 if (ret < 0) 845 if (ret < 0)
845 goto unlock; 846 goto unlock;
846 } 847 }
847 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
848 xfer = gspca_dev->cam.bulk ? USB_ENDPOINT_XFER_BULK 848 xfer = gspca_dev->cam.bulk ? USB_ENDPOINT_XFER_BULK
849 : USB_ENDPOINT_XFER_ISOC; 849 : USB_ENDPOINT_XFER_ISOC;
850 850
@@ -957,7 +957,7 @@ retry:
957 ret = -EIO; 957 ret = -EIO;
958 goto out; 958 goto out;
959 } 959 }
960 alt = ep_tb[--alt_idx].alt; 960 gspca_dev->alt = ep_tb[--alt_idx].alt;
961 } 961 }
962 } 962 }
963out: 963out:
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 89d09a8914f..82c8817bd32 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -162,7 +162,6 @@ struct m5mols_version {
162 * @pad: media pad 162 * @pad: media pad
163 * @ffmt: current fmt according to resolution type 163 * @ffmt: current fmt according to resolution type
164 * @res_type: current resolution type 164 * @res_type: current resolution type
165 * @code: current code
166 * @irq_waitq: waitqueue for the capture 165 * @irq_waitq: waitqueue for the capture
167 * @work_irq: workqueue for the IRQ 166 * @work_irq: workqueue for the IRQ
168 * @flags: state variable for the interrupt handler 167 * @flags: state variable for the interrupt handler
@@ -192,7 +191,6 @@ struct m5mols_info {
192 struct media_pad pad; 191 struct media_pad pad;
193 struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; 192 struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX];
194 int res_type; 193 int res_type;
195 enum v4l2_mbus_pixelcode code;
196 wait_queue_head_t irq_waitq; 194 wait_queue_head_t irq_waitq;
197 struct work_struct work_irq; 195 struct work_struct work_irq;
198 unsigned long flags; 196 unsigned long flags;
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c
index 05ab3700647..e0f09e53180 100644
--- a/drivers/media/video/m5mols/m5mols_core.c
+++ b/drivers/media/video/m5mols/m5mols_core.c
@@ -334,7 +334,7 @@ int m5mols_mode(struct m5mols_info *info, u8 mode)
334 int ret = -EINVAL; 334 int ret = -EINVAL;
335 u8 reg; 335 u8 reg;
336 336
337 if (mode < REG_PARAMETER && mode > REG_CAPTURE) 337 if (mode < REG_PARAMETER || mode > REG_CAPTURE)
338 return ret; 338 return ret;
339 339
340 ret = m5mols_read_u8(sd, SYSTEM_SYSMODE, &reg); 340 ret = m5mols_read_u8(sd, SYSTEM_SYSMODE, &reg);
@@ -511,9 +511,6 @@ static int m5mols_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
511 struct m5mols_info *info = to_m5mols(sd); 511 struct m5mols_info *info = to_m5mols(sd);
512 struct v4l2_mbus_framefmt *format; 512 struct v4l2_mbus_framefmt *format;
513 513
514 if (fmt->pad != 0)
515 return -EINVAL;
516
517 format = __find_format(info, fh, fmt->which, info->res_type); 514 format = __find_format(info, fh, fmt->which, info->res_type);
518 if (!format) 515 if (!format)
519 return -EINVAL; 516 return -EINVAL;
@@ -532,9 +529,6 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
532 u32 resolution = 0; 529 u32 resolution = 0;
533 int ret; 530 int ret;
534 531
535 if (fmt->pad != 0)
536 return -EINVAL;
537
538 ret = __find_resolution(sd, format, &type, &resolution); 532 ret = __find_resolution(sd, format, &type, &resolution);
539 if (ret < 0) 533 if (ret < 0)
540 return ret; 534 return ret;
@@ -543,13 +537,14 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
543 if (!sfmt) 537 if (!sfmt)
544 return 0; 538 return 0;
545 539
546 *sfmt = m5mols_default_ffmt[type]; 540
547 sfmt->width = format->width; 541 format->code = m5mols_default_ffmt[type].code;
548 sfmt->height = format->height; 542 format->colorspace = V4L2_COLORSPACE_JPEG;
543 format->field = V4L2_FIELD_NONE;
549 544
550 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 545 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
546 *sfmt = *format;
551 info->resolution = resolution; 547 info->resolution = resolution;
552 info->code = format->code;
553 info->res_type = type; 548 info->res_type = type;
554 } 549 }
555 550
@@ -626,13 +621,14 @@ static int m5mols_start_monitor(struct m5mols_info *info)
626static int m5mols_s_stream(struct v4l2_subdev *sd, int enable) 621static int m5mols_s_stream(struct v4l2_subdev *sd, int enable)
627{ 622{
628 struct m5mols_info *info = to_m5mols(sd); 623 struct m5mols_info *info = to_m5mols(sd);
624 u32 code = info->ffmt[info->res_type].code;
629 625
630 if (enable) { 626 if (enable) {
631 int ret = -EINVAL; 627 int ret = -EINVAL;
632 628
633 if (is_code(info->code, M5MOLS_RESTYPE_MONITOR)) 629 if (is_code(code, M5MOLS_RESTYPE_MONITOR))
634 ret = m5mols_start_monitor(info); 630 ret = m5mols_start_monitor(info);
635 if (is_code(info->code, M5MOLS_RESTYPE_CAPTURE)) 631 if (is_code(code, M5MOLS_RESTYPE_CAPTURE))
636 ret = m5mols_start_capture(info); 632 ret = m5mols_start_capture(info);
637 633
638 return ret; 634 return ret;
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index cf2c0fb95f2..398f96ffd35 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -955,6 +955,7 @@ static int mt9m111_probe(struct i2c_client *client,
955 mt9m111->rect.height = MT9M111_MAX_HEIGHT; 955 mt9m111->rect.height = MT9M111_MAX_HEIGHT;
956 mt9m111->fmt = &mt9m111_colour_fmts[0]; 956 mt9m111->fmt = &mt9m111_colour_fmts[0];
957 mt9m111->lastpage = -1; 957 mt9m111->lastpage = -1;
958 mutex_init(&mt9m111->power_lock);
958 959
959 ret = mt9m111_video_probe(client); 960 ret = mt9m111_video_probe(client);
960 if (ret) { 961 if (ret) {
diff --git a/drivers/media/video/mt9t112.c b/drivers/media/video/mt9t112.c
index 32114a3c0ca..7b34b11daf2 100644
--- a/drivers/media/video/mt9t112.c
+++ b/drivers/media/video/mt9t112.c
@@ -1083,8 +1083,10 @@ static int mt9t112_probe(struct i2c_client *client,
1083 v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); 1083 v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
1084 1084
1085 ret = mt9t112_camera_probe(client); 1085 ret = mt9t112_camera_probe(client);
1086 if (ret) 1086 if (ret) {
1087 kfree(priv); 1087 kfree(priv);
1088 return ret;
1089 }
1088 1090
1089 /* Cannot fail: using the default supported pixel code */ 1091 /* Cannot fail: using the default supported pixel code */
1090 mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); 1092 mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8);
diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
index 9c5c19f142d..ee0d0b39cd1 100644
--- a/drivers/media/video/omap/omap_vout.c
+++ b/drivers/media/video/omap/omap_vout.c
@@ -38,6 +38,7 @@
38#include <linux/irq.h> 38#include <linux/irq.h>
39#include <linux/videodev2.h> 39#include <linux/videodev2.h>
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/slab.h>
41 42
42#include <media/videobuf-dma-contig.h> 43#include <media/videobuf-dma-contig.h>
43#include <media/v4l2-device.h> 44#include <media/v4l2-device.h>
@@ -2169,6 +2170,14 @@ static int __init omap_vout_probe(struct platform_device *pdev)
2169 vid_dev->num_displays = 0; 2170 vid_dev->num_displays = 0;
2170 for_each_dss_dev(dssdev) { 2171 for_each_dss_dev(dssdev) {
2171 omap_dss_get_device(dssdev); 2172 omap_dss_get_device(dssdev);
2173
2174 if (!dssdev->driver) {
2175 dev_warn(&pdev->dev, "no driver for display: %s\n",
2176 dssdev->name);
2177 omap_dss_put_device(dssdev);
2178 continue;
2179 }
2180
2172 vid_dev->displays[vid_dev->num_displays++] = dssdev; 2181 vid_dev->displays[vid_dev->num_displays++] = dssdev;
2173 } 2182 }
2174 2183
diff --git a/drivers/media/video/omap1_camera.c b/drivers/media/video/omap1_camera.c
index e87ae2f634b..6a6cf388bae 100644
--- a/drivers/media/video/omap1_camera.c
+++ b/drivers/media/video/omap1_camera.c
@@ -24,6 +24,7 @@
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/module.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
29 30
diff --git a/drivers/media/video/omap24xxcam-dma.c b/drivers/media/video/omap24xxcam-dma.c
index 1d54b86c936..3ea38a8def8 100644
--- a/drivers/media/video/omap24xxcam-dma.c
+++ b/drivers/media/video/omap24xxcam-dma.c
@@ -506,7 +506,7 @@ int omap24xxcam_sgdma_queue(struct omap24xxcam_sgdma *sgdma,
506 unsigned long flags; 506 unsigned long flags;
507 struct sgdma_state *sg_state; 507 struct sgdma_state *sg_state;
508 508
509 if ((sglen < 0) || ((sglen > 0) & !sglist)) 509 if ((sglen < 0) || ((sglen > 0) && !sglist))
510 return -EINVAL; 510 return -EINVAL;
511 511
512 spin_lock_irqsave(&sgdma->lock, flags); 512 spin_lock_irqsave(&sgdma->lock, flags);
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c
index b0b0fa5a357..54a4a3f22e2 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -1408,7 +1408,7 @@ static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc)
1408{ 1408{
1409 struct isp_pipeline *pipe = 1409 struct isp_pipeline *pipe =
1410 to_isp_pipeline(&ccdc->video_out.video.entity); 1410 to_isp_pipeline(&ccdc->video_out.video.entity);
1411 struct video_device *vdev = &ccdc->subdev.devnode; 1411 struct video_device *vdev = ccdc->subdev.devnode;
1412 struct v4l2_event event; 1412 struct v4l2_event event;
1413 1413
1414 memset(&event, 0, sizeof(event)); 1414 memset(&event, 0, sizeof(event));
diff --git a/drivers/media/video/omap3isp/ispstat.c b/drivers/media/video/omap3isp/ispstat.c
index 68d539456c5..bc0b2c7349b 100644
--- a/drivers/media/video/omap3isp/ispstat.c
+++ b/drivers/media/video/omap3isp/ispstat.c
@@ -496,7 +496,7 @@ static int isp_stat_bufs_alloc(struct ispstat *stat, u32 size)
496 496
497static void isp_stat_queue_event(struct ispstat *stat, int err) 497static void isp_stat_queue_event(struct ispstat *stat, int err)
498{ 498{
499 struct video_device *vdev = &stat->subdev.devnode; 499 struct video_device *vdev = stat->subdev.devnode;
500 struct v4l2_event event; 500 struct v4l2_event event;
501 struct omap3isp_stat_event_status *status = (void *)event.u.data; 501 struct omap3isp_stat_event_status *status = (void *)event.u.data;
502 502
diff --git a/drivers/media/video/omap3isp/ispvideo.c b/drivers/media/video/omap3isp/ispvideo.c
index d1000723c5a..f2290578448 100644
--- a/drivers/media/video/omap3isp/ispvideo.c
+++ b/drivers/media/video/omap3isp/ispvideo.c
@@ -26,6 +26,7 @@
26#include <asm/cacheflush.h> 26#include <asm/cacheflush.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/module.h>
29#include <linux/pagemap.h> 30#include <linux/pagemap.h>
30#include <linux/scatterlist.h> 31#include <linux/scatterlist.h>
31#include <linux/sched.h> 32#include <linux/sched.h>
diff --git a/drivers/media/video/ov6650.c b/drivers/media/video/ov6650.c
index 9f2d26b1d4c..6806345ec2f 100644
--- a/drivers/media/video/ov6650.c
+++ b/drivers/media/video/ov6650.c
@@ -540,7 +540,7 @@ static u8 to_clkrc(struct v4l2_fract *timeperframe,
540static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) 540static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
541{ 541{
542 struct i2c_client *client = v4l2_get_subdevdata(sd); 542 struct i2c_client *client = v4l2_get_subdevdata(sd);
543 struct soc_camera_device *icd = (struct soc_camera_device *)sd->grp_id; 543 struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd);
544 struct soc_camera_sense *sense = icd->sense; 544 struct soc_camera_sense *sense = icd->sense;
545 struct ov6650 *priv = to_ov6650(client); 545 struct ov6650 *priv = to_ov6650(client);
546 bool half_scale = !is_unscaled_ok(mf->width, mf->height, &priv->rect); 546 bool half_scale = !is_unscaled_ok(mf->width, mf->height, &priv->rect);
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index c8d91b0cd9b..2cc3b916672 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -98,6 +98,10 @@ static int fimc_capture_state_cleanup(struct fimc_dev *fimc, bool suspend)
98 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); 98 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
99 } 99 }
100 set_bit(ST_CAPT_SUSPENDED, &fimc->state); 100 set_bit(ST_CAPT_SUSPENDED, &fimc->state);
101
102 fimc_hw_reset(fimc);
103 cap->buf_index = 0;
104
101 spin_unlock_irqrestore(&fimc->slock, flags); 105 spin_unlock_irqrestore(&fimc->slock, flags);
102 106
103 if (streaming) 107 if (streaming)
@@ -137,7 +141,7 @@ int fimc_capture_config_update(struct fimc_ctx *ctx)
137 struct fimc_dev *fimc = ctx->fimc_dev; 141 struct fimc_dev *fimc = ctx->fimc_dev;
138 int ret; 142 int ret;
139 143
140 if (test_bit(ST_CAPT_APPLY_CFG, &fimc->state)) 144 if (!test_bit(ST_CAPT_APPLY_CFG, &fimc->state))
141 return 0; 145 return 0;
142 146
143 spin_lock(&ctx->slock); 147 spin_lock(&ctx->slock);
@@ -150,7 +154,7 @@ int fimc_capture_config_update(struct fimc_ctx *ctx)
150 fimc_hw_set_rotation(ctx); 154 fimc_hw_set_rotation(ctx);
151 fimc_prepare_dma_offset(ctx, &ctx->d_frame); 155 fimc_prepare_dma_offset(ctx, &ctx->d_frame);
152 fimc_hw_set_out_dma(ctx); 156 fimc_hw_set_out_dma(ctx);
153 set_bit(ST_CAPT_APPLY_CFG, &fimc->state); 157 clear_bit(ST_CAPT_APPLY_CFG, &fimc->state);
154 } 158 }
155 spin_unlock(&ctx->slock); 159 spin_unlock(&ctx->slock);
156 return ret; 160 return ret;
@@ -164,7 +168,6 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
164 int min_bufs; 168 int min_bufs;
165 int ret; 169 int ret;
166 170
167 fimc_hw_reset(fimc);
168 vid_cap->frame_count = 0; 171 vid_cap->frame_count = 0;
169 172
170 ret = fimc_init_capture(fimc); 173 ret = fimc_init_capture(fimc);
@@ -523,7 +526,7 @@ static struct fimc_fmt *fimc_capture_try_format(struct fimc_ctx *ctx,
523 max_w = rotation ? pl->out_rot_en_w : pl->out_rot_dis_w; 526 max_w = rotation ? pl->out_rot_en_w : pl->out_rot_dis_w;
524 min_w = ctx->state & FIMC_DST_CROP ? dst->width : var->min_out_pixsize; 527 min_w = ctx->state & FIMC_DST_CROP ? dst->width : var->min_out_pixsize;
525 min_h = ctx->state & FIMC_DST_CROP ? dst->height : var->min_out_pixsize; 528 min_h = ctx->state & FIMC_DST_CROP ? dst->height : var->min_out_pixsize;
526 if (fimc->id == 1 && var->pix_hoff) 529 if (var->min_vsize_align == 1 && !rotation)
527 align_h = fimc_fmt_is_rgb(ffmt->color) ? 0 : 1; 530 align_h = fimc_fmt_is_rgb(ffmt->color) ? 0 : 1;
528 531
529 depth = fimc_get_format_depth(ffmt); 532 depth = fimc_get_format_depth(ffmt);
@@ -1239,6 +1242,7 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
1239 1242
1240 mutex_lock(&fimc->lock); 1243 mutex_lock(&fimc->lock);
1241 set_frame_bounds(ff, mf->width, mf->height); 1244 set_frame_bounds(ff, mf->width, mf->height);
1245 fimc->vid_cap.mf = *mf;
1242 ff->fmt = ffmt; 1246 ff->fmt = ffmt;
1243 1247
1244 /* Reset the crop rectangle if required. */ 1248 /* Reset the crop rectangle if required. */
@@ -1375,7 +1379,7 @@ static void fimc_destroy_capture_subdev(struct fimc_dev *fimc)
1375 media_entity_cleanup(&sd->entity); 1379 media_entity_cleanup(&sd->entity);
1376 v4l2_device_unregister_subdev(sd); 1380 v4l2_device_unregister_subdev(sd);
1377 kfree(sd); 1381 kfree(sd);
1378 sd = NULL; 1382 fimc->vid_cap.subdev = NULL;
1379} 1383}
1380 1384
1381/* Set default format at the sensor and host interface */ 1385/* Set default format at the sensor and host interface */
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 19ca6db38b2..07c6254faee 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -37,7 +37,7 @@ static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
37static struct fimc_fmt fimc_formats[] = { 37static struct fimc_fmt fimc_formats[] = {
38 { 38 {
39 .name = "RGB565", 39 .name = "RGB565",
40 .fourcc = V4L2_PIX_FMT_RGB565X, 40 .fourcc = V4L2_PIX_FMT_RGB565,
41 .depth = { 16 }, 41 .depth = { 16 },
42 .color = S5P_FIMC_RGB565, 42 .color = S5P_FIMC_RGB565,
43 .memplanes = 1, 43 .memplanes = 1,
@@ -1038,12 +1038,11 @@ static int fimc_try_fmt_mplane(struct fimc_ctx *ctx, struct v4l2_format *f)
1038 mod_x = 6; /* 64 x 32 pixels tile */ 1038 mod_x = 6; /* 64 x 32 pixels tile */
1039 mod_y = 5; 1039 mod_y = 5;
1040 } else { 1040 } else {
1041 if (fimc->id == 1 && variant->pix_hoff) 1041 if (variant->min_vsize_align == 1)
1042 mod_y = fimc_fmt_is_rgb(fmt->color) ? 0 : 1; 1042 mod_y = fimc_fmt_is_rgb(fmt->color) ? 0 : 1;
1043 else 1043 else
1044 mod_y = mod_x; 1044 mod_y = ffs(variant->min_vsize_align) - 1;
1045 } 1045 }
1046 dbg("mod_x: %d, mod_y: %d, max_w: %d", mod_x, mod_y, max_w);
1047 1046
1048 v4l_bound_align_image(&pix->width, 16, max_w, mod_x, 1047 v4l_bound_align_image(&pix->width, 16, max_w, mod_x,
1049 &pix->height, 8, variant->pix_limit->scaler_dis_w, mod_y, 0); 1048 &pix->height, 8, variant->pix_limit->scaler_dis_w, mod_y, 0);
@@ -1226,10 +1225,10 @@ static int fimc_m2m_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
1226 fimc->variant->min_inp_pixsize : fimc->variant->min_out_pixsize; 1225 fimc->variant->min_inp_pixsize : fimc->variant->min_out_pixsize;
1227 1226
1228 /* Get pixel alignment constraints. */ 1227 /* Get pixel alignment constraints. */
1229 if (fimc->id == 1 && fimc->variant->pix_hoff) 1228 if (fimc->variant->min_vsize_align == 1)
1230 halign = fimc_fmt_is_rgb(f->fmt->color) ? 0 : 1; 1229 halign = fimc_fmt_is_rgb(f->fmt->color) ? 0 : 1;
1231 else 1230 else
1232 halign = ffs(min_size) - 1; 1231 halign = ffs(fimc->variant->min_vsize_align) - 1;
1233 1232
1234 for (i = 0; i < f->fmt->colplanes; i++) 1233 for (i = 0; i < f->fmt->colplanes; i++)
1235 depth += f->fmt->depth[i]; 1234 depth += f->fmt->depth[i];
@@ -1615,7 +1614,6 @@ static int fimc_probe(struct platform_device *pdev)
1615 pdata = pdev->dev.platform_data; 1614 pdata = pdev->dev.platform_data;
1616 fimc->pdata = pdata; 1615 fimc->pdata = pdata;
1617 1616
1618 set_bit(ST_LPM, &fimc->state);
1619 1617
1620 init_waitqueue_head(&fimc->irq_queue); 1618 init_waitqueue_head(&fimc->irq_queue);
1621 spin_lock_init(&fimc->slock); 1619 spin_lock_init(&fimc->slock);
@@ -1707,8 +1705,6 @@ static int fimc_runtime_resume(struct device *dev)
1707 /* Enable clocks and perform basic initalization */ 1705 /* Enable clocks and perform basic initalization */
1708 clk_enable(fimc->clock[CLK_GATE]); 1706 clk_enable(fimc->clock[CLK_GATE]);
1709 fimc_hw_reset(fimc); 1707 fimc_hw_reset(fimc);
1710 if (fimc->variant->out_buf_count > 4)
1711 fimc_hw_set_dma_seq(fimc, 0xF);
1712 1708
1713 /* Resume the capture or mem-to-mem device */ 1709 /* Resume the capture or mem-to-mem device */
1714 if (fimc_capture_busy(fimc)) 1710 if (fimc_capture_busy(fimc))
@@ -1750,8 +1746,6 @@ static int fimc_resume(struct device *dev)
1750 return 0; 1746 return 0;
1751 } 1747 }
1752 fimc_hw_reset(fimc); 1748 fimc_hw_reset(fimc);
1753 if (fimc->variant->out_buf_count > 4)
1754 fimc_hw_set_dma_seq(fimc, 0xF);
1755 spin_unlock_irqrestore(&fimc->slock, flags); 1749 spin_unlock_irqrestore(&fimc->slock, flags);
1756 1750
1757 if (fimc_capture_busy(fimc)) 1751 if (fimc_capture_busy(fimc))
@@ -1780,7 +1774,6 @@ static int __devexit fimc_remove(struct platform_device *pdev)
1780 struct fimc_dev *fimc = platform_get_drvdata(pdev); 1774 struct fimc_dev *fimc = platform_get_drvdata(pdev);
1781 1775
1782 pm_runtime_disable(&pdev->dev); 1776 pm_runtime_disable(&pdev->dev);
1783 fimc_runtime_suspend(&pdev->dev);
1784 pm_runtime_set_suspended(&pdev->dev); 1777 pm_runtime_set_suspended(&pdev->dev);
1785 1778
1786 vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx); 1779 vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
@@ -1840,6 +1833,7 @@ static struct samsung_fimc_variant fimc0_variant_s5p = {
1840 .min_inp_pixsize = 16, 1833 .min_inp_pixsize = 16,
1841 .min_out_pixsize = 16, 1834 .min_out_pixsize = 16,
1842 .hor_offs_align = 8, 1835 .hor_offs_align = 8,
1836 .min_vsize_align = 16,
1843 .out_buf_count = 4, 1837 .out_buf_count = 4,
1844 .pix_limit = &s5p_pix_limit[0], 1838 .pix_limit = &s5p_pix_limit[0],
1845}; 1839};
@@ -1849,6 +1843,7 @@ static struct samsung_fimc_variant fimc2_variant_s5p = {
1849 .min_inp_pixsize = 16, 1843 .min_inp_pixsize = 16,
1850 .min_out_pixsize = 16, 1844 .min_out_pixsize = 16,
1851 .hor_offs_align = 8, 1845 .hor_offs_align = 8,
1846 .min_vsize_align = 16,
1852 .out_buf_count = 4, 1847 .out_buf_count = 4,
1853 .pix_limit = &s5p_pix_limit[1], 1848 .pix_limit = &s5p_pix_limit[1],
1854}; 1849};
@@ -1861,6 +1856,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv210 = {
1861 .min_inp_pixsize = 16, 1856 .min_inp_pixsize = 16,
1862 .min_out_pixsize = 16, 1857 .min_out_pixsize = 16,
1863 .hor_offs_align = 8, 1858 .hor_offs_align = 8,
1859 .min_vsize_align = 16,
1864 .out_buf_count = 4, 1860 .out_buf_count = 4,
1865 .pix_limit = &s5p_pix_limit[1], 1861 .pix_limit = &s5p_pix_limit[1],
1866}; 1862};
@@ -1874,6 +1870,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = {
1874 .min_inp_pixsize = 16, 1870 .min_inp_pixsize = 16,
1875 .min_out_pixsize = 16, 1871 .min_out_pixsize = 16,
1876 .hor_offs_align = 1, 1872 .hor_offs_align = 1,
1873 .min_vsize_align = 1,
1877 .out_buf_count = 4, 1874 .out_buf_count = 4,
1878 .pix_limit = &s5p_pix_limit[2], 1875 .pix_limit = &s5p_pix_limit[2],
1879}; 1876};
@@ -1884,6 +1881,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv210 = {
1884 .min_inp_pixsize = 16, 1881 .min_inp_pixsize = 16,
1885 .min_out_pixsize = 16, 1882 .min_out_pixsize = 16,
1886 .hor_offs_align = 8, 1883 .hor_offs_align = 8,
1884 .min_vsize_align = 16,
1887 .out_buf_count = 4, 1885 .out_buf_count = 4,
1888 .pix_limit = &s5p_pix_limit[2], 1886 .pix_limit = &s5p_pix_limit[2],
1889}; 1887};
@@ -1898,6 +1896,7 @@ static struct samsung_fimc_variant fimc0_variant_exynos4 = {
1898 .min_inp_pixsize = 16, 1896 .min_inp_pixsize = 16,
1899 .min_out_pixsize = 16, 1897 .min_out_pixsize = 16,
1900 .hor_offs_align = 2, 1898 .hor_offs_align = 2,
1899 .min_vsize_align = 1,
1901 .out_buf_count = 32, 1900 .out_buf_count = 32,
1902 .pix_limit = &s5p_pix_limit[1], 1901 .pix_limit = &s5p_pix_limit[1],
1903}; 1902};
@@ -1910,6 +1909,7 @@ static struct samsung_fimc_variant fimc3_variant_exynos4 = {
1910 .min_inp_pixsize = 16, 1909 .min_inp_pixsize = 16,
1911 .min_out_pixsize = 16, 1910 .min_out_pixsize = 16,
1912 .hor_offs_align = 2, 1911 .hor_offs_align = 2,
1912 .min_vsize_align = 1,
1913 .out_buf_count = 32, 1913 .out_buf_count = 32,
1914 .pix_limit = &s5p_pix_limit[3], 1914 .pix_limit = &s5p_pix_limit[3],
1915}; 1915};
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h b/drivers/media/video/s5p-fimc/fimc-core.h
index a6936dad5b1..c7f01c47b20 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -377,6 +377,7 @@ struct fimc_pix_limit {
377 * @min_inp_pixsize: minimum input pixel size 377 * @min_inp_pixsize: minimum input pixel size
378 * @min_out_pixsize: minimum output pixel size 378 * @min_out_pixsize: minimum output pixel size
379 * @hor_offs_align: horizontal pixel offset aligment 379 * @hor_offs_align: horizontal pixel offset aligment
380 * @min_vsize_align: minimum vertical pixel size alignment
380 * @out_buf_count: the number of buffers in output DMA sequence 381 * @out_buf_count: the number of buffers in output DMA sequence
381 */ 382 */
382struct samsung_fimc_variant { 383struct samsung_fimc_variant {
@@ -390,6 +391,7 @@ struct samsung_fimc_variant {
390 u16 min_inp_pixsize; 391 u16 min_inp_pixsize;
391 u16 min_out_pixsize; 392 u16 min_out_pixsize;
392 u16 hor_offs_align; 393 u16 hor_offs_align;
394 u16 min_vsize_align;
393 u16 out_buf_count; 395 u16 out_buf_count;
394}; 396};
395 397
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c b/drivers/media/video/s5p-fimc/fimc-mdevice.c
index cc337b1de91..615c862f036 100644
--- a/drivers/media/video/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c
@@ -220,6 +220,7 @@ static struct v4l2_subdev *fimc_md_register_sensor(struct fimc_md *fmd,
220 sd = v4l2_i2c_new_subdev_board(&fmd->v4l2_dev, adapter, 220 sd = v4l2_i2c_new_subdev_board(&fmd->v4l2_dev, adapter,
221 s_info->pdata->board_info, NULL); 221 s_info->pdata->board_info, NULL);
222 if (IS_ERR_OR_NULL(sd)) { 222 if (IS_ERR_OR_NULL(sd)) {
223 i2c_put_adapter(adapter);
223 v4l2_err(&fmd->v4l2_dev, "Failed to acquire subdev\n"); 224 v4l2_err(&fmd->v4l2_dev, "Failed to acquire subdev\n");
224 return NULL; 225 return NULL;
225 } 226 }
@@ -234,12 +235,15 @@ static struct v4l2_subdev *fimc_md_register_sensor(struct fimc_md *fmd,
234static void fimc_md_unregister_sensor(struct v4l2_subdev *sd) 235static void fimc_md_unregister_sensor(struct v4l2_subdev *sd)
235{ 236{
236 struct i2c_client *client = v4l2_get_subdevdata(sd); 237 struct i2c_client *client = v4l2_get_subdevdata(sd);
238 struct i2c_adapter *adapter;
237 239
238 if (!client) 240 if (!client)
239 return; 241 return;
240 v4l2_device_unregister_subdev(sd); 242 v4l2_device_unregister_subdev(sd);
243 adapter = client->adapter;
241 i2c_unregister_device(client); 244 i2c_unregister_device(client);
242 i2c_put_adapter(client->adapter); 245 if (adapter)
246 i2c_put_adapter(adapter);
243} 247}
244 248
245static int fimc_md_register_sensor_entities(struct fimc_md *fmd) 249static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
@@ -381,20 +385,28 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd)
381 385
382static int fimc_md_register_video_nodes(struct fimc_md *fmd) 386static int fimc_md_register_video_nodes(struct fimc_md *fmd)
383{ 387{
388 struct video_device *vdev;
384 int i, ret = 0; 389 int i, ret = 0;
385 390
386 for (i = 0; i < FIMC_MAX_DEVS && !ret; i++) { 391 for (i = 0; i < FIMC_MAX_DEVS && !ret; i++) {
387 if (!fmd->fimc[i]) 392 if (!fmd->fimc[i])
388 continue; 393 continue;
389 394
390 if (fmd->fimc[i]->m2m.vfd) 395 vdev = fmd->fimc[i]->m2m.vfd;
391 ret = video_register_device(fmd->fimc[i]->m2m.vfd, 396 if (vdev) {
392 VFL_TYPE_GRABBER, -1); 397 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
393 if (ret) 398 if (ret)
394 break; 399 break;
395 if (fmd->fimc[i]->vid_cap.vfd) 400 v4l2_info(&fmd->v4l2_dev, "Registered %s as /dev/%s\n",
396 ret = video_register_device(fmd->fimc[i]->vid_cap.vfd, 401 vdev->name, video_device_node_name(vdev));
397 VFL_TYPE_GRABBER, -1); 402 }
403
404 vdev = fmd->fimc[i]->vid_cap.vfd;
405 if (vdev == NULL)
406 continue;
407 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
408 v4l2_info(&fmd->v4l2_dev, "Registered %s as /dev/%s\n",
409 vdev->name, video_device_node_name(vdev));
398 } 410 }
399 411
400 return ret; 412 return ret;
@@ -502,7 +514,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
502 if (WARN(csis == NULL, 514 if (WARN(csis == NULL,
503 "MIPI-CSI interface specified " 515 "MIPI-CSI interface specified "
504 "but s5p-csis module is not loaded!\n")) 516 "but s5p-csis module is not loaded!\n"))
505 continue; 517 return -EINVAL;
506 518
507 ret = media_entity_create_link(&sensor->entity, 0, 519 ret = media_entity_create_link(&sensor->entity, 0,
508 &csis->entity, CSIS_PAD_SINK, 520 &csis->entity, CSIS_PAD_SINK,
@@ -742,9 +754,6 @@ static int __devinit fimc_md_probe(struct platform_device *pdev)
742 struct fimc_md *fmd; 754 struct fimc_md *fmd;
743 int ret; 755 int ret;
744 756
745 if (WARN(!pdev->dev.platform_data, "Platform data not specified!\n"))
746 return -EINVAL;
747
748 fmd = kzalloc(sizeof(struct fimc_md), GFP_KERNEL); 757 fmd = kzalloc(sizeof(struct fimc_md), GFP_KERNEL);
749 if (!fmd) 758 if (!fmd)
750 return -ENOMEM; 759 return -ENOMEM;
@@ -782,9 +791,11 @@ static int __devinit fimc_md_probe(struct platform_device *pdev)
782 if (ret) 791 if (ret)
783 goto err3; 792 goto err3;
784 793
785 ret = fimc_md_register_sensor_entities(fmd); 794 if (pdev->dev.platform_data) {
786 if (ret) 795 ret = fimc_md_register_sensor_entities(fmd);
787 goto err3; 796 if (ret)
797 goto err3;
798 }
788 ret = fimc_md_create_links(fmd); 799 ret = fimc_md_create_links(fmd);
789 if (ret) 800 if (ret)
790 goto err3; 801 goto err3;
diff --git a/drivers/media/video/s5p-fimc/fimc-reg.c b/drivers/media/video/s5p-fimc/fimc-reg.c
index 20e664e3416..44f5c2d1920 100644
--- a/drivers/media/video/s5p-fimc/fimc-reg.c
+++ b/drivers/media/video/s5p-fimc/fimc-reg.c
@@ -35,6 +35,9 @@ void fimc_hw_reset(struct fimc_dev *dev)
35 cfg = readl(dev->regs + S5P_CIGCTRL); 35 cfg = readl(dev->regs + S5P_CIGCTRL);
36 cfg &= ~S5P_CIGCTRL_SWRST; 36 cfg &= ~S5P_CIGCTRL_SWRST;
37 writel(cfg, dev->regs + S5P_CIGCTRL); 37 writel(cfg, dev->regs + S5P_CIGCTRL);
38
39 if (dev->variant->out_buf_count > 4)
40 fimc_hw_set_dma_seq(dev, 0xF);
38} 41}
39 42
40static u32 fimc_hw_get_in_flip(struct fimc_ctx *ctx) 43static u32 fimc_hw_get_in_flip(struct fimc_ctx *ctx)
@@ -251,7 +254,14 @@ static void fimc_hw_set_scaler(struct fimc_ctx *ctx)
251 struct fimc_scaler *sc = &ctx->scaler; 254 struct fimc_scaler *sc = &ctx->scaler;
252 struct fimc_frame *src_frame = &ctx->s_frame; 255 struct fimc_frame *src_frame = &ctx->s_frame;
253 struct fimc_frame *dst_frame = &ctx->d_frame; 256 struct fimc_frame *dst_frame = &ctx->d_frame;
254 u32 cfg = 0; 257
258 u32 cfg = readl(dev->regs + S5P_CISCCTRL);
259
260 cfg &= ~(S5P_CISCCTRL_CSCR2Y_WIDE | S5P_CISCCTRL_CSCY2R_WIDE |
261 S5P_CISCCTRL_SCALEUP_H | S5P_CISCCTRL_SCALEUP_V |
262 S5P_CISCCTRL_SCALERBYPASS | S5P_CISCCTRL_ONE2ONE |
263 S5P_CISCCTRL_INRGB_FMT_MASK | S5P_CISCCTRL_OUTRGB_FMT_MASK |
264 S5P_CISCCTRL_INTERLACE | S5P_CISCCTRL_RGB_EXT);
255 265
256 if (!(ctx->flags & FIMC_COLOR_RANGE_NARROW)) 266 if (!(ctx->flags & FIMC_COLOR_RANGE_NARROW))
257 cfg |= (S5P_CISCCTRL_CSCR2Y_WIDE | S5P_CISCCTRL_CSCY2R_WIDE); 267 cfg |= (S5P_CISCCTRL_CSCR2Y_WIDE | S5P_CISCCTRL_CSCY2R_WIDE);
@@ -308,9 +318,9 @@ void fimc_hw_set_mainscaler(struct fimc_ctx *ctx)
308 fimc_hw_set_scaler(ctx); 318 fimc_hw_set_scaler(ctx);
309 319
310 cfg = readl(dev->regs + S5P_CISCCTRL); 320 cfg = readl(dev->regs + S5P_CISCCTRL);
321 cfg &= ~(S5P_CISCCTRL_MHRATIO_MASK | S5P_CISCCTRL_MVRATIO_MASK);
311 322
312 if (variant->has_mainscaler_ext) { 323 if (variant->has_mainscaler_ext) {
313 cfg &= ~(S5P_CISCCTRL_MHRATIO_MASK | S5P_CISCCTRL_MVRATIO_MASK);
314 cfg |= S5P_CISCCTRL_MHRATIO_EXT(sc->main_hratio); 324 cfg |= S5P_CISCCTRL_MHRATIO_EXT(sc->main_hratio);
315 cfg |= S5P_CISCCTRL_MVRATIO_EXT(sc->main_vratio); 325 cfg |= S5P_CISCCTRL_MVRATIO_EXT(sc->main_vratio);
316 writel(cfg, dev->regs + S5P_CISCCTRL); 326 writel(cfg, dev->regs + S5P_CISCCTRL);
@@ -323,7 +333,6 @@ void fimc_hw_set_mainscaler(struct fimc_ctx *ctx)
323 cfg |= S5P_CIEXTEN_MVRATIO_EXT(sc->main_vratio); 333 cfg |= S5P_CIEXTEN_MVRATIO_EXT(sc->main_vratio);
324 writel(cfg, dev->regs + S5P_CIEXTEN); 334 writel(cfg, dev->regs + S5P_CIEXTEN);
325 } else { 335 } else {
326 cfg &= ~(S5P_CISCCTRL_MHRATIO_MASK | S5P_CISCCTRL_MVRATIO_MASK);
327 cfg |= S5P_CISCCTRL_MHRATIO(sc->main_hratio); 336 cfg |= S5P_CISCCTRL_MHRATIO(sc->main_hratio);
328 cfg |= S5P_CISCCTRL_MVRATIO(sc->main_vratio); 337 cfg |= S5P_CISCCTRL_MVRATIO(sc->main_vratio);
329 writel(cfg, dev->regs + S5P_CISCCTRL); 338 writel(cfg, dev->regs + S5P_CISCCTRL);
diff --git a/drivers/media/video/s5p-mfc/s5p_mfc_enc.c b/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
index 1e8cdb77d4b..dff9dc79879 100644
--- a/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/video/s5p-mfc/s5p_mfc_enc.c
@@ -61,7 +61,7 @@ static struct s5p_mfc_fmt formats[] = {
61 .num_planes = 1, 61 .num_planes = 1,
62 }, 62 },
63 { 63 {
64 .name = "H264 Encoded Stream", 64 .name = "H263 Encoded Stream",
65 .fourcc = V4L2_PIX_FMT_H263, 65 .fourcc = V4L2_PIX_FMT_H263,
66 .codec_mode = S5P_FIMV_CODEC_H263_ENC, 66 .codec_mode = S5P_FIMV_CODEC_H263_ENC,
67 .type = MFC_FMT_ENC, 67 .type = MFC_FMT_ENC,
diff --git a/drivers/media/video/s5p-tv/mixer_video.c b/drivers/media/video/s5p-tv/mixer_video.c
index e16d3a4bc1d..b47d0c06ecf 100644
--- a/drivers/media/video/s5p-tv/mixer_video.c
+++ b/drivers/media/video/s5p-tv/mixer_video.c
@@ -16,6 +16,7 @@
16#include <media/v4l2-ioctl.h> 16#include <media/v4l2-ioctl.h>
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/module.h>
19#include <linux/version.h> 20#include <linux/version.h>
20#include <linux/timer.h> 21#include <linux/timer.h>
21#include <media/videobuf2-dma-contig.h> 22#include <media/videobuf2-dma-contig.h>
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index f390682629c..c51decfcae1 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -566,8 +566,10 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
566 ret = sh_mobile_ceu_soft_reset(pcdev); 566 ret = sh_mobile_ceu_soft_reset(pcdev);
567 567
568 csi2_sd = find_csi2(pcdev); 568 csi2_sd = find_csi2(pcdev);
569 if (csi2_sd) 569 if (csi2_sd) {
570 csi2_sd->grp_id = (long)icd; 570 csi2_sd->grp_id = soc_camera_grp_id(icd);
571 v4l2_set_subdev_hostdata(csi2_sd, icd);
572 }
571 573
572 ret = v4l2_subdev_call(csi2_sd, core, s_power, 1); 574 ret = v4l2_subdev_call(csi2_sd, core, s_power, 1);
573 if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) { 575 if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) {
@@ -768,7 +770,7 @@ static struct v4l2_subdev *find_bus_subdev(struct sh_mobile_ceu_dev *pcdev,
768{ 770{
769 if (pcdev->csi2_pdev) { 771 if (pcdev->csi2_pdev) {
770 struct v4l2_subdev *csi2_sd = find_csi2(pcdev); 772 struct v4l2_subdev *csi2_sd = find_csi2(pcdev);
771 if (csi2_sd && csi2_sd->grp_id == (u32)icd) 773 if (csi2_sd && csi2_sd->grp_id == soc_camera_grp_id(icd))
772 return csi2_sd; 774 return csi2_sd;
773 } 775 }
774 776
@@ -1089,8 +1091,9 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
1089 /* Try 2560x1920, 1280x960, 640x480, 320x240 */ 1091 /* Try 2560x1920, 1280x960, 640x480, 320x240 */
1090 mf.width = 2560 >> shift; 1092 mf.width = 2560 >> shift;
1091 mf.height = 1920 >> shift; 1093 mf.height = 1920 >> shift;
1092 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, 1094 ret = v4l2_device_call_until_err(sd->v4l2_dev,
1093 s_mbus_fmt, &mf); 1095 soc_camera_grp_id(icd), video,
1096 s_mbus_fmt, &mf);
1094 if (ret < 0) 1097 if (ret < 0)
1095 return ret; 1098 return ret;
1096 shift++; 1099 shift++;
@@ -1389,7 +1392,8 @@ static int client_s_fmt(struct soc_camera_device *icd,
1389 bool ceu_1to1; 1392 bool ceu_1to1;
1390 int ret; 1393 int ret;
1391 1394
1392 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, 1395 ret = v4l2_device_call_until_err(sd->v4l2_dev,
1396 soc_camera_grp_id(icd), video,
1393 s_mbus_fmt, mf); 1397 s_mbus_fmt, mf);
1394 if (ret < 0) 1398 if (ret < 0)
1395 return ret; 1399 return ret;
@@ -1426,8 +1430,9 @@ static int client_s_fmt(struct soc_camera_device *icd,
1426 tmp_h = min(2 * tmp_h, max_height); 1430 tmp_h = min(2 * tmp_h, max_height);
1427 mf->width = tmp_w; 1431 mf->width = tmp_w;
1428 mf->height = tmp_h; 1432 mf->height = tmp_h;
1429 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, 1433 ret = v4l2_device_call_until_err(sd->v4l2_dev,
1430 s_mbus_fmt, mf); 1434 soc_camera_grp_id(icd), video,
1435 s_mbus_fmt, mf);
1431 dev_geo(dev, "Camera scaled to %ux%u\n", 1436 dev_geo(dev, "Camera scaled to %ux%u\n",
1432 mf->width, mf->height); 1437 mf->width, mf->height);
1433 if (ret < 0) { 1438 if (ret < 0) {
@@ -1580,8 +1585,9 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
1580 } 1585 }
1581 1586
1582 if (interm_width < icd->user_width || interm_height < icd->user_height) { 1587 if (interm_width < icd->user_width || interm_height < icd->user_height) {
1583 ret = v4l2_device_call_until_err(sd->v4l2_dev, (int)icd, video, 1588 ret = v4l2_device_call_until_err(sd->v4l2_dev,
1584 s_mbus_fmt, &mf); 1589 soc_camera_grp_id(icd), video,
1590 s_mbus_fmt, &mf);
1585 if (ret < 0) 1591 if (ret < 0)
1586 return ret; 1592 return ret;
1587 1593
@@ -1867,7 +1873,8 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1867 mf.code = xlate->code; 1873 mf.code = xlate->code;
1868 mf.colorspace = pix->colorspace; 1874 mf.colorspace = pix->colorspace;
1869 1875
1870 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, try_mbus_fmt, &mf); 1876 ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd),
1877 video, try_mbus_fmt, &mf);
1871 if (ret < 0) 1878 if (ret < 0)
1872 return ret; 1879 return ret;
1873 1880
@@ -1891,8 +1898,9 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1891 */ 1898 */
1892 mf.width = 2560; 1899 mf.width = 2560;
1893 mf.height = 1920; 1900 mf.height = 1920;
1894 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, 1901 ret = v4l2_device_call_until_err(sd->v4l2_dev,
1895 try_mbus_fmt, &mf); 1902 soc_camera_grp_id(icd), video,
1903 try_mbus_fmt, &mf);
1896 if (ret < 0) { 1904 if (ret < 0) {
1897 /* Shouldn't actually happen... */ 1905 /* Shouldn't actually happen... */
1898 dev_err(icd->parent, 1906 dev_err(icd->parent,
diff --git a/drivers/media/video/sh_mobile_csi2.c b/drivers/media/video/sh_mobile_csi2.c
index ea4f0473ed3..8a652b53ff7 100644
--- a/drivers/media/video/sh_mobile_csi2.c
+++ b/drivers/media/video/sh_mobile_csi2.c
@@ -143,7 +143,7 @@ static int sh_csi2_s_mbus_config(struct v4l2_subdev *sd,
143 const struct v4l2_mbus_config *cfg) 143 const struct v4l2_mbus_config *cfg)
144{ 144{
145 struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); 145 struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev);
146 struct soc_camera_device *icd = (struct soc_camera_device *)sd->grp_id; 146 struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd);
147 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd); 147 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd);
148 struct v4l2_mbus_config client_cfg = {.type = V4L2_MBUS_CSI2, 148 struct v4l2_mbus_config client_cfg = {.type = V4L2_MBUS_CSI2,
149 .flags = priv->mipi_flags}; 149 .flags = priv->mipi_flags};
@@ -202,7 +202,7 @@ static void sh_csi2_hwinit(struct sh_csi2 *priv)
202static int sh_csi2_client_connect(struct sh_csi2 *priv) 202static int sh_csi2_client_connect(struct sh_csi2 *priv)
203{ 203{
204 struct sh_csi2_pdata *pdata = priv->pdev->dev.platform_data; 204 struct sh_csi2_pdata *pdata = priv->pdev->dev.platform_data;
205 struct soc_camera_device *icd = (struct soc_camera_device *)priv->subdev.grp_id; 205 struct soc_camera_device *icd = v4l2_get_subdev_hostdata(&priv->subdev);
206 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd); 206 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd);
207 struct device *dev = v4l2_get_subdevdata(&priv->subdev); 207 struct device *dev = v4l2_get_subdevdata(&priv->subdev);
208 struct v4l2_mbus_config cfg; 208 struct v4l2_mbus_config cfg;
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index b72580c3895..62e4312515c 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -1103,7 +1103,8 @@ static int soc_camera_probe(struct soc_camera_device *icd)
1103 } 1103 }
1104 1104
1105 sd = soc_camera_to_subdev(icd); 1105 sd = soc_camera_to_subdev(icd);
1106 sd->grp_id = (long)icd; 1106 sd->grp_id = soc_camera_grp_id(icd);
1107 v4l2_set_subdev_hostdata(sd, icd);
1107 1108
1108 if (v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler)) 1109 if (v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler))
1109 goto ectrl; 1110 goto ectrl;
diff --git a/drivers/mfd/ab5500-debugfs.c b/drivers/mfd/ab5500-debugfs.c
index 43c0ebb8195..b7b2d3483fd 100644
--- a/drivers/mfd/ab5500-debugfs.c
+++ b/drivers/mfd/ab5500-debugfs.c
@@ -4,7 +4,7 @@
4 * Debugfs support for the AB5500 MFD driver 4 * Debugfs support for the AB5500 MFD driver
5 */ 5 */
6 6
7#include <linux/export.h> 7#include <linux/module.h>
8#include <linux/debugfs.h> 8#include <linux/debugfs.h>
9#include <linux/seq_file.h> 9#include <linux/seq_file.h>
10#include <linux/mfd/ab5500/ab5500.h> 10#include <linux/mfd/ab5500/ab5500.h>
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 1e9173804ed..d3d572b2317 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -620,6 +620,7 @@ static struct resource __devinitdata ab8500_fg_resources[] = {
620 620
621static struct resource __devinitdata ab8500_chargalg_resources[] = {}; 621static struct resource __devinitdata ab8500_chargalg_resources[] = {};
622 622
623#ifdef CONFIG_DEBUG_FS
623static struct resource __devinitdata ab8500_debug_resources[] = { 624static struct resource __devinitdata ab8500_debug_resources[] = {
624 { 625 {
625 .name = "IRQ_FIRST", 626 .name = "IRQ_FIRST",
@@ -634,6 +635,7 @@ static struct resource __devinitdata ab8500_debug_resources[] = {
634 .flags = IORESOURCE_IRQ, 635 .flags = IORESOURCE_IRQ,
635 }, 636 },
636}; 637};
638#endif
637 639
638static struct resource __devinitdata ab8500_usb_resources[] = { 640static struct resource __devinitdata ab8500_usb_resources[] = {
639 { 641 {
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
index f1d88483112..8d816cce832 100644
--- a/drivers/mfd/adp5520.c
+++ b/drivers/mfd/adp5520.c
@@ -109,7 +109,7 @@ int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask)
109 109
110 ret = __adp5520_read(chip->client, reg, &reg_val); 110 ret = __adp5520_read(chip->client, reg, &reg_val);
111 111
112 if (!ret && ((reg_val & bit_mask) == 0)) { 112 if (!ret && ((reg_val & bit_mask) != bit_mask)) {
113 reg_val |= bit_mask; 113 reg_val |= bit_mask;
114 ret = __adp5520_write(chip->client, reg, reg_val); 114 ret = __adp5520_write(chip->client, reg, reg_val);
115 } 115 }
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index 1b79c37fd59..1924b857a0f 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -182,7 +182,7 @@ int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask)
182 if (ret) 182 if (ret)
183 goto out; 183 goto out;
184 184
185 if ((reg_val & bit_mask) == 0) { 185 if ((reg_val & bit_mask) != bit_mask) {
186 reg_val |= bit_mask; 186 reg_val |= bit_mask;
187 ret = __da903x_write(chip->client, reg, reg_val); 187 ret = __da903x_write(chip->client, reg, reg_val);
188 } 188 }
@@ -549,6 +549,7 @@ static int __devexit da903x_remove(struct i2c_client *client)
549 struct da903x_chip *chip = i2c_get_clientdata(client); 549 struct da903x_chip *chip = i2c_get_clientdata(client);
550 550
551 da903x_remove_subdevs(chip); 551 da903x_remove_subdevs(chip);
552 free_irq(client->irq, chip);
552 kfree(chip); 553 kfree(chip);
553 return 0; 554 return 0;
554} 555}
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c
index 1e9ee533eac..ef39528088f 100644
--- a/drivers/mfd/jz4740-adc.c
+++ b/drivers/mfd/jz4740-adc.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/io.h>
19#include <linux/irq.h> 20#include <linux/irq.h>
20#include <linux/interrupt.h> 21#include <linux/interrupt.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index bba26d96c24..a5ddf31b60c 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -197,7 +197,7 @@ int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask)
197 if (ret) 197 if (ret)
198 goto out; 198 goto out;
199 199
200 if ((reg_val & bit_mask) == 0) { 200 if ((reg_val & bit_mask) != bit_mask) {
201 reg_val |= bit_mask; 201 reg_val |= bit_mask;
202 ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val); 202 ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val);
203 } 203 }
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 6f5b8cf2f65..c1da84bc157 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -120,7 +120,7 @@ int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask)
120 goto out; 120 goto out;
121 } 121 }
122 122
123 data &= mask; 123 data &= ~mask;
124 err = tps65910_i2c_write(tps65910, reg, 1, &data); 124 err = tps65910_i2c_write(tps65910, reg, 1, &data);
125 if (err) 125 if (err)
126 dev_err(tps65910->dev, "write to reg %x failed\n", reg); 126 dev_err(tps65910->dev, "write to reg %x failed\n", reg);
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index bfbd66021af..61e70cfaa77 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -363,13 +363,13 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
363 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 363 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
364 return -EPERM; 364 return -EPERM;
365 } 365 }
366 sid = twl_map[mod_no].sid;
367 twl = &twl_modules[sid];
368
369 if (unlikely(!inuse)) { 366 if (unlikely(!inuse)) {
370 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 367 pr_err("%s: not initialized\n", DRIVER_NAME);
371 return -EPERM; 368 return -EPERM;
372 } 369 }
370 sid = twl_map[mod_no].sid;
371 twl = &twl_modules[sid];
372
373 mutex_lock(&twl->xfer_lock); 373 mutex_lock(&twl->xfer_lock);
374 /* 374 /*
375 * [MSG1]: fill the register address data 375 * [MSG1]: fill the register address data
@@ -420,13 +420,13 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
420 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 420 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
421 return -EPERM; 421 return -EPERM;
422 } 422 }
423 sid = twl_map[mod_no].sid;
424 twl = &twl_modules[sid];
425
426 if (unlikely(!inuse)) { 423 if (unlikely(!inuse)) {
427 pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid); 424 pr_err("%s: not initialized\n", DRIVER_NAME);
428 return -EPERM; 425 return -EPERM;
429 } 426 }
427 sid = twl_map[mod_no].sid;
428 twl = &twl_modules[sid];
429
430 mutex_lock(&twl->xfer_lock); 430 mutex_lock(&twl->xfer_lock);
431 /* [MSG1] fill the register address data */ 431 /* [MSG1] fill the register address data */
432 msg = &twl->xfer_msg[0]; 432 msg = &twl->xfer_msg[0];
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index f062c8cc6c3..29f11e0765f 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -432,6 +432,7 @@ struct sih_agent {
432 u32 edge_change; 432 u32 edge_change;
433 433
434 struct mutex irq_lock; 434 struct mutex irq_lock;
435 char *irq_name;
435}; 436};
436 437
437/*----------------------------------------------------------------------*/ 438/*----------------------------------------------------------------------*/
@@ -589,7 +590,7 @@ static inline int sih_read_isr(const struct sih *sih)
589 * Generic handler for SIH interrupts ... we "know" this is called 590 * Generic handler for SIH interrupts ... we "know" this is called
590 * in task context, with IRQs enabled. 591 * in task context, with IRQs enabled.
591 */ 592 */
592static void handle_twl4030_sih(unsigned irq, struct irq_desc *desc) 593static irqreturn_t handle_twl4030_sih(int irq, void *data)
593{ 594{
594 struct sih_agent *agent = irq_get_handler_data(irq); 595 struct sih_agent *agent = irq_get_handler_data(irq);
595 const struct sih *sih = agent->sih; 596 const struct sih *sih = agent->sih;
@@ -602,7 +603,7 @@ static void handle_twl4030_sih(unsigned irq, struct irq_desc *desc)
602 pr_err("twl4030: %s SIH, read ISR error %d\n", 603 pr_err("twl4030: %s SIH, read ISR error %d\n",
603 sih->name, isr); 604 sih->name, isr);
604 /* REVISIT: recover; eventually mask it all, etc */ 605 /* REVISIT: recover; eventually mask it all, etc */
605 return; 606 return IRQ_HANDLED;
606 } 607 }
607 608
608 while (isr) { 609 while (isr) {
@@ -616,6 +617,7 @@ static void handle_twl4030_sih(unsigned irq, struct irq_desc *desc)
616 pr_err("twl4030: %s SIH, invalid ISR bit %d\n", 617 pr_err("twl4030: %s SIH, invalid ISR bit %d\n",
617 sih->name, irq); 618 sih->name, irq);
618 } 619 }
620 return IRQ_HANDLED;
619} 621}
620 622
621static unsigned twl4030_irq_next; 623static unsigned twl4030_irq_next;
@@ -668,18 +670,19 @@ int twl4030_sih_setup(int module)
668 activate_irq(irq); 670 activate_irq(irq);
669 } 671 }
670 672
671 status = irq_base;
672 twl4030_irq_next += i; 673 twl4030_irq_next += i;
673 674
674 /* replace generic PIH handler (handle_simple_irq) */ 675 /* replace generic PIH handler (handle_simple_irq) */
675 irq = sih_mod + twl4030_irq_base; 676 irq = sih_mod + twl4030_irq_base;
676 irq_set_handler_data(irq, agent); 677 irq_set_handler_data(irq, agent);
677 irq_set_chained_handler(irq, handle_twl4030_sih); 678 agent->irq_name = kasprintf(GFP_KERNEL, "twl4030_%s", sih->name);
679 status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0,
680 agent->irq_name ?: sih->name, NULL);
678 681
679 pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name, 682 pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name,
680 irq, irq_base, twl4030_irq_next - 1); 683 irq, irq_base, twl4030_irq_next - 1);
681 684
682 return status; 685 return status < 0 ? status : irq_base;
683} 686}
684 687
685/* FIXME need a call to reverse twl4030_sih_setup() ... */ 688/* FIXME need a call to reverse twl4030_sih_setup() ... */
@@ -733,8 +736,9 @@ int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
733 } 736 }
734 737
735 /* install an irq handler to demultiplex the TWL4030 interrupt */ 738 /* install an irq handler to demultiplex the TWL4030 interrupt */
736 status = request_threaded_irq(irq_num, NULL, handle_twl4030_pih, 0, 739 status = request_threaded_irq(irq_num, NULL, handle_twl4030_pih,
737 "TWL4030-PIH", NULL); 740 IRQF_ONESHOT,
741 "TWL4030-PIH", NULL);
738 if (status < 0) { 742 if (status < 0) {
739 pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status); 743 pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status);
740 goto fail_rqirq; 744 goto fail_rqirq;
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 5d6ba132837..61894fced8e 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -239,6 +239,7 @@ static int wm8994_suspend(struct device *dev)
239 239
240 switch (wm8994->type) { 240 switch (wm8994->type) {
241 case WM8958: 241 case WM8958:
242 case WM1811:
242 ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1); 243 ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1);
243 if (ret < 0) { 244 if (ret < 0) {
244 dev_err(dev, "Failed to read power status: %d\n", ret); 245 dev_err(dev, "Failed to read power status: %d\n", ret);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index e8a5eb38748..d31c78b72b0 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
302 host->max_blk_size = 512; 302 host->max_blk_size = 512;
303 host->max_blk_count = PAGE_CACHE_SIZE / 512; 303 host->max_blk_count = PAGE_CACHE_SIZE / 512;
304 304
305 /*
306 * Enable runtime power management by default. This flag was added due
307 * to runtime power management causing disruption for some users, but
308 * the power on/off code has been improved since then.
309 *
310 * We'll enable this flag by default as an experiment, and if no
311 * problems are reported, we will follow up later and remove the flag
312 * altogether.
313 */
314 host->caps = MMC_CAP_POWER_OFF_CARD;
315
316 return host; 305 return host;
317 306
318free: 307free:
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 50b5f9926f6..0726e59fd41 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -675,7 +675,8 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
675 unsigned int status) 675 unsigned int status)
676{ 676{
677 /* First check for errors */ 677 /* First check for errors */
678 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 678 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
679 MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
679 u32 remain, success; 680 u32 remain, success;
680 681
681 /* Terminate the DMA transfer */ 682 /* Terminate the DMA transfer */
@@ -754,8 +755,12 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
754 } 755 }
755 756
756 if (!cmd->data || cmd->error) { 757 if (!cmd->data || cmd->error) {
757 if (host->data) 758 if (host->data) {
759 /* Terminate the DMA transfer */
760 if (dma_inprogress(host))
761 mmci_dma_data_error(host);
758 mmci_stop_data(host); 762 mmci_stop_data(host);
763 }
759 mmci_request_end(host, cmd->mrq); 764 mmci_request_end(host, cmd->mrq);
760 } else if (!(cmd->data->flags & MMC_DATA_READ)) { 765 } else if (!(cmd->data->flags & MMC_DATA_READ)) {
761 mmci_start_data(host, cmd->data); 766 mmci_start_data(host, cmd->data);
@@ -955,8 +960,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
955 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status); 960 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
956 961
957 data = host->data; 962 data = host->data;
958 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN| 963 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
959 MCI_RXOVERRUN|MCI_DATAEND|MCI_DATABLOCKEND) && data) 964 MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND|
965 MCI_DATABLOCKEND) && data)
960 mmci_data_irq(host, data, status); 966 mmci_data_irq(host, data, status);
961 967
962 cmd = host->cmd; 968 cmd = host->cmd;
diff --git a/drivers/mmc/host/sdhci-cns3xxx.c b/drivers/mmc/host/sdhci-cns3xxx.c
index 87b6f079b6e..b4257e70061 100644
--- a/drivers/mmc/host/sdhci-cns3xxx.c
+++ b/drivers/mmc/host/sdhci-cns3xxx.c
@@ -109,13 +109,10 @@ static struct platform_driver sdhci_cns3xxx_driver = {
109 .driver = { 109 .driver = {
110 .name = "sdhci-cns3xxx", 110 .name = "sdhci-cns3xxx",
111 .owner = THIS_MODULE, 111 .owner = THIS_MODULE,
112 .pm = SDHCI_PLTFM_PMOPS,
112 }, 113 },
113 .probe = sdhci_cns3xxx_probe, 114 .probe = sdhci_cns3xxx_probe,
114 .remove = __devexit_p(sdhci_cns3xxx_remove), 115 .remove = __devexit_p(sdhci_cns3xxx_remove),
115#ifdef CONFIG_PM
116 .suspend = sdhci_pltfm_suspend,
117 .resume = sdhci_pltfm_resume,
118#endif
119}; 116};
120 117
121static int __init sdhci_cns3xxx_init(void) 118static int __init sdhci_cns3xxx_init(void)
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index f2d29dca442..a81312c91f7 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -82,13 +82,10 @@ static struct platform_driver sdhci_dove_driver = {
82 .driver = { 82 .driver = {
83 .name = "sdhci-dove", 83 .name = "sdhci-dove",
84 .owner = THIS_MODULE, 84 .owner = THIS_MODULE,
85 .pm = SDHCI_PLTFM_PMOPS,
85 }, 86 },
86 .probe = sdhci_dove_probe, 87 .probe = sdhci_dove_probe,
87 .remove = __devexit_p(sdhci_dove_remove), 88 .remove = __devexit_p(sdhci_dove_remove),
88#ifdef CONFIG_PM
89 .suspend = sdhci_pltfm_suspend,
90 .resume = sdhci_pltfm_resume,
91#endif
92}; 89};
93 90
94static int __init sdhci_dove_init(void) 91static int __init sdhci_dove_init(void)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 4b976f00ea8..38ebc4ea259 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -599,14 +599,11 @@ static struct platform_driver sdhci_esdhc_imx_driver = {
599 .name = "sdhci-esdhc-imx", 599 .name = "sdhci-esdhc-imx",
600 .owner = THIS_MODULE, 600 .owner = THIS_MODULE,
601 .of_match_table = imx_esdhc_dt_ids, 601 .of_match_table = imx_esdhc_dt_ids,
602 .pm = SDHCI_PLTFM_PMOPS,
602 }, 603 },
603 .id_table = imx_esdhc_devtype, 604 .id_table = imx_esdhc_devtype,
604 .probe = sdhci_esdhc_imx_probe, 605 .probe = sdhci_esdhc_imx_probe,
605 .remove = __devexit_p(sdhci_esdhc_imx_remove), 606 .remove = __devexit_p(sdhci_esdhc_imx_remove),
606#ifdef CONFIG_PM
607 .suspend = sdhci_pltfm_suspend,
608 .resume = sdhci_pltfm_resume,
609#endif
610}; 607};
611 608
612static int __init sdhci_esdhc_imx_init(void) 609static int __init sdhci_esdhc_imx_init(void)
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 59e9d003e58..01e5f627e0f 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -125,13 +125,10 @@ static struct platform_driver sdhci_esdhc_driver = {
125 .name = "sdhci-esdhc", 125 .name = "sdhci-esdhc",
126 .owner = THIS_MODULE, 126 .owner = THIS_MODULE,
127 .of_match_table = sdhci_esdhc_of_match, 127 .of_match_table = sdhci_esdhc_of_match,
128 .pm = SDHCI_PLTFM_PMOPS,
128 }, 129 },
129 .probe = sdhci_esdhc_probe, 130 .probe = sdhci_esdhc_probe,
130 .remove = __devexit_p(sdhci_esdhc_remove), 131 .remove = __devexit_p(sdhci_esdhc_remove),
131#ifdef CONFIG_PM
132 .suspend = sdhci_pltfm_suspend,
133 .resume = sdhci_pltfm_resume,
134#endif
135}; 132};
136 133
137static int __init sdhci_esdhc_init(void) 134static int __init sdhci_esdhc_init(void)
diff --git a/drivers/mmc/host/sdhci-of-hlwd.c b/drivers/mmc/host/sdhci-of-hlwd.c
index 9b0d794a4f6..3619adc7d9f 100644
--- a/drivers/mmc/host/sdhci-of-hlwd.c
+++ b/drivers/mmc/host/sdhci-of-hlwd.c
@@ -87,13 +87,10 @@ static struct platform_driver sdhci_hlwd_driver = {
87 .name = "sdhci-hlwd", 87 .name = "sdhci-hlwd",
88 .owner = THIS_MODULE, 88 .owner = THIS_MODULE,
89 .of_match_table = sdhci_hlwd_of_match, 89 .of_match_table = sdhci_hlwd_of_match,
90 .pm = SDHCI_PLTFM_PMOPS,
90 }, 91 },
91 .probe = sdhci_hlwd_probe, 92 .probe = sdhci_hlwd_probe,
92 .remove = __devexit_p(sdhci_hlwd_remove), 93 .remove = __devexit_p(sdhci_hlwd_remove),
93#ifdef CONFIG_PM
94 .suspend = sdhci_pltfm_suspend,
95 .resume = sdhci_pltfm_resume,
96#endif
97}; 94};
98 95
99static int __init sdhci_hlwd_init(void) 96static int __init sdhci_hlwd_init(void)
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index d833d9c2f7e..6878a94626b 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -54,8 +54,7 @@ struct sdhci_pci_fixes {
54 int (*probe_slot) (struct sdhci_pci_slot *); 54 int (*probe_slot) (struct sdhci_pci_slot *);
55 void (*remove_slot) (struct sdhci_pci_slot *, int); 55 void (*remove_slot) (struct sdhci_pci_slot *, int);
56 56
57 int (*suspend) (struct sdhci_pci_chip *, 57 int (*suspend) (struct sdhci_pci_chip *);
58 pm_message_t);
59 int (*resume) (struct sdhci_pci_chip *); 58 int (*resume) (struct sdhci_pci_chip *);
60}; 59};
61 60
@@ -549,7 +548,7 @@ static void jmicron_remove_slot(struct sdhci_pci_slot *slot, int dead)
549 jmicron_enable_mmc(slot->host, 0); 548 jmicron_enable_mmc(slot->host, 0);
550} 549}
551 550
552static int jmicron_suspend(struct sdhci_pci_chip *chip, pm_message_t state) 551static int jmicron_suspend(struct sdhci_pci_chip *chip)
553{ 552{
554 int i; 553 int i;
555 554
@@ -993,8 +992,9 @@ static struct sdhci_ops sdhci_pci_ops = {
993 992
994#ifdef CONFIG_PM 993#ifdef CONFIG_PM
995 994
996static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state) 995static int sdhci_pci_suspend(struct device *dev)
997{ 996{
997 struct pci_dev *pdev = to_pci_dev(dev);
998 struct sdhci_pci_chip *chip; 998 struct sdhci_pci_chip *chip;
999 struct sdhci_pci_slot *slot; 999 struct sdhci_pci_slot *slot;
1000 mmc_pm_flag_t slot_pm_flags; 1000 mmc_pm_flag_t slot_pm_flags;
@@ -1010,7 +1010,7 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1010 if (!slot) 1010 if (!slot)
1011 continue; 1011 continue;
1012 1012
1013 ret = sdhci_suspend_host(slot->host, state); 1013 ret = sdhci_suspend_host(slot->host);
1014 1014
1015 if (ret) { 1015 if (ret) {
1016 for (i--; i >= 0; i--) 1016 for (i--; i >= 0; i--)
@@ -1026,7 +1026,7 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1026 } 1026 }
1027 1027
1028 if (chip->fixes && chip->fixes->suspend) { 1028 if (chip->fixes && chip->fixes->suspend) {
1029 ret = chip->fixes->suspend(chip, state); 1029 ret = chip->fixes->suspend(chip);
1030 if (ret) { 1030 if (ret) {
1031 for (i = chip->num_slots - 1; i >= 0; i--) 1031 for (i = chip->num_slots - 1; i >= 0; i--)
1032 sdhci_resume_host(chip->slots[i]->host); 1032 sdhci_resume_host(chip->slots[i]->host);
@@ -1042,16 +1042,17 @@ static int sdhci_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1042 } 1042 }
1043 pci_set_power_state(pdev, PCI_D3hot); 1043 pci_set_power_state(pdev, PCI_D3hot);
1044 } else { 1044 } else {
1045 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); 1045 pci_enable_wake(pdev, PCI_D3hot, 0);
1046 pci_disable_device(pdev); 1046 pci_disable_device(pdev);
1047 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1047 pci_set_power_state(pdev, PCI_D3hot);
1048 } 1048 }
1049 1049
1050 return 0; 1050 return 0;
1051} 1051}
1052 1052
1053static int sdhci_pci_resume(struct pci_dev *pdev) 1053static int sdhci_pci_resume(struct device *dev)
1054{ 1054{
1055 struct pci_dev *pdev = to_pci_dev(dev);
1055 struct sdhci_pci_chip *chip; 1056 struct sdhci_pci_chip *chip;
1056 struct sdhci_pci_slot *slot; 1057 struct sdhci_pci_slot *slot;
1057 int i, ret; 1058 int i, ret;
@@ -1099,7 +1100,6 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
1099 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 1100 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
1100 struct sdhci_pci_chip *chip; 1101 struct sdhci_pci_chip *chip;
1101 struct sdhci_pci_slot *slot; 1102 struct sdhci_pci_slot *slot;
1102 pm_message_t state = { .event = PM_EVENT_SUSPEND };
1103 int i, ret; 1103 int i, ret;
1104 1104
1105 chip = pci_get_drvdata(pdev); 1105 chip = pci_get_drvdata(pdev);
@@ -1121,7 +1121,7 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
1121 } 1121 }
1122 1122
1123 if (chip->fixes && chip->fixes->suspend) { 1123 if (chip->fixes && chip->fixes->suspend) {
1124 ret = chip->fixes->suspend(chip, state); 1124 ret = chip->fixes->suspend(chip);
1125 if (ret) { 1125 if (ret) {
1126 for (i = chip->num_slots - 1; i >= 0; i--) 1126 for (i = chip->num_slots - 1; i >= 0; i--)
1127 sdhci_runtime_resume_host(chip->slots[i]->host); 1127 sdhci_runtime_resume_host(chip->slots[i]->host);
@@ -1176,6 +1176,8 @@ static int sdhci_pci_runtime_idle(struct device *dev)
1176#endif 1176#endif
1177 1177
1178static const struct dev_pm_ops sdhci_pci_pm_ops = { 1178static const struct dev_pm_ops sdhci_pci_pm_ops = {
1179 .suspend = sdhci_pci_suspend,
1180 .resume = sdhci_pci_resume,
1179 .runtime_suspend = sdhci_pci_runtime_suspend, 1181 .runtime_suspend = sdhci_pci_runtime_suspend,
1180 .runtime_resume = sdhci_pci_runtime_resume, 1182 .runtime_resume = sdhci_pci_runtime_resume,
1181 .runtime_idle = sdhci_pci_runtime_idle, 1183 .runtime_idle = sdhci_pci_runtime_idle,
@@ -1428,8 +1430,6 @@ static struct pci_driver sdhci_driver = {
1428 .id_table = pci_ids, 1430 .id_table = pci_ids,
1429 .probe = sdhci_pci_probe, 1431 .probe = sdhci_pci_probe,
1430 .remove = __devexit_p(sdhci_pci_remove), 1432 .remove = __devexit_p(sdhci_pci_remove),
1431 .suspend = sdhci_pci_suspend,
1432 .resume = sdhci_pci_resume,
1433 .driver = { 1433 .driver = {
1434 .pm = &sdhci_pci_pm_ops 1434 .pm = &sdhci_pci_pm_ops
1435 }, 1435 },
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index a9e12ea0558..03970bcb349 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -194,21 +194,25 @@ int sdhci_pltfm_unregister(struct platform_device *pdev)
194EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); 194EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister);
195 195
196#ifdef CONFIG_PM 196#ifdef CONFIG_PM
197int sdhci_pltfm_suspend(struct platform_device *dev, pm_message_t state) 197static int sdhci_pltfm_suspend(struct device *dev)
198{ 198{
199 struct sdhci_host *host = platform_get_drvdata(dev); 199 struct sdhci_host *host = dev_get_drvdata(dev);
200 200
201 return sdhci_suspend_host(host, state); 201 return sdhci_suspend_host(host);
202} 202}
203EXPORT_SYMBOL_GPL(sdhci_pltfm_suspend);
204 203
205int sdhci_pltfm_resume(struct platform_device *dev) 204static int sdhci_pltfm_resume(struct device *dev)
206{ 205{
207 struct sdhci_host *host = platform_get_drvdata(dev); 206 struct sdhci_host *host = dev_get_drvdata(dev);
208 207
209 return sdhci_resume_host(host); 208 return sdhci_resume_host(host);
210} 209}
211EXPORT_SYMBOL_GPL(sdhci_pltfm_resume); 210
211const struct dev_pm_ops sdhci_pltfm_pmops = {
212 .suspend = sdhci_pltfm_suspend,
213 .resume = sdhci_pltfm_resume,
214};
215EXPORT_SYMBOL_GPL(sdhci_pltfm_pmops);
212#endif /* CONFIG_PM */ 216#endif /* CONFIG_PM */
213 217
214static int __init sdhci_pltfm_drv_init(void) 218static int __init sdhci_pltfm_drv_init(void)
diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h
index 3a9fc3f4084..37e0e184a0b 100644
--- a/drivers/mmc/host/sdhci-pltfm.h
+++ b/drivers/mmc/host/sdhci-pltfm.h
@@ -99,8 +99,10 @@ extern int sdhci_pltfm_register(struct platform_device *pdev,
99extern int sdhci_pltfm_unregister(struct platform_device *pdev); 99extern int sdhci_pltfm_unregister(struct platform_device *pdev);
100 100
101#ifdef CONFIG_PM 101#ifdef CONFIG_PM
102extern int sdhci_pltfm_suspend(struct platform_device *dev, pm_message_t state); 102extern const struct dev_pm_ops sdhci_pltfm_pmops;
103extern int sdhci_pltfm_resume(struct platform_device *dev); 103#define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
104#else
105#define SDHCI_PLTFM_PMOPS NULL
104#endif 106#endif
105 107
106#endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */ 108#endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c
index d4bf6d30c7b..7a039c3cb1f 100644
--- a/drivers/mmc/host/sdhci-pxav2.c
+++ b/drivers/mmc/host/sdhci-pxav2.c
@@ -218,13 +218,10 @@ static struct platform_driver sdhci_pxav2_driver = {
218 .driver = { 218 .driver = {
219 .name = "sdhci-pxav2", 219 .name = "sdhci-pxav2",
220 .owner = THIS_MODULE, 220 .owner = THIS_MODULE,
221 .pm = SDHCI_PLTFM_PMOPS,
221 }, 222 },
222 .probe = sdhci_pxav2_probe, 223 .probe = sdhci_pxav2_probe,
223 .remove = __devexit_p(sdhci_pxav2_remove), 224 .remove = __devexit_p(sdhci_pxav2_remove),
224#ifdef CONFIG_PM
225 .suspend = sdhci_pltfm_suspend,
226 .resume = sdhci_pltfm_resume,
227#endif
228}; 225};
229static int __init sdhci_pxav2_init(void) 226static int __init sdhci_pxav2_init(void)
230{ 227{
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index cff4ad3e7a5..15673a7ee6a 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -264,13 +264,10 @@ static struct platform_driver sdhci_pxav3_driver = {
264 .driver = { 264 .driver = {
265 .name = "sdhci-pxav3", 265 .name = "sdhci-pxav3",
266 .owner = THIS_MODULE, 266 .owner = THIS_MODULE,
267 .pm = SDHCI_PLTFM_PMOPS,
267 }, 268 },
268 .probe = sdhci_pxav3_probe, 269 .probe = sdhci_pxav3_probe,
269 .remove = __devexit_p(sdhci_pxav3_remove), 270 .remove = __devexit_p(sdhci_pxav3_remove),
270#ifdef CONFIG_PM
271 .suspend = sdhci_pltfm_suspend,
272 .resume = sdhci_pltfm_resume,
273#endif
274}; 271};
275static int __init sdhci_pxav3_init(void) 272static int __init sdhci_pxav3_init(void)
276{ 273{
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index cb60c4197e0..0d33ff0d67f 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -622,23 +622,29 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
622 622
623#ifdef CONFIG_PM 623#ifdef CONFIG_PM
624 624
625static int sdhci_s3c_suspend(struct platform_device *dev, pm_message_t pm) 625static int sdhci_s3c_suspend(struct device *dev)
626{ 626{
627 struct sdhci_host *host = platform_get_drvdata(dev); 627 struct sdhci_host *host = dev_get_drvdata(dev);
628 628
629 return sdhci_suspend_host(host, pm); 629 return sdhci_suspend_host(host);
630} 630}
631 631
632static int sdhci_s3c_resume(struct platform_device *dev) 632static int sdhci_s3c_resume(struct device *dev)
633{ 633{
634 struct sdhci_host *host = platform_get_drvdata(dev); 634 struct sdhci_host *host = dev_get_drvdata(dev);
635 635
636 return sdhci_resume_host(host); 636 return sdhci_resume_host(host);
637} 637}
638 638
639static const struct dev_pm_ops sdhci_s3c_pmops = {
640 .suspend = sdhci_s3c_suspend,
641 .resume = sdhci_s3c_resume,
642};
643
644#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
645
639#else 646#else
640#define sdhci_s3c_suspend NULL 647#define SDHCI_S3C_PMOPS NULL
641#define sdhci_s3c_resume NULL
642#endif 648#endif
643 649
644static struct platform_driver sdhci_s3c_driver = { 650static struct platform_driver sdhci_s3c_driver = {
@@ -647,6 +653,7 @@ static struct platform_driver sdhci_s3c_driver = {
647 .driver = { 653 .driver = {
648 .owner = THIS_MODULE, 654 .owner = THIS_MODULE,
649 .name = "s3c-sdhci", 655 .name = "s3c-sdhci",
656 .pm = SDHCI_S3C_PMOPS,
650 }, 657 },
651}; 658};
652 659
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 89699e861fc..e2e18d3f949 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -318,13 +318,10 @@ static struct platform_driver sdhci_tegra_driver = {
318 .name = "sdhci-tegra", 318 .name = "sdhci-tegra",
319 .owner = THIS_MODULE, 319 .owner = THIS_MODULE,
320 .of_match_table = sdhci_tegra_dt_match, 320 .of_match_table = sdhci_tegra_dt_match,
321 .pm = SDHCI_PLTFM_PMOPS,
321 }, 322 },
322 .probe = sdhci_tegra_probe, 323 .probe = sdhci_tegra_probe,
323 .remove = __devexit_p(sdhci_tegra_remove), 324 .remove = __devexit_p(sdhci_tegra_remove),
324#ifdef CONFIG_PM
325 .suspend = sdhci_pltfm_suspend,
326 .resume = sdhci_pltfm_resume,
327#endif
328}; 325};
329 326
330static int __init sdhci_tegra_init(void) 327static int __init sdhci_tegra_init(void)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea32354..19ed580f2ca 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2327,7 +2327,7 @@ out:
2327 2327
2328#ifdef CONFIG_PM 2328#ifdef CONFIG_PM
2329 2329
2330int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state) 2330int sdhci_suspend_host(struct sdhci_host *host)
2331{ 2331{
2332 int ret; 2332 int ret;
2333 2333
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a5b65460d8..a04d4d0c6fd 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -374,7 +374,7 @@ extern int sdhci_add_host(struct sdhci_host *host);
374extern void sdhci_remove_host(struct sdhci_host *host, int dead); 374extern void sdhci_remove_host(struct sdhci_host *host, int dead);
375 375
376#ifdef CONFIG_PM 376#ifdef CONFIG_PM
377extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); 377extern int sdhci_suspend_host(struct sdhci_host *host);
378extern int sdhci_resume_host(struct sdhci_host *host); 378extern int sdhci_resume_host(struct sdhci_host *host);
379extern void sdhci_enable_irq_wakeups(struct sdhci_host *host); 379extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
380#endif 380#endif
diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index e8f6e65183d..2ec978bc32b 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -259,7 +259,7 @@ static int firmware_rom_wait_states = 0x04;
259static int firmware_rom_wait_states = 0x1C; 259static int firmware_rom_wait_states = 0x1C;
260#endif 260#endif
261 261
262module_param(firmware_rom_wait_states, bool, 0644); 262module_param(firmware_rom_wait_states, int, 0644);
263MODULE_PARM_DESC(firmware_rom_wait_states, 263MODULE_PARM_DESC(firmware_rom_wait_states,
264 "ROM wait states byte=RRRIIEEE (Reserved Internal External)"); 264 "ROM wait states byte=RRRIIEEE (Reserved Internal External)");
265 265
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 94f55348972..45876d0e5b8 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -227,10 +227,14 @@ static int platram_probe(struct platform_device *pdev)
227 if (!err) 227 if (!err)
228 dev_info(&pdev->dev, "registered mtd device\n"); 228 dev_info(&pdev->dev, "registered mtd device\n");
229 229
230 /* add the whole device. */ 230 if (pdata->nr_partitions) {
231 err = mtd_device_register(info->mtd, NULL, 0); 231 /* add the whole device. */
232 if (err) 232 err = mtd_device_register(info->mtd, NULL, 0);
233 dev_err(&pdev->dev, "failed to register the entire device\n"); 233 if (err) {
234 dev_err(&pdev->dev,
235 "failed to register the entire device\n");
236 }
237 }
234 238
235 return err; 239 return err;
236 240
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index 411a17df9fc..2a25b6789af 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -98,7 +98,7 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev)
98 } 98 }
99 info->mtd->owner = THIS_MODULE; 99 info->mtd->owner = THIS_MODULE;
100 100
101 mtd_device_parse_register(info->mtd, probes, 0, NULL, 0); 101 mtd_device_parse_register(info->mtd, probes, 0, flash->parts, flash->nr_parts);
102 102
103 platform_set_drvdata(pdev, info); 103 platform_set_drvdata(pdev, info);
104 return 0; 104 return 0;
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 071b63420f0..493ec2fcf97 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -21,9 +21,9 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/module.h>
24#include <linux/mtd/gpmi-nand.h> 25#include <linux/mtd/gpmi-nand.h>
25#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
26
27#include "gpmi-nand.h" 27#include "gpmi-nand.h"
28 28
29/* add our owner bbt descriptor */ 29/* add our owner bbt descriptor */
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index ee1713907b9..f8aacf48ecd 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -188,7 +188,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
188 if (!flash_np) 188 if (!flash_np)
189 return -ENODEV; 189 return -ENODEV;
190 190
191 ppdata->of_node = flash_np; 191 ppdata.of_node = flash_np;
192 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s", 192 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
193 dev_name(&ndfc->ofdev->dev), flash_np->name); 193 dev_name(&ndfc->ofdev->dev), flash_np->name);
194 if (!ndfc->mtd.name) { 194 if (!ndfc->mtd.name) {
diff --git a/drivers/net/ethernet/freescale/Kconfig b/drivers/net/ethernet/freescale/Kconfig
index 5272f9d4dda..9de37642f09 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -23,8 +23,8 @@ if NET_VENDOR_FREESCALE
23config FEC 23config FEC
24 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" 24 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
25 depends on (M523x || M527x || M5272 || M528x || M520x || M532x || \ 25 depends on (M523x || M527x || M5272 || M528x || M520x || M532x || \
26 ARCH_MXC || ARCH_MXS) 26 ARCH_MXC || SOC_IMX28)
27 default ARCH_MXC || ARCH_MXS if ARM 27 default ARCH_MXC || SOC_IMX28 if ARM
28 select PHYLIB 28 select PHYLIB
29 ---help--- 29 ---help---
30 Say Y here if you want to use the built-in 10/100 Fast ethernet 30 Say Y here if you want to use the built-in 10/100 Fast ethernet
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index c7b60839ac9..dea0cb4400e 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -2606,6 +2606,9 @@ static int skge_up(struct net_device *dev)
2606 spin_unlock_irq(&hw->hw_lock); 2606 spin_unlock_irq(&hw->hw_lock);
2607 2607
2608 napi_enable(&skge->napi); 2608 napi_enable(&skge->napi);
2609
2610 skge_set_multicast(dev);
2611
2609 return 0; 2612 return 0;
2610 2613
2611 free_tx_ring: 2614 free_tx_ring:
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
index 227997d775e..5829e0b47e7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
@@ -147,6 +147,7 @@ void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
147 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); 147 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size);
148 if (priv->mdev->dev->caps.comp_pool && cq->vector) 148 if (priv->mdev->dev->caps.comp_pool && cq->vector)
149 mlx4_release_eq(priv->mdev->dev, cq->vector); 149 mlx4_release_eq(priv->mdev->dev, cq->vector);
150 cq->vector = 0;
150 cq->buf_size = 0; 151 cq->buf_size = 0;
151 cq->buf = NULL; 152 cq->buf = NULL;
152} 153}
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 67bf0781999..c8f47f17186 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -477,7 +477,6 @@ enum rtl_register_content {
477 /* Config1 register p.24 */ 477 /* Config1 register p.24 */
478 LEDS1 = (1 << 7), 478 LEDS1 = (1 << 7),
479 LEDS0 = (1 << 6), 479 LEDS0 = (1 << 6),
480 MSIEnable = (1 << 5), /* Enable Message Signaled Interrupt */
481 Speed_down = (1 << 4), 480 Speed_down = (1 << 4),
482 MEMMAP = (1 << 3), 481 MEMMAP = (1 << 3),
483 IOMAP = (1 << 2), 482 IOMAP = (1 << 2),
@@ -485,6 +484,7 @@ enum rtl_register_content {
485 PMEnable = (1 << 0), /* Power Management Enable */ 484 PMEnable = (1 << 0), /* Power Management Enable */
486 485
487 /* Config2 register p. 25 */ 486 /* Config2 register p. 25 */
487 MSIEnable = (1 << 5), /* 8169 only. Reserved in the 8168. */
488 PCI_Clock_66MHz = 0x01, 488 PCI_Clock_66MHz = 0x01,
489 PCI_Clock_33MHz = 0x00, 489 PCI_Clock_33MHz = 0x00,
490 490
@@ -3426,22 +3426,24 @@ static const struct rtl_cfg_info {
3426}; 3426};
3427 3427
3428/* Cfg9346_Unlock assumed. */ 3428/* Cfg9346_Unlock assumed. */
3429static unsigned rtl_try_msi(struct pci_dev *pdev, void __iomem *ioaddr, 3429static unsigned rtl_try_msi(struct rtl8169_private *tp,
3430 const struct rtl_cfg_info *cfg) 3430 const struct rtl_cfg_info *cfg)
3431{ 3431{
3432 void __iomem *ioaddr = tp->mmio_addr;
3432 unsigned msi = 0; 3433 unsigned msi = 0;
3433 u8 cfg2; 3434 u8 cfg2;
3434 3435
3435 cfg2 = RTL_R8(Config2) & ~MSIEnable; 3436 cfg2 = RTL_R8(Config2) & ~MSIEnable;
3436 if (cfg->features & RTL_FEATURE_MSI) { 3437 if (cfg->features & RTL_FEATURE_MSI) {
3437 if (pci_enable_msi(pdev)) { 3438 if (pci_enable_msi(tp->pci_dev)) {
3438 dev_info(&pdev->dev, "no MSI. Back to INTx.\n"); 3439 netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n");
3439 } else { 3440 } else {
3440 cfg2 |= MSIEnable; 3441 cfg2 |= MSIEnable;
3441 msi = RTL_FEATURE_MSI; 3442 msi = RTL_FEATURE_MSI;
3442 } 3443 }
3443 } 3444 }
3444 RTL_W8(Config2, cfg2); 3445 if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
3446 RTL_W8(Config2, cfg2);
3445 return msi; 3447 return msi;
3446} 3448}
3447 3449
@@ -4077,7 +4079,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4077 tp->features |= RTL_FEATURE_WOL; 4079 tp->features |= RTL_FEATURE_WOL;
4078 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0) 4080 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
4079 tp->features |= RTL_FEATURE_WOL; 4081 tp->features |= RTL_FEATURE_WOL;
4080 tp->features |= rtl_try_msi(pdev, ioaddr, cfg); 4082 tp->features |= rtl_try_msi(tp, cfg);
4081 RTL_W8(Cfg9346, Cfg9346_Lock); 4083 RTL_W8(Cfg9346, Cfg9346_Lock);
4082 4084
4083 if (rtl_tbi_enabled(tp)) { 4085 if (rtl_tbi_enabled(tp)) {
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index dca9d3369cd..c97d2f59085 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -836,11 +836,13 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
836 chan_write(chan, cp, CPDMA_TEARDOWN_VALUE); 836 chan_write(chan, cp, CPDMA_TEARDOWN_VALUE);
837 837
838 /* handle completed packets */ 838 /* handle completed packets */
839 spin_unlock_irqrestore(&chan->lock, flags);
839 do { 840 do {
840 ret = __cpdma_chan_process(chan); 841 ret = __cpdma_chan_process(chan);
841 if (ret < 0) 842 if (ret < 0)
842 break; 843 break;
843 } while ((ret & CPDMA_DESC_TD_COMPLETE) == 0); 844 } while ((ret & CPDMA_DESC_TD_COMPLETE) == 0);
845 spin_lock_irqsave(&chan->lock, flags);
844 846
845 /* remaining packets haven't been tx/rx'ed, clean them up */ 847 /* remaining packets haven't been tx/rx'ed, clean them up */
846 while (chan->head) { 848 while (chan->head) {
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index e6fed4d4cb7..e95f0e60a9b 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1655,6 +1655,10 @@ static const struct usb_device_id products [] = {
1655 // ASIX 88772a 1655 // ASIX 88772a
1656 USB_DEVICE(0x0db0, 0xa877), 1656 USB_DEVICE(0x0db0, 0xa877),
1657 .driver_info = (unsigned long) &ax88772_info, 1657 .driver_info = (unsigned long) &ax88772_info,
1658}, {
1659 // Asus USB Ethernet Adapter
1660 USB_DEVICE (0x0b95, 0x7e2b),
1661 .driver_info = (unsigned long) &ax88772_info,
1658}, 1662},
1659 { }, // END 1663 { }, // END
1660}; 1664};
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index d2348a5a780..a9c5ae75277 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1843,6 +1843,9 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
1843 struct ath_softc *sc = hw->priv; 1843 struct ath_softc *sc = hw->priv;
1844 struct ath_node *an = (struct ath_node *) sta->drv_priv; 1844 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1845 1845
1846 if (!(sc->sc_flags & SC_OP_TXAGGR))
1847 return;
1848
1846 switch (cmd) { 1849 switch (cmd) {
1847 case STA_NOTIFY_SLEEP: 1850 case STA_NOTIFY_SLEEP:
1848 an->sleeping = true; 1851 an->sleeping = true;
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 888abc2be3a..528d5f3e868 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1271,7 +1271,9 @@ static void ath_rc_init(struct ath_softc *sc,
1271 1271
1272 ath_rc_priv->max_valid_rate = k; 1272 ath_rc_priv->max_valid_rate = k;
1273 ath_rc_sort_validrates(rate_table, ath_rc_priv); 1273 ath_rc_sort_validrates(rate_table, ath_rc_priv);
1274 ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; 1274 ath_rc_priv->rate_max_phy = (k > 4) ?
1275 ath_rc_priv->valid_rate_index[k-4] :
1276 ath_rc_priv->valid_rate_index[k-1];
1275 ath_rc_priv->rate_table = rate_table; 1277 ath_rc_priv->rate_table = rate_table;
1276 1278
1277 ath_dbg(common, ATH_DBG_CONFIG, 1279 ath_dbg(common, ATH_DBG_CONFIG,
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
index fcff923b3c1..279a53eae4c 100644
--- a/drivers/net/wireless/b43/pio.c
+++ b/drivers/net/wireless/b43/pio.c
@@ -617,9 +617,19 @@ static bool pio_rx_frame(struct b43_pio_rxqueue *q)
617 const char *err_msg = NULL; 617 const char *err_msg = NULL;
618 struct b43_rxhdr_fw4 *rxhdr = 618 struct b43_rxhdr_fw4 *rxhdr =
619 (struct b43_rxhdr_fw4 *)wl->pio_scratchspace; 619 (struct b43_rxhdr_fw4 *)wl->pio_scratchspace;
620 size_t rxhdr_size = sizeof(*rxhdr);
620 621
621 BUILD_BUG_ON(sizeof(wl->pio_scratchspace) < sizeof(*rxhdr)); 622 BUILD_BUG_ON(sizeof(wl->pio_scratchspace) < sizeof(*rxhdr));
622 memset(rxhdr, 0, sizeof(*rxhdr)); 623 switch (dev->fw.hdr_format) {
624 case B43_FW_HDR_410:
625 case B43_FW_HDR_351:
626 rxhdr_size -= sizeof(rxhdr->format_598) -
627 sizeof(rxhdr->format_351);
628 break;
629 case B43_FW_HDR_598:
630 break;
631 }
632 memset(rxhdr, 0, rxhdr_size);
623 633
624 /* Check if we have data and wait for it to get ready. */ 634 /* Check if we have data and wait for it to get ready. */
625 if (q->rev >= 8) { 635 if (q->rev >= 8) {
@@ -657,11 +667,11 @@ data_ready:
657 667
658 /* Get the preamble (RX header) */ 668 /* Get the preamble (RX header) */
659 if (q->rev >= 8) { 669 if (q->rev >= 8) {
660 b43_block_read(dev, rxhdr, sizeof(*rxhdr), 670 b43_block_read(dev, rxhdr, rxhdr_size,
661 q->mmio_base + B43_PIO8_RXDATA, 671 q->mmio_base + B43_PIO8_RXDATA,
662 sizeof(u32)); 672 sizeof(u32));
663 } else { 673 } else {
664 b43_block_read(dev, rxhdr, sizeof(*rxhdr), 674 b43_block_read(dev, rxhdr, rxhdr_size,
665 q->mmio_base + B43_PIO_RXDATA, 675 q->mmio_base + B43_PIO_RXDATA,
666 sizeof(u16)); 676 sizeof(u16));
667 } 677 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index a7a6def40d0..5c7c17c7166 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -606,8 +606,8 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
606 if (ctx->ht.enabled) { 606 if (ctx->ht.enabled) {
607 /* if HT40 is used, it should not change 607 /* if HT40 is used, it should not change
608 * after associated except channel switch */ 608 * after associated except channel switch */
609 if (iwl_is_associated_ctx(ctx) && 609 if (!ctx->ht.is_40mhz ||
610 !ctx->ht.is_40mhz) 610 !iwl_is_associated_ctx(ctx))
611 iwlagn_config_ht40(conf, ctx); 611 iwlagn_config_ht40(conf, ctx);
612 } else 612 } else
613 ctx->ht.is_40mhz = false; 613 ctx->ht.is_40mhz = false;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 35a6b71f358..df1540ca610 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -91,7 +91,10 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
91 tx_cmd->tid_tspec = qc[0] & 0xf; 91 tx_cmd->tid_tspec = qc[0] & 0xf;
92 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; 92 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK;
93 } else { 93 } else {
94 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 94 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
95 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
96 else
97 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK;
95 } 98 }
96 99
97 iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags); 100 iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index bacc06c95e7..e0e9a3dfbc0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2850,6 +2850,9 @@ static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw,
2850 int ret; 2850 int ret;
2851 u8 sta_id; 2851 u8 sta_id;
2852 2852
2853 if (ctx->ctxid != IWL_RXON_CTX_PAN)
2854 return 0;
2855
2853 IWL_DEBUG_MAC80211(priv, "enter\n"); 2856 IWL_DEBUG_MAC80211(priv, "enter\n");
2854 mutex_lock(&priv->shrd->mutex); 2857 mutex_lock(&priv->shrd->mutex);
2855 2858
@@ -2898,6 +2901,9 @@ static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw,
2898 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 2901 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
2899 struct iwl_rxon_context *ctx = vif_priv->ctx; 2902 struct iwl_rxon_context *ctx = vif_priv->ctx;
2900 2903
2904 if (ctx->ctxid != IWL_RXON_CTX_PAN)
2905 return;
2906
2901 IWL_DEBUG_MAC80211(priv, "enter\n"); 2907 IWL_DEBUG_MAC80211(priv, "enter\n");
2902 mutex_lock(&priv->shrd->mutex); 2908 mutex_lock(&priv->shrd->mutex);
2903 2909
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index ce918980e97..5f17ab8e76b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -1197,9 +1197,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
1197 iwl_print_hex_dump(trans, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); 1197 iwl_print_hex_dump(trans, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len);
1198 1198
1199 /* Set up entry for this TFD in Tx byte-count array */ 1199 /* Set up entry for this TFD in Tx byte-count array */
1200 if (is_agg) 1200 iwl_trans_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len));
1201 iwl_trans_txq_update_byte_cnt_tbl(trans, txq,
1202 le16_to_cpu(tx_cmd->len));
1203 1201
1204 dma_sync_single_for_device(bus(trans)->dev, txcmd_phys, firstlen, 1202 dma_sync_single_for_device(bus(trans)->dev, txcmd_phys, firstlen,
1205 DMA_BIDIRECTIONAL); 1203 DMA_BIDIRECTIONAL);
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index ac278156d39..6e0a3eaecf7 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -939,7 +939,6 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
939{ 939{
940 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 940 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
941 unsigned long cmd_flags; 941 unsigned long cmd_flags;
942 unsigned long cmd_pending_q_flags;
943 unsigned long scan_pending_q_flags; 942 unsigned long scan_pending_q_flags;
944 uint16_t cancel_scan_cmd = false; 943 uint16_t cancel_scan_cmd = false;
945 944
@@ -949,12 +948,9 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
949 cmd_node = adapter->curr_cmd; 948 cmd_node = adapter->curr_cmd;
950 cmd_node->wait_q_enabled = false; 949 cmd_node->wait_q_enabled = false;
951 cmd_node->cmd_flag |= CMD_F_CANCELED; 950 cmd_node->cmd_flag |= CMD_F_CANCELED;
952 spin_lock_irqsave(&adapter->cmd_pending_q_lock,
953 cmd_pending_q_flags);
954 list_del(&cmd_node->list);
955 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
956 cmd_pending_q_flags);
957 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 951 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
952 mwifiex_complete_cmd(adapter, adapter->curr_cmd);
953 adapter->curr_cmd = NULL;
958 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 954 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
959 } 955 }
960 956
@@ -981,7 +977,6 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
981 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 977 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
982 } 978 }
983 adapter->cmd_wait_q.status = -1; 979 adapter->cmd_wait_q.status = -1;
984 mwifiex_complete_cmd(adapter, adapter->curr_cmd);
985} 980}
986 981
987/* 982/*
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index ea4a29b7e33..1679c2593b7 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -55,9 +55,14 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
55{ 55{
56 bool cancel_flag = false; 56 bool cancel_flag = false;
57 int status = adapter->cmd_wait_q.status; 57 int status = adapter->cmd_wait_q.status;
58 struct cmd_ctrl_node *cmd_queued = adapter->cmd_queued; 58 struct cmd_ctrl_node *cmd_queued;
59 59
60 if (!adapter->cmd_queued)
61 return 0;
62
63 cmd_queued = adapter->cmd_queued;
60 adapter->cmd_queued = NULL; 64 adapter->cmd_queued = NULL;
65
61 dev_dbg(adapter->dev, "cmd pending\n"); 66 dev_dbg(adapter->dev, "cmd pending\n");
62 atomic_inc(&adapter->cmd_pending); 67 atomic_inc(&adapter->cmd_pending);
63 68
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index cbd5d701c7e..63b3ec48c20 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -314,7 +314,7 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l
314 if (!lookup) 314 if (!lookup)
315 return NULL; 315 return NULL;
316 316
317 for(; lookup->name != 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))
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index 89f63456646..84a208dbed9 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -45,7 +45,7 @@ static ssize_t timeout_write(struct file *file, char const __user *buf,
45 return -EINVAL; 45 return -EINVAL;
46 46
47 retval = oprofilefs_ulong_from_user(&val, buf, count); 47 retval = oprofilefs_ulong_from_user(&val, buf, count);
48 if (retval) 48 if (retval <= 0)
49 return retval; 49 return retval;
50 50
51 retval = oprofile_set_timeout(val); 51 retval = oprofile_set_timeout(val);
@@ -84,7 +84,7 @@ static ssize_t depth_write(struct file *file, char const __user *buf, size_t cou
84 return -EINVAL; 84 return -EINVAL;
85 85
86 retval = oprofilefs_ulong_from_user(&val, buf, count); 86 retval = oprofilefs_ulong_from_user(&val, buf, count);
87 if (retval) 87 if (retval <= 0)
88 return retval; 88 return retval;
89 89
90 retval = oprofile_set_ulong(&oprofile_backtrace_depth, val); 90 retval = oprofile_set_ulong(&oprofile_backtrace_depth, val);
@@ -141,9 +141,10 @@ static ssize_t enable_write(struct file *file, char const __user *buf, size_t co
141 return -EINVAL; 141 return -EINVAL;
142 142
143 retval = oprofilefs_ulong_from_user(&val, buf, count); 143 retval = oprofilefs_ulong_from_user(&val, buf, count);
144 if (retval) 144 if (retval <= 0)
145 return retval; 145 return retval;
146 146
147 retval = 0;
147 if (val) 148 if (val)
148 retval = oprofile_start(); 149 retval = oprofile_start();
149 else 150 else
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index d0de6cc2d7a..2f0aa0f700e 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -60,6 +60,13 @@ ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user *buf, size_t cou
60} 60}
61 61
62 62
63/*
64 * Note: If oprofilefs_ulong_from_user() returns 0, then *val remains
65 * unchanged and might be uninitialized. This follows write syscall
66 * implementation when count is zero: "If count is zero ... [and if]
67 * no errors are detected, 0 will be returned without causing any
68 * other effect." (man 2 write)
69 */
63int oprofilefs_ulong_from_user(unsigned long *val, char const __user *buf, size_t count) 70int oprofilefs_ulong_from_user(unsigned long *val, char const __user *buf, size_t count)
64{ 71{
65 char tmpbuf[TMPBUFSIZE]; 72 char tmpbuf[TMPBUFSIZE];
@@ -79,7 +86,7 @@ int oprofilefs_ulong_from_user(unsigned long *val, char const __user *buf, size_
79 raw_spin_lock_irqsave(&oprofilefs_lock, flags); 86 raw_spin_lock_irqsave(&oprofilefs_lock, flags);
80 *val = simple_strtoul(tmpbuf, NULL, 0); 87 *val = simple_strtoul(tmpbuf, NULL, 0);
81 raw_spin_unlock_irqrestore(&oprofilefs_lock, flags); 88 raw_spin_unlock_irqrestore(&oprofilefs_lock, flags);
82 return 0; 89 return count;
83} 90}
84 91
85 92
@@ -99,7 +106,7 @@ static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_
99 return -EINVAL; 106 return -EINVAL;
100 107
101 retval = oprofilefs_ulong_from_user(&value, buf, count); 108 retval = oprofilefs_ulong_from_user(&value, buf, count);
102 if (retval) 109 if (retval <= 0)
103 return retval; 110 return retval;
104 111
105 retval = oprofile_set_ulong(file->private_data, value); 112 retval = oprofile_set_ulong(file->private_data, value);
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 7ec56fb0bd7..b0dd08e6a9d 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -13,6 +13,7 @@
13#include <linux/export.h> 13#include <linux/export.h>
14#include <linux/pci-ats.h> 14#include <linux/pci-ats.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/slab.h>
16 17
17#include "pci.h" 18#include "pci.h"
18 19
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index fce1c54a0c8..9ddf69e3bbe 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -132,6 +132,18 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
132 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle)) 132 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle))
133 return AE_OK; 133 return AE_OK;
134 134
135 pdev = pbus->self;
136 if (pdev && pci_is_pcie(pdev)) {
137 tmp = acpi_find_root_bridge_handle(pdev);
138 if (tmp) {
139 struct acpi_pci_root *root = acpi_pci_find_root(tmp);
140
141 if (root && (root->osc_control_set &
142 OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
143 return AE_OK;
144 }
145 }
146
135 acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 147 acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
136 device = (adr >> 16) & 0xffff; 148 device = (adr >> 16) & 0xffff;
137 function = adr & 0xffff; 149 function = adr & 0xffff;
@@ -213,7 +225,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
213 225
214 pdev = pci_get_slot(pbus, PCI_DEVFN(device, function)); 226 pdev = pci_get_slot(pbus, PCI_DEVFN(device, function));
215 if (pdev) { 227 if (pdev) {
216 pdev->current_state = PCI_D0;
217 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 228 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
218 pci_dev_put(pdev); 229 pci_dev_put(pdev);
219 } 230 }
@@ -459,17 +470,8 @@ static int add_bridge(acpi_handle handle)
459{ 470{
460 acpi_status status; 471 acpi_status status;
461 unsigned long long tmp; 472 unsigned long long tmp;
462 struct acpi_pci_root *root;
463 acpi_handle dummy_handle; 473 acpi_handle dummy_handle;
464 474
465 /*
466 * We shouldn't use this bridge if PCIe native hotplug control has been
467 * granted by the BIOS for it.
468 */
469 root = acpi_pci_find_root(handle);
470 if (root && (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
471 return -ENODEV;
472
473 /* if the bridge doesn't have _STA, we assume it is always there */ 475 /* if the bridge doesn't have _STA, we assume it is always there */
474 status = acpi_get_handle(handle, "_STA", &dummy_handle); 476 status = acpi_get_handle(handle, "_STA", &dummy_handle);
475 if (ACPI_SUCCESS(status)) { 477 if (ACPI_SUCCESS(status)) {
@@ -1385,19 +1387,11 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type,
1385static acpi_status 1387static acpi_status
1386find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) 1388find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
1387{ 1389{
1388 struct acpi_pci_root *root;
1389 int *count = (int *)context; 1390 int *count = (int *)context;
1390 1391
1391 if (!acpi_is_root_bridge(handle)) 1392 if (!acpi_is_root_bridge(handle))
1392 return AE_OK; 1393 return AE_OK;
1393 1394
1394 root = acpi_pci_find_root(handle);
1395 if (!root)
1396 return AE_OK;
1397
1398 if (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
1399 return AE_OK;
1400
1401 (*count)++; 1395 (*count)++;
1402 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1396 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1403 handle_hotplug_event_bridge, NULL); 1397 handle_hotplug_event_bridge, NULL);
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index b82c155d7b3..1969a3ee305 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -283,6 +283,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
283 struct resource *res; 283 struct resource *res;
284 struct pci_dev *pdev; 284 struct pci_dev *pdev;
285 struct pci_sriov *iov = dev->sriov; 285 struct pci_sriov *iov = dev->sriov;
286 int bars = 0;
286 287
287 if (!nr_virtfn) 288 if (!nr_virtfn)
288 return 0; 289 return 0;
@@ -307,6 +308,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
307 308
308 nres = 0; 309 nres = 0;
309 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { 310 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
311 bars |= (1 << (i + PCI_IOV_RESOURCES));
310 res = dev->resource + PCI_IOV_RESOURCES + i; 312 res = dev->resource + PCI_IOV_RESOURCES + i;
311 if (res->parent) 313 if (res->parent)
312 nres++; 314 nres++;
@@ -324,6 +326,11 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
324 return -ENOMEM; 326 return -ENOMEM;
325 } 327 }
326 328
329 if (pci_enable_resources(dev, bars)) {
330 dev_err(&dev->dev, "SR-IOV: IOV BARS not allocated\n");
331 return -ENOMEM;
332 }
333
327 if (iov->link != dev->devfn) { 334 if (iov->link != dev->devfn) {
328 pdev = pci_get_slot(dev->bus, iov->link); 335 pdev = pci_get_slot(dev->bus, iov->link);
329 if (!pdev) 336 if (!pdev)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6f45a73c6e9..6d4a5319148 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -664,6 +664,9 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
664 error = platform_pci_set_power_state(dev, state); 664 error = platform_pci_set_power_state(dev, state);
665 if (!error) 665 if (!error)
666 pci_update_current_state(dev, state); 666 pci_update_current_state(dev, state);
667 /* Fall back to PCI_D0 if native PM is not supported */
668 if (!dev->pm_cap)
669 dev->current_state = PCI_D0;
667 } else { 670 } else {
668 error = -ENODEV; 671 error = -ENODEV;
669 /* Fall back to PCI_D0 if native PM is not supported */ 672 /* Fall back to PCI_D0 if native PM is not supported */
@@ -1126,7 +1129,11 @@ static int __pci_enable_device_flags(struct pci_dev *dev,
1126 if (atomic_add_return(1, &dev->enable_cnt) > 1) 1129 if (atomic_add_return(1, &dev->enable_cnt) > 1)
1127 return 0; /* already enabled */ 1130 return 0; /* already enabled */
1128 1131
1129 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) 1132 /* only skip sriov related */
1133 for (i = 0; i <= PCI_ROM_RESOURCE; i++)
1134 if (dev->resource[i].flags & flags)
1135 bars |= (1 << i);
1136 for (i = PCI_BRIDGE_RESOURCES; i < DEVICE_COUNT_RESOURCE; i++)
1130 if (dev->resource[i].flags & flags) 1137 if (dev->resource[i].flags & flags)
1131 bars |= (1 << i); 1138 bars |= (1 << i);
1132 1139
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index fa4d9f32418..8e286259a00 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -319,20 +319,6 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
319} 319}
320EXPORT_SYMBOL_GPL(rtc_read_alarm); 320EXPORT_SYMBOL_GPL(rtc_read_alarm);
321 321
322static int ___rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
323{
324 int err;
325
326 if (!rtc->ops)
327 err = -ENODEV;
328 else if (!rtc->ops->set_alarm)
329 err = -EINVAL;
330 else
331 err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
332
333 return err;
334}
335
336static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) 322static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
337{ 323{
338 struct rtc_time tm; 324 struct rtc_time tm;
@@ -356,7 +342,14 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
356 * over right here, before we set the alarm. 342 * over right here, before we set the alarm.
357 */ 343 */
358 344
359 return ___rtc_set_alarm(rtc, alarm); 345 if (!rtc->ops)
346 err = -ENODEV;
347 else if (!rtc->ops->set_alarm)
348 err = -EINVAL;
349 else
350 err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
351
352 return err;
360} 353}
361 354
362int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) 355int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
@@ -770,20 +763,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
770 return 0; 763 return 0;
771} 764}
772 765
773static void rtc_alarm_disable(struct rtc_device *rtc)
774{
775 struct rtc_wkalrm alarm;
776 struct rtc_time tm;
777
778 __rtc_read_time(rtc, &tm);
779
780 alarm.time = rtc_ktime_to_tm(ktime_add(rtc_tm_to_ktime(tm),
781 ktime_set(300, 0)));
782 alarm.enabled = 0;
783
784 ___rtc_set_alarm(rtc, &alarm);
785}
786
787/** 766/**
788 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue 767 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
789 * @rtc rtc device 768 * @rtc rtc device
@@ -805,10 +784,8 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
805 struct rtc_wkalrm alarm; 784 struct rtc_wkalrm alarm;
806 int err; 785 int err;
807 next = timerqueue_getnext(&rtc->timerqueue); 786 next = timerqueue_getnext(&rtc->timerqueue);
808 if (!next) { 787 if (!next)
809 rtc_alarm_disable(rtc);
810 return; 788 return;
811 }
812 alarm.time = rtc_ktime_to_tm(next->expires); 789 alarm.time = rtc_ktime_to_tm(next->expires);
813 alarm.enabled = 1; 790 alarm.enabled = 1;
814 err = __rtc_set_alarm(rtc, &alarm); 791 err = __rtc_set_alarm(rtc, &alarm);
@@ -870,8 +847,7 @@ again:
870 err = __rtc_set_alarm(rtc, &alarm); 847 err = __rtc_set_alarm(rtc, &alarm);
871 if (err == -ETIME) 848 if (err == -ETIME)
872 goto again; 849 goto again;
873 } else 850 }
874 rtc_alarm_disable(rtc);
875 851
876 mutex_unlock(&rtc->ops_lock); 852 mutex_unlock(&rtc->ops_lock);
877} 853}
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index eda128fc1d3..64aedd8cc09 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -357,10 +357,19 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
357static struct rtc_class_ops m41t80_rtc_ops = { 357static struct rtc_class_ops m41t80_rtc_ops = {
358 .read_time = m41t80_rtc_read_time, 358 .read_time = m41t80_rtc_read_time,
359 .set_time = m41t80_rtc_set_time, 359 .set_time = m41t80_rtc_set_time,
360 /*
361 * XXX - m41t80 alarm functionality is reported broken.
362 * until it is fixed, don't register alarm functions.
363 *
360 .read_alarm = m41t80_rtc_read_alarm, 364 .read_alarm = m41t80_rtc_read_alarm,
361 .set_alarm = m41t80_rtc_set_alarm, 365 .set_alarm = m41t80_rtc_set_alarm,
366 */
362 .proc = m41t80_rtc_proc, 367 .proc = m41t80_rtc_proc,
368 /*
369 * See above comment on broken alarm
370 *
363 .alarm_irq_enable = m41t80_rtc_alarm_irq_enable, 371 .alarm_irq_enable = m41t80_rtc_alarm_irq_enable,
372 */
364}; 373};
365 374
366#if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) 375#if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE)
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 11f07f88822..b79576b64f4 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -55,6 +55,10 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdev)
55{ 55{
56 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); 56 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
57 57
58 /* if previous slave_alloc returned early, there is nothing to do */
59 if (!zfcp_sdev->port)
60 return;
61
58 zfcp_erp_lun_shutdown_wait(sdev, "scssd_1"); 62 zfcp_erp_lun_shutdown_wait(sdev, "scssd_1");
59 put_device(&zfcp_sdev->port->dev); 63 put_device(&zfcp_sdev->port->dev);
60} 64}
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index dba72a4e6a1..1ad0b822556 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1906,18 +1906,19 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
1906 spin_lock(&session->lock); 1906 spin_lock(&session->lock);
1907 task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data, 1907 task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
1908 cqe->itt & ISCSI_CMD_RESPONSE_INDEX); 1908 cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
1909 if (!task) { 1909 if (!task || !task->sc) {
1910 spin_unlock(&session->lock); 1910 spin_unlock(&session->lock);
1911 return -EINVAL; 1911 return -EINVAL;
1912 } 1912 }
1913 sc = task->sc; 1913 sc = task->sc;
1914 spin_unlock(&session->lock);
1915 1914
1916 if (!blk_rq_cpu_valid(sc->request)) 1915 if (!blk_rq_cpu_valid(sc->request))
1917 cpu = smp_processor_id(); 1916 cpu = smp_processor_id();
1918 else 1917 else
1919 cpu = sc->request->cpu; 1918 cpu = sc->request->cpu;
1920 1919
1920 spin_unlock(&session->lock);
1921
1921 p = &per_cpu(bnx2i_percpu, cpu); 1922 p = &per_cpu(bnx2i_percpu, cpu);
1922 spin_lock(&p->p_work_lock); 1923 spin_lock(&p->p_work_lock);
1923 if (unlikely(!p->iothread)) { 1924 if (unlikely(!p->iothread)) {
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index cefbe44bb84..8d67467dd9c 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -31,6 +31,8 @@
31#include <linux/sysfs.h> 31#include <linux/sysfs.h>
32#include <linux/ctype.h> 32#include <linux/ctype.h>
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <net/dcbnl.h>
35#include <net/dcbevent.h>
34#include <scsi/scsi_tcq.h> 36#include <scsi/scsi_tcq.h>
35#include <scsi/scsicam.h> 37#include <scsi/scsicam.h>
36#include <scsi/scsi_transport.h> 38#include <scsi/scsi_transport.h>
@@ -101,6 +103,8 @@ static int fcoe_ddp_done(struct fc_lport *, u16);
101static int fcoe_ddp_target(struct fc_lport *, u16, struct scatterlist *, 103static int fcoe_ddp_target(struct fc_lport *, u16, struct scatterlist *,
102 unsigned int); 104 unsigned int);
103static int fcoe_cpu_callback(struct notifier_block *, unsigned long, void *); 105static int fcoe_cpu_callback(struct notifier_block *, unsigned long, void *);
106static int fcoe_dcb_app_notification(struct notifier_block *notifier,
107 ulong event, void *ptr);
104 108
105static bool fcoe_match(struct net_device *netdev); 109static bool fcoe_match(struct net_device *netdev);
106static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode); 110static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode);
@@ -129,6 +133,11 @@ static struct notifier_block fcoe_cpu_notifier = {
129 .notifier_call = fcoe_cpu_callback, 133 .notifier_call = fcoe_cpu_callback,
130}; 134};
131 135
136/* notification function for DCB events */
137static struct notifier_block dcb_notifier = {
138 .notifier_call = fcoe_dcb_app_notification,
139};
140
132static struct scsi_transport_template *fcoe_nport_scsi_transport; 141static struct scsi_transport_template *fcoe_nport_scsi_transport;
133static struct scsi_transport_template *fcoe_vport_scsi_transport; 142static struct scsi_transport_template *fcoe_vport_scsi_transport;
134 143
@@ -1522,6 +1531,8 @@ int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)
1522 skb_reset_network_header(skb); 1531 skb_reset_network_header(skb);
1523 skb->mac_len = elen; 1532 skb->mac_len = elen;
1524 skb->protocol = htons(ETH_P_FCOE); 1533 skb->protocol = htons(ETH_P_FCOE);
1534 skb->priority = port->priority;
1535
1525 if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN && 1536 if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN &&
1526 fcoe->realdev->features & NETIF_F_HW_VLAN_TX) { 1537 fcoe->realdev->features & NETIF_F_HW_VLAN_TX) {
1527 skb->vlan_tci = VLAN_TAG_PRESENT | 1538 skb->vlan_tci = VLAN_TAG_PRESENT |
@@ -1624,6 +1635,7 @@ static inline int fcoe_filter_frames(struct fc_lport *lport,
1624 stats->InvalidCRCCount++; 1635 stats->InvalidCRCCount++;
1625 if (stats->InvalidCRCCount < 5) 1636 if (stats->InvalidCRCCount < 5)
1626 printk(KERN_WARNING "fcoe: dropping frame with CRC error\n"); 1637 printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");
1638 put_cpu();
1627 return -EINVAL; 1639 return -EINVAL;
1628} 1640}
1629 1641
@@ -1746,6 +1758,7 @@ int fcoe_percpu_receive_thread(void *arg)
1746 */ 1758 */
1747static void fcoe_dev_setup(void) 1759static void fcoe_dev_setup(void)
1748{ 1760{
1761 register_dcbevent_notifier(&dcb_notifier);
1749 register_netdevice_notifier(&fcoe_notifier); 1762 register_netdevice_notifier(&fcoe_notifier);
1750} 1763}
1751 1764
@@ -1754,9 +1767,69 @@ static void fcoe_dev_setup(void)
1754 */ 1767 */
1755static void fcoe_dev_cleanup(void) 1768static void fcoe_dev_cleanup(void)
1756{ 1769{
1770 unregister_dcbevent_notifier(&dcb_notifier);
1757 unregister_netdevice_notifier(&fcoe_notifier); 1771 unregister_netdevice_notifier(&fcoe_notifier);
1758} 1772}
1759 1773
1774static struct fcoe_interface *
1775fcoe_hostlist_lookup_realdev_port(struct net_device *netdev)
1776{
1777 struct fcoe_interface *fcoe;
1778 struct net_device *real_dev;
1779
1780 list_for_each_entry(fcoe, &fcoe_hostlist, list) {
1781 if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN)
1782 real_dev = vlan_dev_real_dev(fcoe->netdev);
1783 else
1784 real_dev = fcoe->netdev;
1785
1786 if (netdev == real_dev)
1787 return fcoe;
1788 }
1789 return NULL;
1790}
1791
1792static int fcoe_dcb_app_notification(struct notifier_block *notifier,
1793 ulong event, void *ptr)
1794{
1795 struct dcb_app_type *entry = ptr;
1796 struct fcoe_interface *fcoe;
1797 struct net_device *netdev;
1798 struct fcoe_port *port;
1799 int prio;
1800
1801 if (entry->app.selector != DCB_APP_IDTYPE_ETHTYPE)
1802 return NOTIFY_OK;
1803
1804 netdev = dev_get_by_index(&init_net, entry->ifindex);
1805 if (!netdev)
1806 return NOTIFY_OK;
1807
1808 fcoe = fcoe_hostlist_lookup_realdev_port(netdev);
1809 dev_put(netdev);
1810 if (!fcoe)
1811 return NOTIFY_OK;
1812
1813 if (entry->dcbx & DCB_CAP_DCBX_VER_CEE)
1814 prio = ffs(entry->app.priority) - 1;
1815 else
1816 prio = entry->app.priority;
1817
1818 if (prio < 0)
1819 return NOTIFY_OK;
1820
1821 if (entry->app.protocol == ETH_P_FIP ||
1822 entry->app.protocol == ETH_P_FCOE)
1823 fcoe->ctlr.priority = prio;
1824
1825 if (entry->app.protocol == ETH_P_FCOE) {
1826 port = lport_priv(fcoe->ctlr.lp);
1827 port->priority = prio;
1828 }
1829
1830 return NOTIFY_OK;
1831}
1832
1760/** 1833/**
1761 * fcoe_device_notification() - Handler for net device events 1834 * fcoe_device_notification() - Handler for net device events
1762 * @notifier: The context of the notification 1835 * @notifier: The context of the notification
@@ -1965,6 +2038,46 @@ static bool fcoe_match(struct net_device *netdev)
1965} 2038}
1966 2039
1967/** 2040/**
2041 * fcoe_dcb_create() - Initialize DCB attributes and hooks
2042 * @netdev: The net_device object of the L2 link that should be queried
2043 * @port: The fcoe_port to bind FCoE APP priority with
2044 * @
2045 */
2046static void fcoe_dcb_create(struct fcoe_interface *fcoe)
2047{
2048#ifdef CONFIG_DCB
2049 int dcbx;
2050 u8 fup, up;
2051 struct net_device *netdev = fcoe->realdev;
2052 struct fcoe_port *port = lport_priv(fcoe->ctlr.lp);
2053 struct dcb_app app = {
2054 .priority = 0,
2055 .protocol = ETH_P_FCOE
2056 };
2057
2058 /* setup DCB priority attributes. */
2059 if (netdev && netdev->dcbnl_ops && netdev->dcbnl_ops->getdcbx) {
2060 dcbx = netdev->dcbnl_ops->getdcbx(netdev);
2061
2062 if (dcbx & DCB_CAP_DCBX_VER_IEEE) {
2063 app.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
2064 up = dcb_ieee_getapp_mask(netdev, &app);
2065 app.protocol = ETH_P_FIP;
2066 fup = dcb_ieee_getapp_mask(netdev, &app);
2067 } else {
2068 app.selector = DCB_APP_IDTYPE_ETHTYPE;
2069 up = dcb_getapp(netdev, &app);
2070 app.protocol = ETH_P_FIP;
2071 fup = dcb_getapp(netdev, &app);
2072 }
2073
2074 port->priority = ffs(up) ? ffs(up) - 1 : 0;
2075 fcoe->ctlr.priority = ffs(fup) ? ffs(fup) - 1 : port->priority;
2076 }
2077#endif
2078}
2079
2080/**
1968 * fcoe_create() - Create a fcoe interface 2081 * fcoe_create() - Create a fcoe interface
1969 * @netdev : The net_device object the Ethernet interface to create on 2082 * @netdev : The net_device object the Ethernet interface to create on
1970 * @fip_mode: The FIP mode for this creation 2083 * @fip_mode: The FIP mode for this creation
@@ -2007,6 +2120,9 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
2007 /* Make this the "master" N_Port */ 2120 /* Make this the "master" N_Port */
2008 fcoe->ctlr.lp = lport; 2121 fcoe->ctlr.lp = lport;
2009 2122
2123 /* setup DCB priority attributes. */
2124 fcoe_dcb_create(fcoe);
2125
2010 /* add to lports list */ 2126 /* add to lports list */
2011 fcoe_hostlist_add(lport); 2127 fcoe_hostlist_add(lport);
2012 2128
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index c74c4b8e71e..e7522dcc296 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -320,6 +320,7 @@ static void fcoe_ctlr_solicit(struct fcoe_ctlr *fip, struct fcoe_fcf *fcf)
320 320
321 skb_put(skb, sizeof(*sol)); 321 skb_put(skb, sizeof(*sol));
322 skb->protocol = htons(ETH_P_FIP); 322 skb->protocol = htons(ETH_P_FIP);
323 skb->priority = fip->priority;
323 skb_reset_mac_header(skb); 324 skb_reset_mac_header(skb);
324 skb_reset_network_header(skb); 325 skb_reset_network_header(skb);
325 fip->send(fip, skb); 326 fip->send(fip, skb);
@@ -474,6 +475,7 @@ static void fcoe_ctlr_send_keep_alive(struct fcoe_ctlr *fip,
474 } 475 }
475 skb_put(skb, len); 476 skb_put(skb, len);
476 skb->protocol = htons(ETH_P_FIP); 477 skb->protocol = htons(ETH_P_FIP);
478 skb->priority = fip->priority;
477 skb_reset_mac_header(skb); 479 skb_reset_mac_header(skb);
478 skb_reset_network_header(skb); 480 skb_reset_network_header(skb);
479 fip->send(fip, skb); 481 fip->send(fip, skb);
@@ -566,6 +568,7 @@ static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
566 cap->fip.fip_dl_len = htons(dlen / FIP_BPW); 568 cap->fip.fip_dl_len = htons(dlen / FIP_BPW);
567 569
568 skb->protocol = htons(ETH_P_FIP); 570 skb->protocol = htons(ETH_P_FIP);
571 skb->priority = fip->priority;
569 skb_reset_mac_header(skb); 572 skb_reset_mac_header(skb);
570 skb_reset_network_header(skb); 573 skb_reset_network_header(skb);
571 return 0; 574 return 0;
@@ -1911,6 +1914,7 @@ static void fcoe_ctlr_vn_send(struct fcoe_ctlr *fip,
1911 1914
1912 skb_put(skb, len); 1915 skb_put(skb, len);
1913 skb->protocol = htons(ETH_P_FIP); 1916 skb->protocol = htons(ETH_P_FIP);
1917 skb->priority = fip->priority;
1914 skb_reset_mac_header(skb); 1918 skb_reset_mac_header(skb);
1915 skb_reset_network_header(skb); 1919 skb_reset_network_header(skb);
1916 1920
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 4e041f6d808..d570573b796 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -4335,7 +4335,7 @@ _scsih_smart_predicted_fault(struct MPT2SAS_ADAPTER *ioc, u16 handle)
4335 /* insert into event log */ 4335 /* insert into event log */
4336 sz = offsetof(Mpi2EventNotificationReply_t, EventData) + 4336 sz = offsetof(Mpi2EventNotificationReply_t, EventData) +
4337 sizeof(Mpi2EventDataSasDeviceStatusChange_t); 4337 sizeof(Mpi2EventDataSasDeviceStatusChange_t);
4338 event_reply = kzalloc(sz, GFP_KERNEL); 4338 event_reply = kzalloc(sz, GFP_ATOMIC);
4339 if (!event_reply) { 4339 if (!event_reply) {
4340 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 4340 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
4341 ioc->name, __FILE__, __LINE__, __func__); 4341 ioc->name, __FILE__, __LINE__, __func__);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ac326c41e93..6465dae5883 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1762,12 +1762,31 @@ qla2x00_get_host_port_state(struct Scsi_Host *shost)
1762 scsi_qla_host_t *vha = shost_priv(shost); 1762 scsi_qla_host_t *vha = shost_priv(shost);
1763 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev); 1763 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
1764 1764
1765 if (!base_vha->flags.online) 1765 if (!base_vha->flags.online) {
1766 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; 1766 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
1767 else if (atomic_read(&base_vha->loop_state) == LOOP_TIMEOUT) 1767 return;
1768 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; 1768 }
1769 else 1769
1770 switch (atomic_read(&base_vha->loop_state)) {
1771 case LOOP_UPDATE:
1772 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1773 break;
1774 case LOOP_DOWN:
1775 if (test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags))
1776 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1777 else
1778 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
1779 break;
1780 case LOOP_DEAD:
1781 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
1782 break;
1783 case LOOP_READY:
1770 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; 1784 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
1785 break;
1786 default:
1787 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
1788 break;
1789 }
1771} 1790}
1772 1791
1773static int 1792static int
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 9df4787715c..f3cddd5800c 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -12,17 +12,17 @@
12 * | Level | Last Value Used | Holes | 12 * | Level | Last Value Used | Holes |
13 * ---------------------------------------------------------------------- 13 * ----------------------------------------------------------------------
14 * | Module Init and Probe | 0x0116 | | 14 * | Module Init and Probe | 0x0116 | |
15 * | Mailbox commands | 0x1129 | | 15 * | Mailbox commands | 0x112b | |
16 * | Device Discovery | 0x2083 | | 16 * | Device Discovery | 0x2083 | |
17 * | Queue Command and IO tracing | 0x302e | 0x3008 | 17 * | Queue Command and IO tracing | 0x302e | 0x3008 |
18 * | DPC Thread | 0x401c | | 18 * | DPC Thread | 0x401c | |
19 * | Async Events | 0x5059 | | 19 * | Async Events | 0x5059 | |
20 * | Timer Routines | 0x600d | | 20 * | Timer Routines | 0x6010 | 0x600e,0x600f |
21 * | User Space Interactions | 0x709d | | 21 * | User Space Interactions | 0x709d | |
22 * | Task Management | 0x8041 | | 22 * | Task Management | 0x8041 | 0x800b |
23 * | AER/EEH | 0x900f | | 23 * | AER/EEH | 0x900f | |
24 * | Virtual Port | 0xa007 | | 24 * | Virtual Port | 0xa007 | |
25 * | ISP82XX Specific | 0xb051 | | 25 * | ISP82XX Specific | 0xb052 | |
26 * | MultiQ | 0xc00b | | 26 * | MultiQ | 0xc00b | |
27 * | Misc | 0xd00b | | 27 * | Misc | 0xd00b | |
28 * ---------------------------------------------------------------------- 28 * ----------------------------------------------------------------------
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index ce32d8135c9..c0c11afb685 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -578,6 +578,7 @@ extern int qla82xx_check_md_needed(scsi_qla_host_t *);
578extern void qla82xx_chip_reset_cleanup(scsi_qla_host_t *); 578extern void qla82xx_chip_reset_cleanup(scsi_qla_host_t *);
579extern int qla82xx_mbx_beacon_ctl(scsi_qla_host_t *, int); 579extern int qla82xx_mbx_beacon_ctl(scsi_qla_host_t *, int);
580extern char *qdev_state(uint32_t); 580extern char *qdev_state(uint32_t);
581extern void qla82xx_clear_pending_mbx(scsi_qla_host_t *);
581 582
582/* BSG related functions */ 583/* BSG related functions */
583extern int qla24xx_bsg_request(struct fc_bsg_job *); 584extern int qla24xx_bsg_request(struct fc_bsg_job *);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index f03e915f187..54ea68cec4c 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1509,7 +1509,8 @@ enable_82xx_npiv:
1509 &ha->fw_xcb_count, NULL, NULL, 1509 &ha->fw_xcb_count, NULL, NULL,
1510 &ha->max_npiv_vports, NULL); 1510 &ha->max_npiv_vports, NULL);
1511 1511
1512 if (!fw_major_version && ql2xallocfwdump) 1512 if (!fw_major_version && ql2xallocfwdump
1513 && !IS_QLA82XX(ha))
1513 qla2x00_alloc_fw_dump(vha); 1514 qla2x00_alloc_fw_dump(vha);
1514 } 1515 }
1515 } else { 1516 } else {
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index dbec89622a0..a4b267e60a3 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -120,11 +120,10 @@ qla2x00_prep_cont_type0_iocb(struct scsi_qla_host *vha)
120 * Returns a pointer to the continuation type 1 IOCB packet. 120 * Returns a pointer to the continuation type 1 IOCB packet.
121 */ 121 */
122static inline cont_a64_entry_t * 122static inline cont_a64_entry_t *
123qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *vha) 123qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *vha, struct req_que *req)
124{ 124{
125 cont_a64_entry_t *cont_pkt; 125 cont_a64_entry_t *cont_pkt;
126 126
127 struct req_que *req = vha->req;
128 /* Adjust ring index. */ 127 /* Adjust ring index. */
129 req->ring_index++; 128 req->ring_index++;
130 if (req->ring_index == req->length) { 129 if (req->ring_index == req->length) {
@@ -292,7 +291,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
292 * Five DSDs are available in the Continuation 291 * Five DSDs are available in the Continuation
293 * Type 1 IOCB. 292 * Type 1 IOCB.
294 */ 293 */
295 cont_pkt = qla2x00_prep_cont_type1_iocb(vha); 294 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req);
296 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; 295 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
297 avail_dsds = 5; 296 avail_dsds = 5;
298 } 297 }
@@ -684,7 +683,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
684 * Five DSDs are available in the Continuation 683 * Five DSDs are available in the Continuation
685 * Type 1 IOCB. 684 * Type 1 IOCB.
686 */ 685 */
687 cont_pkt = qla2x00_prep_cont_type1_iocb(vha); 686 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req);
688 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; 687 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
689 avail_dsds = 5; 688 avail_dsds = 5;
690 } 689 }
@@ -2070,7 +2069,8 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb)
2070 * Five DSDs are available in the Cont. 2069 * Five DSDs are available in the Cont.
2071 * Type 1 IOCB. 2070 * Type 1 IOCB.
2072 */ 2071 */
2073 cont_pkt = qla2x00_prep_cont_type1_iocb(vha); 2072 cont_pkt = qla2x00_prep_cont_type1_iocb(vha,
2073 vha->hw->req_q_map[0]);
2074 cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; 2074 cur_dsd = (uint32_t *) cont_pkt->dseg_0_address;
2075 avail_dsds = 5; 2075 avail_dsds = 5;
2076 cont_iocb_prsnt = 1; 2076 cont_iocb_prsnt = 1;
@@ -2096,6 +2096,7 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb)
2096 int index; 2096 int index;
2097 uint16_t tot_dsds; 2097 uint16_t tot_dsds;
2098 scsi_qla_host_t *vha = sp->fcport->vha; 2098 scsi_qla_host_t *vha = sp->fcport->vha;
2099 struct qla_hw_data *ha = vha->hw;
2099 struct fc_bsg_job *bsg_job = ((struct srb_ctx *)sp->ctx)->u.bsg_job; 2100 struct fc_bsg_job *bsg_job = ((struct srb_ctx *)sp->ctx)->u.bsg_job;
2100 int loop_iterartion = 0; 2101 int loop_iterartion = 0;
2101 int cont_iocb_prsnt = 0; 2102 int cont_iocb_prsnt = 0;
@@ -2141,7 +2142,8 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb)
2141 * Five DSDs are available in the Cont. 2142 * Five DSDs are available in the Cont.
2142 * Type 1 IOCB. 2143 * Type 1 IOCB.
2143 */ 2144 */
2144 cont_pkt = qla2x00_prep_cont_type1_iocb(vha); 2145 cont_pkt = qla2x00_prep_cont_type1_iocb(vha,
2146 ha->req_q_map[0]);
2145 cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; 2147 cur_dsd = (uint32_t *) cont_pkt->dseg_0_address;
2146 avail_dsds = 5; 2148 avail_dsds = 5;
2147 cont_iocb_prsnt = 1; 2149 cont_iocb_prsnt = 1;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 2516adf1aee..7b91b290ffd 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1741,7 +1741,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1741 resid, scsi_bufflen(cp)); 1741 resid, scsi_bufflen(cp));
1742 1742
1743 cp->result = DID_ERROR << 16 | lscsi_status; 1743 cp->result = DID_ERROR << 16 | lscsi_status;
1744 break; 1744 goto check_scsi_status;
1745 } 1745 }
1746 1746
1747 if (!lscsi_status && 1747 if (!lscsi_status &&
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 3b3cec9f6ac..82a33533ed2 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -79,8 +79,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
79 mcp->mb[0] = MBS_LINK_DOWN_ERROR; 79 mcp->mb[0] = MBS_LINK_DOWN_ERROR;
80 ql_log(ql_log_warn, base_vha, 0x1004, 80 ql_log(ql_log_warn, base_vha, 0x1004,
81 "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); 81 "FW hung = %d.\n", ha->flags.isp82xx_fw_hung);
82 rval = QLA_FUNCTION_FAILED; 82 return QLA_FUNCTION_TIMEOUT;
83 goto premature_exit;
84 } 83 }
85 84
86 /* 85 /*
@@ -163,6 +162,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
163 HINT_MBX_INT_PENDING) { 162 HINT_MBX_INT_PENDING) {
164 spin_unlock_irqrestore(&ha->hardware_lock, 163 spin_unlock_irqrestore(&ha->hardware_lock,
165 flags); 164 flags);
165 ha->flags.mbox_busy = 0;
166 ql_dbg(ql_dbg_mbx, base_vha, 0x1010, 166 ql_dbg(ql_dbg_mbx, base_vha, 0x1010,
167 "Pending mailbox timeout, exiting.\n"); 167 "Pending mailbox timeout, exiting.\n");
168 rval = QLA_FUNCTION_TIMEOUT; 168 rval = QLA_FUNCTION_TIMEOUT;
@@ -188,6 +188,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
188 HINT_MBX_INT_PENDING) { 188 HINT_MBX_INT_PENDING) {
189 spin_unlock_irqrestore(&ha->hardware_lock, 189 spin_unlock_irqrestore(&ha->hardware_lock,
190 flags); 190 flags);
191 ha->flags.mbox_busy = 0;
191 ql_dbg(ql_dbg_mbx, base_vha, 0x1012, 192 ql_dbg(ql_dbg_mbx, base_vha, 0x1012,
192 "Pending mailbox timeout, exiting.\n"); 193 "Pending mailbox timeout, exiting.\n");
193 rval = QLA_FUNCTION_TIMEOUT; 194 rval = QLA_FUNCTION_TIMEOUT;
@@ -302,7 +303,15 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
302 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && 303 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) &&
303 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && 304 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
304 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { 305 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
305 306 if (IS_QLA82XX(ha)) {
307 ql_dbg(ql_dbg_mbx, vha, 0x112a,
308 "disabling pause transmit on port "
309 "0 & 1.\n");
310 qla82xx_wr_32(ha,
311 QLA82XX_CRB_NIU + 0x98,
312 CRB_NIU_XG_PAUSE_CTL_P0|
313 CRB_NIU_XG_PAUSE_CTL_P1);
314 }
306 ql_log(ql_log_info, base_vha, 0x101c, 315 ql_log(ql_log_info, base_vha, 0x101c,
307 "Mailbox cmd timeout occured. " 316 "Mailbox cmd timeout occured. "
308 "Scheduling ISP abort eeh_busy=0x%x.\n", 317 "Scheduling ISP abort eeh_busy=0x%x.\n",
@@ -318,7 +327,15 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
318 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && 327 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) &&
319 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && 328 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
320 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { 329 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
321 330 if (IS_QLA82XX(ha)) {
331 ql_dbg(ql_dbg_mbx, vha, 0x112b,
332 "disabling pause transmit on port "
333 "0 & 1.\n");
334 qla82xx_wr_32(ha,
335 QLA82XX_CRB_NIU + 0x98,
336 CRB_NIU_XG_PAUSE_CTL_P0|
337 CRB_NIU_XG_PAUSE_CTL_P1);
338 }
322 ql_log(ql_log_info, base_vha, 0x101e, 339 ql_log(ql_log_info, base_vha, 0x101e,
323 "Mailbox cmd timeout occured. " 340 "Mailbox cmd timeout occured. "
324 "Scheduling ISP abort.\n"); 341 "Scheduling ISP abort.\n");
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 94bded5ddce..03554934b0a 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -3817,6 +3817,20 @@ exit:
3817 return rval; 3817 return rval;
3818} 3818}
3819 3819
3820void qla82xx_clear_pending_mbx(scsi_qla_host_t *vha)
3821{
3822 struct qla_hw_data *ha = vha->hw;
3823
3824 if (ha->flags.mbox_busy) {
3825 ha->flags.mbox_int = 1;
3826 ha->flags.mbox_busy = 0;
3827 ql_log(ql_log_warn, vha, 0x6010,
3828 "Doing premature completion of mbx command.\n");
3829 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags))
3830 complete(&ha->mbx_intr_comp);
3831 }
3832}
3833
3820void qla82xx_watchdog(scsi_qla_host_t *vha) 3834void qla82xx_watchdog(scsi_qla_host_t *vha)
3821{ 3835{
3822 uint32_t dev_state, halt_status; 3836 uint32_t dev_state, halt_status;
@@ -3839,9 +3853,13 @@ void qla82xx_watchdog(scsi_qla_host_t *vha)
3839 qla2xxx_wake_dpc(vha); 3853 qla2xxx_wake_dpc(vha);
3840 } else { 3854 } else {
3841 if (qla82xx_check_fw_alive(vha)) { 3855 if (qla82xx_check_fw_alive(vha)) {
3856 ql_dbg(ql_dbg_timer, vha, 0x6011,
3857 "disabling pause transmit on port 0 & 1.\n");
3858 qla82xx_wr_32(ha, QLA82XX_CRB_NIU + 0x98,
3859 CRB_NIU_XG_PAUSE_CTL_P0|CRB_NIU_XG_PAUSE_CTL_P1);
3842 halt_status = qla82xx_rd_32(ha, 3860 halt_status = qla82xx_rd_32(ha,
3843 QLA82XX_PEG_HALT_STATUS1); 3861 QLA82XX_PEG_HALT_STATUS1);
3844 ql_dbg(ql_dbg_timer, vha, 0x6005, 3862 ql_log(ql_log_info, vha, 0x6005,
3845 "dumping hw/fw registers:.\n " 3863 "dumping hw/fw registers:.\n "
3846 " PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,.\n " 3864 " PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,.\n "
3847 " PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,.\n " 3865 " PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,.\n "
@@ -3858,6 +3876,11 @@ void qla82xx_watchdog(scsi_qla_host_t *vha)
3858 QLA82XX_CRB_PEG_NET_3 + 0x3c), 3876 QLA82XX_CRB_PEG_NET_3 + 0x3c),
3859 qla82xx_rd_32(ha, 3877 qla82xx_rd_32(ha,
3860 QLA82XX_CRB_PEG_NET_4 + 0x3c)); 3878 QLA82XX_CRB_PEG_NET_4 + 0x3c));
3879 if (LSW(MSB(halt_status)) == 0x67)
3880 ql_log(ql_log_warn, vha, 0xb052,
3881 "Firmware aborted with "
3882 "error code 0x00006700. Device is "
3883 "being reset.\n");
3861 if (halt_status & HALT_STATUS_UNRECOVERABLE) { 3884 if (halt_status & HALT_STATUS_UNRECOVERABLE) {
3862 set_bit(ISP_UNRECOVERABLE, 3885 set_bit(ISP_UNRECOVERABLE,
3863 &vha->dpc_flags); 3886 &vha->dpc_flags);
@@ -3869,16 +3892,8 @@ void qla82xx_watchdog(scsi_qla_host_t *vha)
3869 } 3892 }
3870 qla2xxx_wake_dpc(vha); 3893 qla2xxx_wake_dpc(vha);
3871 ha->flags.isp82xx_fw_hung = 1; 3894 ha->flags.isp82xx_fw_hung = 1;
3872 if (ha->flags.mbox_busy) { 3895 ql_log(ql_log_warn, vha, 0x6007, "Firmware hung.\n");
3873 ha->flags.mbox_int = 1; 3896 qla82xx_clear_pending_mbx(vha);
3874 ql_log(ql_log_warn, vha, 0x6007,
3875 "Due to FW hung, doing "
3876 "premature completion of mbx "
3877 "command.\n");
3878 if (test_bit(MBX_INTR_WAIT,
3879 &ha->mbx_cmd_flags))
3880 complete(&ha->mbx_intr_comp);
3881 }
3882 } 3897 }
3883 } 3898 }
3884 } 3899 }
@@ -4073,10 +4088,7 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha)
4073 msleep(1000); 4088 msleep(1000);
4074 if (qla82xx_check_fw_alive(vha)) { 4089 if (qla82xx_check_fw_alive(vha)) {
4075 ha->flags.isp82xx_fw_hung = 1; 4090 ha->flags.isp82xx_fw_hung = 1;
4076 if (ha->flags.mbox_busy) { 4091 qla82xx_clear_pending_mbx(vha);
4077 ha->flags.mbox_int = 1;
4078 complete(&ha->mbx_intr_comp);
4079 }
4080 break; 4092 break;
4081 } 4093 }
4082 } 4094 }
diff --git a/drivers/scsi/qla2xxx/qla_nx.h b/drivers/scsi/qla2xxx/qla_nx.h
index 57820c199bc..57a226be339 100644
--- a/drivers/scsi/qla2xxx/qla_nx.h
+++ b/drivers/scsi/qla2xxx/qla_nx.h
@@ -1173,4 +1173,8 @@ struct qla82xx_md_entry_queue {
1173 1173
1174static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8, 0x410000AC, 1174static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8, 0x410000AC,
1175 0x410000B8, 0x410000BC }; 1175 0x410000B8, 0x410000BC };
1176
1177#define CRB_NIU_XG_PAUSE_CTL_P0 0x1
1178#define CRB_NIU_XG_PAUSE_CTL_P1 0x8
1179
1176#endif 1180#endif
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index fd14c7bfc62..f9e5b85e84d 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -201,12 +201,12 @@ MODULE_PARM_DESC(ql2xmdcapmask,
201 "Set the Minidump driver capture mask level. " 201 "Set the Minidump driver capture mask level. "
202 "Default is 0x7F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); 202 "Default is 0x7F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F.");
203 203
204int ql2xmdenable; 204int ql2xmdenable = 1;
205module_param(ql2xmdenable, int, S_IRUGO); 205module_param(ql2xmdenable, int, S_IRUGO);
206MODULE_PARM_DESC(ql2xmdenable, 206MODULE_PARM_DESC(ql2xmdenable,
207 "Enable/disable MiniDump. " 207 "Enable/disable MiniDump. "
208 "0 (Default) - MiniDump disabled. " 208 "0 - MiniDump disabled. "
209 "1 - MiniDump enabled."); 209 "1 (Default) - MiniDump enabled.");
210 210
211/* 211/*
212 * SCSI host template entry points 212 * SCSI host template entry points
@@ -423,6 +423,7 @@ fail2:
423 qla25xx_delete_queues(vha); 423 qla25xx_delete_queues(vha);
424 destroy_workqueue(ha->wq); 424 destroy_workqueue(ha->wq);
425 ha->wq = NULL; 425 ha->wq = NULL;
426 vha->req = ha->req_q_map[0];
426fail: 427fail:
427 ha->mqenable = 0; 428 ha->mqenable = 0;
428 kfree(ha->req_q_map); 429 kfree(ha->req_q_map);
@@ -814,49 +815,6 @@ qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha)
814 return return_status; 815 return return_status;
815} 816}
816 817
817/*
818 * qla2x00_wait_for_loop_ready
819 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
820 * to be in LOOP_READY state.
821 * Input:
822 * ha - pointer to host adapter structure
823 *
824 * Note:
825 * Does context switching-Release SPIN_LOCK
826 * (if any) before calling this routine.
827 *
828 *
829 * Return:
830 * Success (LOOP_READY) : 0
831 * Failed (LOOP_NOT_READY) : 1
832 */
833static inline int
834qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
835{
836 int return_status = QLA_SUCCESS;
837 unsigned long loop_timeout ;
838 struct qla_hw_data *ha = vha->hw;
839 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
840
841 /* wait for 5 min at the max for loop to be ready */
842 loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ);
843
844 while ((!atomic_read(&base_vha->loop_down_timer) &&
845 atomic_read(&base_vha->loop_state) == LOOP_DOWN) ||
846 atomic_read(&base_vha->loop_state) != LOOP_READY) {
847 if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
848 return_status = QLA_FUNCTION_FAILED;
849 break;
850 }
851 msleep(1000);
852 if (time_after_eq(jiffies, loop_timeout)) {
853 return_status = QLA_FUNCTION_FAILED;
854 break;
855 }
856 }
857 return (return_status);
858}
859
860static void 818static void
861sp_get(struct srb *sp) 819sp_get(struct srb *sp)
862{ 820{
@@ -1035,12 +993,6 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
1035 "Wait for hba online failed for cmd=%p.\n", cmd); 993 "Wait for hba online failed for cmd=%p.\n", cmd);
1036 goto eh_reset_failed; 994 goto eh_reset_failed;
1037 } 995 }
1038 err = 1;
1039 if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS) {
1040 ql_log(ql_log_warn, vha, 0x800b,
1041 "Wait for loop ready failed for cmd=%p.\n", cmd);
1042 goto eh_reset_failed;
1043 }
1044 err = 2; 996 err = 2;
1045 if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) 997 if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1)
1046 != QLA_SUCCESS) { 998 != QLA_SUCCESS) {
@@ -1137,10 +1089,9 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
1137 goto eh_bus_reset_done; 1089 goto eh_bus_reset_done;
1138 } 1090 }
1139 1091
1140 if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) { 1092 if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
1141 if (qla2x00_loop_reset(vha) == QLA_SUCCESS) 1093 ret = SUCCESS;
1142 ret = SUCCESS; 1094
1143 }
1144 if (ret == FAILED) 1095 if (ret == FAILED)
1145 goto eh_bus_reset_done; 1096 goto eh_bus_reset_done;
1146 1097
@@ -1206,15 +1157,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1206 if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS) 1157 if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS)
1207 goto eh_host_reset_lock; 1158 goto eh_host_reset_lock;
1208 1159
1209 /*
1210 * Fixme-may be dpc thread is active and processing
1211 * loop_resync,so wait a while for it to
1212 * be completed and then issue big hammer.Otherwise
1213 * it may cause I/O failure as big hammer marks the
1214 * devices as lost kicking of the port_down_timer
1215 * while dpc is stuck for the mailbox to complete.
1216 */
1217 qla2x00_wait_for_loop_ready(vha);
1218 if (vha != base_vha) { 1160 if (vha != base_vha) {
1219 if (qla2x00_vp_abort_isp(vha)) 1161 if (qla2x00_vp_abort_isp(vha))
1220 goto eh_host_reset_lock; 1162 goto eh_host_reset_lock;
@@ -1297,16 +1239,13 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
1297 atomic_set(&vha->loop_state, LOOP_DOWN); 1239 atomic_set(&vha->loop_state, LOOP_DOWN);
1298 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 1240 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
1299 qla2x00_mark_all_devices_lost(vha, 0); 1241 qla2x00_mark_all_devices_lost(vha, 0);
1300 qla2x00_wait_for_loop_ready(vha);
1301 } 1242 }
1302 1243
1303 if (ha->flags.enable_lip_reset) { 1244 if (ha->flags.enable_lip_reset) {
1304 ret = qla2x00_lip_reset(vha); 1245 ret = qla2x00_lip_reset(vha);
1305 if (ret != QLA_SUCCESS) { 1246 if (ret != QLA_SUCCESS)
1306 ql_dbg(ql_dbg_taskm, vha, 0x802e, 1247 ql_dbg(ql_dbg_taskm, vha, 0x802e,
1307 "lip_reset failed (%d).\n", ret); 1248 "lip_reset failed (%d).\n", ret);
1308 } else
1309 qla2x00_wait_for_loop_ready(vha);
1310 } 1249 }
1311 1250
1312 /* Issue marker command only when we are going to start the I/O */ 1251 /* Issue marker command only when we are going to start the I/O */
@@ -4070,13 +4009,8 @@ qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
4070 /* For ISP82XX complete any pending mailbox cmd */ 4009 /* For ISP82XX complete any pending mailbox cmd */
4071 if (IS_QLA82XX(ha)) { 4010 if (IS_QLA82XX(ha)) {
4072 ha->flags.isp82xx_fw_hung = 1; 4011 ha->flags.isp82xx_fw_hung = 1;
4073 if (ha->flags.mbox_busy) { 4012 ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n");
4074 ha->flags.mbox_int = 1; 4013 qla82xx_clear_pending_mbx(vha);
4075 ql_dbg(ql_dbg_aer, vha, 0x9001,
4076 "Due to pci channel io frozen, doing premature "
4077 "completion of mbx command.\n");
4078 complete(&ha->mbx_intr_comp);
4079 }
4080 } 4014 }
4081 qla2x00_free_irqs(vha); 4015 qla2x00_free_irqs(vha);
4082 pci_disable_device(pdev); 4016 pci_disable_device(pdev);
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 13b6357c1fa..23f33a6d52d 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.07.07-k" 10#define QLA2XXX_VERSION "8.03.07.12-k"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index ace637bf254..fd5edc6e166 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -147,7 +147,7 @@
147#define ISCSI_ALIAS_SIZE 32 /* ISCSI Alias name size */ 147#define ISCSI_ALIAS_SIZE 32 /* ISCSI Alias name size */
148#define ISCSI_NAME_SIZE 0xE0 /* ISCSI Name size */ 148#define ISCSI_NAME_SIZE 0xE0 /* ISCSI Name size */
149 149
150#define QL4_SESS_RECOVERY_TMO 30 /* iSCSI session */ 150#define QL4_SESS_RECOVERY_TMO 120 /* iSCSI session */
151 /* recovery timeout */ 151 /* recovery timeout */
152 152
153#define LSDW(x) ((u32)((u64)(x))) 153#define LSDW(x) ((u32)((u64)(x)))
@@ -173,6 +173,8 @@
173#define ISNS_DEREG_TOV 5 173#define ISNS_DEREG_TOV 5
174#define HBA_ONLINE_TOV 30 174#define HBA_ONLINE_TOV 30
175#define DISABLE_ACB_TOV 30 175#define DISABLE_ACB_TOV 30
176#define IP_CONFIG_TOV 30
177#define LOGIN_TOV 12
176 178
177#define MAX_RESET_HA_RETRIES 2 179#define MAX_RESET_HA_RETRIES 2
178 180
@@ -240,6 +242,45 @@ struct ddb_entry {
240 242
241 uint16_t fw_ddb_index; /* DDB firmware index */ 243 uint16_t fw_ddb_index; /* DDB firmware index */
242 uint32_t fw_ddb_device_state; /* F/W Device State -- see ql4_fw.h */ 244 uint32_t fw_ddb_device_state; /* F/W Device State -- see ql4_fw.h */
245 uint16_t ddb_type;
246#define FLASH_DDB 0x01
247
248 struct dev_db_entry fw_ddb_entry;
249 int (*unblock_sess)(struct iscsi_cls_session *cls_session);
250 int (*ddb_change)(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
251 struct ddb_entry *ddb_entry, uint32_t state);
252
253 /* Driver Re-login */
254 unsigned long flags; /* DDB Flags */
255 uint16_t default_relogin_timeout; /* Max time to wait for
256 * relogin to complete */
257 atomic_t retry_relogin_timer; /* Min Time between relogins
258 * (4000 only) */
259 atomic_t relogin_timer; /* Max Time to wait for
260 * relogin to complete */
261 atomic_t relogin_retry_count; /* Num of times relogin has been
262 * retried */
263 uint32_t default_time2wait; /* Default Min time between
264 * relogins (+aens) */
265
266};
267
268struct qla_ddb_index {
269 struct list_head list;
270 uint16_t fw_ddb_idx;
271 struct dev_db_entry fw_ddb;
272};
273
274#define DDB_IPADDR_LEN 64
275
276struct ql4_tuple_ddb {
277 int port;
278 int tpgt;
279 char ip_addr[DDB_IPADDR_LEN];
280 char iscsi_name[ISCSI_NAME_SIZE];
281 uint16_t options;
282#define DDB_OPT_IPV6 0x0e0e
283#define DDB_OPT_IPV4 0x0f0f
243}; 284};
244 285
245/* 286/*
@@ -411,7 +452,7 @@ struct scsi_qla_host {
411#define AF_FW_RECOVERY 19 /* 0x00080000 */ 452#define AF_FW_RECOVERY 19 /* 0x00080000 */
412#define AF_EEH_BUSY 20 /* 0x00100000 */ 453#define AF_EEH_BUSY 20 /* 0x00100000 */
413#define AF_PCI_CHANNEL_IO_PERM_FAILURE 21 /* 0x00200000 */ 454#define AF_PCI_CHANNEL_IO_PERM_FAILURE 21 /* 0x00200000 */
414 455#define AF_BUILD_DDB_LIST 22 /* 0x00400000 */
415 unsigned long dpc_flags; 456 unsigned long dpc_flags;
416 457
417#define DPC_RESET_HA 1 /* 0x00000002 */ 458#define DPC_RESET_HA 1 /* 0x00000002 */
@@ -604,6 +645,7 @@ struct scsi_qla_host {
604 uint16_t bootload_minor; 645 uint16_t bootload_minor;
605 uint16_t bootload_patch; 646 uint16_t bootload_patch;
606 uint16_t bootload_build; 647 uint16_t bootload_build;
648 uint16_t def_timeout; /* Default login timeout */
607 649
608 uint32_t flash_state; 650 uint32_t flash_state;
609#define QLFLASH_WAITING 0 651#define QLFLASH_WAITING 0
@@ -623,6 +665,11 @@ struct scsi_qla_host {
623 uint16_t iscsi_pci_func_cnt; 665 uint16_t iscsi_pci_func_cnt;
624 uint8_t model_name[16]; 666 uint8_t model_name[16];
625 struct completion disable_acb_comp; 667 struct completion disable_acb_comp;
668 struct dma_pool *fw_ddb_dma_pool;
669#define DDB_DMA_BLOCK_SIZE 512
670 uint16_t pri_ddb_idx;
671 uint16_t sec_ddb_idx;
672 int is_reset;
626}; 673};
627 674
628struct ql4_task_data { 675struct ql4_task_data {
@@ -835,6 +882,10 @@ static inline int ql4xxx_reset_active(struct scsi_qla_host *ha)
835/*---------------------------------------------------------------------------*/ 882/*---------------------------------------------------------------------------*/
836 883
837/* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */ 884/* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */
885
886#define INIT_ADAPTER 0
887#define RESET_ADAPTER 1
888
838#define PRESERVE_DDB_LIST 0 889#define PRESERVE_DDB_LIST 0
839#define REBUILD_DDB_LIST 1 890#define REBUILD_DDB_LIST 1
840 891
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index cbd5a20dbbd..4ac07f88252 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -12,6 +12,7 @@
12#define MAX_PRST_DEV_DB_ENTRIES 64 12#define MAX_PRST_DEV_DB_ENTRIES 64
13#define MIN_DISC_DEV_DB_ENTRY MAX_PRST_DEV_DB_ENTRIES 13#define MIN_DISC_DEV_DB_ENTRY MAX_PRST_DEV_DB_ENTRIES
14#define MAX_DEV_DB_ENTRIES 512 14#define MAX_DEV_DB_ENTRIES 512
15#define MAX_DEV_DB_ENTRIES_40XX 256
15 16
16/************************************************************************* 17/*************************************************************************
17 * 18 *
@@ -604,6 +605,13 @@ struct addr_ctrl_blk {
604 uint8_t res14[140]; /* 274-2FF */ 605 uint8_t res14[140]; /* 274-2FF */
605}; 606};
606 607
608#define IP_ADDR_COUNT 4 /* Total 4 IP address supported in one interface
609 * One IPv4, one IPv6 link local and 2 IPv6
610 */
611
612#define IP_STATE_MASK 0x0F000000
613#define IP_STATE_SHIFT 24
614
607struct init_fw_ctrl_blk { 615struct init_fw_ctrl_blk {
608 struct addr_ctrl_blk pri; 616 struct addr_ctrl_blk pri;
609/* struct addr_ctrl_blk sec;*/ 617/* struct addr_ctrl_blk sec;*/
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 160db9d5ea2..d0dd4b33020 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -13,7 +13,7 @@ struct iscsi_cls_conn;
13int qla4xxx_hw_reset(struct scsi_qla_host *ha); 13int qla4xxx_hw_reset(struct scsi_qla_host *ha);
14int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a); 14int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a);
15int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb *srb); 15int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb *srb);
16int qla4xxx_initialize_adapter(struct scsi_qla_host *ha); 16int qla4xxx_initialize_adapter(struct scsi_qla_host *ha, int is_reset);
17int qla4xxx_soft_reset(struct scsi_qla_host *ha); 17int qla4xxx_soft_reset(struct scsi_qla_host *ha);
18irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id); 18irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id);
19 19
@@ -153,10 +153,13 @@ int qla4xxx_req_ddb_entry(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
153 uint32_t *mbx_sts); 153 uint32_t *mbx_sts);
154int qla4xxx_clear_ddb_entry(struct scsi_qla_host *ha, uint32_t fw_ddb_index); 154int qla4xxx_clear_ddb_entry(struct scsi_qla_host *ha, uint32_t fw_ddb_index);
155int qla4xxx_send_passthru0(struct iscsi_task *task); 155int qla4xxx_send_passthru0(struct iscsi_task *task);
156void qla4xxx_free_ddb_index(struct scsi_qla_host *ha);
156int qla4xxx_get_mgmt_data(struct scsi_qla_host *ha, uint16_t fw_ddb_index, 157int qla4xxx_get_mgmt_data(struct scsi_qla_host *ha, uint16_t fw_ddb_index,
157 uint16_t stats_size, dma_addr_t stats_dma); 158 uint16_t stats_size, dma_addr_t stats_dma);
158void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha, 159void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
159 struct ddb_entry *ddb_entry); 160 struct ddb_entry *ddb_entry);
161void qla4xxx_update_session_conn_fwddb_param(struct scsi_qla_host *ha,
162 struct ddb_entry *ddb_entry);
160int qla4xxx_bootdb_by_index(struct scsi_qla_host *ha, 163int qla4xxx_bootdb_by_index(struct scsi_qla_host *ha,
161 struct dev_db_entry *fw_ddb_entry, 164 struct dev_db_entry *fw_ddb_entry,
162 dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index); 165 dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index);
@@ -169,11 +172,22 @@ int qla4xxx_set_nvram(struct scsi_qla_host *ha, dma_addr_t nvram_dma,
169int qla4xxx_restore_factory_defaults(struct scsi_qla_host *ha, 172int qla4xxx_restore_factory_defaults(struct scsi_qla_host *ha,
170 uint32_t region, uint32_t field0, 173 uint32_t region, uint32_t field0,
171 uint32_t field1); 174 uint32_t field1);
175int qla4xxx_get_ddb_index(struct scsi_qla_host *ha, uint16_t *ddb_index);
176void qla4xxx_login_flash_ddb(struct iscsi_cls_session *cls_session);
177int qla4xxx_unblock_ddb(struct iscsi_cls_session *cls_session);
178int qla4xxx_unblock_flash_ddb(struct iscsi_cls_session *cls_session);
179int qla4xxx_flash_ddb_change(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
180 struct ddb_entry *ddb_entry, uint32_t state);
181int qla4xxx_ddb_change(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
182 struct ddb_entry *ddb_entry, uint32_t state);
183void qla4xxx_build_ddb_list(struct scsi_qla_host *ha, int is_reset);
172 184
173/* BSG Functions */ 185/* BSG Functions */
174int qla4xxx_bsg_request(struct bsg_job *bsg_job); 186int qla4xxx_bsg_request(struct bsg_job *bsg_job);
175int qla4xxx_process_vendor_specific(struct bsg_job *bsg_job); 187int qla4xxx_process_vendor_specific(struct bsg_job *bsg_job);
176 188
189void qla4xxx_arm_relogin_timer(struct ddb_entry *ddb_entry);
190
177extern int ql4xextended_error_logging; 191extern int ql4xextended_error_logging;
178extern int ql4xdontresethba; 192extern int ql4xdontresethba;
179extern int ql4xenablemsix; 193extern int ql4xenablemsix;
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index 3075fbaef55..1bdfa8120ac 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -773,22 +773,24 @@ int qla4xxx_start_firmware(struct scsi_qla_host *ha)
773 * be freed so that when login happens from user space there are free DDB 773 * be freed so that when login happens from user space there are free DDB
774 * indices available. 774 * indices available.
775 **/ 775 **/
776static void qla4xxx_free_ddb_index(struct scsi_qla_host *ha) 776void qla4xxx_free_ddb_index(struct scsi_qla_host *ha)
777{ 777{
778 int max_ddbs; 778 int max_ddbs;
779 int ret; 779 int ret;
780 uint32_t idx = 0, next_idx = 0; 780 uint32_t idx = 0, next_idx = 0;
781 uint32_t state = 0, conn_err = 0; 781 uint32_t state = 0, conn_err = 0;
782 782
783 max_ddbs = is_qla40XX(ha) ? MAX_PRST_DEV_DB_ENTRIES : 783 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
784 MAX_DEV_DB_ENTRIES; 784 MAX_DEV_DB_ENTRIES;
785 785
786 for (idx = 0; idx < max_ddbs; idx = next_idx) { 786 for (idx = 0; idx < max_ddbs; idx = next_idx) {
787 ret = qla4xxx_get_fwddb_entry(ha, idx, NULL, 0, NULL, 787 ret = qla4xxx_get_fwddb_entry(ha, idx, NULL, 0, NULL,
788 &next_idx, &state, &conn_err, 788 &next_idx, &state, &conn_err,
789 NULL, NULL); 789 NULL, NULL);
790 if (ret == QLA_ERROR) 790 if (ret == QLA_ERROR) {
791 next_idx++;
791 continue; 792 continue;
793 }
792 if (state == DDB_DS_NO_CONNECTION_ACTIVE || 794 if (state == DDB_DS_NO_CONNECTION_ACTIVE ||
793 state == DDB_DS_SESSION_FAILED) { 795 state == DDB_DS_SESSION_FAILED) {
794 DEBUG2(ql4_printk(KERN_INFO, ha, 796 DEBUG2(ql4_printk(KERN_INFO, ha,
@@ -804,7 +806,6 @@ static void qla4xxx_free_ddb_index(struct scsi_qla_host *ha)
804 } 806 }
805} 807}
806 808
807
808/** 809/**
809 * qla4xxx_initialize_adapter - initiailizes hba 810 * qla4xxx_initialize_adapter - initiailizes hba
810 * @ha: Pointer to host adapter structure. 811 * @ha: Pointer to host adapter structure.
@@ -812,7 +813,7 @@ static void qla4xxx_free_ddb_index(struct scsi_qla_host *ha)
812 * This routine parforms all of the steps necessary to initialize the adapter. 813 * This routine parforms all of the steps necessary to initialize the adapter.
813 * 814 *
814 **/ 815 **/
815int qla4xxx_initialize_adapter(struct scsi_qla_host *ha) 816int qla4xxx_initialize_adapter(struct scsi_qla_host *ha, int is_reset)
816{ 817{
817 int status = QLA_ERROR; 818 int status = QLA_ERROR;
818 819
@@ -840,7 +841,8 @@ int qla4xxx_initialize_adapter(struct scsi_qla_host *ha)
840 if (status == QLA_ERROR) 841 if (status == QLA_ERROR)
841 goto exit_init_hba; 842 goto exit_init_hba;
842 843
843 qla4xxx_free_ddb_index(ha); 844 if (is_reset == RESET_ADAPTER)
845 qla4xxx_build_ddb_list(ha, is_reset);
844 846
845 set_bit(AF_ONLINE, &ha->flags); 847 set_bit(AF_ONLINE, &ha->flags);
846exit_init_hba: 848exit_init_hba:
@@ -855,38 +857,12 @@ exit_init_hba:
855 return status; 857 return status;
856} 858}
857 859
858/** 860int qla4xxx_ddb_change(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
859 * qla4xxx_process_ddb_changed - process ddb state change 861 struct ddb_entry *ddb_entry, uint32_t state)
860 * @ha - Pointer to host adapter structure.
861 * @fw_ddb_index - Firmware's device database index
862 * @state - Device state
863 *
864 * This routine processes a Decive Database Changed AEN Event.
865 **/
866int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
867 uint32_t state, uint32_t conn_err)
868{ 862{
869 struct ddb_entry * ddb_entry;
870 uint32_t old_fw_ddb_device_state; 863 uint32_t old_fw_ddb_device_state;
871 int status = QLA_ERROR; 864 int status = QLA_ERROR;
872 865
873 /* check for out of range index */
874 if (fw_ddb_index >= MAX_DDB_ENTRIES)
875 goto exit_ddb_event;
876
877 /* Get the corresponging ddb entry */
878 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, fw_ddb_index);
879 /* Device does not currently exist in our database. */
880 if (ddb_entry == NULL) {
881 ql4_printk(KERN_ERR, ha, "%s: No ddb_entry at FW index [%d]\n",
882 __func__, fw_ddb_index);
883
884 if (state == DDB_DS_NO_CONNECTION_ACTIVE)
885 clear_bit(fw_ddb_index, ha->ddb_idx_map);
886
887 goto exit_ddb_event;
888 }
889
890 old_fw_ddb_device_state = ddb_entry->fw_ddb_device_state; 866 old_fw_ddb_device_state = ddb_entry->fw_ddb_device_state;
891 DEBUG2(ql4_printk(KERN_INFO, ha, 867 DEBUG2(ql4_printk(KERN_INFO, ha,
892 "%s: DDB - old state = 0x%x, new state = 0x%x for " 868 "%s: DDB - old state = 0x%x, new state = 0x%x for "
@@ -900,9 +876,7 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
900 switch (state) { 876 switch (state) {
901 case DDB_DS_SESSION_ACTIVE: 877 case DDB_DS_SESSION_ACTIVE:
902 case DDB_DS_DISCOVERY: 878 case DDB_DS_DISCOVERY:
903 iscsi_conn_start(ddb_entry->conn); 879 ddb_entry->unblock_sess(ddb_entry->sess);
904 iscsi_conn_login_event(ddb_entry->conn,
905 ISCSI_CONN_STATE_LOGGED_IN);
906 qla4xxx_update_session_conn_param(ha, ddb_entry); 880 qla4xxx_update_session_conn_param(ha, ddb_entry);
907 status = QLA_SUCCESS; 881 status = QLA_SUCCESS;
908 break; 882 break;
@@ -936,9 +910,7 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
936 switch (state) { 910 switch (state) {
937 case DDB_DS_SESSION_ACTIVE: 911 case DDB_DS_SESSION_ACTIVE:
938 case DDB_DS_DISCOVERY: 912 case DDB_DS_DISCOVERY:
939 iscsi_conn_start(ddb_entry->conn); 913 ddb_entry->unblock_sess(ddb_entry->sess);
940 iscsi_conn_login_event(ddb_entry->conn,
941 ISCSI_CONN_STATE_LOGGED_IN);
942 qla4xxx_update_session_conn_param(ha, ddb_entry); 914 qla4xxx_update_session_conn_param(ha, ddb_entry);
943 status = QLA_SUCCESS; 915 status = QLA_SUCCESS;
944 break; 916 break;
@@ -954,7 +926,198 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
954 __func__)); 926 __func__));
955 break; 927 break;
956 } 928 }
929 return status;
930}
931
932void qla4xxx_arm_relogin_timer(struct ddb_entry *ddb_entry)
933{
934 /*
935 * This triggers a relogin. After the relogin_timer
936 * expires, the relogin gets scheduled. We must wait a
937 * minimum amount of time since receiving an 0x8014 AEN
938 * with failed device_state or a logout response before
939 * we can issue another relogin.
940 *
941 * Firmware pads this timeout: (time2wait +1).
942 * Driver retry to login should be longer than F/W.
943 * Otherwise F/W will fail
944 * set_ddb() mbx cmd with 0x4005 since it still
945 * counting down its time2wait.
946 */
947 atomic_set(&ddb_entry->relogin_timer, 0);
948 atomic_set(&ddb_entry->retry_relogin_timer,
949 ddb_entry->default_time2wait + 4);
950
951}
952
953int qla4xxx_flash_ddb_change(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
954 struct ddb_entry *ddb_entry, uint32_t state)
955{
956 uint32_t old_fw_ddb_device_state;
957 int status = QLA_ERROR;
958
959 old_fw_ddb_device_state = ddb_entry->fw_ddb_device_state;
960 DEBUG2(ql4_printk(KERN_INFO, ha,
961 "%s: DDB - old state = 0x%x, new state = 0x%x for "
962 "index [%d]\n", __func__,
963 ddb_entry->fw_ddb_device_state, state, fw_ddb_index));
964
965 ddb_entry->fw_ddb_device_state = state;
966
967 switch (old_fw_ddb_device_state) {
968 case DDB_DS_LOGIN_IN_PROCESS:
969 case DDB_DS_NO_CONNECTION_ACTIVE:
970 switch (state) {
971 case DDB_DS_SESSION_ACTIVE:
972 ddb_entry->unblock_sess(ddb_entry->sess);
973 qla4xxx_update_session_conn_fwddb_param(ha, ddb_entry);
974 status = QLA_SUCCESS;
975 break;
976 case DDB_DS_SESSION_FAILED:
977 iscsi_block_session(ddb_entry->sess);
978 if (!test_bit(DF_RELOGIN, &ddb_entry->flags))
979 qla4xxx_arm_relogin_timer(ddb_entry);
980 status = QLA_SUCCESS;
981 break;
982 }
983 break;
984 case DDB_DS_SESSION_ACTIVE:
985 switch (state) {
986 case DDB_DS_SESSION_FAILED:
987 iscsi_block_session(ddb_entry->sess);
988 if (!test_bit(DF_RELOGIN, &ddb_entry->flags))
989 qla4xxx_arm_relogin_timer(ddb_entry);
990 status = QLA_SUCCESS;
991 break;
992 }
993 break;
994 case DDB_DS_SESSION_FAILED:
995 switch (state) {
996 case DDB_DS_SESSION_ACTIVE:
997 ddb_entry->unblock_sess(ddb_entry->sess);
998 qla4xxx_update_session_conn_fwddb_param(ha, ddb_entry);
999 status = QLA_SUCCESS;
1000 break;
1001 case DDB_DS_SESSION_FAILED:
1002 if (!test_bit(DF_RELOGIN, &ddb_entry->flags))
1003 qla4xxx_arm_relogin_timer(ddb_entry);
1004 status = QLA_SUCCESS;
1005 break;
1006 }
1007 break;
1008 default:
1009 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Unknown Event\n",
1010 __func__));
1011 break;
1012 }
1013 return status;
1014}
1015
1016/**
1017 * qla4xxx_process_ddb_changed - process ddb state change
1018 * @ha - Pointer to host adapter structure.
1019 * @fw_ddb_index - Firmware's device database index
1020 * @state - Device state
1021 *
1022 * This routine processes a Decive Database Changed AEN Event.
1023 **/
1024int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha,
1025 uint32_t fw_ddb_index,
1026 uint32_t state, uint32_t conn_err)
1027{
1028 struct ddb_entry *ddb_entry;
1029 int status = QLA_ERROR;
1030
1031 /* check for out of range index */
1032 if (fw_ddb_index >= MAX_DDB_ENTRIES)
1033 goto exit_ddb_event;
1034
1035 /* Get the corresponging ddb entry */
1036 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, fw_ddb_index);
1037 /* Device does not currently exist in our database. */
1038 if (ddb_entry == NULL) {
1039 ql4_printk(KERN_ERR, ha, "%s: No ddb_entry at FW index [%d]\n",
1040 __func__, fw_ddb_index);
1041
1042 if (state == DDB_DS_NO_CONNECTION_ACTIVE)
1043 clear_bit(fw_ddb_index, ha->ddb_idx_map);
1044
1045 goto exit_ddb_event;
1046 }
1047
1048 ddb_entry->ddb_change(ha, fw_ddb_index, ddb_entry, state);
957 1049
958exit_ddb_event: 1050exit_ddb_event:
959 return status; 1051 return status;
960} 1052}
1053
1054/**
1055 * qla4xxx_login_flash_ddb - Login to target (DDB)
1056 * @cls_session: Pointer to the session to login
1057 *
1058 * This routine logins to the target.
1059 * Issues setddb and conn open mbx
1060 **/
1061void qla4xxx_login_flash_ddb(struct iscsi_cls_session *cls_session)
1062{
1063 struct iscsi_session *sess;
1064 struct ddb_entry *ddb_entry;
1065 struct scsi_qla_host *ha;
1066 struct dev_db_entry *fw_ddb_entry = NULL;
1067 dma_addr_t fw_ddb_dma;
1068 uint32_t mbx_sts = 0;
1069 int ret;
1070
1071 sess = cls_session->dd_data;
1072 ddb_entry = sess->dd_data;
1073 ha = ddb_entry->ha;
1074
1075 if (!test_bit(AF_LINK_UP, &ha->flags))
1076 return;
1077
1078 if (ddb_entry->ddb_type != FLASH_DDB) {
1079 DEBUG2(ql4_printk(KERN_INFO, ha,
1080 "Skipping login to non FLASH DB"));
1081 goto exit_login;
1082 }
1083
1084 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
1085 &fw_ddb_dma);
1086 if (fw_ddb_entry == NULL) {
1087 DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n"));
1088 goto exit_login;
1089 }
1090
1091 if (ddb_entry->fw_ddb_index == INVALID_ENTRY) {
1092 ret = qla4xxx_get_ddb_index(ha, &ddb_entry->fw_ddb_index);
1093 if (ret == QLA_ERROR)
1094 goto exit_login;
1095
1096 ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry;
1097 ha->tot_ddbs++;
1098 }
1099
1100 memcpy(fw_ddb_entry, &ddb_entry->fw_ddb_entry,
1101 sizeof(struct dev_db_entry));
1102 ddb_entry->sess->target_id = ddb_entry->fw_ddb_index;
1103
1104 ret = qla4xxx_set_ddb_entry(ha, ddb_entry->fw_ddb_index,
1105 fw_ddb_dma, &mbx_sts);
1106 if (ret == QLA_ERROR) {
1107 DEBUG2(ql4_printk(KERN_ERR, ha, "Set DDB failed\n"));
1108 goto exit_login;
1109 }
1110
1111 ddb_entry->fw_ddb_device_state = DDB_DS_LOGIN_IN_PROCESS;
1112 ret = qla4xxx_conn_open(ha, ddb_entry->fw_ddb_index);
1113 if (ret == QLA_ERROR) {
1114 ql4_printk(KERN_ERR, ha, "%s: Login failed: %s\n", __func__,
1115 sess->targetname);
1116 goto exit_login;
1117 }
1118
1119exit_login:
1120 if (fw_ddb_entry)
1121 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
1122}
1123
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 4c2b8487039..c2593782fbb 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -41,6 +41,16 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
41 return status; 41 return status;
42 } 42 }
43 43
44 if (is_qla40XX(ha)) {
45 if (test_bit(AF_HA_REMOVAL, &ha->flags)) {
46 DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: "
47 "prematurely completing mbx cmd as "
48 "adapter removal detected\n",
49 ha->host_no, __func__));
50 return status;
51 }
52 }
53
44 if (is_qla8022(ha)) { 54 if (is_qla8022(ha)) {
45 if (test_bit(AF_FW_RECOVERY, &ha->flags)) { 55 if (test_bit(AF_FW_RECOVERY, &ha->flags)) {
46 DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: " 56 DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: "
@@ -413,6 +423,7 @@ qla4xxx_update_local_ifcb(struct scsi_qla_host *ha,
413 memcpy(ha->name_string, init_fw_cb->iscsi_name, 423 memcpy(ha->name_string, init_fw_cb->iscsi_name,
414 min(sizeof(ha->name_string), 424 min(sizeof(ha->name_string),
415 sizeof(init_fw_cb->iscsi_name))); 425 sizeof(init_fw_cb->iscsi_name)));
426 ha->def_timeout = le16_to_cpu(init_fw_cb->def_timeout);
416 /*memcpy(ha->alias, init_fw_cb->Alias, 427 /*memcpy(ha->alias, init_fw_cb->Alias,
417 min(sizeof(ha->alias), sizeof(init_fw_cb->Alias)));*/ 428 min(sizeof(ha->alias), sizeof(init_fw_cb->Alias)));*/
418 429
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 30f31b127f3..4169c8baa11 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -8,6 +8,7 @@
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <linux/blkdev.h> 9#include <linux/blkdev.h>
10#include <linux/iscsi_boot_sysfs.h> 10#include <linux/iscsi_boot_sysfs.h>
11#include <linux/inet.h>
11 12
12#include <scsi/scsi_tcq.h> 13#include <scsi/scsi_tcq.h>
13#include <scsi/scsicam.h> 14#include <scsi/scsicam.h>
@@ -31,6 +32,13 @@ static struct kmem_cache *srb_cachep;
31/* 32/*
32 * Module parameter information and variables 33 * Module parameter information and variables
33 */ 34 */
35int ql4xdisablesysfsboot = 1;
36module_param(ql4xdisablesysfsboot, int, S_IRUGO | S_IWUSR);
37MODULE_PARM_DESC(ql4xdisablesysfsboot,
38 "Set to disable exporting boot targets to sysfs\n"
39 " 0 - Export boot targets\n"
40 " 1 - Do not export boot targets (Default)");
41
34int ql4xdontresethba = 0; 42int ql4xdontresethba = 0;
35module_param(ql4xdontresethba, int, S_IRUGO | S_IWUSR); 43module_param(ql4xdontresethba, int, S_IRUGO | S_IWUSR);
36MODULE_PARM_DESC(ql4xdontresethba, 44MODULE_PARM_DESC(ql4xdontresethba,
@@ -63,7 +71,7 @@ static int ql4xsess_recovery_tmo = QL4_SESS_RECOVERY_TMO;
63module_param(ql4xsess_recovery_tmo, int, S_IRUGO); 71module_param(ql4xsess_recovery_tmo, int, S_IRUGO);
64MODULE_PARM_DESC(ql4xsess_recovery_tmo, 72MODULE_PARM_DESC(ql4xsess_recovery_tmo,
65 "Target Session Recovery Timeout.\n" 73 "Target Session Recovery Timeout.\n"
66 " Default: 30 sec."); 74 " Default: 120 sec.");
67 75
68static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha); 76static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha);
69/* 77/*
@@ -415,7 +423,7 @@ static int qla4xxx_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
415 qla_ep = ep->dd_data; 423 qla_ep = ep->dd_data;
416 ha = to_qla_host(qla_ep->host); 424 ha = to_qla_host(qla_ep->host);
417 425
418 if (adapter_up(ha)) 426 if (adapter_up(ha) && !test_bit(AF_BUILD_DDB_LIST, &ha->flags))
419 ret = 1; 427 ret = 1;
420 428
421 return ret; 429 return ret;
@@ -975,6 +983,150 @@ static int qla4xxx_conn_get_param(struct iscsi_cls_conn *cls_conn,
975 983
976} 984}
977 985
986int qla4xxx_get_ddb_index(struct scsi_qla_host *ha, uint16_t *ddb_index)
987{
988 uint32_t mbx_sts = 0;
989 uint16_t tmp_ddb_index;
990 int ret;
991
992get_ddb_index:
993 tmp_ddb_index = find_first_zero_bit(ha->ddb_idx_map, MAX_DDB_ENTRIES);
994
995 if (tmp_ddb_index >= MAX_DDB_ENTRIES) {
996 DEBUG2(ql4_printk(KERN_INFO, ha,
997 "Free DDB index not available\n"));
998 ret = QLA_ERROR;
999 goto exit_get_ddb_index;
1000 }
1001
1002 if (test_and_set_bit(tmp_ddb_index, ha->ddb_idx_map))
1003 goto get_ddb_index;
1004
1005 DEBUG2(ql4_printk(KERN_INFO, ha,
1006 "Found a free DDB index at %d\n", tmp_ddb_index));
1007 ret = qla4xxx_req_ddb_entry(ha, tmp_ddb_index, &mbx_sts);
1008 if (ret == QLA_ERROR) {
1009 if (mbx_sts == MBOX_STS_COMMAND_ERROR) {
1010 ql4_printk(KERN_INFO, ha,
1011 "DDB index = %d not available trying next\n",
1012 tmp_ddb_index);
1013 goto get_ddb_index;
1014 }
1015 DEBUG2(ql4_printk(KERN_INFO, ha,
1016 "Free FW DDB not available\n"));
1017 }
1018
1019 *ddb_index = tmp_ddb_index;
1020
1021exit_get_ddb_index:
1022 return ret;
1023}
1024
1025static int qla4xxx_match_ipaddress(struct scsi_qla_host *ha,
1026 struct ddb_entry *ddb_entry,
1027 char *existing_ipaddr,
1028 char *user_ipaddr)
1029{
1030 uint8_t dst_ipaddr[IPv6_ADDR_LEN];
1031 char formatted_ipaddr[DDB_IPADDR_LEN];
1032 int status = QLA_SUCCESS, ret = 0;
1033
1034 if (ddb_entry->fw_ddb_entry.options & DDB_OPT_IPV6_DEVICE) {
1035 ret = in6_pton(user_ipaddr, strlen(user_ipaddr), dst_ipaddr,
1036 '\0', NULL);
1037 if (ret == 0) {
1038 status = QLA_ERROR;
1039 goto out_match;
1040 }
1041 ret = sprintf(formatted_ipaddr, "%pI6", dst_ipaddr);
1042 } else {
1043 ret = in4_pton(user_ipaddr, strlen(user_ipaddr), dst_ipaddr,
1044 '\0', NULL);
1045 if (ret == 0) {
1046 status = QLA_ERROR;
1047 goto out_match;
1048 }
1049 ret = sprintf(formatted_ipaddr, "%pI4", dst_ipaddr);
1050 }
1051
1052 if (strcmp(existing_ipaddr, formatted_ipaddr))
1053 status = QLA_ERROR;
1054
1055out_match:
1056 return status;
1057}
1058
1059static int qla4xxx_match_fwdb_session(struct scsi_qla_host *ha,
1060 struct iscsi_cls_conn *cls_conn)
1061{
1062 int idx = 0, max_ddbs, rval;
1063 struct iscsi_cls_session *cls_sess = iscsi_conn_to_session(cls_conn);
1064 struct iscsi_session *sess, *existing_sess;
1065 struct iscsi_conn *conn, *existing_conn;
1066 struct ddb_entry *ddb_entry;
1067
1068 sess = cls_sess->dd_data;
1069 conn = cls_conn->dd_data;
1070
1071 if (sess->targetname == NULL ||
1072 conn->persistent_address == NULL ||
1073 conn->persistent_port == 0)
1074 return QLA_ERROR;
1075
1076 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
1077 MAX_DEV_DB_ENTRIES;
1078
1079 for (idx = 0; idx < max_ddbs; idx++) {
1080 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
1081 if (ddb_entry == NULL)
1082 continue;
1083
1084 if (ddb_entry->ddb_type != FLASH_DDB)
1085 continue;
1086
1087 existing_sess = ddb_entry->sess->dd_data;
1088 existing_conn = ddb_entry->conn->dd_data;
1089
1090 if (existing_sess->targetname == NULL ||
1091 existing_conn->persistent_address == NULL ||
1092 existing_conn->persistent_port == 0)
1093 continue;
1094
1095 DEBUG2(ql4_printk(KERN_INFO, ha,
1096 "IQN = %s User IQN = %s\n",
1097 existing_sess->targetname,
1098 sess->targetname));
1099
1100 DEBUG2(ql4_printk(KERN_INFO, ha,
1101 "IP = %s User IP = %s\n",
1102 existing_conn->persistent_address,
1103 conn->persistent_address));
1104
1105 DEBUG2(ql4_printk(KERN_INFO, ha,
1106 "Port = %d User Port = %d\n",
1107 existing_conn->persistent_port,
1108 conn->persistent_port));
1109
1110 if (strcmp(existing_sess->targetname, sess->targetname))
1111 continue;
1112 rval = qla4xxx_match_ipaddress(ha, ddb_entry,
1113 existing_conn->persistent_address,
1114 conn->persistent_address);
1115 if (rval == QLA_ERROR)
1116 continue;
1117 if (existing_conn->persistent_port != conn->persistent_port)
1118 continue;
1119 break;
1120 }
1121
1122 if (idx == max_ddbs)
1123 return QLA_ERROR;
1124
1125 DEBUG2(ql4_printk(KERN_INFO, ha,
1126 "Match found in fwdb sessions\n"));
1127 return QLA_SUCCESS;
1128}
1129
978static struct iscsi_cls_session * 1130static struct iscsi_cls_session *
979qla4xxx_session_create(struct iscsi_endpoint *ep, 1131qla4xxx_session_create(struct iscsi_endpoint *ep,
980 uint16_t cmds_max, uint16_t qdepth, 1132 uint16_t cmds_max, uint16_t qdepth,
@@ -984,8 +1136,7 @@ qla4xxx_session_create(struct iscsi_endpoint *ep,
984 struct scsi_qla_host *ha; 1136 struct scsi_qla_host *ha;
985 struct qla_endpoint *qla_ep; 1137 struct qla_endpoint *qla_ep;
986 struct ddb_entry *ddb_entry; 1138 struct ddb_entry *ddb_entry;
987 uint32_t ddb_index; 1139 uint16_t ddb_index;
988 uint32_t mbx_sts = 0;
989 struct iscsi_session *sess; 1140 struct iscsi_session *sess;
990 struct sockaddr *dst_addr; 1141 struct sockaddr *dst_addr;
991 int ret; 1142 int ret;
@@ -1000,32 +1151,9 @@ qla4xxx_session_create(struct iscsi_endpoint *ep,
1000 dst_addr = (struct sockaddr *)&qla_ep->dst_addr; 1151 dst_addr = (struct sockaddr *)&qla_ep->dst_addr;
1001 ha = to_qla_host(qla_ep->host); 1152 ha = to_qla_host(qla_ep->host);
1002 1153
1003get_ddb_index: 1154 ret = qla4xxx_get_ddb_index(ha, &ddb_index);
1004 ddb_index = find_first_zero_bit(ha->ddb_idx_map, MAX_DDB_ENTRIES); 1155 if (ret == QLA_ERROR)
1005
1006 if (ddb_index >= MAX_DDB_ENTRIES) {
1007 DEBUG2(ql4_printk(KERN_INFO, ha,
1008 "Free DDB index not available\n"));
1009 return NULL;
1010 }
1011
1012 if (test_and_set_bit(ddb_index, ha->ddb_idx_map))
1013 goto get_ddb_index;
1014
1015 DEBUG2(ql4_printk(KERN_INFO, ha,
1016 "Found a free DDB index at %d\n", ddb_index));
1017 ret = qla4xxx_req_ddb_entry(ha, ddb_index, &mbx_sts);
1018 if (ret == QLA_ERROR) {
1019 if (mbx_sts == MBOX_STS_COMMAND_ERROR) {
1020 ql4_printk(KERN_INFO, ha,
1021 "DDB index = %d not available trying next\n",
1022 ddb_index);
1023 goto get_ddb_index;
1024 }
1025 DEBUG2(ql4_printk(KERN_INFO, ha,
1026 "Free FW DDB not available\n"));
1027 return NULL; 1156 return NULL;
1028 }
1029 1157
1030 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, qla_ep->host, 1158 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, qla_ep->host,
1031 cmds_max, sizeof(struct ddb_entry), 1159 cmds_max, sizeof(struct ddb_entry),
@@ -1040,6 +1168,8 @@ get_ddb_index:
1040 ddb_entry->fw_ddb_device_state = DDB_DS_NO_CONNECTION_ACTIVE; 1168 ddb_entry->fw_ddb_device_state = DDB_DS_NO_CONNECTION_ACTIVE;
1041 ddb_entry->ha = ha; 1169 ddb_entry->ha = ha;
1042 ddb_entry->sess = cls_sess; 1170 ddb_entry->sess = cls_sess;
1171 ddb_entry->unblock_sess = qla4xxx_unblock_ddb;
1172 ddb_entry->ddb_change = qla4xxx_ddb_change;
1043 cls_sess->recovery_tmo = ql4xsess_recovery_tmo; 1173 cls_sess->recovery_tmo = ql4xsess_recovery_tmo;
1044 ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry; 1174 ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry;
1045 ha->tot_ddbs++; 1175 ha->tot_ddbs++;
@@ -1077,6 +1207,9 @@ qla4xxx_conn_create(struct iscsi_cls_session *cls_sess, uint32_t conn_idx)
1077 DEBUG2(printk(KERN_INFO "Func: %s\n", __func__)); 1207 DEBUG2(printk(KERN_INFO "Func: %s\n", __func__));
1078 cls_conn = iscsi_conn_setup(cls_sess, sizeof(struct qla_conn), 1208 cls_conn = iscsi_conn_setup(cls_sess, sizeof(struct qla_conn),
1079 conn_idx); 1209 conn_idx);
1210 if (!cls_conn)
1211 return NULL;
1212
1080 sess = cls_sess->dd_data; 1213 sess = cls_sess->dd_data;
1081 ddb_entry = sess->dd_data; 1214 ddb_entry = sess->dd_data;
1082 ddb_entry->conn = cls_conn; 1215 ddb_entry->conn = cls_conn;
@@ -1109,7 +1242,7 @@ static int qla4xxx_conn_start(struct iscsi_cls_conn *cls_conn)
1109 struct iscsi_session *sess; 1242 struct iscsi_session *sess;
1110 struct ddb_entry *ddb_entry; 1243 struct ddb_entry *ddb_entry;
1111 struct scsi_qla_host *ha; 1244 struct scsi_qla_host *ha;
1112 struct dev_db_entry *fw_ddb_entry; 1245 struct dev_db_entry *fw_ddb_entry = NULL;
1113 dma_addr_t fw_ddb_entry_dma; 1246 dma_addr_t fw_ddb_entry_dma;
1114 uint32_t mbx_sts = 0; 1247 uint32_t mbx_sts = 0;
1115 int ret = 0; 1248 int ret = 0;
@@ -1120,12 +1253,25 @@ static int qla4xxx_conn_start(struct iscsi_cls_conn *cls_conn)
1120 ddb_entry = sess->dd_data; 1253 ddb_entry = sess->dd_data;
1121 ha = ddb_entry->ha; 1254 ha = ddb_entry->ha;
1122 1255
1256 /* Check if we have matching FW DDB, if yes then do not
1257 * login to this target. This could cause target to logout previous
1258 * connection
1259 */
1260 ret = qla4xxx_match_fwdb_session(ha, cls_conn);
1261 if (ret == QLA_SUCCESS) {
1262 ql4_printk(KERN_INFO, ha,
1263 "Session already exist in FW.\n");
1264 ret = -EEXIST;
1265 goto exit_conn_start;
1266 }
1267
1123 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), 1268 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
1124 &fw_ddb_entry_dma, GFP_KERNEL); 1269 &fw_ddb_entry_dma, GFP_KERNEL);
1125 if (!fw_ddb_entry) { 1270 if (!fw_ddb_entry) {
1126 ql4_printk(KERN_ERR, ha, 1271 ql4_printk(KERN_ERR, ha,
1127 "%s: Unable to allocate dma buffer\n", __func__); 1272 "%s: Unable to allocate dma buffer\n", __func__);
1128 return -ENOMEM; 1273 ret = -ENOMEM;
1274 goto exit_conn_start;
1129 } 1275 }
1130 1276
1131 ret = qla4xxx_set_param_ddbentry(ha, ddb_entry, cls_conn, &mbx_sts); 1277 ret = qla4xxx_set_param_ddbentry(ha, ddb_entry, cls_conn, &mbx_sts);
@@ -1138,9 +1284,7 @@ static int qla4xxx_conn_start(struct iscsi_cls_conn *cls_conn)
1138 if (mbx_sts) 1284 if (mbx_sts)
1139 if (ddb_entry->fw_ddb_device_state == 1285 if (ddb_entry->fw_ddb_device_state ==
1140 DDB_DS_SESSION_ACTIVE) { 1286 DDB_DS_SESSION_ACTIVE) {
1141 iscsi_conn_start(ddb_entry->conn); 1287 ddb_entry->unblock_sess(ddb_entry->sess);
1142 iscsi_conn_login_event(ddb_entry->conn,
1143 ISCSI_CONN_STATE_LOGGED_IN);
1144 goto exit_set_param; 1288 goto exit_set_param;
1145 } 1289 }
1146 1290
@@ -1167,8 +1311,9 @@ exit_set_param:
1167 ret = 0; 1311 ret = 0;
1168 1312
1169exit_conn_start: 1313exit_conn_start:
1170 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), 1314 if (fw_ddb_entry)
1171 fw_ddb_entry, fw_ddb_entry_dma); 1315 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
1316 fw_ddb_entry, fw_ddb_entry_dma);
1172 return ret; 1317 return ret;
1173} 1318}
1174 1319
@@ -1344,6 +1489,101 @@ static int qla4xxx_task_xmit(struct iscsi_task *task)
1344 return -ENOSYS; 1489 return -ENOSYS;
1345} 1490}
1346 1491
1492static void qla4xxx_copy_fwddb_param(struct scsi_qla_host *ha,
1493 struct dev_db_entry *fw_ddb_entry,
1494 struct iscsi_cls_session *cls_sess,
1495 struct iscsi_cls_conn *cls_conn)
1496{
1497 int buflen = 0;
1498 struct iscsi_session *sess;
1499 struct iscsi_conn *conn;
1500 char ip_addr[DDB_IPADDR_LEN];
1501 uint16_t options = 0;
1502
1503 sess = cls_sess->dd_data;
1504 conn = cls_conn->dd_data;
1505
1506 conn->max_recv_dlength = BYTE_UNITS *
1507 le16_to_cpu(fw_ddb_entry->iscsi_max_rcv_data_seg_len);
1508
1509 conn->max_xmit_dlength = BYTE_UNITS *
1510 le16_to_cpu(fw_ddb_entry->iscsi_max_snd_data_seg_len);
1511
1512 sess->initial_r2t_en =
1513 (BIT_10 & le16_to_cpu(fw_ddb_entry->iscsi_options));
1514
1515 sess->max_r2t = le16_to_cpu(fw_ddb_entry->iscsi_max_outsnd_r2t);
1516
1517 sess->imm_data_en = (BIT_11 & le16_to_cpu(fw_ddb_entry->iscsi_options));
1518
1519 sess->first_burst = BYTE_UNITS *
1520 le16_to_cpu(fw_ddb_entry->iscsi_first_burst_len);
1521
1522 sess->max_burst = BYTE_UNITS *
1523 le16_to_cpu(fw_ddb_entry->iscsi_max_burst_len);
1524
1525 sess->time2wait = le16_to_cpu(fw_ddb_entry->iscsi_def_time2wait);
1526
1527 sess->time2retain = le16_to_cpu(fw_ddb_entry->iscsi_def_time2retain);
1528
1529 conn->persistent_port = le16_to_cpu(fw_ddb_entry->port);
1530
1531 sess->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
1532
1533 options = le16_to_cpu(fw_ddb_entry->options);
1534 if (options & DDB_OPT_IPV6_DEVICE)
1535 sprintf(ip_addr, "%pI6", fw_ddb_entry->ip_addr);
1536 else
1537 sprintf(ip_addr, "%pI4", fw_ddb_entry->ip_addr);
1538
1539 iscsi_set_param(cls_conn, ISCSI_PARAM_TARGET_NAME,
1540 (char *)fw_ddb_entry->iscsi_name, buflen);
1541 iscsi_set_param(cls_conn, ISCSI_PARAM_INITIATOR_NAME,
1542 (char *)ha->name_string, buflen);
1543 iscsi_set_param(cls_conn, ISCSI_PARAM_PERSISTENT_ADDRESS,
1544 (char *)ip_addr, buflen);
1545}
1546
1547void qla4xxx_update_session_conn_fwddb_param(struct scsi_qla_host *ha,
1548 struct ddb_entry *ddb_entry)
1549{
1550 struct iscsi_cls_session *cls_sess;
1551 struct iscsi_cls_conn *cls_conn;
1552 uint32_t ddb_state;
1553 dma_addr_t fw_ddb_entry_dma;
1554 struct dev_db_entry *fw_ddb_entry;
1555
1556 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
1557 &fw_ddb_entry_dma, GFP_KERNEL);
1558 if (!fw_ddb_entry) {
1559 ql4_printk(KERN_ERR, ha,
1560 "%s: Unable to allocate dma buffer\n", __func__);
1561 goto exit_session_conn_fwddb_param;
1562 }
1563
1564 if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry,
1565 fw_ddb_entry_dma, NULL, NULL, &ddb_state,
1566 NULL, NULL, NULL) == QLA_ERROR) {
1567 DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed "
1568 "get_ddb_entry for fw_ddb_index %d\n",
1569 ha->host_no, __func__,
1570 ddb_entry->fw_ddb_index));
1571 goto exit_session_conn_fwddb_param;
1572 }
1573
1574 cls_sess = ddb_entry->sess;
1575
1576 cls_conn = ddb_entry->conn;
1577
1578 /* Update params */
1579 qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess, cls_conn);
1580
1581exit_session_conn_fwddb_param:
1582 if (fw_ddb_entry)
1583 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
1584 fw_ddb_entry, fw_ddb_entry_dma);
1585}
1586
1347void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha, 1587void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
1348 struct ddb_entry *ddb_entry) 1588 struct ddb_entry *ddb_entry)
1349{ 1589{
@@ -1360,7 +1600,7 @@ void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
1360 if (!fw_ddb_entry) { 1600 if (!fw_ddb_entry) {
1361 ql4_printk(KERN_ERR, ha, 1601 ql4_printk(KERN_ERR, ha,
1362 "%s: Unable to allocate dma buffer\n", __func__); 1602 "%s: Unable to allocate dma buffer\n", __func__);
1363 return; 1603 goto exit_session_conn_param;
1364 } 1604 }
1365 1605
1366 if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry, 1606 if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry,
@@ -1370,7 +1610,7 @@ void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
1370 "get_ddb_entry for fw_ddb_index %d\n", 1610 "get_ddb_entry for fw_ddb_index %d\n",
1371 ha->host_no, __func__, 1611 ha->host_no, __func__,
1372 ddb_entry->fw_ddb_index)); 1612 ddb_entry->fw_ddb_index));
1373 return; 1613 goto exit_session_conn_param;
1374 } 1614 }
1375 1615
1376 cls_sess = ddb_entry->sess; 1616 cls_sess = ddb_entry->sess;
@@ -1379,6 +1619,12 @@ void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
1379 cls_conn = ddb_entry->conn; 1619 cls_conn = ddb_entry->conn;
1380 conn = cls_conn->dd_data; 1620 conn = cls_conn->dd_data;
1381 1621
1622 /* Update timers after login */
1623 ddb_entry->default_relogin_timeout =
1624 le16_to_cpu(fw_ddb_entry->def_timeout);
1625 ddb_entry->default_time2wait =
1626 le16_to_cpu(fw_ddb_entry->iscsi_def_time2wait);
1627
1382 /* Update params */ 1628 /* Update params */
1383 conn->max_recv_dlength = BYTE_UNITS * 1629 conn->max_recv_dlength = BYTE_UNITS *
1384 le16_to_cpu(fw_ddb_entry->iscsi_max_rcv_data_seg_len); 1630 le16_to_cpu(fw_ddb_entry->iscsi_max_rcv_data_seg_len);
@@ -1407,6 +1653,11 @@ void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha,
1407 1653
1408 memcpy(sess->initiatorname, ha->name_string, 1654 memcpy(sess->initiatorname, ha->name_string,
1409 min(sizeof(ha->name_string), sizeof(sess->initiatorname))); 1655 min(sizeof(ha->name_string), sizeof(sess->initiatorname)));
1656
1657exit_session_conn_param:
1658 if (fw_ddb_entry)
1659 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
1660 fw_ddb_entry, fw_ddb_entry_dma);
1410} 1661}
1411 1662
1412/* 1663/*
@@ -1607,6 +1858,9 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
1607 vfree(ha->chap_list); 1858 vfree(ha->chap_list);
1608 ha->chap_list = NULL; 1859 ha->chap_list = NULL;
1609 1860
1861 if (ha->fw_ddb_dma_pool)
1862 dma_pool_destroy(ha->fw_ddb_dma_pool);
1863
1610 /* release io space registers */ 1864 /* release io space registers */
1611 if (is_qla8022(ha)) { 1865 if (is_qla8022(ha)) {
1612 if (ha->nx_pcibase) 1866 if (ha->nx_pcibase)
@@ -1689,6 +1943,16 @@ static int qla4xxx_mem_alloc(struct scsi_qla_host *ha)
1689 goto mem_alloc_error_exit; 1943 goto mem_alloc_error_exit;
1690 } 1944 }
1691 1945
1946 ha->fw_ddb_dma_pool = dma_pool_create("ql4_fw_ddb", &ha->pdev->dev,
1947 DDB_DMA_BLOCK_SIZE, 8, 0);
1948
1949 if (ha->fw_ddb_dma_pool == NULL) {
1950 ql4_printk(KERN_WARNING, ha,
1951 "%s: fw_ddb_dma_pool allocation failed..\n",
1952 __func__);
1953 goto mem_alloc_error_exit;
1954 }
1955
1692 return QLA_SUCCESS; 1956 return QLA_SUCCESS;
1693 1957
1694mem_alloc_error_exit: 1958mem_alloc_error_exit:
@@ -1800,6 +2064,60 @@ void qla4_8xxx_watchdog(struct scsi_qla_host *ha)
1800 } 2064 }
1801} 2065}
1802 2066
2067void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
2068{
2069 struct iscsi_session *sess;
2070 struct ddb_entry *ddb_entry;
2071 struct scsi_qla_host *ha;
2072
2073 sess = cls_sess->dd_data;
2074 ddb_entry = sess->dd_data;
2075 ha = ddb_entry->ha;
2076
2077 if (!(ddb_entry->ddb_type == FLASH_DDB))
2078 return;
2079
2080 if (adapter_up(ha) && !test_bit(DF_RELOGIN, &ddb_entry->flags) &&
2081 !iscsi_is_session_online(cls_sess)) {
2082 if (atomic_read(&ddb_entry->retry_relogin_timer) !=
2083 INVALID_ENTRY) {
2084 if (atomic_read(&ddb_entry->retry_relogin_timer) ==
2085 0) {
2086 atomic_set(&ddb_entry->retry_relogin_timer,
2087 INVALID_ENTRY);
2088 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
2089 set_bit(DF_RELOGIN, &ddb_entry->flags);
2090 DEBUG2(ql4_printk(KERN_INFO, ha,
2091 "%s: index [%d] login device\n",
2092 __func__, ddb_entry->fw_ddb_index));
2093 } else
2094 atomic_dec(&ddb_entry->retry_relogin_timer);
2095 }
2096 }
2097
2098 /* Wait for relogin to timeout */
2099 if (atomic_read(&ddb_entry->relogin_timer) &&
2100 (atomic_dec_and_test(&ddb_entry->relogin_timer) != 0)) {
2101 /*
2102 * If the relogin times out and the device is
2103 * still NOT ONLINE then try and relogin again.
2104 */
2105 if (!iscsi_is_session_online(cls_sess)) {
2106 /* Reset retry relogin timer */
2107 atomic_inc(&ddb_entry->relogin_retry_count);
2108 DEBUG2(ql4_printk(KERN_INFO, ha,
2109 "%s: index[%d] relogin timed out-retrying"
2110 " relogin (%d), retry (%d)\n", __func__,
2111 ddb_entry->fw_ddb_index,
2112 atomic_read(&ddb_entry->relogin_retry_count),
2113 ddb_entry->default_time2wait + 4));
2114 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
2115 atomic_set(&ddb_entry->retry_relogin_timer,
2116 ddb_entry->default_time2wait + 4);
2117 }
2118 }
2119}
2120
1803/** 2121/**
1804 * qla4xxx_timer - checks every second for work to do. 2122 * qla4xxx_timer - checks every second for work to do.
1805 * @ha: Pointer to host adapter structure. 2123 * @ha: Pointer to host adapter structure.
@@ -1809,6 +2127,8 @@ static void qla4xxx_timer(struct scsi_qla_host *ha)
1809 int start_dpc = 0; 2127 int start_dpc = 0;
1810 uint16_t w; 2128 uint16_t w;
1811 2129
2130 iscsi_host_for_each_session(ha->host, qla4xxx_check_relogin_flash_ddb);
2131
1812 /* If we are in the middle of AER/EEH processing 2132 /* If we are in the middle of AER/EEH processing
1813 * skip any processing and reschedule the timer 2133 * skip any processing and reschedule the timer
1814 */ 2134 */
@@ -2078,7 +2398,12 @@ static void qla4xxx_fail_session(struct iscsi_cls_session *cls_session)
2078 sess = cls_session->dd_data; 2398 sess = cls_session->dd_data;
2079 ddb_entry = sess->dd_data; 2399 ddb_entry = sess->dd_data;
2080 ddb_entry->fw_ddb_device_state = DDB_DS_SESSION_FAILED; 2400 ddb_entry->fw_ddb_device_state = DDB_DS_SESSION_FAILED;
2081 iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED); 2401
2402 if (ddb_entry->ddb_type == FLASH_DDB)
2403 iscsi_block_session(ddb_entry->sess);
2404 else
2405 iscsi_session_failure(cls_session->dd_data,
2406 ISCSI_ERR_CONN_FAILED);
2082} 2407}
2083 2408
2084/** 2409/**
@@ -2163,7 +2488,7 @@ recover_ha_init_adapter:
2163 2488
2164 /* NOTE: AF_ONLINE flag set upon successful completion of 2489 /* NOTE: AF_ONLINE flag set upon successful completion of
2165 * qla4xxx_initialize_adapter */ 2490 * qla4xxx_initialize_adapter */
2166 status = qla4xxx_initialize_adapter(ha); 2491 status = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
2167 } 2492 }
2168 2493
2169 /* Retry failed adapter initialization, if necessary 2494 /* Retry failed adapter initialization, if necessary
@@ -2245,17 +2570,108 @@ static void qla4xxx_relogin_devices(struct iscsi_cls_session *cls_session)
2245 iscsi_unblock_session(ddb_entry->sess); 2570 iscsi_unblock_session(ddb_entry->sess);
2246 } else { 2571 } else {
2247 /* Trigger relogin */ 2572 /* Trigger relogin */
2248 iscsi_session_failure(cls_session->dd_data, 2573 if (ddb_entry->ddb_type == FLASH_DDB) {
2249 ISCSI_ERR_CONN_FAILED); 2574 if (!test_bit(DF_RELOGIN, &ddb_entry->flags))
2575 qla4xxx_arm_relogin_timer(ddb_entry);
2576 } else
2577 iscsi_session_failure(cls_session->dd_data,
2578 ISCSI_ERR_CONN_FAILED);
2250 } 2579 }
2251 } 2580 }
2252} 2581}
2253 2582
2583int qla4xxx_unblock_flash_ddb(struct iscsi_cls_session *cls_session)
2584{
2585 struct iscsi_session *sess;
2586 struct ddb_entry *ddb_entry;
2587 struct scsi_qla_host *ha;
2588
2589 sess = cls_session->dd_data;
2590 ddb_entry = sess->dd_data;
2591 ha = ddb_entry->ha;
2592 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
2593 " unblock session\n", ha->host_no, __func__,
2594 ddb_entry->fw_ddb_index);
2595
2596 iscsi_unblock_session(ddb_entry->sess);
2597
2598 /* Start scan target */
2599 if (test_bit(AF_ONLINE, &ha->flags)) {
2600 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
2601 " start scan\n", ha->host_no, __func__,
2602 ddb_entry->fw_ddb_index);
2603 scsi_queue_work(ha->host, &ddb_entry->sess->scan_work);
2604 }
2605 return QLA_SUCCESS;
2606}
2607
2608int qla4xxx_unblock_ddb(struct iscsi_cls_session *cls_session)
2609{
2610 struct iscsi_session *sess;
2611 struct ddb_entry *ddb_entry;
2612 struct scsi_qla_host *ha;
2613
2614 sess = cls_session->dd_data;
2615 ddb_entry = sess->dd_data;
2616 ha = ddb_entry->ha;
2617 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]"
2618 " unblock user space session\n", ha->host_no, __func__,
2619 ddb_entry->fw_ddb_index);
2620 iscsi_conn_start(ddb_entry->conn);
2621 iscsi_conn_login_event(ddb_entry->conn,
2622 ISCSI_CONN_STATE_LOGGED_IN);
2623
2624 return QLA_SUCCESS;
2625}
2626
2254static void qla4xxx_relogin_all_devices(struct scsi_qla_host *ha) 2627static void qla4xxx_relogin_all_devices(struct scsi_qla_host *ha)
2255{ 2628{
2256 iscsi_host_for_each_session(ha->host, qla4xxx_relogin_devices); 2629 iscsi_host_for_each_session(ha->host, qla4xxx_relogin_devices);
2257} 2630}
2258 2631
2632static void qla4xxx_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
2633{
2634 uint16_t relogin_timer;
2635 struct iscsi_session *sess;
2636 struct ddb_entry *ddb_entry;
2637 struct scsi_qla_host *ha;
2638
2639 sess = cls_sess->dd_data;
2640 ddb_entry = sess->dd_data;
2641 ha = ddb_entry->ha;
2642
2643 relogin_timer = max(ddb_entry->default_relogin_timeout,
2644 (uint16_t)RELOGIN_TOV);
2645 atomic_set(&ddb_entry->relogin_timer, relogin_timer);
2646
2647 DEBUG2(ql4_printk(KERN_INFO, ha,
2648 "scsi%ld: Relogin index [%d]. TOV=%d\n", ha->host_no,
2649 ddb_entry->fw_ddb_index, relogin_timer));
2650
2651 qla4xxx_login_flash_ddb(cls_sess);
2652}
2653
2654static void qla4xxx_dpc_relogin(struct iscsi_cls_session *cls_sess)
2655{
2656 struct iscsi_session *sess;
2657 struct ddb_entry *ddb_entry;
2658 struct scsi_qla_host *ha;
2659
2660 sess = cls_sess->dd_data;
2661 ddb_entry = sess->dd_data;
2662 ha = ddb_entry->ha;
2663
2664 if (!(ddb_entry->ddb_type == FLASH_DDB))
2665 return;
2666
2667 if (test_and_clear_bit(DF_RELOGIN, &ddb_entry->flags) &&
2668 !iscsi_is_session_online(cls_sess)) {
2669 DEBUG2(ql4_printk(KERN_INFO, ha,
2670 "relogin issued\n"));
2671 qla4xxx_relogin_flash_ddb(cls_sess);
2672 }
2673}
2674
2259void qla4xxx_wake_dpc(struct scsi_qla_host *ha) 2675void qla4xxx_wake_dpc(struct scsi_qla_host *ha)
2260{ 2676{
2261 if (ha->dpc_thread) 2677 if (ha->dpc_thread)
@@ -2356,6 +2772,12 @@ dpc_post_reset_ha:
2356 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags)) 2772 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags))
2357 qla4xxx_get_dhcp_ip_address(ha); 2773 qla4xxx_get_dhcp_ip_address(ha);
2358 2774
2775 /* ---- relogin device? --- */
2776 if (adapter_up(ha) &&
2777 test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) {
2778 iscsi_host_for_each_session(ha->host, qla4xxx_dpc_relogin);
2779 }
2780
2359 /* ---- link change? --- */ 2781 /* ---- link change? --- */
2360 if (test_and_clear_bit(DPC_LINK_CHANGED, &ha->dpc_flags)) { 2782 if (test_and_clear_bit(DPC_LINK_CHANGED, &ha->dpc_flags)) {
2361 if (!test_bit(AF_LINK_UP, &ha->flags)) { 2783 if (!test_bit(AF_LINK_UP, &ha->flags)) {
@@ -2368,8 +2790,12 @@ dpc_post_reset_ha:
2368 * fatal error recovery. Therefore, the driver must 2790 * fatal error recovery. Therefore, the driver must
2369 * manually relogin to devices when recovering from 2791 * manually relogin to devices when recovering from
2370 * connection failures, logouts, expired KATO, etc. */ 2792 * connection failures, logouts, expired KATO, etc. */
2371 2793 if (test_and_clear_bit(AF_BUILD_DDB_LIST, &ha->flags)) {
2372 qla4xxx_relogin_all_devices(ha); 2794 qla4xxx_build_ddb_list(ha, ha->is_reset);
2795 iscsi_host_for_each_session(ha->host,
2796 qla4xxx_login_flash_ddb);
2797 } else
2798 qla4xxx_relogin_all_devices(ha);
2373 } 2799 }
2374 } 2800 }
2375} 2801}
@@ -2867,6 +3293,9 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[])
2867 " target ID %d\n", __func__, ddb_index[0], 3293 " target ID %d\n", __func__, ddb_index[0],
2868 ddb_index[1])); 3294 ddb_index[1]));
2869 3295
3296 ha->pri_ddb_idx = ddb_index[0];
3297 ha->sec_ddb_idx = ddb_index[1];
3298
2870exit_boot_info_free: 3299exit_boot_info_free:
2871 dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma); 3300 dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
2872exit_boot_info: 3301exit_boot_info:
@@ -3034,6 +3463,9 @@ static int qla4xxx_get_boot_info(struct scsi_qla_host *ha)
3034 return ret; 3463 return ret;
3035 } 3464 }
3036 3465
3466 if (ql4xdisablesysfsboot)
3467 return QLA_SUCCESS;
3468
3037 if (ddb_index[0] == 0xffff) 3469 if (ddb_index[0] == 0xffff)
3038 goto sec_target; 3470 goto sec_target;
3039 3471
@@ -3066,7 +3498,15 @@ static int qla4xxx_setup_boot_info(struct scsi_qla_host *ha)
3066 struct iscsi_boot_kobj *boot_kobj; 3498 struct iscsi_boot_kobj *boot_kobj;
3067 3499
3068 if (qla4xxx_get_boot_info(ha) != QLA_SUCCESS) 3500 if (qla4xxx_get_boot_info(ha) != QLA_SUCCESS)
3069 return 0; 3501 return QLA_ERROR;
3502
3503 if (ql4xdisablesysfsboot) {
3504 ql4_printk(KERN_INFO, ha,
3505 "%s: syfsboot disabled - driver will trigger login"
3506 "and publish session for discovery .\n", __func__);
3507 return QLA_SUCCESS;
3508 }
3509
3070 3510
3071 ha->boot_kset = iscsi_boot_create_host_kset(ha->host->host_no); 3511 ha->boot_kset = iscsi_boot_create_host_kset(ha->host->host_no);
3072 if (!ha->boot_kset) 3512 if (!ha->boot_kset)
@@ -3108,7 +3548,7 @@ static int qla4xxx_setup_boot_info(struct scsi_qla_host *ha)
3108 if (!boot_kobj) 3548 if (!boot_kobj)
3109 goto put_host; 3549 goto put_host;
3110 3550
3111 return 0; 3551 return QLA_SUCCESS;
3112 3552
3113put_host: 3553put_host:
3114 scsi_host_put(ha->host); 3554 scsi_host_put(ha->host);
@@ -3174,9 +3614,507 @@ static void qla4xxx_create_chap_list(struct scsi_qla_host *ha)
3174exit_chap_list: 3614exit_chap_list:
3175 dma_free_coherent(&ha->pdev->dev, chap_size, 3615 dma_free_coherent(&ha->pdev->dev, chap_size,
3176 chap_flash_data, chap_dma); 3616 chap_flash_data, chap_dma);
3177 return;
3178} 3617}
3179 3618
3619static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry,
3620 struct ql4_tuple_ddb *tddb)
3621{
3622 struct scsi_qla_host *ha;
3623 struct iscsi_cls_session *cls_sess;
3624 struct iscsi_cls_conn *cls_conn;
3625 struct iscsi_session *sess;
3626 struct iscsi_conn *conn;
3627
3628 DEBUG2(printk(KERN_INFO "Func: %s\n", __func__));
3629 ha = ddb_entry->ha;
3630 cls_sess = ddb_entry->sess;
3631 sess = cls_sess->dd_data;
3632 cls_conn = ddb_entry->conn;
3633 conn = cls_conn->dd_data;
3634
3635 tddb->tpgt = sess->tpgt;
3636 tddb->port = conn->persistent_port;
3637 strncpy(tddb->iscsi_name, sess->targetname, ISCSI_NAME_SIZE);
3638 strncpy(tddb->ip_addr, conn->persistent_address, DDB_IPADDR_LEN);
3639}
3640
3641static void qla4xxx_convert_param_ddb(struct dev_db_entry *fw_ddb_entry,
3642 struct ql4_tuple_ddb *tddb)
3643{
3644 uint16_t options = 0;
3645
3646 tddb->tpgt = le32_to_cpu(fw_ddb_entry->tgt_portal_grp);
3647 memcpy(&tddb->iscsi_name[0], &fw_ddb_entry->iscsi_name[0],
3648 min(sizeof(tddb->iscsi_name), sizeof(fw_ddb_entry->iscsi_name)));
3649
3650 options = le16_to_cpu(fw_ddb_entry->options);
3651 if (options & DDB_OPT_IPV6_DEVICE)
3652 sprintf(tddb->ip_addr, "%pI6", fw_ddb_entry->ip_addr);
3653 else
3654 sprintf(tddb->ip_addr, "%pI4", fw_ddb_entry->ip_addr);
3655
3656 tddb->port = le16_to_cpu(fw_ddb_entry->port);
3657}
3658
3659static int qla4xxx_compare_tuple_ddb(struct scsi_qla_host *ha,
3660 struct ql4_tuple_ddb *old_tddb,
3661 struct ql4_tuple_ddb *new_tddb)
3662{
3663 if (strcmp(old_tddb->iscsi_name, new_tddb->iscsi_name))
3664 return QLA_ERROR;
3665
3666 if (strcmp(old_tddb->ip_addr, new_tddb->ip_addr))
3667 return QLA_ERROR;
3668
3669 if (old_tddb->port != new_tddb->port)
3670 return QLA_ERROR;
3671
3672 DEBUG2(ql4_printk(KERN_INFO, ha,
3673 "Match Found, fw[%d,%d,%s,%s], [%d,%d,%s,%s]",
3674 old_tddb->port, old_tddb->tpgt, old_tddb->ip_addr,
3675 old_tddb->iscsi_name, new_tddb->port, new_tddb->tpgt,
3676 new_tddb->ip_addr, new_tddb->iscsi_name));
3677
3678 return QLA_SUCCESS;
3679}
3680
3681static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
3682 struct dev_db_entry *fw_ddb_entry)
3683{
3684 struct ddb_entry *ddb_entry;
3685 struct ql4_tuple_ddb *fw_tddb = NULL;
3686 struct ql4_tuple_ddb *tmp_tddb = NULL;
3687 int idx;
3688 int ret = QLA_ERROR;
3689
3690 fw_tddb = vzalloc(sizeof(*fw_tddb));
3691 if (!fw_tddb) {
3692 DEBUG2(ql4_printk(KERN_WARNING, ha,
3693 "Memory Allocation failed.\n"));
3694 ret = QLA_SUCCESS;
3695 goto exit_check;
3696 }
3697
3698 tmp_tddb = vzalloc(sizeof(*tmp_tddb));
3699 if (!tmp_tddb) {
3700 DEBUG2(ql4_printk(KERN_WARNING, ha,
3701 "Memory Allocation failed.\n"));
3702 ret = QLA_SUCCESS;
3703 goto exit_check;
3704 }
3705
3706 qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb);
3707
3708 for (idx = 0; idx < MAX_DDB_ENTRIES; idx++) {
3709 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
3710 if (ddb_entry == NULL)
3711 continue;
3712
3713 qla4xxx_get_param_ddb(ddb_entry, tmp_tddb);
3714 if (!qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb)) {
3715 ret = QLA_SUCCESS; /* found */
3716 goto exit_check;
3717 }
3718 }
3719
3720exit_check:
3721 if (fw_tddb)
3722 vfree(fw_tddb);
3723 if (tmp_tddb)
3724 vfree(tmp_tddb);
3725 return ret;
3726}
3727
3728static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
3729 struct list_head *list_nt,
3730 struct dev_db_entry *fw_ddb_entry)
3731{
3732 struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp;
3733 struct ql4_tuple_ddb *fw_tddb = NULL;
3734 struct ql4_tuple_ddb *tmp_tddb = NULL;
3735 int ret = QLA_ERROR;
3736
3737 fw_tddb = vzalloc(sizeof(*fw_tddb));
3738 if (!fw_tddb) {
3739 DEBUG2(ql4_printk(KERN_WARNING, ha,
3740 "Memory Allocation failed.\n"));
3741 ret = QLA_SUCCESS;
3742 goto exit_check;
3743 }
3744
3745 tmp_tddb = vzalloc(sizeof(*tmp_tddb));
3746 if (!tmp_tddb) {
3747 DEBUG2(ql4_printk(KERN_WARNING, ha,
3748 "Memory Allocation failed.\n"));
3749 ret = QLA_SUCCESS;
3750 goto exit_check;
3751 }
3752
3753 qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb);
3754
3755 list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
3756 qla4xxx_convert_param_ddb(&nt_ddb_idx->fw_ddb, tmp_tddb);
3757 if (!qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb)) {
3758 ret = QLA_SUCCESS; /* found */
3759 goto exit_check;
3760 }
3761 }
3762
3763exit_check:
3764 if (fw_tddb)
3765 vfree(fw_tddb);
3766 if (tmp_tddb)
3767 vfree(tmp_tddb);
3768 return ret;
3769}
3770
3771static void qla4xxx_free_nt_list(struct list_head *list_nt)
3772{
3773 struct qla_ddb_index *nt_ddb_idx, *nt_ddb_idx_tmp;
3774
3775 /* Free up the normaltargets list */
3776 list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
3777 list_del_init(&nt_ddb_idx->list);
3778 vfree(nt_ddb_idx);
3779 }
3780
3781}
3782
3783static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha,
3784 struct dev_db_entry *fw_ddb_entry)
3785{
3786 struct iscsi_endpoint *ep;
3787 struct sockaddr_in *addr;
3788 struct sockaddr_in6 *addr6;
3789 struct sockaddr *dst_addr;
3790 char *ip;
3791
3792 /* TODO: need to destroy on unload iscsi_endpoint*/
3793 dst_addr = vmalloc(sizeof(*dst_addr));
3794 if (!dst_addr)
3795 return NULL;
3796
3797 if (fw_ddb_entry->options & DDB_OPT_IPV6_DEVICE) {
3798 dst_addr->sa_family = AF_INET6;
3799 addr6 = (struct sockaddr_in6 *)dst_addr;
3800 ip = (char *)&addr6->sin6_addr;
3801 memcpy(ip, fw_ddb_entry->ip_addr, IPv6_ADDR_LEN);
3802 addr6->sin6_port = htons(le16_to_cpu(fw_ddb_entry->port));
3803
3804 } else {
3805 dst_addr->sa_family = AF_INET;
3806 addr = (struct sockaddr_in *)dst_addr;
3807 ip = (char *)&addr->sin_addr;
3808 memcpy(ip, fw_ddb_entry->ip_addr, IP_ADDR_LEN);
3809 addr->sin_port = htons(le16_to_cpu(fw_ddb_entry->port));
3810 }
3811
3812 ep = qla4xxx_ep_connect(ha->host, dst_addr, 0);
3813 vfree(dst_addr);
3814 return ep;
3815}
3816
3817static int qla4xxx_verify_boot_idx(struct scsi_qla_host *ha, uint16_t idx)
3818{
3819 if (ql4xdisablesysfsboot)
3820 return QLA_SUCCESS;
3821 if (idx == ha->pri_ddb_idx || idx == ha->sec_ddb_idx)
3822 return QLA_ERROR;
3823 return QLA_SUCCESS;
3824}
3825
3826static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
3827 struct ddb_entry *ddb_entry)
3828{
3829 ddb_entry->ddb_type = FLASH_DDB;
3830 ddb_entry->fw_ddb_index = INVALID_ENTRY;
3831 ddb_entry->fw_ddb_device_state = DDB_DS_NO_CONNECTION_ACTIVE;
3832 ddb_entry->ha = ha;
3833 ddb_entry->unblock_sess = qla4xxx_unblock_flash_ddb;
3834 ddb_entry->ddb_change = qla4xxx_flash_ddb_change;
3835
3836 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
3837 atomic_set(&ddb_entry->relogin_timer, 0);
3838 atomic_set(&ddb_entry->relogin_retry_count, 0);
3839
3840 ddb_entry->default_relogin_timeout =
3841 le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
3842 ddb_entry->default_time2wait =
3843 le16_to_cpu(ddb_entry->fw_ddb_entry.iscsi_def_time2wait);
3844}
3845
3846static void qla4xxx_wait_for_ip_configuration(struct scsi_qla_host *ha)
3847{
3848 uint32_t idx = 0;
3849 uint32_t ip_idx[IP_ADDR_COUNT] = {0, 1, 2, 3}; /* 4 IP interfaces */
3850 uint32_t sts[MBOX_REG_COUNT];
3851 uint32_t ip_state;
3852 unsigned long wtime;
3853 int ret;
3854
3855 wtime = jiffies + (HZ * IP_CONFIG_TOV);
3856 do {
3857 for (idx = 0; idx < IP_ADDR_COUNT; idx++) {
3858 if (ip_idx[idx] == -1)
3859 continue;
3860
3861 ret = qla4xxx_get_ip_state(ha, 0, ip_idx[idx], sts);
3862
3863 if (ret == QLA_ERROR) {
3864 ip_idx[idx] = -1;
3865 continue;
3866 }
3867
3868 ip_state = (sts[1] & IP_STATE_MASK) >> IP_STATE_SHIFT;
3869
3870 DEBUG2(ql4_printk(KERN_INFO, ha,
3871 "Waiting for IP state for idx = %d, state = 0x%x\n",
3872 ip_idx[idx], ip_state));
3873 if (ip_state == IP_ADDRSTATE_UNCONFIGURED ||
3874 ip_state == IP_ADDRSTATE_INVALID ||
3875 ip_state == IP_ADDRSTATE_PREFERRED ||
3876 ip_state == IP_ADDRSTATE_DEPRICATED ||
3877 ip_state == IP_ADDRSTATE_DISABLING)
3878 ip_idx[idx] = -1;
3879
3880 }
3881
3882 /* Break if all IP states checked */
3883 if ((ip_idx[0] == -1) &&
3884 (ip_idx[1] == -1) &&
3885 (ip_idx[2] == -1) &&
3886 (ip_idx[3] == -1))
3887 break;
3888 schedule_timeout_uninterruptible(HZ);
3889 } while (time_after(wtime, jiffies));
3890}
3891
3892void qla4xxx_build_ddb_list(struct scsi_qla_host *ha, int is_reset)
3893{
3894 int max_ddbs;
3895 int ret;
3896 uint32_t idx = 0, next_idx = 0;
3897 uint32_t state = 0, conn_err = 0;
3898 uint16_t conn_id;
3899 struct dev_db_entry *fw_ddb_entry;
3900 struct ddb_entry *ddb_entry = NULL;
3901 dma_addr_t fw_ddb_dma;
3902 struct iscsi_cls_session *cls_sess;
3903 struct iscsi_session *sess;
3904 struct iscsi_cls_conn *cls_conn;
3905 struct iscsi_endpoint *ep;
3906 uint16_t cmds_max = 32, tmo = 0;
3907 uint32_t initial_cmdsn = 0;
3908 struct list_head list_st, list_nt; /* List of sendtargets */
3909 struct qla_ddb_index *st_ddb_idx, *st_ddb_idx_tmp;
3910 int fw_idx_size;
3911 unsigned long wtime;
3912 struct qla_ddb_index *nt_ddb_idx;
3913
3914 if (!test_bit(AF_LINK_UP, &ha->flags)) {
3915 set_bit(AF_BUILD_DDB_LIST, &ha->flags);
3916 ha->is_reset = is_reset;
3917 return;
3918 }
3919 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX :
3920 MAX_DEV_DB_ENTRIES;
3921
3922 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
3923 &fw_ddb_dma);
3924 if (fw_ddb_entry == NULL) {
3925 DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n"));
3926 goto exit_ddb_list;
3927 }
3928
3929 INIT_LIST_HEAD(&list_st);
3930 INIT_LIST_HEAD(&list_nt);
3931 fw_idx_size = sizeof(struct qla_ddb_index);
3932
3933 for (idx = 0; idx < max_ddbs; idx = next_idx) {
3934 ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry,
3935 fw_ddb_dma, NULL,
3936 &next_idx, &state, &conn_err,
3937 NULL, &conn_id);
3938 if (ret == QLA_ERROR)
3939 break;
3940
3941 if (qla4xxx_verify_boot_idx(ha, idx) != QLA_SUCCESS)
3942 goto continue_next_st;
3943
3944 /* Check if ST, add to the list_st */
3945 if (strlen((char *) fw_ddb_entry->iscsi_name) != 0)
3946 goto continue_next_st;
3947
3948 st_ddb_idx = vzalloc(fw_idx_size);
3949 if (!st_ddb_idx)
3950 break;
3951
3952 st_ddb_idx->fw_ddb_idx = idx;
3953
3954 list_add_tail(&st_ddb_idx->list, &list_st);
3955continue_next_st:
3956 if (next_idx == 0)
3957 break;
3958 }
3959
3960 /* Before issuing conn open mbox, ensure all IPs states are configured
3961 * Note, conn open fails if IPs are not configured
3962 */
3963 qla4xxx_wait_for_ip_configuration(ha);
3964
3965 /* Go thru the STs and fire the sendtargets by issuing conn open mbx */
3966 list_for_each_entry_safe(st_ddb_idx, st_ddb_idx_tmp, &list_st, list) {
3967 qla4xxx_conn_open(ha, st_ddb_idx->fw_ddb_idx);
3968 }
3969
3970 /* Wait to ensure all sendtargets are done for min 12 sec wait */
3971 tmo = ((ha->def_timeout < LOGIN_TOV) ? LOGIN_TOV : ha->def_timeout);
3972 DEBUG2(ql4_printk(KERN_INFO, ha,
3973 "Default time to wait for build ddb %d\n", tmo));
3974
3975 wtime = jiffies + (HZ * tmo);
3976 do {
3977 list_for_each_entry_safe(st_ddb_idx, st_ddb_idx_tmp, &list_st,
3978 list) {
3979 ret = qla4xxx_get_fwddb_entry(ha,
3980 st_ddb_idx->fw_ddb_idx,
3981 NULL, 0, NULL, &next_idx,
3982 &state, &conn_err, NULL,
3983 NULL);
3984 if (ret == QLA_ERROR)
3985 continue;
3986
3987 if (state == DDB_DS_NO_CONNECTION_ACTIVE ||
3988 state == DDB_DS_SESSION_FAILED) {
3989 list_del_init(&st_ddb_idx->list);
3990 vfree(st_ddb_idx);
3991 }
3992 }
3993 schedule_timeout_uninterruptible(HZ / 10);
3994 } while (time_after(wtime, jiffies));
3995
3996 /* Free up the sendtargets list */
3997 list_for_each_entry_safe(st_ddb_idx, st_ddb_idx_tmp, &list_st, list) {
3998 list_del_init(&st_ddb_idx->list);
3999 vfree(st_ddb_idx);
4000 }
4001
4002 for (idx = 0; idx < max_ddbs; idx = next_idx) {
4003 ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry,
4004 fw_ddb_dma, NULL,
4005 &next_idx, &state, &conn_err,
4006 NULL, &conn_id);
4007 if (ret == QLA_ERROR)
4008 break;
4009
4010 if (qla4xxx_verify_boot_idx(ha, idx) != QLA_SUCCESS)
4011 goto continue_next_nt;
4012
4013 /* Check if NT, then add to list it */
4014 if (strlen((char *) fw_ddb_entry->iscsi_name) == 0)
4015 goto continue_next_nt;
4016
4017 if (state == DDB_DS_NO_CONNECTION_ACTIVE ||
4018 state == DDB_DS_SESSION_FAILED) {
4019 DEBUG2(ql4_printk(KERN_INFO, ha,
4020 "Adding DDB to session = 0x%x\n",
4021 idx));
4022 if (is_reset == INIT_ADAPTER) {
4023 nt_ddb_idx = vmalloc(fw_idx_size);
4024 if (!nt_ddb_idx)
4025 break;
4026
4027 nt_ddb_idx->fw_ddb_idx = idx;
4028
4029 memcpy(&nt_ddb_idx->fw_ddb, fw_ddb_entry,
4030 sizeof(struct dev_db_entry));
4031
4032 if (qla4xxx_is_flash_ddb_exists(ha, &list_nt,
4033 fw_ddb_entry) == QLA_SUCCESS) {
4034 vfree(nt_ddb_idx);
4035 goto continue_next_nt;
4036 }
4037 list_add_tail(&nt_ddb_idx->list, &list_nt);
4038 } else if (is_reset == RESET_ADAPTER) {
4039 if (qla4xxx_is_session_exists(ha,
4040 fw_ddb_entry) == QLA_SUCCESS)
4041 goto continue_next_nt;
4042 }
4043
4044 /* Create session object, with INVALID_ENTRY,
4045 * the targer_id would get set when we issue the login
4046 */
4047 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport,
4048 ha->host, cmds_max,
4049 sizeof(struct ddb_entry),
4050 sizeof(struct ql4_task_data),
4051 initial_cmdsn, INVALID_ENTRY);
4052 if (!cls_sess)
4053 goto exit_ddb_list;
4054
4055 /*
4056 * iscsi_session_setup increments the driver reference
4057 * count which wouldn't let the driver to be unloaded.
4058 * so calling module_put function to decrement the
4059 * reference count.
4060 **/
4061 module_put(qla4xxx_iscsi_transport.owner);
4062 sess = cls_sess->dd_data;
4063 ddb_entry = sess->dd_data;
4064 ddb_entry->sess = cls_sess;
4065
4066 cls_sess->recovery_tmo = ql4xsess_recovery_tmo;
4067 memcpy(&ddb_entry->fw_ddb_entry, fw_ddb_entry,
4068 sizeof(struct dev_db_entry));
4069
4070 qla4xxx_setup_flash_ddb_entry(ha, ddb_entry);
4071
4072 cls_conn = iscsi_conn_setup(cls_sess,
4073 sizeof(struct qla_conn),
4074 conn_id);
4075 if (!cls_conn)
4076 goto exit_ddb_list;
4077
4078 ddb_entry->conn = cls_conn;
4079
4080 /* Setup ep, for displaying attributes in sysfs */
4081 ep = qla4xxx_get_ep_fwdb(ha, fw_ddb_entry);
4082 if (ep) {
4083 ep->conn = cls_conn;
4084 cls_conn->ep = ep;
4085 } else {
4086 DEBUG2(ql4_printk(KERN_ERR, ha,
4087 "Unable to get ep\n"));
4088 }
4089
4090 /* Update sess/conn params */
4091 qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess,
4092 cls_conn);
4093
4094 if (is_reset == RESET_ADAPTER) {
4095 iscsi_block_session(cls_sess);
4096 /* Use the relogin path to discover new devices
4097 * by short-circuting the logic of setting
4098 * timer to relogin - instead set the flags
4099 * to initiate login right away.
4100 */
4101 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
4102 set_bit(DF_RELOGIN, &ddb_entry->flags);
4103 }
4104 }
4105continue_next_nt:
4106 if (next_idx == 0)
4107 break;
4108 }
4109exit_ddb_list:
4110 qla4xxx_free_nt_list(&list_nt);
4111 if (fw_ddb_entry)
4112 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
4113
4114 qla4xxx_free_ddb_index(ha);
4115}
4116
4117
3180/** 4118/**
3181 * qla4xxx_probe_adapter - callback function to probe HBA 4119 * qla4xxx_probe_adapter - callback function to probe HBA
3182 * @pdev: pointer to pci_dev structure 4120 * @pdev: pointer to pci_dev structure
@@ -3298,7 +4236,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
3298 * firmware 4236 * firmware
3299 * NOTE: interrupts enabled upon successful completion 4237 * NOTE: interrupts enabled upon successful completion
3300 */ 4238 */
3301 status = qla4xxx_initialize_adapter(ha); 4239 status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER);
3302 while ((!test_bit(AF_ONLINE, &ha->flags)) && 4240 while ((!test_bit(AF_ONLINE, &ha->flags)) &&
3303 init_retry_count++ < MAX_INIT_RETRIES) { 4241 init_retry_count++ < MAX_INIT_RETRIES) {
3304 4242
@@ -3319,7 +4257,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
3319 if (ha->isp_ops->reset_chip(ha) == QLA_ERROR) 4257 if (ha->isp_ops->reset_chip(ha) == QLA_ERROR)
3320 continue; 4258 continue;
3321 4259
3322 status = qla4xxx_initialize_adapter(ha); 4260 status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER);
3323 } 4261 }
3324 4262
3325 if (!test_bit(AF_ONLINE, &ha->flags)) { 4263 if (!test_bit(AF_ONLINE, &ha->flags)) {
@@ -3386,12 +4324,16 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
3386 ha->host_no, ha->firmware_version[0], ha->firmware_version[1], 4324 ha->host_no, ha->firmware_version[0], ha->firmware_version[1],
3387 ha->patch_number, ha->build_number); 4325 ha->patch_number, ha->build_number);
3388 4326
3389 qla4xxx_create_chap_list(ha);
3390
3391 if (qla4xxx_setup_boot_info(ha)) 4327 if (qla4xxx_setup_boot_info(ha))
3392 ql4_printk(KERN_ERR, ha, "%s:ISCSI boot info setup failed\n", 4328 ql4_printk(KERN_ERR, ha, "%s:ISCSI boot info setup failed\n",
3393 __func__); 4329 __func__);
3394 4330
4331 /* Perform the build ddb list and login to each */
4332 qla4xxx_build_ddb_list(ha, INIT_ADAPTER);
4333 iscsi_host_for_each_session(ha->host, qla4xxx_login_flash_ddb);
4334
4335 qla4xxx_create_chap_list(ha);
4336
3395 qla4xxx_create_ifaces(ha); 4337 qla4xxx_create_ifaces(ha);
3396 return 0; 4338 return 0;
3397 4339
@@ -3449,6 +4391,38 @@ static void qla4xxx_prevent_other_port_reinit(struct scsi_qla_host *ha)
3449 } 4391 }
3450} 4392}
3451 4393
4394static void qla4xxx_destroy_fw_ddb_session(struct scsi_qla_host *ha)
4395{
4396 struct ddb_entry *ddb_entry;
4397 int options;
4398 int idx;
4399
4400 for (idx = 0; idx < MAX_DDB_ENTRIES; idx++) {
4401
4402 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx);
4403 if ((ddb_entry != NULL) &&
4404 (ddb_entry->ddb_type == FLASH_DDB)) {
4405
4406 options = LOGOUT_OPTION_CLOSE_SESSION;
4407 if (qla4xxx_session_logout_ddb(ha, ddb_entry, options)
4408 == QLA_ERROR)
4409 ql4_printk(KERN_ERR, ha, "%s: Logout failed\n",
4410 __func__);
4411
4412 qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index);
4413 /*
4414 * we have decremented the reference count of the driver
4415 * when we setup the session to have the driver unload
4416 * to be seamless without actually destroying the
4417 * session
4418 **/
4419 try_module_get(qla4xxx_iscsi_transport.owner);
4420 iscsi_destroy_endpoint(ddb_entry->conn->ep);
4421 qla4xxx_free_ddb(ha, ddb_entry);
4422 iscsi_session_teardown(ddb_entry->sess);
4423 }
4424 }
4425}
3452/** 4426/**
3453 * qla4xxx_remove_adapter - calback function to remove adapter. 4427 * qla4xxx_remove_adapter - calback function to remove adapter.
3454 * @pci_dev: PCI device pointer 4428 * @pci_dev: PCI device pointer
@@ -3465,9 +4439,11 @@ static void __devexit qla4xxx_remove_adapter(struct pci_dev *pdev)
3465 /* destroy iface from sysfs */ 4439 /* destroy iface from sysfs */
3466 qla4xxx_destroy_ifaces(ha); 4440 qla4xxx_destroy_ifaces(ha);
3467 4441
3468 if (ha->boot_kset) 4442 if ((!ql4xdisablesysfsboot) && ha->boot_kset)
3469 iscsi_boot_destroy_kset(ha->boot_kset); 4443 iscsi_boot_destroy_kset(ha->boot_kset);
3470 4444
4445 qla4xxx_destroy_fw_ddb_session(ha);
4446
3471 scsi_remove_host(ha->host); 4447 scsi_remove_host(ha->host);
3472 4448
3473 qla4xxx_free_adapter(ha); 4449 qla4xxx_free_adapter(ha);
@@ -4115,7 +5091,7 @@ static uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host *ha)
4115 5091
4116 qla4_8xxx_idc_unlock(ha); 5092 qla4_8xxx_idc_unlock(ha);
4117 clear_bit(AF_FW_RECOVERY, &ha->flags); 5093 clear_bit(AF_FW_RECOVERY, &ha->flags);
4118 rval = qla4xxx_initialize_adapter(ha); 5094 rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
4119 qla4_8xxx_idc_lock(ha); 5095 qla4_8xxx_idc_lock(ha);
4120 5096
4121 if (rval != QLA_SUCCESS) { 5097 if (rval != QLA_SUCCESS) {
@@ -4151,7 +5127,7 @@ static uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host *ha)
4151 if ((qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == 5127 if ((qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE) ==
4152 QLA82XX_DEV_READY)) { 5128 QLA82XX_DEV_READY)) {
4153 clear_bit(AF_FW_RECOVERY, &ha->flags); 5129 clear_bit(AF_FW_RECOVERY, &ha->flags);
4154 rval = qla4xxx_initialize_adapter(ha); 5130 rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER);
4155 if (rval == QLA_SUCCESS) { 5131 if (rval == QLA_SUCCESS) {
4156 ret = qla4xxx_request_irqs(ha); 5132 ret = qla4xxx_request_irqs(ha);
4157 if (ret) { 5133 if (ret) {
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index c15347d3f53..5254e57968f 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,4 +5,4 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7 7
8#define QLA4XXX_DRIVER_VERSION "5.02.00-k8" 8#define QLA4XXX_DRIVER_VERSION "5.02.00-k9"
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 717ebc9ff94..600d8234851 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -264,7 +264,7 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc)
264 ret = -ENODEV; 264 ret = -ENODEV;
265 goto err0; 265 goto err0;
266 } 266 }
267 dwc->revision = reg & DWC3_GSNPSREV_MASK; 267 dwc->revision = reg;
268 268
269 dwc3_core_soft_reset(dwc); 269 dwc3_core_soft_reset(dwc);
270 270
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 596a0b464e6..4dff83d2f26 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -130,9 +130,6 @@ ep_matches (
130 num_req_streams = ep_comp->bmAttributes & 0x1f; 130 num_req_streams = ep_comp->bmAttributes & 0x1f;
131 if (num_req_streams > ep->max_streams) 131 if (num_req_streams > ep->max_streams)
132 return 0; 132 return 0;
133 /* Update the ep_comp descriptor if needed */
134 if (num_req_streams != ep->max_streams)
135 ep_comp->bmAttributes = ep->max_streams;
136 } 133 }
137 134
138 } 135 }
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index a7dc1e1d45f..2ac4ac2e4ef 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -18,7 +18,7 @@
18 18
19#include "isp1760-hcd.h" 19#include "isp1760-hcd.h"
20 20
21#ifdef CONFIG_OF 21#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
@@ -31,7 +31,7 @@
31#include <linux/pci.h> 31#include <linux/pci.h>
32#endif 32#endif
33 33
34#ifdef CONFIG_OF 34#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
35struct isp1760 { 35struct isp1760 {
36 struct usb_hcd *hcd; 36 struct usb_hcd *hcd;
37 int rst_gpio; 37 int rst_gpio;
@@ -437,7 +437,7 @@ static int __init isp1760_init(void)
437 ret = platform_driver_register(&isp1760_plat_driver); 437 ret = platform_driver_register(&isp1760_plat_driver);
438 if (!ret) 438 if (!ret)
439 any_ret = 0; 439 any_ret = 0;
440#ifdef CONFIG_OF 440#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
441 ret = platform_driver_register(&isp1760_of_driver); 441 ret = platform_driver_register(&isp1760_of_driver);
442 if (!ret) 442 if (!ret)
443 any_ret = 0; 443 any_ret = 0;
@@ -457,7 +457,7 @@ module_init(isp1760_init);
457static void __exit isp1760_exit(void) 457static void __exit isp1760_exit(void)
458{ 458{
459 platform_driver_unregister(&isp1760_plat_driver); 459 platform_driver_unregister(&isp1760_plat_driver);
460#ifdef CONFIG_OF 460#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
461 platform_driver_unregister(&isp1760_of_driver); 461 platform_driver_unregister(&isp1760_of_driver);
462#endif 462#endif
463#ifdef CONFIG_PCI 463#ifdef CONFIG_PCI
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 60ddba8066e..79cb0af779f 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -774,6 +774,10 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
774 if (musb->double_buffer_not_ok) 774 if (musb->double_buffer_not_ok)
775 musb_writew(epio, MUSB_TXMAXP, 775 musb_writew(epio, MUSB_TXMAXP,
776 hw_ep->max_packet_sz_tx); 776 hw_ep->max_packet_sz_tx);
777 else if (can_bulk_split(musb, qh->type))
778 musb_writew(epio, MUSB_TXMAXP, packet_sz
779 | ((hw_ep->max_packet_sz_tx /
780 packet_sz) - 1) << 11);
777 else 781 else
778 musb_writew(epio, MUSB_TXMAXP, 782 musb_writew(epio, MUSB_TXMAXP,
779 qh->maxpacket | 783 qh->maxpacket |
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 03f449a430d..5b89f7d6cd0 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -76,8 +76,6 @@ static int irq;
76static void __iomem *virtbase; 76static void __iomem *virtbase;
77static unsigned long coh901327_users; 77static unsigned long coh901327_users;
78static unsigned long boot_status; 78static unsigned long boot_status;
79static u16 wdogenablestore;
80static u16 irqmaskstore;
81static struct device *parent; 79static struct device *parent;
82 80
83/* 81/*
@@ -461,6 +459,10 @@ out:
461} 459}
462 460
463#ifdef CONFIG_PM 461#ifdef CONFIG_PM
462
463static u16 wdogenablestore;
464static u16 irqmaskstore;
465
464static int coh901327_suspend(struct platform_device *pdev, pm_message_t state) 466static int coh901327_suspend(struct platform_device *pdev, pm_message_t state)
465{ 467{
466 irqmaskstore = readw(virtbase + U300_WDOG_IMR) & 0x0001U; 468 irqmaskstore = readw(virtbase + U300_WDOG_IMR) & 0x0001U;
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 3774c9b8dac..8464ea1c36a 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -231,6 +231,7 @@ static int __devinit cru_detect(unsigned long map_entry,
231 231
232 cmn_regs.u1.reax = CRU_BIOS_SIGNATURE_VALUE; 232 cmn_regs.u1.reax = CRU_BIOS_SIGNATURE_VALUE;
233 233
234 set_memory_x((unsigned long)bios32_entrypoint, (2 * PAGE_SIZE));
234 asminline_call(&cmn_regs, bios32_entrypoint); 235 asminline_call(&cmn_regs, bios32_entrypoint);
235 236
236 if (cmn_regs.u1.ral != 0) { 237 if (cmn_regs.u1.ral != 0) {
@@ -248,8 +249,10 @@ static int __devinit cru_detect(unsigned long map_entry,
248 if ((physical_bios_base + physical_bios_offset)) { 249 if ((physical_bios_base + physical_bios_offset)) {
249 cru_rom_addr = 250 cru_rom_addr =
250 ioremap(cru_physical_address, cru_length); 251 ioremap(cru_physical_address, cru_length);
251 if (cru_rom_addr) 252 if (cru_rom_addr) {
253 set_memory_x((unsigned long)cru_rom_addr, cru_length);
252 retval = 0; 254 retval = 0;
255 }
253 } 256 }
254 257
255 printk(KERN_DEBUG "hpwdt: CRU Base Address: 0x%lx\n", 258 printk(KERN_DEBUG "hpwdt: CRU Base Address: 0x%lx\n",
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index ba6ad662635..99796c5d913 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -384,10 +384,10 @@ MODULE_PARM_DESC(nowayout,
384 "Watchdog cannot be stopped once started (default=" 384 "Watchdog cannot be stopped once started (default="
385 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 385 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
386 386
387static int turn_SMI_watchdog_clear_off = 0; 387static int turn_SMI_watchdog_clear_off = 1;
388module_param(turn_SMI_watchdog_clear_off, int, 0); 388module_param(turn_SMI_watchdog_clear_off, int, 0);
389MODULE_PARM_DESC(turn_SMI_watchdog_clear_off, 389MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
390 "Turn off SMI clearing watchdog (default=0)"); 390 "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
391 391
392/* 392/*
393 * Some TCO specific functions 393 * Some TCO specific functions
@@ -813,7 +813,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
813 ret = -EIO; 813 ret = -EIO;
814 goto out_unmap; 814 goto out_unmap;
815 } 815 }
816 if (turn_SMI_watchdog_clear_off) { 816 if (turn_SMI_watchdog_clear_off >= iTCO_wdt_private.iTCO_version) {
817 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */ 817 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
818 val32 = inl(SMI_EN); 818 val32 = inl(SMI_EN);
819 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */ 819 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index cc2cfbe33b3..bfaf9bb1ee0 100644
--- a/drivers/watchdog/sp805_wdt.c
+++ b/drivers/watchdog/sp805_wdt.c
@@ -351,7 +351,7 @@ static int __devexit sp805_wdt_remove(struct amba_device *adev)
351 return 0; 351 return 0;
352} 352}
353 353
354static struct amba_id sp805_wdt_ids[] __initdata = { 354static struct amba_id sp805_wdt_ids[] = {
355 { 355 {
356 .id = 0x00141805, 356 .id = 0x00141805,
357 .mask = 0x00ffffff, 357 .mask = 0x00ffffff,
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index b3b8f2f3ad1..ede860f921d 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -621,15 +621,6 @@ static struct xenbus_watch *find_watch(const char *token)
621 return NULL; 621 return NULL;
622} 622}
623 623
624static void xs_reset_watches(void)
625{
626 int err;
627
628 err = xs_error(xs_single(XBT_NIL, XS_RESET_WATCHES, "", NULL));
629 if (err && err != -EEXIST)
630 printk(KERN_WARNING "xs_reset_watches failed: %d\n", err);
631}
632
633/* Register callback to watch this node. */ 624/* Register callback to watch this node. */
634int register_xenbus_watch(struct xenbus_watch *watch) 625int register_xenbus_watch(struct xenbus_watch *watch)
635{ 626{
@@ -906,9 +897,5 @@ int xs_init(void)
906 if (IS_ERR(task)) 897 if (IS_ERR(task))
907 return PTR_ERR(task); 898 return PTR_ERR(task);
908 899
909 /* shutdown watches for kexec boot */
910 if (xen_hvm_domain())
911 xs_reset_watches();
912
913 return 0; 900 return 0;
914} 901}
diff --git a/firmware/README.AddingFirmware b/firmware/README.AddingFirmware
index e24cd8986d8..ea78c3a17ee 100644
--- a/firmware/README.AddingFirmware
+++ b/firmware/README.AddingFirmware
@@ -12,7 +12,7 @@ here.
12This directory is _NOT_ for adding arbitrary new firmware images. The 12This directory is _NOT_ for adding arbitrary new firmware images. The
13place to add those is the separate linux-firmware repository: 13place to add those is the separate linux-firmware repository:
14 14
15 git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git 15 git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
16 16
17That repository contains all these firmware images which have been 17That repository contains all these firmware images which have been
18extracted from older drivers, as well various new firmware images which 18extracted from older drivers, as well various new firmware images which
@@ -22,6 +22,7 @@ been permitted to redistribute under separate cover.
22To submit firmware to that repository, please send either a git binary 22To submit firmware to that repository, please send either a git binary
23diff or preferably a git pull request to: 23diff or preferably a git pull request to:
24 David Woodhouse <dwmw2@infradead.org> 24 David Woodhouse <dwmw2@infradead.org>
25 Ben Hutchings <ben@decadent.org.uk>
25 26
26Your commit should include an update to the WHENCE file clearly 27Your commit should include an update to the WHENCE file clearly
27identifying the licence under which the firmware is available, and 28identifying the licence under which the firmware is available, and
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index cb97174e236..0b394580d86 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -563,8 +563,8 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers)
563 struct list_head *fallback; 563 struct list_head *fallback;
564 int ret; 564 int ret;
565 565
566again:
567 spin_lock_irqsave(&workers->lock, flags); 566 spin_lock_irqsave(&workers->lock, flags);
567again:
568 worker = next_worker(workers); 568 worker = next_worker(workers);
569 569
570 if (!worker) { 570 if (!worker) {
@@ -579,6 +579,7 @@ again:
579 spin_unlock_irqrestore(&workers->lock, flags); 579 spin_unlock_irqrestore(&workers->lock, flags);
580 /* we're below the limit, start another worker */ 580 /* we're below the limit, start another worker */
581 ret = __btrfs_start_workers(workers); 581 ret = __btrfs_start_workers(workers);
582 spin_lock_irqsave(&workers->lock, flags);
582 if (ret) 583 if (ret)
583 goto fallback; 584 goto fallback;
584 goto again; 585 goto again;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0a6b928813a..fd1a06df5bc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4590,10 +4590,6 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
4590 int err = btrfs_add_link(trans, dir, inode, 4590 int err = btrfs_add_link(trans, dir, inode,
4591 dentry->d_name.name, dentry->d_name.len, 4591 dentry->d_name.name, dentry->d_name.len,
4592 backref, index); 4592 backref, index);
4593 if (!err) {
4594 d_instantiate(dentry, inode);
4595 return 0;
4596 }
4597 if (err > 0) 4593 if (err > 0)
4598 err = -EEXIST; 4594 err = -EEXIST;
4599 return err; 4595 return err;
@@ -4655,6 +4651,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
4655 else { 4651 else {
4656 init_special_inode(inode, inode->i_mode, rdev); 4652 init_special_inode(inode, inode->i_mode, rdev);
4657 btrfs_update_inode(trans, root, inode); 4653 btrfs_update_inode(trans, root, inode);
4654 d_instantiate(dentry, inode);
4658 } 4655 }
4659out_unlock: 4656out_unlock:
4660 nr = trans->blocks_used; 4657 nr = trans->blocks_used;
@@ -4722,6 +4719,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
4722 inode->i_mapping->a_ops = &btrfs_aops; 4719 inode->i_mapping->a_ops = &btrfs_aops;
4723 inode->i_mapping->backing_dev_info = &root->fs_info->bdi; 4720 inode->i_mapping->backing_dev_info = &root->fs_info->bdi;
4724 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; 4721 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
4722 d_instantiate(dentry, inode);
4725 } 4723 }
4726out_unlock: 4724out_unlock:
4727 nr = trans->blocks_used; 4725 nr = trans->blocks_used;
@@ -4779,6 +4777,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
4779 struct dentry *parent = dentry->d_parent; 4777 struct dentry *parent = dentry->d_parent;
4780 err = btrfs_update_inode(trans, root, inode); 4778 err = btrfs_update_inode(trans, root, inode);
4781 BUG_ON(err); 4779 BUG_ON(err);
4780 d_instantiate(dentry, inode);
4782 btrfs_log_new_name(trans, inode, NULL, parent); 4781 btrfs_log_new_name(trans, inode, NULL, parent);
4783 } 4782 }
4784 4783
@@ -7245,6 +7244,8 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
7245 drop_inode = 1; 7244 drop_inode = 1;
7246 7245
7247out_unlock: 7246out_unlock:
7247 if (!err)
7248 d_instantiate(dentry, inode);
7248 nr = trans->blocks_used; 7249 nr = trans->blocks_used;
7249 btrfs_end_transaction_throttle(trans, root); 7250 btrfs_end_transaction_throttle(trans, root);
7250 if (drop_inode) { 7251 if (drop_inode) {
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 3eeb9766126..98954003a8d 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1094,42 +1094,19 @@ static int ceph_snapdir_d_revalidate(struct dentry *dentry,
1094/* 1094/*
1095 * Set/clear/test dir complete flag on the dir's dentry. 1095 * Set/clear/test dir complete flag on the dir's dentry.
1096 */ 1096 */
1097static struct dentry * __d_find_any_alias(struct inode *inode)
1098{
1099 struct dentry *alias;
1100
1101 if (list_empty(&inode->i_dentry))
1102 return NULL;
1103 alias = list_first_entry(&inode->i_dentry, struct dentry, d_alias);
1104 return alias;
1105}
1106
1107void ceph_dir_set_complete(struct inode *inode) 1097void ceph_dir_set_complete(struct inode *inode)
1108{ 1098{
1109 struct dentry *dentry = __d_find_any_alias(inode); 1099 /* not yet implemented */
1110
1111 if (dentry && ceph_dentry(dentry)) {
1112 dout(" marking %p (%p) complete\n", inode, dentry);
1113 set_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags);
1114 }
1115} 1100}
1116 1101
1117void ceph_dir_clear_complete(struct inode *inode) 1102void ceph_dir_clear_complete(struct inode *inode)
1118{ 1103{
1119 struct dentry *dentry = __d_find_any_alias(inode); 1104 /* not yet implemented */
1120
1121 if (dentry && ceph_dentry(dentry)) {
1122 dout(" marking %p (%p) NOT complete\n", inode, dentry);
1123 clear_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags);
1124 }
1125} 1105}
1126 1106
1127bool ceph_dir_test_complete(struct inode *inode) 1107bool ceph_dir_test_complete(struct inode *inode)
1128{ 1108{
1129 struct dentry *dentry = __d_find_any_alias(inode); 1109 /* not yet implemented */
1130
1131 if (dentry && ceph_dentry(dentry))
1132 return test_bit(CEPH_D_COMPLETE, &ceph_dentry(dentry)->flags);
1133 return false; 1110 return false;
1134} 1111}
1135 1112
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8cd4b52d421..f3670cf7258 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -282,7 +282,7 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
282 byte_count = be32_to_cpu(pTargetSMB->smb_buf_length); 282 byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
283 byte_count += total_in_buf2; 283 byte_count += total_in_buf2;
284 /* don't allow buffer to overflow */ 284 /* don't allow buffer to overflow */
285 if (byte_count > CIFSMaxBufSize) 285 if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
286 return -ENOBUFS; 286 return -ENOBUFS;
287 pTargetSMB->smb_buf_length = cpu_to_be32(byte_count); 287 pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
288 288
@@ -2122,7 +2122,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
2122 warned_on_ntlm = true; 2122 warned_on_ntlm = true;
2123 cERROR(1, "default security mechanism requested. The default " 2123 cERROR(1, "default security mechanism requested. The default "
2124 "security mechanism will be upgraded from ntlm to " 2124 "security mechanism will be upgraded from ntlm to "
2125 "ntlmv2 in kernel release 3.2"); 2125 "ntlmv2 in kernel release 3.3");
2126 } 2126 }
2127 ses->overrideSecFlg = volume_info->secFlg; 2127 ses->overrideSecFlg = volume_info->secFlg;
2128 2128
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index ac86f8b3e3c..517f211a3bd 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -47,17 +47,6 @@ struct wb_writeback_work {
47 struct completion *done; /* set if the caller waits */ 47 struct completion *done; /* set if the caller waits */
48}; 48};
49 49
50const char *wb_reason_name[] = {
51 [WB_REASON_BACKGROUND] = "background",
52 [WB_REASON_TRY_TO_FREE_PAGES] = "try_to_free_pages",
53 [WB_REASON_SYNC] = "sync",
54 [WB_REASON_PERIODIC] = "periodic",
55 [WB_REASON_LAPTOP_TIMER] = "laptop_timer",
56 [WB_REASON_FREE_MORE_MEM] = "free_more_memory",
57 [WB_REASON_FS_FREE_SPACE] = "fs_free_space",
58 [WB_REASON_FORKER_THREAD] = "forker_thread"
59};
60
61/* 50/*
62 * Include the creation of the trace points after defining the 51 * Include the creation of the trace points after defining the
63 * wb_writeback_work structure so that the definition remains local to this 52 * wb_writeback_work structure so that the definition remains local to this
diff --git a/fs/locks.c b/fs/locks.c
index 3b0d05dcd7c..637694bf3a0 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1205,6 +1205,8 @@ int __break_lease(struct inode *inode, unsigned int mode)
1205 int want_write = (mode & O_ACCMODE) != O_RDONLY; 1205 int want_write = (mode & O_ACCMODE) != O_RDONLY;
1206 1206
1207 new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); 1207 new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK);
1208 if (IS_ERR(new_fl))
1209 return PTR_ERR(new_fl);
1208 1210
1209 lock_flocks(); 1211 lock_flocks();
1210 1212
@@ -1221,12 +1223,6 @@ int __break_lease(struct inode *inode, unsigned int mode)
1221 if (fl->fl_owner == current->files) 1223 if (fl->fl_owner == current->files)
1222 i_have_this_lease = 1; 1224 i_have_this_lease = 1;
1223 1225
1224 if (IS_ERR(new_fl) && !i_have_this_lease
1225 && ((mode & O_NONBLOCK) == 0)) {
1226 error = PTR_ERR(new_fl);
1227 goto out;
1228 }
1229
1230 break_time = 0; 1226 break_time = 0;
1231 if (lease_break_time > 0) { 1227 if (lease_break_time > 0) {
1232 break_time = jiffies + lease_break_time * HZ; 1228 break_time = jiffies + lease_break_time * HZ;
@@ -1284,8 +1280,7 @@ restart:
1284 1280
1285out: 1281out:
1286 unlock_flocks(); 1282 unlock_flocks();
1287 if (!IS_ERR(new_fl)) 1283 locks_free_lock(new_fl);
1288 locks_free_lock(new_fl);
1289 return error; 1284 return error;
1290} 1285}
1291 1286
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 1d9e33966db..4d46a6a5907 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -263,23 +263,6 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
263 goto out_no_root; 263 goto out_no_root;
264 } 264 }
265 265
266 ret = -ENOMEM;
267 s->s_root = d_alloc_root(root_inode);
268 if (!s->s_root)
269 goto out_iput;
270
271 if (!(s->s_flags & MS_RDONLY)) {
272 if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
273 ms->s_state &= ~MINIX_VALID_FS;
274 mark_buffer_dirty(bh);
275 }
276 if (!(sbi->s_mount_state & MINIX_VALID_FS))
277 printk("MINIX-fs: mounting unchecked file system, "
278 "running fsck is recommended\n");
279 else if (sbi->s_mount_state & MINIX_ERROR_FS)
280 printk("MINIX-fs: mounting file system with errors, "
281 "running fsck is recommended\n");
282
283 /* Apparently minix can create filesystems that allocate more blocks for 266 /* Apparently minix can create filesystems that allocate more blocks for
284 * the bitmaps than needed. We simply ignore that, but verify it didn't 267 * the bitmaps than needed. We simply ignore that, but verify it didn't
285 * create one with not enough blocks and bail out if so. 268 * create one with not enough blocks and bail out if so.
@@ -300,6 +283,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
300 goto out_iput; 283 goto out_iput;
301 } 284 }
302 285
286 ret = -ENOMEM;
287 s->s_root = d_alloc_root(root_inode);
288 if (!s->s_root)
289 goto out_iput;
290
291 if (!(s->s_flags & MS_RDONLY)) {
292 if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
293 ms->s_state &= ~MINIX_VALID_FS;
294 mark_buffer_dirty(bh);
295 }
296 if (!(sbi->s_mount_state & MINIX_VALID_FS))
297 printk("MINIX-fs: mounting unchecked file system, "
298 "running fsck is recommended\n");
299 else if (sbi->s_mount_state & MINIX_ERROR_FS)
300 printk("MINIX-fs: mounting file system with errors, "
301 "running fsck is recommended\n");
302
303 return 0; 303 return 0;
304 304
305out_iput: 305out_iput:
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index eca56d4b39c..606ef0f20ae 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -147,7 +147,7 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
147 * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate 147 * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
148 * the cached file length 148 * the cached file length
149 */ 149 */
150 if (origin != SEEK_SET || origin != SEEK_CUR) { 150 if (origin != SEEK_SET && origin != SEEK_CUR) {
151 struct inode *inode = filp->f_mapping->host; 151 struct inode *inode = filp->f_mapping->host;
152 152
153 int retval = nfs_revalidate_file_size(inode, filp); 153 int retval = nfs_revalidate_file_size(inode, filp);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index be2bbac1381..d9f4d78c341 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -39,6 +39,8 @@
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/string.h> 41#include <linux/string.h>
42#include <linux/ratelimit.h>
43#include <linux/printk.h>
42#include <linux/slab.h> 44#include <linux/slab.h>
43#include <linux/sunrpc/clnt.h> 45#include <linux/sunrpc/clnt.h>
44#include <linux/sunrpc/gss_api.h> 46#include <linux/sunrpc/gss_api.h>
@@ -894,6 +896,8 @@ out:
894 896
895static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode) 897static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode)
896{ 898{
899 if (delegation == NULL)
900 return 0;
897 if ((delegation->type & fmode) != fmode) 901 if ((delegation->type & fmode) != fmode)
898 return 0; 902 return 0;
899 if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags)) 903 if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))
@@ -1036,8 +1040,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
1036 } 1040 }
1037 rcu_read_lock(); 1041 rcu_read_lock();
1038 delegation = rcu_dereference(nfsi->delegation); 1042 delegation = rcu_dereference(nfsi->delegation);
1039 if (delegation == NULL || 1043 if (!can_open_delegated(delegation, fmode)) {
1040 !can_open_delegated(delegation, fmode)) {
1041 rcu_read_unlock(); 1044 rcu_read_unlock();
1042 break; 1045 break;
1043 } 1046 }
@@ -1091,7 +1094,12 @@ static struct nfs4_state *nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data
1091 if (delegation) 1094 if (delegation)
1092 delegation_flags = delegation->flags; 1095 delegation_flags = delegation->flags;
1093 rcu_read_unlock(); 1096 rcu_read_unlock();
1094 if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0) 1097 if (data->o_arg.claim == NFS4_OPEN_CLAIM_DELEGATE_CUR) {
1098 pr_err_ratelimited("NFS: Broken NFSv4 server %s is "
1099 "returning a delegation for "
1100 "OPEN(CLAIM_DELEGATE_CUR)\n",
1101 NFS_CLIENT(inode)->cl_server);
1102 } else if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0)
1095 nfs_inode_set_delegation(state->inode, 1103 nfs_inode_set_delegation(state->inode,
1096 data->owner->so_cred, 1104 data->owner->so_cred,
1097 &data->o_res); 1105 &data->o_res);
@@ -1423,11 +1431,9 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
1423 goto out_no_action; 1431 goto out_no_action;
1424 rcu_read_lock(); 1432 rcu_read_lock();
1425 delegation = rcu_dereference(NFS_I(data->state->inode)->delegation); 1433 delegation = rcu_dereference(NFS_I(data->state->inode)->delegation);
1426 if (delegation != NULL && 1434 if (data->o_arg.claim != NFS4_OPEN_CLAIM_DELEGATE_CUR &&
1427 test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) == 0) { 1435 can_open_delegated(delegation, data->o_arg.fmode))
1428 rcu_read_unlock(); 1436 goto unlock_no_action;
1429 goto out_no_action;
1430 }
1431 rcu_read_unlock(); 1437 rcu_read_unlock();
1432 } 1438 }
1433 /* Update sequence id. */ 1439 /* Update sequence id. */
@@ -1444,6 +1450,8 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
1444 return; 1450 return;
1445 rpc_call_start(task); 1451 rpc_call_start(task);
1446 return; 1452 return;
1453unlock_no_action:
1454 rcu_read_unlock();
1447out_no_action: 1455out_no_action:
1448 task->tk_action = NULL; 1456 task->tk_action = NULL;
1449 1457
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 39914be40b0..6a7107ae6b7 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1156,11 +1156,13 @@ restart:
1156 if (status >= 0) { 1156 if (status >= 0) {
1157 status = nfs4_reclaim_locks(state, ops); 1157 status = nfs4_reclaim_locks(state, ops);
1158 if (status >= 0) { 1158 if (status >= 0) {
1159 spin_lock(&state->state_lock);
1159 list_for_each_entry(lock, &state->lock_states, ls_locks) { 1160 list_for_each_entry(lock, &state->lock_states, ls_locks) {
1160 if (!(lock->ls_flags & NFS_LOCK_INITIALIZED)) 1161 if (!(lock->ls_flags & NFS_LOCK_INITIALIZED))
1161 printk("%s: Lock reclaim failed!\n", 1162 printk("%s: Lock reclaim failed!\n",
1162 __func__); 1163 __func__);
1163 } 1164 }
1165 spin_unlock(&state->state_lock);
1164 nfs4_put_open_state(state); 1166 nfs4_put_open_state(state);
1165 goto restart; 1167 goto restart;
1166 } 1168 }
@@ -1224,10 +1226,12 @@ static void nfs4_clear_open_state(struct nfs4_state *state)
1224 clear_bit(NFS_O_RDONLY_STATE, &state->flags); 1226 clear_bit(NFS_O_RDONLY_STATE, &state->flags);
1225 clear_bit(NFS_O_WRONLY_STATE, &state->flags); 1227 clear_bit(NFS_O_WRONLY_STATE, &state->flags);
1226 clear_bit(NFS_O_RDWR_STATE, &state->flags); 1228 clear_bit(NFS_O_RDWR_STATE, &state->flags);
1229 spin_lock(&state->state_lock);
1227 list_for_each_entry(lock, &state->lock_states, ls_locks) { 1230 list_for_each_entry(lock, &state->lock_states, ls_locks) {
1228 lock->ls_seqid.flags = 0; 1231 lock->ls_seqid.flags = 0;
1229 lock->ls_flags &= ~NFS_LOCK_INITIALIZED; 1232 lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
1230 } 1233 }
1234 spin_unlock(&state->state_lock);
1231} 1235}
1232 1236
1233static void nfs4_reset_seqids(struct nfs_server *server, 1237static void nfs4_reset_seqids(struct nfs_server *server,
@@ -1350,12 +1354,14 @@ static void nfs4_warn_keyexpired(const char *s)
1350static int nfs4_recovery_handle_error(struct nfs_client *clp, int error) 1354static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1351{ 1355{
1352 switch (error) { 1356 switch (error) {
1357 case 0:
1358 break;
1353 case -NFS4ERR_CB_PATH_DOWN: 1359 case -NFS4ERR_CB_PATH_DOWN:
1354 nfs_handle_cb_pathdown(clp); 1360 nfs_handle_cb_pathdown(clp);
1355 return 0; 1361 break;
1356 case -NFS4ERR_NO_GRACE: 1362 case -NFS4ERR_NO_GRACE:
1357 nfs4_state_end_reclaim_reboot(clp); 1363 nfs4_state_end_reclaim_reboot(clp);
1358 return 0; 1364 break;
1359 case -NFS4ERR_STALE_CLIENTID: 1365 case -NFS4ERR_STALE_CLIENTID:
1360 case -NFS4ERR_LEASE_MOVED: 1366 case -NFS4ERR_LEASE_MOVED:
1361 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); 1367 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
@@ -1375,13 +1381,15 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
1375 case -NFS4ERR_SEQ_MISORDERED: 1381 case -NFS4ERR_SEQ_MISORDERED:
1376 set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); 1382 set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
1377 /* Zero session reset errors */ 1383 /* Zero session reset errors */
1378 return 0; 1384 break;
1379 case -EKEYEXPIRED: 1385 case -EKEYEXPIRED:
1380 /* Nothing we can do */ 1386 /* Nothing we can do */
1381 nfs4_warn_keyexpired(clp->cl_hostname); 1387 nfs4_warn_keyexpired(clp->cl_hostname);
1382 return 0; 1388 break;
1389 default:
1390 return error;
1383 } 1391 }
1384 return error; 1392 return 0;
1385} 1393}
1386 1394
1387static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) 1395static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops)
@@ -1428,7 +1436,7 @@ static int nfs4_check_lease(struct nfs_client *clp)
1428 struct rpc_cred *cred; 1436 struct rpc_cred *cred;
1429 const struct nfs4_state_maintenance_ops *ops = 1437 const struct nfs4_state_maintenance_ops *ops =
1430 clp->cl_mvops->state_renewal_ops; 1438 clp->cl_mvops->state_renewal_ops;
1431 int status = -NFS4ERR_EXPIRED; 1439 int status;
1432 1440
1433 /* Is the client already known to have an expired lease? */ 1441 /* Is the client already known to have an expired lease? */
1434 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) 1442 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
@@ -1438,6 +1446,7 @@ static int nfs4_check_lease(struct nfs_client *clp)
1438 spin_unlock(&clp->cl_lock); 1446 spin_unlock(&clp->cl_lock);
1439 if (cred == NULL) { 1447 if (cred == NULL) {
1440 cred = nfs4_get_setclientid_cred(clp); 1448 cred = nfs4_get_setclientid_cred(clp);
1449 status = -ENOKEY;
1441 if (cred == NULL) 1450 if (cred == NULL)
1442 goto out; 1451 goto out;
1443 } 1452 }
@@ -1525,16 +1534,16 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
1525{ 1534{
1526 if (!flags) 1535 if (!flags)
1527 return; 1536 return;
1528 else if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) 1537 if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED)
1529 nfs41_handle_server_reboot(clp); 1538 nfs41_handle_server_reboot(clp);
1530 else if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED | 1539 if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED |
1531 SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED | 1540 SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED |
1532 SEQ4_STATUS_ADMIN_STATE_REVOKED | 1541 SEQ4_STATUS_ADMIN_STATE_REVOKED |
1533 SEQ4_STATUS_LEASE_MOVED)) 1542 SEQ4_STATUS_LEASE_MOVED))
1534 nfs41_handle_state_revoked(clp); 1543 nfs41_handle_state_revoked(clp);
1535 else if (flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED) 1544 if (flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED)
1536 nfs41_handle_recallable_state_revoked(clp); 1545 nfs41_handle_recallable_state_revoked(clp);
1537 else if (flags & (SEQ4_STATUS_CB_PATH_DOWN | 1546 if (flags & (SEQ4_STATUS_CB_PATH_DOWN |
1538 SEQ4_STATUS_BACKCHANNEL_FAULT | 1547 SEQ4_STATUS_BACKCHANNEL_FAULT |
1539 SEQ4_STATUS_CB_PATH_DOWN_SESSION)) 1548 SEQ4_STATUS_CB_PATH_DOWN_SESSION))
1540 nfs41_handle_cb_path_down(clp); 1549 nfs41_handle_cb_path_down(clp);
@@ -1662,10 +1671,10 @@ static void nfs4_state_manager(struct nfs_client *clp)
1662 1671
1663 if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { 1672 if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) {
1664 status = nfs4_check_lease(clp); 1673 status = nfs4_check_lease(clp);
1674 if (status < 0)
1675 goto out_error;
1665 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) 1676 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1666 continue; 1677 continue;
1667 if (status < 0 && status != -NFS4ERR_CB_PATH_DOWN)
1668 goto out_error;
1669 } 1678 }
1670 1679
1671 /* Initialize or reset the session */ 1680 /* Initialize or reset the session */
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 41d6743d303..ac258beeda3 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -625,6 +625,9 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
625 if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment) 625 if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment)
626 goto out_free; 626 goto out_free;
627 627
628 if (argv[n].v_nmembs >= UINT_MAX / argv[n].v_size)
629 goto out_free;
630
628 len = argv[n].v_size * argv[n].v_nmembs; 631 len = argv[n].v_size * argv[n].v_nmembs;
629 base = (void __user *)(unsigned long)argv[n].v_base; 632 base = (void __user *)(unsigned long)argv[n].v_base;
630 if (len == 0) { 633 if (len == 0) {
@@ -842,6 +845,19 @@ long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
842 case FS_IOC32_GETVERSION: 845 case FS_IOC32_GETVERSION:
843 cmd = FS_IOC_GETVERSION; 846 cmd = FS_IOC_GETVERSION;
844 break; 847 break;
848 case NILFS_IOCTL_CHANGE_CPMODE:
849 case NILFS_IOCTL_DELETE_CHECKPOINT:
850 case NILFS_IOCTL_GET_CPINFO:
851 case NILFS_IOCTL_GET_CPSTAT:
852 case NILFS_IOCTL_GET_SUINFO:
853 case NILFS_IOCTL_GET_SUSTAT:
854 case NILFS_IOCTL_GET_VINFO:
855 case NILFS_IOCTL_GET_BDESCS:
856 case NILFS_IOCTL_CLEAN_SEGMENTS:
857 case NILFS_IOCTL_SYNC:
858 case NILFS_IOCTL_RESIZE:
859 case NILFS_IOCTL_SET_ALLOC_RANGE:
860 break;
845 default: 861 default:
846 return -ENOIOCTLCMD; 862 return -ENOIOCTLCMD;
847 } 863 }
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index 2a30d67dd6b..0855e6f2039 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -32,7 +32,7 @@ static cputime64_t get_idle_time(int cpu)
32 idle = kstat_cpu(cpu).cpustat.idle; 32 idle = kstat_cpu(cpu).cpustat.idle;
33 idle = cputime64_add(idle, arch_idle_time(cpu)); 33 idle = cputime64_add(idle, arch_idle_time(cpu));
34 } else 34 } else
35 idle = nsecs_to_jiffies64(1000 * idle_time); 35 idle = usecs_to_cputime64(idle_time);
36 36
37 return idle; 37 return idle;
38} 38}
@@ -46,7 +46,7 @@ static cputime64_t get_iowait_time(int cpu)
46 /* !NO_HZ so we can rely on cpustat.iowait */ 46 /* !NO_HZ so we can rely on cpustat.iowait */
47 iowait = kstat_cpu(cpu).cpustat.iowait; 47 iowait = kstat_cpu(cpu).cpustat.iowait;
48 else 48 else
49 iowait = nsecs_to_jiffies64(1000 * iowait_time); 49 iowait = usecs_to_cputime64(iowait_time);
50 50
51 return iowait; 51 return iowait;
52} 52}
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 3eca58f51ae..8a899496fd5 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -869,27 +869,6 @@ xfs_fs_dirty_inode(
869} 869}
870 870
871STATIC int 871STATIC int
872xfs_log_inode(
873 struct xfs_inode *ip)
874{
875 struct xfs_mount *mp = ip->i_mount;
876 struct xfs_trans *tp;
877 int error;
878
879 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
880 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);
881 if (error) {
882 xfs_trans_cancel(tp, 0);
883 return error;
884 }
885
886 xfs_ilock(ip, XFS_ILOCK_EXCL);
887 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
888 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
889 return xfs_trans_commit(tp, 0);
890}
891
892STATIC int
893xfs_fs_write_inode( 872xfs_fs_write_inode(
894 struct inode *inode, 873 struct inode *inode,
895 struct writeback_control *wbc) 874 struct writeback_control *wbc)
@@ -902,10 +881,8 @@ xfs_fs_write_inode(
902 881
903 if (XFS_FORCED_SHUTDOWN(mp)) 882 if (XFS_FORCED_SHUTDOWN(mp))
904 return -XFS_ERROR(EIO); 883 return -XFS_ERROR(EIO);
905 if (!ip->i_update_core)
906 return 0;
907 884
908 if (wbc->sync_mode == WB_SYNC_ALL) { 885 if (wbc->sync_mode == WB_SYNC_ALL || wbc->for_kupdate) {
909 /* 886 /*
910 * Make sure the inode has made it it into the log. Instead 887 * Make sure the inode has made it it into the log. Instead
911 * of forcing it all the way to stable storage using a 888 * of forcing it all the way to stable storage using a
@@ -913,11 +890,14 @@ xfs_fs_write_inode(
913 * ->sync_fs call do that for thus, which reduces the number 890 * ->sync_fs call do that for thus, which reduces the number
914 * of synchronous log forces dramatically. 891 * of synchronous log forces dramatically.
915 */ 892 */
916 error = xfs_log_inode(ip); 893 error = xfs_log_dirty_inode(ip, NULL, 0);
917 if (error) 894 if (error)
918 goto out; 895 goto out;
919 return 0; 896 return 0;
920 } else { 897 } else {
898 if (!ip->i_update_core)
899 return 0;
900
921 /* 901 /*
922 * We make this non-blocking if the inode is contended, return 902 * We make this non-blocking if the inode is contended, return
923 * EAGAIN to indicate to the caller that they did not succeed. 903 * EAGAIN to indicate to the caller that they did not succeed.
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index be5c51d8f75..f0994aedcd1 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -336,6 +336,32 @@ xfs_sync_fsdata(
336 return error; 336 return error;
337} 337}
338 338
339int
340xfs_log_dirty_inode(
341 struct xfs_inode *ip,
342 struct xfs_perag *pag,
343 int flags)
344{
345 struct xfs_mount *mp = ip->i_mount;
346 struct xfs_trans *tp;
347 int error;
348
349 if (!ip->i_update_core)
350 return 0;
351
352 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
353 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);
354 if (error) {
355 xfs_trans_cancel(tp, 0);
356 return error;
357 }
358
359 xfs_ilock(ip, XFS_ILOCK_EXCL);
360 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
361 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
362 return xfs_trans_commit(tp, 0);
363}
364
339/* 365/*
340 * When remounting a filesystem read-only or freezing the filesystem, we have 366 * When remounting a filesystem read-only or freezing the filesystem, we have
341 * two phases to execute. This first phase is syncing the data before we 367 * two phases to execute. This first phase is syncing the data before we
@@ -359,6 +385,16 @@ xfs_quiesce_data(
359{ 385{
360 int error, error2 = 0; 386 int error, error2 = 0;
361 387
388 /*
389 * Log all pending size and timestamp updates. The vfs writeback
390 * code is supposed to do this, but due to its overagressive
391 * livelock detection it will skip inodes where appending writes
392 * were written out in the first non-blocking sync phase if their
393 * completion took long enough that it happened after taking the
394 * timestamp for the cut-off in the blocking phase.
395 */
396 xfs_inode_ag_iterator(mp, xfs_log_dirty_inode, 0);
397
362 xfs_qm_sync(mp, SYNC_TRYLOCK); 398 xfs_qm_sync(mp, SYNC_TRYLOCK);
363 xfs_qm_sync(mp, SYNC_WAIT); 399 xfs_qm_sync(mp, SYNC_WAIT);
364 400
diff --git a/fs/xfs/xfs_sync.h b/fs/xfs/xfs_sync.h
index 941202e7ac6..fa965479d78 100644
--- a/fs/xfs/xfs_sync.h
+++ b/fs/xfs/xfs_sync.h
@@ -34,6 +34,8 @@ void xfs_quiesce_attr(struct xfs_mount *mp);
34 34
35void xfs_flush_inodes(struct xfs_inode *ip); 35void xfs_flush_inodes(struct xfs_inode *ip);
36 36
37int xfs_log_dirty_inode(struct xfs_inode *ip, struct xfs_perag *pag, int flags);
38
37int xfs_reclaim_inodes(struct xfs_mount *mp, int mode); 39int xfs_reclaim_inodes(struct xfs_mount *mp, int mode);
38int xfs_reclaim_inodes_count(struct xfs_mount *mp); 40int xfs_reclaim_inodes_count(struct xfs_mount *mp);
39void xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan); 41void xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan);
diff --git a/include/asm-generic/cputime.h b/include/asm-generic/cputime.h
index 62ce6823c0f..12a1764f612 100644
--- a/include/asm-generic/cputime.h
+++ b/include/asm-generic/cputime.h
@@ -40,6 +40,7 @@ typedef u64 cputime64_t;
40 */ 40 */
41#define cputime_to_usecs(__ct) jiffies_to_usecs(__ct) 41#define cputime_to_usecs(__ct) jiffies_to_usecs(__ct)
42#define usecs_to_cputime(__msecs) usecs_to_jiffies(__msecs) 42#define usecs_to_cputime(__msecs) usecs_to_jiffies(__msecs)
43#define usecs_to_cputime64(__msecs) nsecs_to_jiffies64((__msecs) * 1000)
43 44
44/* 45/*
45 * Convert cputime to seconds and back. 46 * Convert cputime to seconds and back.
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index c86c940d1de..081147da056 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -71,7 +71,7 @@ struct timecounter {
71 71
72/** 72/**
73 * cyclecounter_cyc2ns - converts cycle counter cycles to nanoseconds 73 * cyclecounter_cyc2ns - converts cycle counter cycles to nanoseconds
74 * @tc: Pointer to cycle counter. 74 * @cc: Pointer to cycle counter.
75 * @cycles: Cycles 75 * @cycles: Cycles
76 * 76 *
77 * XXX - This could use some mult_lxl_ll() asm optimization. Same code 77 * XXX - This could use some mult_lxl_ll() asm optimization. Same code
@@ -114,7 +114,7 @@ extern u64 timecounter_read(struct timecounter *tc);
114 * time base as values returned by 114 * time base as values returned by
115 * timecounter_read() 115 * timecounter_read()
116 * @tc: Pointer to time counter. 116 * @tc: Pointer to time counter.
117 * @cycle: a value returned by tc->cc->read() 117 * @cycle_tstamp: a value returned by tc->cc->read()
118 * 118 *
119 * Cycle counts that are converted correctly as long as they 119 * Cycle counts that are converted correctly as long as they
120 * fall into the interval [-1/2 max cycle count, +1/2 max cycle count], 120 * fall into the interval [-1/2 max cycle count, +1/2 max cycle count],
@@ -156,11 +156,12 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
156 * @mult: cycle to nanosecond multiplier 156 * @mult: cycle to nanosecond multiplier
157 * @shift: cycle to nanosecond divisor (power of two) 157 * @shift: cycle to nanosecond divisor (power of two)
158 * @max_idle_ns: max idle time permitted by the clocksource (nsecs) 158 * @max_idle_ns: max idle time permitted by the clocksource (nsecs)
159 * @maxadj maximum adjustment value to mult (~11%) 159 * @maxadj: maximum adjustment value to mult (~11%)
160 * @flags: flags describing special properties 160 * @flags: flags describing special properties
161 * @archdata: arch-specific data 161 * @archdata: arch-specific data
162 * @suspend: suspend function for the clocksource, if necessary 162 * @suspend: suspend function for the clocksource, if necessary
163 * @resume: resume function for the clocksource, if necessary 163 * @resume: resume function for the clocksource, if necessary
164 * @cycle_last: most recent cycle counter value seen by ::read()
164 */ 165 */
165struct clocksource { 166struct clocksource {
166 /* 167 /*
@@ -187,6 +188,7 @@ struct clocksource {
187 void (*suspend)(struct clocksource *cs); 188 void (*suspend)(struct clocksource *cs);
188 void (*resume)(struct clocksource *cs); 189 void (*resume)(struct clocksource *cs);
189 190
191 /* private: */
190#ifdef CONFIG_CLOCKSOURCE_WATCHDOG 192#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
191 /* Watchdog related data, used by the framework */ 193 /* Watchdog related data, used by the framework */
192 struct list_head wd_list; 194 struct list_head wd_list;
@@ -261,6 +263,9 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
261 263
262/** 264/**
263 * clocksource_cyc2ns - converts clocksource cycles to nanoseconds 265 * clocksource_cyc2ns - converts clocksource cycles to nanoseconds
266 * @cycles: cycles
267 * @mult: cycle to nanosecond multiplier
268 * @shift: cycle to nanosecond divisor (power of two)
264 * 269 *
265 * Converts cycles to nanoseconds, using the given mult and shift. 270 * Converts cycles to nanoseconds, using the given mult and shift.
266 * 271 *
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c3892fc1d53..68e67e50d02 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
557#define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 557#define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */
558#define KVM_CAP_PPC_PAPR 68 558#define KVM_CAP_PPC_PAPR 68
559#define KVM_CAP_S390_GMAP 71 559#define KVM_CAP_S390_GMAP 71
560#define KVM_CAP_TSC_DEADLINE_TIMER 72
560 561
561#ifdef KVM_CAP_IRQ_ROUTING 562#ifdef KVM_CAP_IRQ_ROUTING
562 563
diff --git a/include/linux/lglock.h b/include/linux/lglock.h
index f549056fb20..87f402ccec5 100644
--- a/include/linux/lglock.h
+++ b/include/linux/lglock.h
@@ -22,6 +22,7 @@
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/lockdep.h> 23#include <linux/lockdep.h>
24#include <linux/percpu.h> 24#include <linux/percpu.h>
25#include <linux/cpu.h>
25 26
26/* can make br locks by using local lock for read side, global lock for write */ 27/* can make br locks by using local lock for read side, global lock for write */
27#define br_lock_init(name) name##_lock_init() 28#define br_lock_init(name) name##_lock_init()
@@ -72,9 +73,31 @@
72 73
73#define DEFINE_LGLOCK(name) \ 74#define DEFINE_LGLOCK(name) \
74 \ 75 \
76 DEFINE_SPINLOCK(name##_cpu_lock); \
77 cpumask_t name##_cpus __read_mostly; \
75 DEFINE_PER_CPU(arch_spinlock_t, name##_lock); \ 78 DEFINE_PER_CPU(arch_spinlock_t, name##_lock); \
76 DEFINE_LGLOCK_LOCKDEP(name); \ 79 DEFINE_LGLOCK_LOCKDEP(name); \
77 \ 80 \
81 static int \
82 name##_lg_cpu_callback(struct notifier_block *nb, \
83 unsigned long action, void *hcpu) \
84 { \
85 switch (action & ~CPU_TASKS_FROZEN) { \
86 case CPU_UP_PREPARE: \
87 spin_lock(&name##_cpu_lock); \
88 cpu_set((unsigned long)hcpu, name##_cpus); \
89 spin_unlock(&name##_cpu_lock); \
90 break; \
91 case CPU_UP_CANCELED: case CPU_DEAD: \
92 spin_lock(&name##_cpu_lock); \
93 cpu_clear((unsigned long)hcpu, name##_cpus); \
94 spin_unlock(&name##_cpu_lock); \
95 } \
96 return NOTIFY_OK; \
97 } \
98 static struct notifier_block name##_lg_cpu_notifier = { \
99 .notifier_call = name##_lg_cpu_callback, \
100 }; \
78 void name##_lock_init(void) { \ 101 void name##_lock_init(void) { \
79 int i; \ 102 int i; \
80 LOCKDEP_INIT_MAP(&name##_lock_dep_map, #name, &name##_lock_key, 0); \ 103 LOCKDEP_INIT_MAP(&name##_lock_dep_map, #name, &name##_lock_key, 0); \
@@ -83,6 +106,11 @@
83 lock = &per_cpu(name##_lock, i); \ 106 lock = &per_cpu(name##_lock, i); \
84 *lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; \ 107 *lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; \
85 } \ 108 } \
109 register_hotcpu_notifier(&name##_lg_cpu_notifier); \
110 get_online_cpus(); \
111 for_each_online_cpu(i) \
112 cpu_set(i, name##_cpus); \
113 put_online_cpus(); \
86 } \ 114 } \
87 EXPORT_SYMBOL(name##_lock_init); \ 115 EXPORT_SYMBOL(name##_lock_init); \
88 \ 116 \
@@ -124,9 +152,9 @@
124 \ 152 \
125 void name##_global_lock_online(void) { \ 153 void name##_global_lock_online(void) { \
126 int i; \ 154 int i; \
127 preempt_disable(); \ 155 spin_lock(&name##_cpu_lock); \
128 rwlock_acquire(&name##_lock_dep_map, 0, 0, _RET_IP_); \ 156 rwlock_acquire(&name##_lock_dep_map, 0, 0, _RET_IP_); \
129 for_each_online_cpu(i) { \ 157 for_each_cpu(i, &name##_cpus) { \
130 arch_spinlock_t *lock; \ 158 arch_spinlock_t *lock; \
131 lock = &per_cpu(name##_lock, i); \ 159 lock = &per_cpu(name##_lock, i); \
132 arch_spin_lock(lock); \ 160 arch_spin_lock(lock); \
@@ -137,12 +165,12 @@
137 void name##_global_unlock_online(void) { \ 165 void name##_global_unlock_online(void) { \
138 int i; \ 166 int i; \
139 rwlock_release(&name##_lock_dep_map, 1, _RET_IP_); \ 167 rwlock_release(&name##_lock_dep_map, 1, _RET_IP_); \
140 for_each_online_cpu(i) { \ 168 for_each_cpu(i, &name##_cpus) { \
141 arch_spinlock_t *lock; \ 169 arch_spinlock_t *lock; \
142 lock = &per_cpu(name##_lock, i); \ 170 lock = &per_cpu(name##_lock, i); \
143 arch_spin_unlock(lock); \ 171 arch_spin_unlock(lock); \
144 } \ 172 } \
145 preempt_enable(); \ 173 spin_unlock(&name##_cpu_lock); \
146 } \ 174 } \
147 EXPORT_SYMBOL(name##_global_unlock_online); \ 175 EXPORT_SYMBOL(name##_global_unlock_online); \
148 \ 176 \
diff --git a/include/linux/security.h b/include/linux/security.h
index 19d8e04e168..e8c619d3929 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -2056,7 +2056,7 @@ static inline int security_old_inode_init_security(struct inode *inode,
2056 char **name, void **value, 2056 char **name, void **value,
2057 size_t *len) 2057 size_t *len)
2058{ 2058{
2059 return 0; 2059 return -EOPNOTSUPP;
2060} 2060}
2061 2061
2062static inline int security_inode_create(struct inode *dir, 2062static inline int security_inode_create(struct inode *dir,
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index b1377b931eb..5fb2c3d10c0 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -254,7 +254,7 @@ unsigned long soc_camera_apply_board_flags(struct soc_camera_link *icl,
254static inline struct video_device *soc_camera_i2c_to_vdev(const struct i2c_client *client) 254static inline struct video_device *soc_camera_i2c_to_vdev(const struct i2c_client *client)
255{ 255{
256 struct v4l2_subdev *sd = i2c_get_clientdata(client); 256 struct v4l2_subdev *sd = i2c_get_clientdata(client);
257 struct soc_camera_device *icd = (struct soc_camera_device *)sd->grp_id; 257 struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd);
258 return icd ? icd->vdev : NULL; 258 return icd ? icd->vdev : NULL;
259} 259}
260 260
@@ -279,6 +279,11 @@ static inline struct soc_camera_device *soc_camera_from_vbq(const struct videobu
279 return container_of(vq, struct soc_camera_device, vb_vidq); 279 return container_of(vq, struct soc_camera_device, vb_vidq);
280} 280}
281 281
282static inline u32 soc_camera_grp_id(const struct soc_camera_device *icd)
283{
284 return (icd->iface << 8) | (icd->devnum + 1);
285}
286
282void soc_camera_lock(struct vb2_queue *vq); 287void soc_camera_lock(struct vb2_queue *vq);
283void soc_camera_unlock(struct vb2_queue *vq); 288void soc_camera_unlock(struct vb2_queue *vq);
284 289
diff --git a/include/net/dst.h b/include/net/dst.h
index 6faec1a6021..75766b42660 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -53,6 +53,7 @@ struct dst_entry {
53#define DST_NOHASH 0x0008 53#define DST_NOHASH 0x0008
54#define DST_NOCACHE 0x0010 54#define DST_NOCACHE 0x0010
55#define DST_NOCOUNT 0x0020 55#define DST_NOCOUNT 0x0020
56#define DST_NOPEER 0x0040
56 57
57 short error; 58 short error;
58 short obsolete; 59 short obsolete;
diff --git a/include/net/flow.h b/include/net/flow.h
index a09447749e2..57f15a7f1cd 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -207,6 +207,7 @@ extern struct flow_cache_object *flow_cache_lookup(
207 u8 dir, flow_resolve_t resolver, void *ctx); 207 u8 dir, flow_resolve_t resolver, void *ctx);
208 208
209extern void flow_cache_flush(void); 209extern void flow_cache_flush(void);
210extern void flow_cache_flush_deferred(void);
210extern atomic_t flow_cache_genid; 211extern atomic_t flow_cache_genid;
211 212
212#endif 213#endif
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 873d5be7926..e5a7b9aaf55 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1207,7 +1207,7 @@ extern void ip_vs_control_cleanup(void);
1207extern struct ip_vs_dest * 1207extern struct ip_vs_dest *
1208ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, 1208ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr,
1209 __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, 1209 __be16 dport, const union nf_inet_addr *vaddr, __be16 vport,
1210 __u16 protocol, __u32 fwmark); 1210 __u16 protocol, __u32 fwmark, __u32 flags);
1211extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); 1211extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
1212 1212
1213 1213
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index e90e7a9935d..a15432da27c 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -241,6 +241,9 @@ extern struct sctp_globals {
241 * bits is an indicator of when to send and window update SACK. 241 * bits is an indicator of when to send and window update SACK.
242 */ 242 */
243 int rwnd_update_shift; 243 int rwnd_update_shift;
244
245 /* Threshold for autoclose timeout, in seconds. */
246 unsigned long max_autoclose;
244} sctp_globals; 247} sctp_globals;
245 248
246#define sctp_rto_initial (sctp_globals.rto_initial) 249#define sctp_rto_initial (sctp_globals.rto_initial)
@@ -281,6 +284,7 @@ extern struct sctp_globals {
281#define sctp_auth_enable (sctp_globals.auth_enable) 284#define sctp_auth_enable (sctp_globals.auth_enable)
282#define sctp_checksum_disable (sctp_globals.checksum_disable) 285#define sctp_checksum_disable (sctp_globals.checksum_disable)
283#define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift) 286#define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift)
287#define sctp_max_autoclose (sctp_globals.max_autoclose)
284 288
285/* SCTP Socket type: UDP or TCP style. */ 289/* SCTP Socket type: UDP or TCP style. */
286typedef enum { 290typedef enum {
diff --git a/include/net/sock.h b/include/net/sock.h
index abb6e0f0c3c..32e39371fba 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -637,12 +637,14 @@ static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
637 637
638/* 638/*
639 * Take into account size of receive queue and backlog queue 639 * Take into account size of receive queue and backlog queue
640 * Do not take into account this skb truesize,
641 * to allow even a single big packet to come.
640 */ 642 */
641static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb) 643static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb)
642{ 644{
643 unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc); 645 unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc);
644 646
645 return qsize + skb->truesize > sk->sk_rcvbuf; 647 return qsize > sk->sk_rcvbuf;
646} 648}
647 649
648/* The per-socket spinlock must be held here. */ 650/* The per-socket spinlock must be held here. */
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index d1e95c6ac77..5a35a2a2d3c 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -147,6 +147,7 @@ struct fcoe_ctlr {
147 u8 map_dest; 147 u8 map_dest;
148 u8 spma; 148 u8 spma;
149 u8 probe_tries; 149 u8 probe_tries;
150 u8 priority;
150 u8 dest_addr[ETH_ALEN]; 151 u8 dest_addr[ETH_ALEN];
151 u8 ctl_src_addr[ETH_ALEN]; 152 u8 ctl_src_addr[ETH_ALEN];
152 153
@@ -301,6 +302,7 @@ struct fcoe_percpu_s {
301 * @lport: The associated local port 302 * @lport: The associated local port
302 * @fcoe_pending_queue: The pending Rx queue of skbs 303 * @fcoe_pending_queue: The pending Rx queue of skbs
303 * @fcoe_pending_queue_active: Indicates if the pending queue is active 304 * @fcoe_pending_queue_active: Indicates if the pending queue is active
305 * @priority: Packet priority (DCB)
304 * @max_queue_depth: Max queue depth of pending queue 306 * @max_queue_depth: Max queue depth of pending queue
305 * @min_queue_depth: Min queue depth of pending queue 307 * @min_queue_depth: Min queue depth of pending queue
306 * @timer: The queue timer 308 * @timer: The queue timer
@@ -316,6 +318,7 @@ struct fcoe_port {
316 struct fc_lport *lport; 318 struct fc_lport *lport;
317 struct sk_buff_head fcoe_pending_queue; 319 struct sk_buff_head fcoe_pending_queue;
318 u8 fcoe_pending_queue_active; 320 u8 fcoe_pending_queue_active;
321 u8 priority;
319 u32 max_queue_depth; 322 u32 max_queue_depth;
320 u32 min_queue_depth; 323 u32 min_queue_depth;
321 struct timer_list timer; 324 struct timer_list timer;
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index b99caa8b780..99d1d0decf8 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -21,6 +21,16 @@
21 {I_REFERENCED, "I_REFERENCED"} \ 21 {I_REFERENCED, "I_REFERENCED"} \
22 ) 22 )
23 23
24#define WB_WORK_REASON \
25 {WB_REASON_BACKGROUND, "background"}, \
26 {WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages"}, \
27 {WB_REASON_SYNC, "sync"}, \
28 {WB_REASON_PERIODIC, "periodic"}, \
29 {WB_REASON_LAPTOP_TIMER, "laptop_timer"}, \
30 {WB_REASON_FREE_MORE_MEM, "free_more_memory"}, \
31 {WB_REASON_FS_FREE_SPACE, "fs_free_space"}, \
32 {WB_REASON_FORKER_THREAD, "forker_thread"}
33
24struct wb_writeback_work; 34struct wb_writeback_work;
25 35
26DECLARE_EVENT_CLASS(writeback_work_class, 36DECLARE_EVENT_CLASS(writeback_work_class,
@@ -55,7 +65,7 @@ DECLARE_EVENT_CLASS(writeback_work_class,
55 __entry->for_kupdate, 65 __entry->for_kupdate,
56 __entry->range_cyclic, 66 __entry->range_cyclic,
57 __entry->for_background, 67 __entry->for_background,
58 wb_reason_name[__entry->reason] 68 __print_symbolic(__entry->reason, WB_WORK_REASON)
59 ) 69 )
60); 70);
61#define DEFINE_WRITEBACK_WORK_EVENT(name) \ 71#define DEFINE_WRITEBACK_WORK_EVENT(name) \
@@ -184,7 +194,8 @@ TRACE_EVENT(writeback_queue_io,
184 __entry->older, /* older_than_this in jiffies */ 194 __entry->older, /* older_than_this in jiffies */
185 __entry->age, /* older_than_this in relative milliseconds */ 195 __entry->age, /* older_than_this in relative milliseconds */
186 __entry->moved, 196 __entry->moved,
187 wb_reason_name[__entry->reason]) 197 __print_symbolic(__entry->reason, WB_WORK_REASON)
198 )
188); 199);
189 200
190TRACE_EVENT(global_dirty_state, 201TRACE_EVENT(global_dirty_state,
diff --git a/include/xen/interface/io/xs_wire.h b/include/xen/interface/io/xs_wire.h
index f0b6890370b..f6f07aa35af 100644
--- a/include/xen/interface/io/xs_wire.h
+++ b/include/xen/interface/io/xs_wire.h
@@ -29,8 +29,7 @@ enum xsd_sockmsg_type
29 XS_IS_DOMAIN_INTRODUCED, 29 XS_IS_DOMAIN_INTRODUCED,
30 XS_RESUME, 30 XS_RESUME,
31 XS_SET_TARGET, 31 XS_SET_TARGET,
32 XS_RESTRICT, 32 XS_RESTRICT
33 XS_RESET_WATCHES
34}; 33};
35 34
36#define XS_WRITE_NONE "NONE" 35#define XS_WRITE_NONE "NONE"
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index d9d5648f3cd..a184470cf9b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2098,11 +2098,6 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
2098 continue; 2098 continue;
2099 /* get old css_set pointer */ 2099 /* get old css_set pointer */
2100 task_lock(tsk); 2100 task_lock(tsk);
2101 if (tsk->flags & PF_EXITING) {
2102 /* ignore this task if it's going away */
2103 task_unlock(tsk);
2104 continue;
2105 }
2106 oldcg = tsk->cgroups; 2101 oldcg = tsk->cgroups;
2107 get_css_set(oldcg); 2102 get_css_set(oldcg);
2108 task_unlock(tsk); 2103 task_unlock(tsk);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9fe58c46a42..0b1712dba58 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -123,6 +123,19 @@ static inline struct cpuset *task_cs(struct task_struct *task)
123 struct cpuset, css); 123 struct cpuset, css);
124} 124}
125 125
126#ifdef CONFIG_NUMA
127static inline bool task_has_mempolicy(struct task_struct *task)
128{
129 return task->mempolicy;
130}
131#else
132static inline bool task_has_mempolicy(struct task_struct *task)
133{
134 return false;
135}
136#endif
137
138
126/* bits in struct cpuset flags field */ 139/* bits in struct cpuset flags field */
127typedef enum { 140typedef enum {
128 CS_CPU_EXCLUSIVE, 141 CS_CPU_EXCLUSIVE,
@@ -949,7 +962,7 @@ static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
949static void cpuset_change_task_nodemask(struct task_struct *tsk, 962static void cpuset_change_task_nodemask(struct task_struct *tsk,
950 nodemask_t *newmems) 963 nodemask_t *newmems)
951{ 964{
952 bool masks_disjoint = !nodes_intersects(*newmems, tsk->mems_allowed); 965 bool need_loop;
953 966
954repeat: 967repeat:
955 /* 968 /*
@@ -962,6 +975,14 @@ repeat:
962 return; 975 return;
963 976
964 task_lock(tsk); 977 task_lock(tsk);
978 /*
979 * Determine if a loop is necessary if another thread is doing
980 * get_mems_allowed(). If at least one node remains unchanged and
981 * tsk does not have a mempolicy, then an empty nodemask will not be
982 * possible when mems_allowed is larger than a word.
983 */
984 need_loop = task_has_mempolicy(tsk) ||
985 !nodes_intersects(*newmems, tsk->mems_allowed);
965 nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems); 986 nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
966 mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1); 987 mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1);
967 988
@@ -981,11 +1002,9 @@ repeat:
981 1002
982 /* 1003 /*
983 * Allocation of memory is very fast, we needn't sleep when waiting 1004 * Allocation of memory is very fast, we needn't sleep when waiting
984 * for the read-side. No wait is necessary, however, if at least one 1005 * for the read-side.
985 * node remains unchanged.
986 */ 1006 */
987 while (masks_disjoint && 1007 while (need_loop && ACCESS_ONCE(tsk->mems_allowed_change_disable)) {
988 ACCESS_ONCE(tsk->mems_allowed_change_disable)) {
989 task_unlock(tsk); 1008 task_unlock(tsk);
990 if (!task_curr(tsk)) 1009 if (!task_curr(tsk))
991 yield(); 1010 yield();
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2f8f3f103cb..24e3a4b1c89 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3360,9 +3360,13 @@ static void ring_buffer_wakeup(struct perf_event *event)
3360 3360
3361 rcu_read_lock(); 3361 rcu_read_lock();
3362 rb = rcu_dereference(event->rb); 3362 rb = rcu_dereference(event->rb);
3363 list_for_each_entry_rcu(event, &rb->event_list, rb_entry) { 3363 if (!rb)
3364 goto unlock;
3365
3366 list_for_each_entry_rcu(event, &rb->event_list, rb_entry)
3364 wake_up_all(&event->waitq); 3367 wake_up_all(&event->waitq);
3365 } 3368
3369unlock:
3366 rcu_read_unlock(); 3370 rcu_read_unlock();
3367} 3371}
3368 3372
diff --git a/kernel/exit.c b/kernel/exit.c
index d0b7d988f87..e6e01b959a0 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1540,8 +1540,15 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1540 } 1540 }
1541 1541
1542 /* dead body doesn't have much to contribute */ 1542 /* dead body doesn't have much to contribute */
1543 if (p->exit_state == EXIT_DEAD) 1543 if (unlikely(p->exit_state == EXIT_DEAD)) {
1544 /*
1545 * But do not ignore this task until the tracer does
1546 * wait_task_zombie()->do_notify_parent().
1547 */
1548 if (likely(!ptrace) && unlikely(ptrace_reparented(p)))
1549 wo->notask_error = 0;
1544 return 0; 1550 return 0;
1551 }
1545 1552
1546 /* slay zombie? */ 1553 /* slay zombie? */
1547 if (p->exit_state == EXIT_ZOMBIE) { 1554 if (p->exit_state == EXIT_ZOMBIE) {
diff --git a/kernel/futex.c b/kernel/futex.c
index ea87f4d2f45..1614be20173 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -314,17 +314,29 @@ again:
314#endif 314#endif
315 315
316 lock_page(page_head); 316 lock_page(page_head);
317
318 /*
319 * If page_head->mapping is NULL, then it cannot be a PageAnon
320 * page; but it might be the ZERO_PAGE or in the gate area or
321 * in a special mapping (all cases which we are happy to fail);
322 * or it may have been a good file page when get_user_pages_fast
323 * found it, but truncated or holepunched or subjected to
324 * invalidate_complete_page2 before we got the page lock (also
325 * cases which we are happy to fail). And we hold a reference,
326 * so refcount care in invalidate_complete_page's remove_mapping
327 * prevents drop_caches from setting mapping to NULL beneath us.
328 *
329 * The case we do have to guard against is when memory pressure made
330 * shmem_writepage move it from filecache to swapcache beneath us:
331 * an unlikely race, but we do need to retry for page_head->mapping.
332 */
317 if (!page_head->mapping) { 333 if (!page_head->mapping) {
334 int shmem_swizzled = PageSwapCache(page_head);
318 unlock_page(page_head); 335 unlock_page(page_head);
319 put_page(page_head); 336 put_page(page_head);
320 /* 337 if (shmem_swizzled)
321 * ZERO_PAGE pages don't have a mapping. Avoid a busy loop 338 goto again;
322 * trying to find one. RW mapping would have COW'd (and thus 339 return -EFAULT;
323 * have a mapping) so this page is RO and won't ever change.
324 */
325 if ((page_head == ZERO_PAGE(address)))
326 return -EFAULT;
327 goto again;
328 } 340 }
329 341
330 /* 342 /*
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 8b1748d0172..2e48ec0c2e9 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -74,11 +74,17 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
74 74
75 /* 75 /*
76 * Ensure the task is not frozen. 76 * Ensure the task is not frozen.
77 * Also, when a freshly created task is scheduled once, changes 77 * Also, skip vfork and any other user process that freezer should skip.
78 * its state to TASK_UNINTERRUPTIBLE without having ever been
79 * switched out once, it musn't be checked.
80 */ 78 */
81 if (unlikely(t->flags & PF_FROZEN || !switch_count)) 79 if (unlikely(t->flags & (PF_FROZEN | PF_FREEZER_SKIP)))
80 return;
81
82 /*
83 * When a freshly created task is scheduled once, changes its state to
84 * TASK_UNINTERRUPTIBLE without having ever been switched out once, it
85 * musn't be checked.
86 */
87 if (unlikely(!switch_count))
82 return; 88 return;
83 89
84 if (switch_count != t->last_switch_count) { 90 if (switch_count != t->last_switch_count) {
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 24d04477b25..78ab24a7b0e 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -96,9 +96,20 @@ void __ptrace_unlink(struct task_struct *child)
96 */ 96 */
97 if (!(child->flags & PF_EXITING) && 97 if (!(child->flags & PF_EXITING) &&
98 (child->signal->flags & SIGNAL_STOP_STOPPED || 98 (child->signal->flags & SIGNAL_STOP_STOPPED ||
99 child->signal->group_stop_count)) 99 child->signal->group_stop_count)) {
100 child->jobctl |= JOBCTL_STOP_PENDING; 100 child->jobctl |= JOBCTL_STOP_PENDING;
101 101
102 /*
103 * This is only possible if this thread was cloned by the
104 * traced task running in the stopped group, set the signal
105 * for the future reports.
106 * FIXME: we should change ptrace_init_task() to handle this
107 * case.
108 */
109 if (!(child->jobctl & JOBCTL_STOP_SIGMASK))
110 child->jobctl |= SIGSTOP;
111 }
112
102 /* 113 /*
103 * If transition to TASK_STOPPED is pending or in TASK_TRACED, kick 114 * If transition to TASK_STOPPED is pending or in TASK_TRACED, kick
104 * @child in the butt. Note that @resume should be used iff @child 115 * @child in the butt. Note that @resume should be used iff @child
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a78ed2736ba..8a39fa3e3c6 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -2352,13 +2352,11 @@ again:
2352 if (!smt && (sd->flags & SD_SHARE_CPUPOWER)) 2352 if (!smt && (sd->flags & SD_SHARE_CPUPOWER))
2353 continue; 2353 continue;
2354 2354
2355 if (!(sd->flags & SD_SHARE_PKG_RESOURCES)) { 2355 if (smt && !(sd->flags & SD_SHARE_CPUPOWER))
2356 if (!smt) { 2356 break;
2357 smt = 1; 2357
2358 goto again; 2358 if (!(sd->flags & SD_SHARE_PKG_RESOURCES))
2359 }
2360 break; 2359 break;
2361 }
2362 2360
2363 sg = sd->groups; 2361 sg = sd->groups;
2364 do { 2362 do {
@@ -2378,6 +2376,10 @@ next:
2378 sg = sg->next; 2376 sg = sg->next;
2379 } while (sg != sd->groups); 2377 } while (sg != sd->groups);
2380 } 2378 }
2379 if (!smt) {
2380 smt = 1;
2381 goto again;
2382 }
2381done: 2383done:
2382 rcu_read_unlock(); 2384 rcu_read_unlock();
2383 2385
diff --git a/kernel/signal.c b/kernel/signal.c
index b3f78d09a10..206551563cc 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1994,8 +1994,6 @@ static bool do_signal_stop(int signr)
1994 */ 1994 */
1995 if (!(sig->flags & SIGNAL_STOP_STOPPED)) 1995 if (!(sig->flags & SIGNAL_STOP_STOPPED))
1996 sig->group_exit_code = signr; 1996 sig->group_exit_code = signr;
1997 else
1998 WARN_ON_ONCE(!current->ptrace);
1999 1997
2000 sig->group_stop_count = 0; 1998 sig->group_stop_count = 0;
2001 1999
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 6318b511afa..a650694883a 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -1354,7 +1354,7 @@ static ssize_t binary_sysctl(const int *name, int nlen,
1354 1354
1355 fput(file); 1355 fput(file);
1356out_putname: 1356out_putname:
1357 putname(pathname); 1357 __putname(pathname);
1358out: 1358out:
1359 return result; 1359 return result;
1360} 1360}
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index c4eb71c8b2e..1ecd6ba36d6 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -387,7 +387,6 @@ void clockevents_exchange_device(struct clock_event_device *old,
387 * released list and do a notify add later. 387 * released list and do a notify add later.
388 */ 388 */
389 if (old) { 389 if (old) {
390 old->event_handler = clockevents_handle_noop;
391 clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED); 390 clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED);
392 list_del(&old->list); 391 list_del(&old->list);
393 list_add(&old->list, &clockevents_released); 392 list_add(&old->list, &clockevents_released);
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index da2f760e780..d3ad022136e 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -647,7 +647,7 @@ static void clocksource_enqueue(struct clocksource *cs)
647 647
648/** 648/**
649 * __clocksource_updatefreq_scale - Used update clocksource with new freq 649 * __clocksource_updatefreq_scale - Used update clocksource with new freq
650 * @t: clocksource to be registered 650 * @cs: clocksource to be registered
651 * @scale: Scale factor multiplied against freq to get clocksource hz 651 * @scale: Scale factor multiplied against freq to get clocksource hz
652 * @freq: clocksource frequency (cycles per second) divided by scale 652 * @freq: clocksource frequency (cycles per second) divided by scale
653 * 653 *
@@ -699,7 +699,7 @@ EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);
699 699
700/** 700/**
701 * __clocksource_register_scale - Used to install new clocksources 701 * __clocksource_register_scale - Used to install new clocksources
702 * @t: clocksource to be registered 702 * @cs: clocksource to be registered
703 * @scale: Scale factor multiplied against freq to get clocksource hz 703 * @scale: Scale factor multiplied against freq to get clocksource hz
704 * @freq: clocksource frequency (cycles per second) divided by scale 704 * @freq: clocksource frequency (cycles per second) divided by scale
705 * 705 *
@@ -727,7 +727,7 @@ EXPORT_SYMBOL_GPL(__clocksource_register_scale);
727 727
728/** 728/**
729 * clocksource_register - Used to install new clocksources 729 * clocksource_register - Used to install new clocksources
730 * @t: clocksource to be registered 730 * @cs: clocksource to be registered
731 * 731 *
732 * Returns -EBUSY if registration fails, zero otherwise. 732 * Returns -EBUSY if registration fails, zero otherwise.
733 */ 733 */
@@ -761,6 +761,8 @@ static void __clocksource_change_rating(struct clocksource *cs, int rating)
761 761
762/** 762/**
763 * clocksource_change_rating - Change the rating of a registered clocksource 763 * clocksource_change_rating - Change the rating of a registered clocksource
764 * @cs: clocksource to be changed
765 * @rating: new rating
764 */ 766 */
765void clocksource_change_rating(struct clocksource *cs, int rating) 767void clocksource_change_rating(struct clocksource *cs, int rating)
766{ 768{
@@ -772,6 +774,7 @@ EXPORT_SYMBOL(clocksource_change_rating);
772 774
773/** 775/**
774 * clocksource_unregister - remove a registered clocksource 776 * clocksource_unregister - remove a registered clocksource
777 * @cs: clocksource to be unregistered
775 */ 778 */
776void clocksource_unregister(struct clocksource *cs) 779void clocksource_unregister(struct clocksource *cs)
777{ 780{
@@ -787,6 +790,7 @@ EXPORT_SYMBOL(clocksource_unregister);
787/** 790/**
788 * sysfs_show_current_clocksources - sysfs interface for current clocksource 791 * sysfs_show_current_clocksources - sysfs interface for current clocksource
789 * @dev: unused 792 * @dev: unused
793 * @attr: unused
790 * @buf: char buffer to be filled with clocksource list 794 * @buf: char buffer to be filled with clocksource list
791 * 795 *
792 * Provides sysfs interface for listing current clocksource. 796 * Provides sysfs interface for listing current clocksource.
@@ -807,6 +811,7 @@ sysfs_show_current_clocksources(struct sys_device *dev,
807/** 811/**
808 * sysfs_override_clocksource - interface for manually overriding clocksource 812 * sysfs_override_clocksource - interface for manually overriding clocksource
809 * @dev: unused 813 * @dev: unused
814 * @attr: unused
810 * @buf: name of override clocksource 815 * @buf: name of override clocksource
811 * @count: length of buffer 816 * @count: length of buffer
812 * 817 *
@@ -842,6 +847,7 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev,
842/** 847/**
843 * sysfs_show_available_clocksources - sysfs interface for listing clocksource 848 * sysfs_show_available_clocksources - sysfs interface for listing clocksource
844 * @dev: unused 849 * @dev: unused
850 * @attr: unused
845 * @buf: char buffer to be filled with clocksource list 851 * @buf: char buffer to be filled with clocksource list
846 * 852 *
847 * Provides sysfs interface for listing registered clocksources 853 * Provides sysfs interface for listing registered clocksources
diff --git a/mm/filemap.c b/mm/filemap.c
index c106d3b3cc6..5f0a3c91fda 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1828,7 +1828,7 @@ repeat:
1828 page = __page_cache_alloc(gfp | __GFP_COLD); 1828 page = __page_cache_alloc(gfp | __GFP_COLD);
1829 if (!page) 1829 if (!page)
1830 return ERR_PTR(-ENOMEM); 1830 return ERR_PTR(-ENOMEM);
1831 err = add_to_page_cache_lru(page, mapping, index, GFP_KERNEL); 1831 err = add_to_page_cache_lru(page, mapping, index, gfp);
1832 if (unlikely(err)) { 1832 if (unlikely(err)) {
1833 page_cache_release(page); 1833 page_cache_release(page);
1834 if (err == -EEXIST) 1834 if (err == -EEXIST)
@@ -1925,10 +1925,7 @@ static struct page *wait_on_page_read(struct page *page)
1925 * @gfp: the page allocator flags to use if allocating 1925 * @gfp: the page allocator flags to use if allocating
1926 * 1926 *
1927 * This is the same as "read_mapping_page(mapping, index, NULL)", but with 1927 * This is the same as "read_mapping_page(mapping, index, NULL)", but with
1928 * any new page allocations done using the specified allocation flags. Note 1928 * any new page allocations done using the specified allocation flags.
1929 * that the Radix tree operations will still use GFP_KERNEL, so you can't
1930 * expect to do this atomically or anything like that - but you can pass in
1931 * other page requirements.
1932 * 1929 *
1933 * If the page does not get brought uptodate, return -EIO. 1930 * If the page does not get brought uptodate, return -EIO.
1934 */ 1931 */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 73f17c0293c..2316840b337 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -901,7 +901,6 @@ retry:
901 h->resv_huge_pages += delta; 901 h->resv_huge_pages += delta;
902 ret = 0; 902 ret = 0;
903 903
904 spin_unlock(&hugetlb_lock);
905 /* Free the needed pages to the hugetlb pool */ 904 /* Free the needed pages to the hugetlb pool */
906 list_for_each_entry_safe(page, tmp, &surplus_list, lru) { 905 list_for_each_entry_safe(page, tmp, &surplus_list, lru) {
907 if ((--needed) < 0) 906 if ((--needed) < 0)
@@ -915,6 +914,7 @@ retry:
915 VM_BUG_ON(page_count(page)); 914 VM_BUG_ON(page_count(page));
916 enqueue_huge_page(h, page); 915 enqueue_huge_page(h, page);
917 } 916 }
917 spin_unlock(&hugetlb_lock);
918 918
919 /* Free unnecessary surplus pages to the buddy allocator */ 919 /* Free unnecessary surplus pages to the buddy allocator */
920free: 920free:
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6aff93c98ac..b63f5f7dfa0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4907,9 +4907,9 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
4907 int cpu; 4907 int cpu;
4908 enable_swap_cgroup(); 4908 enable_swap_cgroup();
4909 parent = NULL; 4909 parent = NULL;
4910 root_mem_cgroup = memcg;
4911 if (mem_cgroup_soft_limit_tree_init()) 4910 if (mem_cgroup_soft_limit_tree_init())
4912 goto free_out; 4911 goto free_out;
4912 root_mem_cgroup = memcg;
4913 for_each_possible_cpu(cpu) { 4913 for_each_possible_cpu(cpu) {
4914 struct memcg_stock_pcp *stock = 4914 struct memcg_stock_pcp *stock =
4915 &per_cpu(memcg_stock, cpu); 4915 &per_cpu(memcg_stock, cpu);
@@ -4948,7 +4948,6 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
4948 return &memcg->css; 4948 return &memcg->css;
4949free_out: 4949free_out:
4950 __mem_cgroup_free(memcg); 4950 __mem_cgroup_free(memcg);
4951 root_mem_cgroup = NULL;
4952 return ERR_PTR(error); 4951 return ERR_PTR(error);
4953} 4952}
4954 4953
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index adc39548181..c3fdbcb1765 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -636,6 +636,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
636 struct vm_area_struct *prev; 636 struct vm_area_struct *prev;
637 struct vm_area_struct *vma; 637 struct vm_area_struct *vma;
638 int err = 0; 638 int err = 0;
639 pgoff_t pgoff;
639 unsigned long vmstart; 640 unsigned long vmstart;
640 unsigned long vmend; 641 unsigned long vmend;
641 642
@@ -643,13 +644,21 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
643 if (!vma || vma->vm_start > start) 644 if (!vma || vma->vm_start > start)
644 return -EFAULT; 645 return -EFAULT;
645 646
647 if (start > vma->vm_start)
648 prev = vma;
649
646 for (; vma && vma->vm_start < end; prev = vma, vma = next) { 650 for (; vma && vma->vm_start < end; prev = vma, vma = next) {
647 next = vma->vm_next; 651 next = vma->vm_next;
648 vmstart = max(start, vma->vm_start); 652 vmstart = max(start, vma->vm_start);
649 vmend = min(end, vma->vm_end); 653 vmend = min(end, vma->vm_end);
650 654
655 if (mpol_equal(vma_policy(vma), new_pol))
656 continue;
657
658 pgoff = vma->vm_pgoff +
659 ((vmstart - vma->vm_start) >> PAGE_SHIFT);
651 prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags, 660 prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
652 vma->anon_vma, vma->vm_file, vma->vm_pgoff, 661 vma->anon_vma, vma->vm_file, pgoff,
653 new_pol); 662 new_pol);
654 if (prev) { 663 if (prev) {
655 vma = prev; 664 vma = prev;
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 76f2c5ae908..069b64e521f 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -176,7 +176,7 @@ static bool oom_unkillable_task(struct task_struct *p,
176unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem, 176unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
177 const nodemask_t *nodemask, unsigned long totalpages) 177 const nodemask_t *nodemask, unsigned long totalpages)
178{ 178{
179 int points; 179 long points;
180 180
181 if (oom_unkillable_task(p, mem, nodemask)) 181 if (oom_unkillable_task(p, mem, nodemask))
182 return 0; 182 return 0;
diff --git a/mm/percpu.c b/mm/percpu.c
index 3bb810a7200..716eb4acf2f 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1023,9 +1023,11 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
1023 if (!is_vmalloc_addr(addr)) 1023 if (!is_vmalloc_addr(addr))
1024 return __pa(addr); 1024 return __pa(addr);
1025 else 1025 else
1026 return page_to_phys(vmalloc_to_page(addr)); 1026 return page_to_phys(vmalloc_to_page(addr)) +
1027 offset_in_page(addr);
1027 } else 1028 } else
1028 return page_to_phys(pcpu_addr_to_page(addr)); 1029 return page_to_phys(pcpu_addr_to_page(addr)) +
1030 offset_in_page(addr);
1029} 1031}
1030 1032
1031/** 1033/**
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1d8b32f0713..27be2f0d4cb 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1290,7 +1290,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
1290 unsigned long align, unsigned long flags, unsigned long start, 1290 unsigned long align, unsigned long flags, unsigned long start,
1291 unsigned long end, int node, gfp_t gfp_mask, void *caller) 1291 unsigned long end, int node, gfp_t gfp_mask, void *caller)
1292{ 1292{
1293 static struct vmap_area *va; 1293 struct vmap_area *va;
1294 struct vm_struct *area; 1294 struct vm_struct *area;
1295 1295
1296 BUG_ON(in_interrupt()); 1296 BUG_ON(in_interrupt());
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index e0af7237cd9..c1c597e3e19 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -673,7 +673,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
673 goto encrypt; 673 goto encrypt;
674 674
675auth: 675auth:
676 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) 676 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
677 return 0; 677 return 0;
678 678
679 if (!hci_conn_auth(conn, sec_level, auth_type)) 679 if (!hci_conn_auth(conn, sec_level, auth_type))
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index be84ae33ae3..b84458dcc22 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -613,7 +613,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
613 if (!test_bit(HCI_RAW, &hdev->flags)) { 613 if (!test_bit(HCI_RAW, &hdev->flags)) {
614 set_bit(HCI_INIT, &hdev->flags); 614 set_bit(HCI_INIT, &hdev->flags);
615 __hci_request(hdev, hci_reset_req, 0, 615 __hci_request(hdev, hci_reset_req, 0,
616 msecs_to_jiffies(HCI_INIT_TIMEOUT)); 616 msecs_to_jiffies(250));
617 clear_bit(HCI_INIT, &hdev->flags); 617 clear_bit(HCI_INIT, &hdev->flags);
618 } 618 }
619 619
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5ea94a1eecf..17b5b1cd965 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2152,7 +2152,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
2152 void *ptr = req->data; 2152 void *ptr = req->data;
2153 int type, olen; 2153 int type, olen;
2154 unsigned long val; 2154 unsigned long val;
2155 struct l2cap_conf_rfc rfc; 2155 struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
2156 2156
2157 BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data); 2157 BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
2158 2158
@@ -2271,6 +2271,16 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
2271 } 2271 }
2272 } 2272 }
2273 2273
2274 /* Use sane default values in case a misbehaving remote device
2275 * did not send an RFC option.
2276 */
2277 rfc.mode = chan->mode;
2278 rfc.retrans_timeout = cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO);
2279 rfc.monitor_timeout = cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO);
2280 rfc.max_pdu_size = cpu_to_le16(chan->imtu);
2281
2282 BT_ERR("Expected RFC option was not found, using defaults");
2283
2274done: 2284done:
2275 switch (rfc.mode) { 2285 switch (rfc.mode) {
2276 case L2CAP_MODE_ERTM: 2286 case L2CAP_MODE_ERTM:
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 4e32e18211f..2d28dfe9838 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -1146,6 +1146,7 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
1146 if (list_empty(&s->dlcs)) { 1146 if (list_empty(&s->dlcs)) {
1147 s->state = BT_DISCONN; 1147 s->state = BT_DISCONN;
1148 rfcomm_send_disc(s, 0); 1148 rfcomm_send_disc(s, 0);
1149 rfcomm_session_clear_timer(s);
1149 } 1150 }
1150 1151
1151 break; 1152 break;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index d6ec3720c77..fa8b8f76358 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -114,12 +114,18 @@ static struct neighbour *fake_neigh_lookup(const struct dst_entry *dst, const vo
114 return NULL; 114 return NULL;
115} 115}
116 116
117static unsigned int fake_mtu(const struct dst_entry *dst)
118{
119 return dst->dev->mtu;
120}
121
117static struct dst_ops fake_dst_ops = { 122static struct dst_ops fake_dst_ops = {
118 .family = AF_INET, 123 .family = AF_INET,
119 .protocol = cpu_to_be16(ETH_P_IP), 124 .protocol = cpu_to_be16(ETH_P_IP),
120 .update_pmtu = fake_update_pmtu, 125 .update_pmtu = fake_update_pmtu,
121 .cow_metrics = fake_cow_metrics, 126 .cow_metrics = fake_cow_metrics,
122 .neigh_lookup = fake_neigh_lookup, 127 .neigh_lookup = fake_neigh_lookup,
128 .mtu = fake_mtu,
123}; 129};
124 130
125/* 131/*
@@ -141,7 +147,7 @@ void br_netfilter_rtable_init(struct net_bridge *br)
141 rt->dst.dev = br->dev; 147 rt->dst.dev = br->dev;
142 rt->dst.path = &rt->dst; 148 rt->dst.path = &rt->dst;
143 dst_init_metrics(&rt->dst, br_dst_default_metrics, true); 149 dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
144 rt->dst.flags = DST_NOXFRM; 150 rt->dst.flags = DST_NOXFRM | DST_NOPEER;
145 rt->dst.ops = &fake_dst_ops; 151 rt->dst.ops = &fake_dst_ops;
146} 152}
147 153
diff --git a/net/core/flow.c b/net/core/flow.c
index 8ae42de9c79..e318c7e9804 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -358,6 +358,18 @@ void flow_cache_flush(void)
358 put_online_cpus(); 358 put_online_cpus();
359} 359}
360 360
361static void flow_cache_flush_task(struct work_struct *work)
362{
363 flow_cache_flush();
364}
365
366static DECLARE_WORK(flow_cache_flush_work, flow_cache_flush_task);
367
368void flow_cache_flush_deferred(void)
369{
370 schedule_work(&flow_cache_flush_work);
371}
372
361static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) 373static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
362{ 374{
363 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu); 375 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index c71c434a4c0..385aefe5364 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -665,11 +665,14 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
665 if (count) { 665 if (count) {
666 int i; 666 int i;
667 667
668 if (count > 1<<30) { 668 if (count > INT_MAX)
669 return -EINVAL;
670 count = roundup_pow_of_two(count);
671 if (count > (ULONG_MAX - sizeof(struct rps_dev_flow_table))
672 / sizeof(struct rps_dev_flow)) {
669 /* Enforce a limit to prevent overflow */ 673 /* Enforce a limit to prevent overflow */
670 return -EINVAL; 674 return -EINVAL;
671 } 675 }
672 count = roundup_pow_of_two(count);
673 table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count)); 676 table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count));
674 if (!table) 677 if (!table)
675 return -ENOMEM; 678 return -ENOMEM;
diff --git a/net/core/sock.c b/net/core/sock.c
index 4ed7b1d12f5..b23f174ab84 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -288,11 +288,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
288 unsigned long flags; 288 unsigned long flags;
289 struct sk_buff_head *list = &sk->sk_receive_queue; 289 struct sk_buff_head *list = &sk->sk_receive_queue;
290 290
291 /* Cast sk->rcvbuf to unsigned... It's pointless, but reduces 291 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
292 number of warnings when compiling with -W --ANK
293 */
294 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
295 (unsigned)sk->sk_rcvbuf) {
296 atomic_inc(&sk->sk_drops); 292 atomic_inc(&sk->sk_drops);
297 trace_sock_rcvqueue_full(sk, skb); 293 trace_sock_rcvqueue_full(sk, skb);
298 return -ENOMEM; 294 return -ENOMEM;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 0da2afc97f3..99ec116bef1 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -253,6 +253,10 @@ static int __init ic_open_devs(void)
253 } 253 }
254 } 254 }
255 255
256 /* no point in waiting if we could not bring up at least one device */
257 if (!ic_first_dev)
258 goto have_carrier;
259
256 /* wait for a carrier on at least one device */ 260 /* wait for a carrier on at least one device */
257 start = jiffies; 261 start = jiffies;
258 while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) { 262 while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 46af62363b8..94cdbc55ca7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -91,6 +91,7 @@
91#include <linux/rcupdate.h> 91#include <linux/rcupdate.h>
92#include <linux/times.h> 92#include <linux/times.h>
93#include <linux/slab.h> 93#include <linux/slab.h>
94#include <linux/prefetch.h>
94#include <net/dst.h> 95#include <net/dst.h>
95#include <net/net_namespace.h> 96#include <net/net_namespace.h>
96#include <net/protocol.h> 97#include <net/protocol.h>
@@ -120,6 +121,7 @@
120 121
121static int ip_rt_max_size; 122static int ip_rt_max_size;
122static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; 123static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT;
124static int ip_rt_gc_interval __read_mostly = 60 * HZ;
123static int ip_rt_gc_min_interval __read_mostly = HZ / 2; 125static int ip_rt_gc_min_interval __read_mostly = HZ / 2;
124static int ip_rt_redirect_number __read_mostly = 9; 126static int ip_rt_redirect_number __read_mostly = 9;
125static int ip_rt_redirect_load __read_mostly = HZ / 50; 127static int ip_rt_redirect_load __read_mostly = HZ / 50;
@@ -133,6 +135,9 @@ static int ip_rt_min_advmss __read_mostly = 256;
133static int rt_chain_length_max __read_mostly = 20; 135static int rt_chain_length_max __read_mostly = 20;
134static int redirect_genid; 136static int redirect_genid;
135 137
138static struct delayed_work expires_work;
139static unsigned long expires_ljiffies;
140
136/* 141/*
137 * Interface to generic destination cache. 142 * Interface to generic destination cache.
138 */ 143 */
@@ -830,6 +835,97 @@ static int has_noalias(const struct rtable *head, const struct rtable *rth)
830 return ONE; 835 return ONE;
831} 836}
832 837
838static void rt_check_expire(void)
839{
840 static unsigned int rover;
841 unsigned int i = rover, goal;
842 struct rtable *rth;
843 struct rtable __rcu **rthp;
844 unsigned long samples = 0;
845 unsigned long sum = 0, sum2 = 0;
846 unsigned long delta;
847 u64 mult;
848
849 delta = jiffies - expires_ljiffies;
850 expires_ljiffies = jiffies;
851 mult = ((u64)delta) << rt_hash_log;
852 if (ip_rt_gc_timeout > 1)
853 do_div(mult, ip_rt_gc_timeout);
854 goal = (unsigned int)mult;
855 if (goal > rt_hash_mask)
856 goal = rt_hash_mask + 1;
857 for (; goal > 0; goal--) {
858 unsigned long tmo = ip_rt_gc_timeout;
859 unsigned long length;
860
861 i = (i + 1) & rt_hash_mask;
862 rthp = &rt_hash_table[i].chain;
863
864 if (need_resched())
865 cond_resched();
866
867 samples++;
868
869 if (rcu_dereference_raw(*rthp) == NULL)
870 continue;
871 length = 0;
872 spin_lock_bh(rt_hash_lock_addr(i));
873 while ((rth = rcu_dereference_protected(*rthp,
874 lockdep_is_held(rt_hash_lock_addr(i)))) != NULL) {
875 prefetch(rth->dst.rt_next);
876 if (rt_is_expired(rth)) {
877 *rthp = rth->dst.rt_next;
878 rt_free(rth);
879 continue;
880 }
881 if (rth->dst.expires) {
882 /* Entry is expired even if it is in use */
883 if (time_before_eq(jiffies, rth->dst.expires)) {
884nofree:
885 tmo >>= 1;
886 rthp = &rth->dst.rt_next;
887 /*
888 * We only count entries on
889 * a chain with equal hash inputs once
890 * so that entries for different QOS
891 * levels, and other non-hash input
892 * attributes don't unfairly skew
893 * the length computation
894 */
895 length += has_noalias(rt_hash_table[i].chain, rth);
896 continue;
897 }
898 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout))
899 goto nofree;
900
901 /* Cleanup aged off entries. */
902 *rthp = rth->dst.rt_next;
903 rt_free(rth);
904 }
905 spin_unlock_bh(rt_hash_lock_addr(i));
906 sum += length;
907 sum2 += length*length;
908 }
909 if (samples) {
910 unsigned long avg = sum / samples;
911 unsigned long sd = int_sqrt(sum2 / samples - avg*avg);
912 rt_chain_length_max = max_t(unsigned long,
913 ip_rt_gc_elasticity,
914 (avg + 4*sd) >> FRACT_BITS);
915 }
916 rover = i;
917}
918
919/*
920 * rt_worker_func() is run in process context.
921 * we call rt_check_expire() to scan part of the hash table
922 */
923static void rt_worker_func(struct work_struct *work)
924{
925 rt_check_expire();
926 schedule_delayed_work(&expires_work, ip_rt_gc_interval);
927}
928
833/* 929/*
834 * Perturbation of rt_genid by a small quantity [1..256] 930 * Perturbation of rt_genid by a small quantity [1..256]
835 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate() 931 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate()
@@ -1271,7 +1367,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1271{ 1367{
1272 struct rtable *rt = (struct rtable *) dst; 1368 struct rtable *rt = (struct rtable *) dst;
1273 1369
1274 if (rt) { 1370 if (rt && !(rt->dst.flags & DST_NOPEER)) {
1275 if (rt->peer == NULL) 1371 if (rt->peer == NULL)
1276 rt_bind_peer(rt, rt->rt_dst, 1); 1372 rt_bind_peer(rt, rt->rt_dst, 1);
1277 1373
@@ -1282,7 +1378,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1282 iph->id = htons(inet_getid(rt->peer, more)); 1378 iph->id = htons(inet_getid(rt->peer, more));
1283 return; 1379 return;
1284 } 1380 }
1285 } else 1381 } else if (!rt)
1286 printk(KERN_DEBUG "rt_bind_peer(0) @%p\n", 1382 printk(KERN_DEBUG "rt_bind_peer(0) @%p\n",
1287 __builtin_return_address(0)); 1383 __builtin_return_address(0));
1288 1384
@@ -3179,6 +3275,13 @@ static ctl_table ipv4_route_table[] = {
3179 .proc_handler = proc_dointvec_jiffies, 3275 .proc_handler = proc_dointvec_jiffies,
3180 }, 3276 },
3181 { 3277 {
3278 .procname = "gc_interval",
3279 .data = &ip_rt_gc_interval,
3280 .maxlen = sizeof(int),
3281 .mode = 0644,
3282 .proc_handler = proc_dointvec_jiffies,
3283 },
3284 {
3182 .procname = "redirect_load", 3285 .procname = "redirect_load",
3183 .data = &ip_rt_redirect_load, 3286 .data = &ip_rt_redirect_load,
3184 .maxlen = sizeof(int), 3287 .maxlen = sizeof(int),
@@ -3388,6 +3491,11 @@ int __init ip_rt_init(void)
3388 devinet_init(); 3491 devinet_init();
3389 ip_fib_init(); 3492 ip_fib_init();
3390 3493
3494 INIT_DELAYED_WORK_DEFERRABLE(&expires_work, rt_worker_func);
3495 expires_ljiffies = jiffies;
3496 schedule_delayed_work(&expires_work,
3497 net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
3498
3391 if (ip_rt_proc_init()) 3499 if (ip_rt_proc_init())
3392 printk(KERN_ERR "Unable to create route proc files\n"); 3500 printk(KERN_ERR "Unable to create route proc files\n");
3393#ifdef CONFIG_XFRM 3501#ifdef CONFIG_XFRM
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 84d0bd5cac9..ec562713db9 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -603,7 +603,7 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
603 static atomic_t ipv6_fragmentation_id; 603 static atomic_t ipv6_fragmentation_id;
604 int old, new; 604 int old, new;
605 605
606 if (rt) { 606 if (rt && !(rt->dst.flags & DST_NOPEER)) {
607 struct inet_peer *peer; 607 struct inet_peer *peer;
608 608
609 if (!rt->rt6i_peer) 609 if (!rt->rt6i_peer)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index dfd3a648a55..a18e6c3d36e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -833,15 +833,15 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
833 copied += used; 833 copied += used;
834 len -= used; 834 len -= used;
835 835
836 /* For non stream protcols we get one packet per recvmsg call */
837 if (sk->sk_type != SOCK_STREAM)
838 goto copy_uaddr;
839
836 if (!(flags & MSG_PEEK)) { 840 if (!(flags & MSG_PEEK)) {
837 sk_eat_skb(sk, skb, 0); 841 sk_eat_skb(sk, skb, 0);
838 *seq = 0; 842 *seq = 0;
839 } 843 }
840 844
841 /* For non stream protcols we get one packet per recvmsg call */
842 if (sk->sk_type != SOCK_STREAM)
843 goto copy_uaddr;
844
845 /* Partial read */ 845 /* Partial read */
846 if (used + offset < skb->len) 846 if (used + offset < skb->len)
847 continue; 847 continue;
@@ -857,6 +857,12 @@ copy_uaddr:
857 } 857 }
858 if (llc_sk(sk)->cmsg_flags) 858 if (llc_sk(sk)->cmsg_flags)
859 llc_cmsg_rcv(msg, skb); 859 llc_cmsg_rcv(msg, skb);
860
861 if (!(flags & MSG_PEEK)) {
862 sk_eat_skb(sk, skb, 0);
863 *seq = 0;
864 }
865
860 goto out; 866 goto out;
861} 867}
862 868
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 12571fb2881..29fa5badde7 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -616,7 +616,7 @@ struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)
616 if ((cp) && (!cp->dest)) { 616 if ((cp) && (!cp->dest)) {
617 dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, &cp->daddr, 617 dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, &cp->daddr,
618 cp->dport, &cp->vaddr, cp->vport, 618 cp->dport, &cp->vaddr, cp->vport,
619 cp->protocol, cp->fwmark); 619 cp->protocol, cp->fwmark, cp->flags);
620 ip_vs_bind_dest(cp, dest); 620 ip_vs_bind_dest(cp, dest);
621 return dest; 621 return dest;
622 } else 622 } else
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 008bf97cc91..e1a66cf37f9 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -619,15 +619,21 @@ struct ip_vs_dest *ip_vs_find_dest(struct net *net, int af,
619 const union nf_inet_addr *daddr, 619 const union nf_inet_addr *daddr,
620 __be16 dport, 620 __be16 dport,
621 const union nf_inet_addr *vaddr, 621 const union nf_inet_addr *vaddr,
622 __be16 vport, __u16 protocol, __u32 fwmark) 622 __be16 vport, __u16 protocol, __u32 fwmark,
623 __u32 flags)
623{ 624{
624 struct ip_vs_dest *dest; 625 struct ip_vs_dest *dest;
625 struct ip_vs_service *svc; 626 struct ip_vs_service *svc;
627 __be16 port = dport;
626 628
627 svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport); 629 svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport);
628 if (!svc) 630 if (!svc)
629 return NULL; 631 return NULL;
630 dest = ip_vs_lookup_dest(svc, daddr, dport); 632 if (fwmark && (flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ)
633 port = 0;
634 dest = ip_vs_lookup_dest(svc, daddr, port);
635 if (!dest)
636 dest = ip_vs_lookup_dest(svc, daddr, port ^ dport);
631 if (dest) 637 if (dest)
632 atomic_inc(&dest->refcnt); 638 atomic_inc(&dest->refcnt);
633 ip_vs_service_put(svc); 639 ip_vs_service_put(svc);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 3cdd479f9b5..2b6678c0ce1 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -740,7 +740,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
740 * but still handled. 740 * but still handled.
741 */ 741 */
742 dest = ip_vs_find_dest(net, type, daddr, dport, param->vaddr, 742 dest = ip_vs_find_dest(net, type, daddr, dport, param->vaddr,
743 param->vport, protocol, fwmark); 743 param->vport, protocol, fwmark, flags);
744 744
745 /* Set the approprite ativity flag */ 745 /* Set the approprite ativity flag */
746 if (protocol == IPPROTO_TCP) { 746 if (protocol == IPPROTO_TCP) {
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ef21b221f03..257e77256c5 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -135,7 +135,7 @@ nla_put_failure:
135static inline int 135static inline int
136ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) 136ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
137{ 137{
138 long timeout = (ct->timeout.expires - jiffies) / HZ; 138 long timeout = ((long)ct->timeout.expires - (long)jiffies) / HZ;
139 139
140 if (timeout < 0) 140 if (timeout < 0)
141 timeout = 0; 141 timeout = 0;
@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1358 nf_ct_protonum(ct)); 1358 nf_ct_protonum(ct));
1359 if (helper == NULL) { 1359 if (helper == NULL) {
1360 rcu_read_unlock(); 1360 rcu_read_unlock();
1361 spin_unlock_bh(&nf_conntrack_lock);
1361#ifdef CONFIG_MODULES 1362#ifdef CONFIG_MODULES
1362 if (request_module("nfct-helper-%s", helpname) < 0) { 1363 if (request_module("nfct-helper-%s", helpname) < 0) {
1364 spin_lock_bh(&nf_conntrack_lock);
1363 err = -EOPNOTSUPP; 1365 err = -EOPNOTSUPP;
1364 goto err1; 1366 goto err1;
1365 } 1367 }
1366 1368
1369 spin_lock_bh(&nf_conntrack_lock);
1367 rcu_read_lock(); 1370 rcu_read_lock();
1368 helper = __nf_conntrack_helper_find(helpname, 1371 helper = __nf_conntrack_helper_find(helpname,
1369 nf_ct_l3num(ct), 1372 nf_ct_l3num(ct),
@@ -1638,7 +1641,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1638 const struct nf_conntrack_expect *exp) 1641 const struct nf_conntrack_expect *exp)
1639{ 1642{
1640 struct nf_conn *master = exp->master; 1643 struct nf_conn *master = exp->master;
1641 long timeout = (exp->timeout.expires - jiffies) / HZ; 1644 long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ;
1642 struct nf_conn_help *help; 1645 struct nf_conn_help *help;
1643 1646
1644 if (timeout < 0) 1647 if (timeout < 0)
@@ -1869,25 +1872,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1869 1872
1870 err = -ENOMEM; 1873 err = -ENOMEM;
1871 skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1874 skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1872 if (skb2 == NULL) 1875 if (skb2 == NULL) {
1876 nf_ct_expect_put(exp);
1873 goto out; 1877 goto out;
1878 }
1874 1879
1875 rcu_read_lock(); 1880 rcu_read_lock();
1876 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, 1881 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1877 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp); 1882 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp);
1878 rcu_read_unlock(); 1883 rcu_read_unlock();
1884 nf_ct_expect_put(exp);
1879 if (err <= 0) 1885 if (err <= 0)
1880 goto free; 1886 goto free;
1881 1887
1882 nf_ct_expect_put(exp); 1888 err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1889 if (err < 0)
1890 goto out;
1883 1891
1884 return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); 1892 return 0;
1885 1893
1886free: 1894free:
1887 kfree_skb(skb2); 1895 kfree_skb(skb2);
1888out: 1896out:
1889 nf_ct_expect_put(exp); 1897 /* this avoids a loop in nfnetlink. */
1890 return err; 1898 return err == -EAGAIN ? -ENOBUFS : err;
1891} 1899}
1892 1900
1893static int 1901static int
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index 5b138506690..9ddf1c3bfb3 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -87,10 +87,10 @@ connbytes_mt(const struct sk_buff *skb, struct xt_action_param *par)
87 break; 87 break;
88 } 88 }
89 89
90 if (sinfo->count.to) 90 if (sinfo->count.to >= sinfo->count.from)
91 return what <= sinfo->count.to && what >= sinfo->count.from; 91 return what <= sinfo->count.to && what >= sinfo->count.from;
92 else 92 else /* inverted */
93 return what >= sinfo->count.from; 93 return what < sinfo->count.to || what > sinfo->count.from;
94} 94}
95 95
96static int connbytes_mt_check(const struct xt_mtchk_param *par) 96static int connbytes_mt_check(const struct xt_mtchk_param *par)
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 3925c657876..ea66034499c 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -69,7 +69,7 @@ static int __nci_request(struct nci_dev *ndev,
69 __u32 timeout) 69 __u32 timeout)
70{ 70{
71 int rc = 0; 71 int rc = 0;
72 unsigned long completion_rc; 72 long completion_rc;
73 73
74 ndev->req_status = NCI_REQ_PEND; 74 ndev->req_status = NCI_REQ_PEND;
75 75
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 82a6f34d39d..d9d4970b9b0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1630,8 +1630,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1630 if (snaplen > res) 1630 if (snaplen > res)
1631 snaplen = res; 1631 snaplen = res;
1632 1632
1633 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 1633 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
1634 (unsigned)sk->sk_rcvbuf)
1635 goto drop_n_acct; 1634 goto drop_n_acct;
1636 1635
1637 if (skb_shared(skb)) { 1636 if (skb_shared(skb)) {
@@ -1762,8 +1761,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
1762 if (po->tp_version <= TPACKET_V2) { 1761 if (po->tp_version <= TPACKET_V2) {
1763 if (macoff + snaplen > po->rx_ring.frame_size) { 1762 if (macoff + snaplen > po->rx_ring.frame_size) {
1764 if (po->copy_thresh && 1763 if (po->copy_thresh &&
1765 atomic_read(&sk->sk_rmem_alloc) + skb->truesize 1764 atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) {
1766 < (unsigned)sk->sk_rcvbuf) {
1767 if (skb_shared(skb)) { 1765 if (skb_shared(skb)) {
1768 copy_skb = skb_clone(skb, GFP_ATOMIC); 1766 copy_skb = skb_clone(skb, GFP_ATOMIC);
1769 } else { 1767 } else {
@@ -2450,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
2450{ 2448{
2451 struct packet_sock *po = pkt_sk(sk); 2449 struct packet_sock *po = pkt_sk(sk);
2452 2450
2453 if (po->fanout) 2451 if (po->fanout) {
2452 if (dev)
2453 dev_put(dev);
2454
2454 return -EINVAL; 2455 return -EINVAL;
2456 }
2455 2457
2456 lock_sock(sk); 2458 lock_sock(sk);
2457 2459
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index f88256cbacb..28de4309233 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -107,7 +107,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)
107 if (!netif_is_multiqueue(dev)) 107 if (!netif_is_multiqueue(dev))
108 return -EOPNOTSUPP; 108 return -EOPNOTSUPP;
109 109
110 if (nla_len(opt) < sizeof(*qopt)) 110 if (!opt || nla_len(opt) < sizeof(*qopt))
111 return -EINVAL; 111 return -EINVAL;
112 112
113 qopt = nla_data(opt); 113 qopt = nla_data(opt);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index eb3b9a86c6e..a4ab207cdc5 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -488,7 +488,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
488 return -EINVAL; 488 return -EINVAL;
489 489
490 s = sizeof(struct disttable) + n * sizeof(s16); 490 s = sizeof(struct disttable) + n * sizeof(s16);
491 d = kmalloc(s, GFP_KERNEL); 491 d = kmalloc(s, GFP_KERNEL | __GFP_NOWARN);
492 if (!d) 492 if (!d)
493 d = vmalloc(s); 493 d = vmalloc(s);
494 if (!d) 494 if (!d)
@@ -501,9 +501,10 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
501 root_lock = qdisc_root_sleeping_lock(sch); 501 root_lock = qdisc_root_sleeping_lock(sch);
502 502
503 spin_lock_bh(root_lock); 503 spin_lock_bh(root_lock);
504 dist_free(q->delay_dist); 504 swap(q->delay_dist, d);
505 q->delay_dist = d;
506 spin_unlock_bh(root_lock); 505 spin_unlock_bh(root_lock);
506
507 dist_free(d);
507 return 0; 508 return 0;
508} 509}
509 510
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 10334340859..7b0325459e7 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -817,11 +817,11 @@ skip_unblock:
817static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl) 817static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl)
818{ 818{
819 unsigned long mask; 819 unsigned long mask;
820 uint32_t limit, roundedF; 820 u64 limit, roundedF;
821 int slot_shift = cl->grp->slot_shift; 821 int slot_shift = cl->grp->slot_shift;
822 822
823 roundedF = qfq_round_down(cl->F, slot_shift); 823 roundedF = qfq_round_down(cl->F, slot_shift);
824 limit = qfq_round_down(q->V, slot_shift) + (1UL << slot_shift); 824 limit = qfq_round_down(q->V, slot_shift) + (1ULL << slot_shift);
825 825
826 if (!qfq_gt(cl->F, q->V) || qfq_gt(roundedF, limit)) { 826 if (!qfq_gt(cl->F, q->V) || qfq_gt(roundedF, limit)) {
827 /* timestamp was stale */ 827 /* timestamp was stale */
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 152b5b3c3ff..acd2edbc073 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -173,7 +173,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
173 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; 173 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
174 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; 174 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
175 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = 175 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
176 (unsigned long)sp->autoclose * HZ; 176 min_t(unsigned long, sp->autoclose, sctp_max_autoclose) * HZ;
177 177
178 /* Initializes the timers */ 178 /* Initializes the timers */
179 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) 179 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 08b3cead650..817174eb5f4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -697,13 +697,7 @@ static void sctp_packet_append_data(struct sctp_packet *packet,
697 /* Keep track of how many bytes are in flight to the receiver. */ 697 /* Keep track of how many bytes are in flight to the receiver. */
698 asoc->outqueue.outstanding_bytes += datasize; 698 asoc->outqueue.outstanding_bytes += datasize;
699 699
700 /* Update our view of the receiver's rwnd. Include sk_buff overhead 700 /* Update our view of the receiver's rwnd. */
701 * while updating peer.rwnd so that it reduces the chances of a
702 * receiver running out of receive buffer space even when receive
703 * window is still open. This can happen when a sender is sending
704 * sending small messages.
705 */
706 datasize += sizeof(struct sk_buff);
707 if (datasize < rwnd) 701 if (datasize < rwnd)
708 rwnd -= datasize; 702 rwnd -= datasize;
709 else 703 else
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 14c2b06028f..cfeb1d4a1ee 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -411,8 +411,7 @@ void sctp_retransmit_mark(struct sctp_outq *q,
411 chunk->transport->flight_size -= 411 chunk->transport->flight_size -=
412 sctp_data_size(chunk); 412 sctp_data_size(chunk);
413 q->outstanding_bytes -= sctp_data_size(chunk); 413 q->outstanding_bytes -= sctp_data_size(chunk);
414 q->asoc->peer.rwnd += (sctp_data_size(chunk) + 414 q->asoc->peer.rwnd += sctp_data_size(chunk);
415 sizeof(struct sk_buff));
416 } 415 }
417 continue; 416 continue;
418 } 417 }
@@ -432,8 +431,7 @@ void sctp_retransmit_mark(struct sctp_outq *q,
432 * (Section 7.2.4)), add the data size of those 431 * (Section 7.2.4)), add the data size of those
433 * chunks to the rwnd. 432 * chunks to the rwnd.
434 */ 433 */
435 q->asoc->peer.rwnd += (sctp_data_size(chunk) + 434 q->asoc->peer.rwnd += sctp_data_size(chunk);
436 sizeof(struct sk_buff));
437 q->outstanding_bytes -= sctp_data_size(chunk); 435 q->outstanding_bytes -= sctp_data_size(chunk);
438 if (chunk->transport) 436 if (chunk->transport)
439 transport->flight_size -= sctp_data_size(chunk); 437 transport->flight_size -= sctp_data_size(chunk);
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 61b9fca5a17..6f6ad868683 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1285,6 +1285,9 @@ SCTP_STATIC __init int sctp_init(void)
1285 sctp_max_instreams = SCTP_DEFAULT_INSTREAMS; 1285 sctp_max_instreams = SCTP_DEFAULT_INSTREAMS;
1286 sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; 1286 sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS;
1287 1287
1288 /* Initialize maximum autoclose timeout. */
1289 sctp_max_autoclose = INT_MAX / HZ;
1290
1288 /* Initialize handle used for association ids. */ 1291 /* Initialize handle used for association ids. */
1289 idr_init(&sctp_assocs_id); 1292 idr_init(&sctp_assocs_id);
1290 1293
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 13bf5fcdbff..54a7cd2fdd7 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2200,8 +2200,6 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2200 return -EINVAL; 2200 return -EINVAL;
2201 if (copy_from_user(&sp->autoclose, optval, optlen)) 2201 if (copy_from_user(&sp->autoclose, optval, optlen))
2202 return -EFAULT; 2202 return -EFAULT;
2203 /* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
2204 sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ);
2205 2203
2206 return 0; 2204 return 0;
2207} 2205}
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 6b3952961b8..60ffbd067ff 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -53,6 +53,10 @@ static int sack_timer_min = 1;
53static int sack_timer_max = 500; 53static int sack_timer_max = 500;
54static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ 54static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
55static int rwnd_scale_max = 16; 55static int rwnd_scale_max = 16;
56static unsigned long max_autoclose_min = 0;
57static unsigned long max_autoclose_max =
58 (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
59 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
56 60
57extern long sysctl_sctp_mem[3]; 61extern long sysctl_sctp_mem[3];
58extern int sysctl_sctp_rmem[3]; 62extern int sysctl_sctp_rmem[3];
@@ -258,6 +262,15 @@ static ctl_table sctp_table[] = {
258 .extra1 = &one, 262 .extra1 = &one,
259 .extra2 = &rwnd_scale_max, 263 .extra2 = &rwnd_scale_max,
260 }, 264 },
265 {
266 .procname = "max_autoclose",
267 .data = &sctp_max_autoclose,
268 .maxlen = sizeof(unsigned long),
269 .mode = 0644,
270 .proc_handler = &proc_doulongvec_minmax,
271 .extra1 = &max_autoclose_min,
272 .extra2 = &max_autoclose_max,
273 },
261 274
262 { /* sentinel */ } 275 { /* sentinel */ }
263}; 276};
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index d12ffa54581..00a1a2acd58 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -590,6 +590,27 @@ void rpc_prepare_task(struct rpc_task *task)
590 task->tk_ops->rpc_call_prepare(task, task->tk_calldata); 590 task->tk_ops->rpc_call_prepare(task, task->tk_calldata);
591} 591}
592 592
593static void
594rpc_init_task_statistics(struct rpc_task *task)
595{
596 /* Initialize retry counters */
597 task->tk_garb_retry = 2;
598 task->tk_cred_retry = 2;
599 task->tk_rebind_retry = 2;
600
601 /* starting timestamp */
602 task->tk_start = ktime_get();
603}
604
605static void
606rpc_reset_task_statistics(struct rpc_task *task)
607{
608 task->tk_timeouts = 0;
609 task->tk_flags &= ~(RPC_CALL_MAJORSEEN|RPC_TASK_KILLED|RPC_TASK_SENT);
610
611 rpc_init_task_statistics(task);
612}
613
593/* 614/*
594 * Helper that calls task->tk_ops->rpc_call_done if it exists 615 * Helper that calls task->tk_ops->rpc_call_done if it exists
595 */ 616 */
@@ -602,6 +623,7 @@ void rpc_exit_task(struct rpc_task *task)
602 WARN_ON(RPC_ASSASSINATED(task)); 623 WARN_ON(RPC_ASSASSINATED(task));
603 /* Always release the RPC slot and buffer memory */ 624 /* Always release the RPC slot and buffer memory */
604 xprt_release(task); 625 xprt_release(task);
626 rpc_reset_task_statistics(task);
605 } 627 }
606 } 628 }
607} 629}
@@ -804,11 +826,6 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
804 task->tk_calldata = task_setup_data->callback_data; 826 task->tk_calldata = task_setup_data->callback_data;
805 INIT_LIST_HEAD(&task->tk_task); 827 INIT_LIST_HEAD(&task->tk_task);
806 828
807 /* Initialize retry counters */
808 task->tk_garb_retry = 2;
809 task->tk_cred_retry = 2;
810 task->tk_rebind_retry = 2;
811
812 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW; 829 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW;
813 task->tk_owner = current->tgid; 830 task->tk_owner = current->tgid;
814 831
@@ -818,8 +835,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
818 if (task->tk_ops->rpc_call_prepare != NULL) 835 if (task->tk_ops->rpc_call_prepare != NULL)
819 task->tk_action = rpc_prepare_task; 836 task->tk_action = rpc_prepare_task;
820 837
821 /* starting timestamp */ 838 rpc_init_task_statistics(task);
822 task->tk_start = ktime_get();
823 839
824 dprintk("RPC: new task initialized, procpid %u\n", 840 dprintk("RPC: new task initialized, procpid %u\n",
825 task_pid_nr(current)); 841 task_pid_nr(current));
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index f4385e45a5f..c64c0ef519b 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -995,13 +995,11 @@ out_init_req:
995 995
996static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req) 996static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
997{ 997{
998 if (xprt_dynamic_free_slot(xprt, req))
999 return;
1000
1001 memset(req, 0, sizeof(*req)); /* mark unused */
1002
1003 spin_lock(&xprt->reserve_lock); 998 spin_lock(&xprt->reserve_lock);
1004 list_add(&req->rq_list, &xprt->free); 999 if (!xprt_dynamic_free_slot(xprt, req)) {
1000 memset(req, 0, sizeof(*req)); /* mark unused */
1001 list_add(&req->rq_list, &xprt->free);
1002 }
1005 rpc_wake_up_next(&xprt->backlog); 1003 rpc_wake_up_next(&xprt->backlog);
1006 spin_unlock(&xprt->reserve_lock); 1004 spin_unlock(&xprt->reserve_lock);
1007} 1005}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 2118d644663..9049a5caeb2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2276,8 +2276,6 @@ static void __xfrm_garbage_collect(struct net *net)
2276{ 2276{
2277 struct dst_entry *head, *next; 2277 struct dst_entry *head, *next;
2278 2278
2279 flow_cache_flush();
2280
2281 spin_lock_bh(&xfrm_policy_sk_bundle_lock); 2279 spin_lock_bh(&xfrm_policy_sk_bundle_lock);
2282 head = xfrm_policy_sk_bundles; 2280 head = xfrm_policy_sk_bundles;
2283 xfrm_policy_sk_bundles = NULL; 2281 xfrm_policy_sk_bundles = NULL;
@@ -2290,6 +2288,18 @@ static void __xfrm_garbage_collect(struct net *net)
2290 } 2288 }
2291} 2289}
2292 2290
2291static void xfrm_garbage_collect(struct net *net)
2292{
2293 flow_cache_flush();
2294 __xfrm_garbage_collect(net);
2295}
2296
2297static void xfrm_garbage_collect_deferred(struct net *net)
2298{
2299 flow_cache_flush_deferred();
2300 __xfrm_garbage_collect(net);
2301}
2302
2293static void xfrm_init_pmtu(struct dst_entry *dst) 2303static void xfrm_init_pmtu(struct dst_entry *dst)
2294{ 2304{
2295 do { 2305 do {
@@ -2422,7 +2432,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
2422 if (likely(dst_ops->neigh_lookup == NULL)) 2432 if (likely(dst_ops->neigh_lookup == NULL))
2423 dst_ops->neigh_lookup = xfrm_neigh_lookup; 2433 dst_ops->neigh_lookup = xfrm_neigh_lookup;
2424 if (likely(afinfo->garbage_collect == NULL)) 2434 if (likely(afinfo->garbage_collect == NULL))
2425 afinfo->garbage_collect = __xfrm_garbage_collect; 2435 afinfo->garbage_collect = xfrm_garbage_collect_deferred;
2426 xfrm_policy_afinfo[afinfo->family] = afinfo; 2436 xfrm_policy_afinfo[afinfo->family] = afinfo;
2427 } 2437 }
2428 write_unlock_bh(&xfrm_policy_afinfo_lock); 2438 write_unlock_bh(&xfrm_policy_afinfo_lock);
@@ -2516,7 +2526,7 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void
2516 2526
2517 switch (event) { 2527 switch (event) {
2518 case NETDEV_DOWN: 2528 case NETDEV_DOWN:
2519 __xfrm_garbage_collect(dev_net(dev)); 2529 xfrm_garbage_collect(dev_net(dev));
2520 } 2530 }
2521 return NOTIFY_DONE; 2531 return NOTIFY_DONE;
2522} 2532}
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index ba573fe7c74..914833d99b0 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -60,8 +60,8 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
60 --directory=$(srctree) --directory=$(objtree) \ 60 --directory=$(srctree) --directory=$(objtree) \
61 --output $(obj)/config.pot 61 --output $(obj)/config.pot
62 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 62 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
63 $(Q)ln -fs Kconfig.x86 arch/um/Kconfig 63 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
64 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \ 64 $(srctree)/arch/*/um/Kconfig`; \
65 do \ 65 do \
66 echo " GEN $$i"; \ 66 echo " GEN $$i"; \
67 $(obj)/kxgettext $$i \ 67 $(obj)/kxgettext $$i \
@@ -69,7 +69,6 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
69 done ) 69 done )
70 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 70 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
71 --output $(obj)/linux.pot 71 --output $(obj)/linux.pot
72 $(Q)rm -f $(srctree)/arch/um/Kconfig
73 $(Q)rm -f $(obj)/config.pot 72 $(Q)rm -f $(obj)/config.pot
74 73
75PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 74PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index f40a6af6bf4..54e35c1e594 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -462,7 +462,7 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
462 succeed_file(); 462 succeed_file();
463 } 463 }
464 if (w(txthdr->sh_type) != SHT_PROGBITS || 464 if (w(txthdr->sh_type) != SHT_PROGBITS ||
465 !(w(txthdr->sh_flags) & SHF_EXECINSTR)) 465 !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
466 return NULL; 466 return NULL;
467 return txtname; 467 return txtname;
468} 468}
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 5dd5b140242..8738deff26f 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -27,20 +27,35 @@ static int evmkey_len = MAX_KEY_SIZE;
27 27
28struct crypto_shash *hmac_tfm; 28struct crypto_shash *hmac_tfm;
29 29
30static DEFINE_MUTEX(mutex);
31
30static struct shash_desc *init_desc(void) 32static struct shash_desc *init_desc(void)
31{ 33{
32 int rc; 34 int rc;
33 struct shash_desc *desc; 35 struct shash_desc *desc;
34 36
35 if (hmac_tfm == NULL) { 37 if (hmac_tfm == NULL) {
38 mutex_lock(&mutex);
39 if (hmac_tfm)
40 goto out;
36 hmac_tfm = crypto_alloc_shash(evm_hmac, 0, CRYPTO_ALG_ASYNC); 41 hmac_tfm = crypto_alloc_shash(evm_hmac, 0, CRYPTO_ALG_ASYNC);
37 if (IS_ERR(hmac_tfm)) { 42 if (IS_ERR(hmac_tfm)) {
38 pr_err("Can not allocate %s (reason: %ld)\n", 43 pr_err("Can not allocate %s (reason: %ld)\n",
39 evm_hmac, PTR_ERR(hmac_tfm)); 44 evm_hmac, PTR_ERR(hmac_tfm));
40 rc = PTR_ERR(hmac_tfm); 45 rc = PTR_ERR(hmac_tfm);
41 hmac_tfm = NULL; 46 hmac_tfm = NULL;
47 mutex_unlock(&mutex);
48 return ERR_PTR(rc);
49 }
50 rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
51 if (rc) {
52 crypto_free_shash(hmac_tfm);
53 hmac_tfm = NULL;
54 mutex_unlock(&mutex);
42 return ERR_PTR(rc); 55 return ERR_PTR(rc);
43 } 56 }
57out:
58 mutex_unlock(&mutex);
44 } 59 }
45 60
46 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac_tfm), 61 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac_tfm),
@@ -51,11 +66,7 @@ static struct shash_desc *init_desc(void)
51 desc->tfm = hmac_tfm; 66 desc->tfm = hmac_tfm;
52 desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 67 desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
53 68
54 rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
55 if (rc)
56 goto out;
57 rc = crypto_shash_init(desc); 69 rc = crypto_shash_init(desc);
58out:
59 if (rc) { 70 if (rc) {
60 kfree(desc); 71 kfree(desc);
61 return ERR_PTR(rc); 72 return ERR_PTR(rc);
diff --git a/security/security.c b/security/security.c
index 0c6cc69c8f8..e2f684aeb70 100644
--- a/security/security.c
+++ b/security/security.c
@@ -381,7 +381,7 @@ int security_old_inode_init_security(struct inode *inode, struct inode *dir,
381 void **value, size_t *len) 381 void **value, size_t *len)
382{ 382{
383 if (unlikely(IS_PRIVATE(inode))) 383 if (unlikely(IS_PRIVATE(inode)))
384 return 0; 384 return -EOPNOTSUPP;
385 return security_ops->inode_init_security(inode, dir, qstr, name, value, 385 return security_ops->inode_init_security(inode, dir, qstr, name, value,
386 len); 386 len);
387} 387}
diff --git a/security/selinux/netport.c b/security/selinux/netport.c
index 0b62bd11246..7b9eb1faf68 100644
--- a/security/selinux/netport.c
+++ b/security/selinux/netport.c
@@ -123,7 +123,9 @@ static void sel_netport_insert(struct sel_netport *port)
123 if (sel_netport_hash[idx].size == SEL_NETPORT_HASH_BKT_LIMIT) { 123 if (sel_netport_hash[idx].size == SEL_NETPORT_HASH_BKT_LIMIT) {
124 struct sel_netport *tail; 124 struct sel_netport *tail;
125 tail = list_entry( 125 tail = list_entry(
126 rcu_dereference(sel_netport_hash[idx].list.prev), 126 rcu_dereference_protected(
127 sel_netport_hash[idx].list.prev,
128 lockdep_is_held(&sel_netport_lock)),
127 struct sel_netport, list); 129 struct sel_netport, list);
128 list_del_rcu(&tail->list); 130 list_del_rcu(&tail->list);
129 kfree_rcu(tail, rcu); 131 kfree_rcu(tail, rcu);
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 6e5addeb236..73516f69ac7 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -899,6 +899,10 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
899 /* AC97 v2.2 specifications says minimum 1 us. */ 899 /* AC97 v2.2 specifications says minimum 1 us. */
900 udelay(2); 900 udelay(2);
901 gpio_set_value(chip->reset_pin, 1); 901 gpio_set_value(chip->reset_pin, 1);
902 } else {
903 ac97c_writel(chip, MR, AC97C_MR_WRST | AC97C_MR_ENA);
904 udelay(2);
905 ac97c_writel(chip, MR, AC97C_MR_ENA);
902 } 906 }
903} 907}
904 908
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index bfdc52370ad..d3b0a20744f 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -235,6 +235,7 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
235 switch (snd_pcm_format_width(params_format(params))) { 235 switch (snd_pcm_format_width(params_format(params))) {
236 case 16: 236 case 16:
237 iface = 0; 237 iface = 0;
238 break;
238 case 20: 239 case 20:
239 iface = 0x10; 240 iface = 0x10;
240 break; 241 break;
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index 3ad0925d23a..758e3b36d4c 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -17,6 +17,8 @@
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/namei.h>
21#include <linux/fs.h>
20#include "irq.h" 22#include "irq.h"
21 23
22static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head, 24static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head,
@@ -480,12 +482,76 @@ out:
480 return r; 482 return r;
481} 483}
482 484
485/*
486 * We want to test whether the caller has been granted permissions to
487 * use this device. To be able to configure and control the device,
488 * the user needs access to PCI configuration space and BAR resources.
489 * These are accessed through PCI sysfs. PCI config space is often
490 * passed to the process calling this ioctl via file descriptor, so we
491 * can't rely on access to that file. We can check for permissions
492 * on each of the BAR resource files, which is a pretty clear
493 * indicator that the user has been granted access to the device.
494 */
495static int probe_sysfs_permissions(struct pci_dev *dev)
496{
497#ifdef CONFIG_SYSFS
498 int i;
499 bool bar_found = false;
500
501 for (i = PCI_STD_RESOURCES; i <= PCI_STD_RESOURCE_END; i++) {
502 char *kpath, *syspath;
503 struct path path;
504 struct inode *inode;
505 int r;
506
507 if (!pci_resource_len(dev, i))
508 continue;
509
510 kpath = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
511 if (!kpath)
512 return -ENOMEM;
513
514 /* Per sysfs-rules, sysfs is always at /sys */
515 syspath = kasprintf(GFP_KERNEL, "/sys%s/resource%d", kpath, i);
516 kfree(kpath);
517 if (!syspath)
518 return -ENOMEM;
519
520 r = kern_path(syspath, LOOKUP_FOLLOW, &path);
521 kfree(syspath);
522 if (r)
523 return r;
524
525 inode = path.dentry->d_inode;
526
527 r = inode_permission(inode, MAY_READ | MAY_WRITE | MAY_ACCESS);
528 path_put(&path);
529 if (r)
530 return r;
531
532 bar_found = true;
533 }
534
535 /* If no resources, probably something special */
536 if (!bar_found)
537 return -EPERM;
538
539 return 0;
540#else
541 return -EINVAL; /* No way to control the device without sysfs */
542#endif
543}
544
483static int kvm_vm_ioctl_assign_device(struct kvm *kvm, 545static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
484 struct kvm_assigned_pci_dev *assigned_dev) 546 struct kvm_assigned_pci_dev *assigned_dev)
485{ 547{
486 int r = 0, idx; 548 int r = 0, idx;
487 struct kvm_assigned_dev_kernel *match; 549 struct kvm_assigned_dev_kernel *match;
488 struct pci_dev *dev; 550 struct pci_dev *dev;
551 u8 header_type;
552
553 if (!(assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU))
554 return -EINVAL;
489 555
490 mutex_lock(&kvm->lock); 556 mutex_lock(&kvm->lock);
491 idx = srcu_read_lock(&kvm->srcu); 557 idx = srcu_read_lock(&kvm->srcu);
@@ -513,6 +579,18 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
513 r = -EINVAL; 579 r = -EINVAL;
514 goto out_free; 580 goto out_free;
515 } 581 }
582
583 /* Don't allow bridges to be assigned */
584 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
585 if ((header_type & PCI_HEADER_TYPE) != PCI_HEADER_TYPE_NORMAL) {
586 r = -EPERM;
587 goto out_put;
588 }
589
590 r = probe_sysfs_permissions(dev);
591 if (r)
592 goto out_put;
593
516 if (pci_enable_device(dev)) { 594 if (pci_enable_device(dev)) {
517 printk(KERN_INFO "%s: Could not enable PCI device\n", __func__); 595 printk(KERN_INFO "%s: Could not enable PCI device\n", __func__);
518 r = -EBUSY; 596 r = -EBUSY;
@@ -544,16 +622,14 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
544 622
545 list_add(&match->list, &kvm->arch.assigned_dev_head); 623 list_add(&match->list, &kvm->arch.assigned_dev_head);
546 624
547 if (assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU) { 625 if (!kvm->arch.iommu_domain) {
548 if (!kvm->arch.iommu_domain) { 626 r = kvm_iommu_map_guest(kvm);
549 r = kvm_iommu_map_guest(kvm);
550 if (r)
551 goto out_list_del;
552 }
553 r = kvm_assign_device(kvm, match);
554 if (r) 627 if (r)
555 goto out_list_del; 628 goto out_list_del;
556 } 629 }
630 r = kvm_assign_device(kvm, match);
631 if (r)
632 goto out_list_del;
557 633
558out: 634out:
559 srcu_read_unlock(&kvm->srcu, idx); 635 srcu_read_unlock(&kvm->srcu, idx);
@@ -593,8 +669,7 @@ static int kvm_vm_ioctl_deassign_device(struct kvm *kvm,
593 goto out; 669 goto out;
594 } 670 }
595 671
596 if (match->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU) 672 kvm_deassign_device(kvm, match);
597 kvm_deassign_device(kvm, match);
598 673
599 kvm_free_assigned_device(kvm, match); 674 kvm_free_assigned_device(kvm, match);
600 675