aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile2
-rw-r--r--arch/arm/common/it8152.c7
-rw-r--r--arch/arm/common/pl330.c3
-rw-r--r--arch/arm/include/asm/assembler.h5
-rw-r--r--arch/arm/include/asm/hardware/pl330.h2
-rw-r--r--arch/arm/include/asm/processor.h1
-rw-r--r--arch/arm/kernel/ptrace.c9
-rw-r--r--arch/arm/kernel/smp_twd.c2
-rw-r--r--arch/arm/mach-omap2/voltagedomains3xxx_data.c2
-rw-r--r--arch/arm/mach-omap2/voltagedomains44xx_data.c2
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c29
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c12
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c3
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c95
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c113
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh73a0.h6
-rw-r--r--arch/arm/mach-shmobile/intc-sh73a0.c2
-rw-r--r--arch/arm/mach-shmobile/pfc-r8a7779.c2
-rw-r--r--arch/arm/mach-shmobile/pfc-sh7372.c41
-rw-r--r--arch/arm/mach-shmobile/smp-sh73a0.c2
-rw-r--r--arch/arm/mm/Kconfig3
-rw-r--r--arch/arm/mm/cache-v7.S2
-rw-r--r--arch/c6x/boot/Makefile2
-rw-r--r--arch/m68k/include/asm/mcf_pgtable.h3
-rw-r--r--arch/m68k/mm/mcfmmu.c9
-rw-r--r--arch/m68k/platform/coldfire/entry.S4
-rw-r--r--arch/powerpc/kernel/entry_32.S2
-rw-r--r--arch/powerpc/kernel/entry_64.S6
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S2
-rw-r--r--arch/powerpc/kernel/signal.c12
-rw-r--r--arch/powerpc/kernel/signal.h2
-rw-r--r--arch/powerpc/platforms/wsp/smp.c2
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/process.c5
-rw-r--r--arch/s390/kernel/time.c7
-rw-r--r--arch/s390/mm/pgtable.c2
-rw-r--r--arch/sh/boards/board-sh7757lcr.c20
-rw-r--r--arch/sh/boards/mach-ap325rxa/setup.c1
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c2
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c1
-rw-r--r--arch/sh/boards/mach-migor/setup.c2
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c1
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c2
-rw-r--r--arch/sh/include/asm/device.h8
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7724.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7757.c22
-rw-r--r--arch/sh/kernel/smp.c2
-rw-r--r--arch/sh/kernel/topology.c2
-rw-r--r--arch/sh/mm/cache-sh2a.c2
-rw-r--r--arch/x86/include/asm/i387.h53
-rw-r--r--arch/x86/include/asm/processor.h3
-rw-r--r--arch/x86/kernel/cpu/common.c5
-rw-r--r--arch/x86/kernel/process_32.c3
-rw-r--r--arch/x86/kernel/process_64.c3
-rw-r--r--arch/x86/kernel/traps.c40
-rw-r--r--drivers/atm/solos-pci.c4
-rw-r--r--drivers/block/nvme.c2
-rw-r--r--drivers/cpuidle/Kconfig2
-rw-r--r--drivers/edac/i3200_edac.c15
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_core.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c6
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c26
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.c34
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.h1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.c70
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c7
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c19
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h15
-rw-r--r--drivers/gpu/drm/i915/intel_display.c24
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c1
-rw-r--r--drivers/gpu/drm/radeon/ni.c1
-rw-r--r--drivers/gpu/drm/radeon/r100.c8
-rw-r--r--drivers/gpu/drm/radeon/r300.c8
-rw-r--r--drivers/gpu/drm/radeon/r420.c8
-rw-r--r--drivers/gpu/drm/radeon/r520.c8
-rw-r--r--drivers/gpu/drm/radeon/r600.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c7
-rw-r--r--drivers/gpu/drm/radeon/rs400.c8
-rw-r--r--drivers/gpu/drm/radeon/rs600.c8
-rw-r--r--drivers/gpu/drm/radeon/rs690.c8
-rw-r--r--drivers/gpu/drm/radeon/rv515.c8
-rw-r--r--drivers/gpu/drm/radeon/rv770.c1
-rw-r--r--drivers/hwmon/ads1015.c3
-rw-r--r--drivers/hwmon/f75375s.c7
-rw-r--r--drivers/hwmon/max6639.c22
-rw-r--r--drivers/hwmon/pmbus/max34440.c2
-rw-r--r--drivers/media/radio/wl128x/Kconfig4
-rw-r--r--drivers/media/rc/imon.c26
-rw-r--r--drivers/media/video/hdpvr/hdpvr-core.c18
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c46
-rw-r--r--drivers/media/video/hdpvr/hdpvr.h1
-rw-r--r--drivers/media/video/omap3isp/ispccdc.c2
-rw-r--r--drivers/net/can/sja1000/sja1000.c13
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c4
-rw-r--r--drivers/net/ethernet/broadcom/b44.c2
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c6
-rw-r--r--drivers/net/ethernet/cisco/enic/cq_enet_desc.h2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_pp.c2
-rw-r--r--drivers/net/ethernet/jme.c10
-rw-r--r--drivers/net/ethernet/jme.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c12
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c2
-rw-r--r--drivers/net/ethernet/sfc/rx.c4
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c6
-rw-r--r--drivers/net/phy/icplus.c55
-rw-r--r--drivers/net/ppp/ppp_generic.c23
-rw-r--r--drivers/net/usb/cdc_ether.c7
-rw-r--r--drivers/net/usb/hso.c2
-rw-r--r--drivers/net/usb/zaurus.c12
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c4
-rw-r--r--drivers/platform/x86/ibm_rtl.c15
-rw-r--r--drivers/platform/x86/intel_ips.c15
-rw-r--r--drivers/s390/char/con3215.c22
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c25
-rw-r--r--drivers/scsi/ipr.c24
-rw-r--r--drivers/scsi/isci/host.c4
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c50
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h13
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c15
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_nx.c23
-rw-r--r--drivers/scsi/scsi_pm.c16
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_scan.c4
-rw-r--r--drivers/sh/clk/cpg.c2
-rw-r--r--drivers/usb/core/hcd-pci.c5
-rw-r--r--drivers/usb/core/hcd.c6
-rw-r--r--drivers/usb/core/hub.c30
-rw-r--r--drivers/usb/host/pci-quirks.c11
-rw-r--r--drivers/usb/host/xhci-hub.c2
-rw-r--r--drivers/usb/host/xhci-mem.c32
-rw-r--r--drivers/usb/host/xhci.c5
-rw-r--r--drivers/usb/serial/cp210x.c2
-rw-r--r--drivers/usb/serial/option.c143
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c6
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h4
-rw-r--r--drivers/usb/storage/usb.c90
-rw-r--r--drivers/usb/storage/usb.h7
-rw-r--r--drivers/video/pvr2fb.c2
-rw-r--r--fs/autofs4/autofs_i.h1
-rw-r--r--fs/autofs4/dev-ioctl.c1
-rw-r--r--fs/autofs4/expire.c2
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/autofs4/waitq.c22
-rw-r--r--fs/btrfs/backref.c2
-rw-r--r--fs/btrfs/check-integrity.c2
-rw-r--r--fs/btrfs/compression.c2
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c12
-rw-r--r--fs/btrfs/extent-tree.c51
-rw-r--r--fs/btrfs/extent_io.c113
-rw-r--r--fs/btrfs/extent_io.h1
-rw-r--r--fs/btrfs/extent_map.h4
-rw-r--r--fs/btrfs/file.c29
-rw-r--r--fs/btrfs/free-space-cache.c1
-rw-r--r--fs/btrfs/inode-map.c6
-rw-r--r--fs/btrfs/inode.c40
-rw-r--r--fs/btrfs/ioctl.c59
-rw-r--r--fs/btrfs/scrub.c8
-rw-r--r--fs/btrfs/transaction.c16
-rw-r--r--fs/btrfs/volumes.c33
-rw-r--r--fs/compat.c56
-rw-r--r--fs/dcache.c8
-rw-r--r--fs/direct-io.c4
-rw-r--r--fs/eventpoll.c30
-rw-r--r--fs/inode.c8
-rw-r--r--fs/namei.c4
-rw-r--r--fs/nfs/nfs4proc.c130
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/nfs4xdr.c5
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/quota/quota.c24
-rw-r--r--fs/select.c2
-rw-r--r--fs/signalfd.c15
-rw-r--r--fs/super.c22
-rw-r--r--fs/xfs/xfs_dquot.c24
-rw-r--r--fs/xfs/xfs_log_recover.c6
-rw-r--r--fs/xfs/xfs_qm_syscalls.c4
-rw-r--r--fs/xfs/xfs_trans.c4
-rw-r--r--fs/xfs/xfs_trans_dquot.c10
-rw-r--r--include/asm-generic/io-64-nonatomic-hi-lo.h28
-rw-r--r--include/asm-generic/io-64-nonatomic-lo-hi.h28
-rw-r--r--include/asm-generic/poll.h2
-rw-r--r--include/linux/compat.h4
-rw-r--r--include/linux/digsig.h4
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/if_link.h1
-rw-r--r--include/linux/netfilter_bridge/ebtables.h4
-rw-r--r--include/linux/nfs_xdr.h2
-rw-r--r--include/linux/rtnetlink.h3
-rw-r--r--include/linux/signalfd.h5
-rw-r--r--include/linux/skbuff.h10
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/usb/ch11.h10
-rw-r--r--include/net/netfilter/nf_conntrack.h2
-rw-r--r--include/net/rtnetlink.h2
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/pid.c4
-rw-r--r--mm/memcontrol.c5
-rw-r--r--mm/nommu.c9
-rw-r--r--mm/page_alloc.c1
-rw-r--r--net/atm/clip.c10
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/rtnetlink.c78
-rw-r--r--net/ipv4/ip_gre.c10
-rw-r--r--net/ipv4/ping.c1
-rw-r--r--net/ipv4/tcp.c5
-rw-r--r--net/ipv4/xfrm4_mode_beet.c5
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c6
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/ndisc.c5
-rw-r--r--net/ipv6/xfrm6_mode_beet.c6
-rw-r--r--net/ipv6/xfrm6_mode_tunnel.c6
-rw-r--r--net/netfilter/ipvs/ip_vs_core.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c38
-rw-r--r--net/netfilter/nf_conntrack_netlink.c46
-rw-r--r--net/netfilter/nf_queue.c40
-rw-r--r--net/netfilter/xt_TEE.c5
-rw-r--r--net/sched/sch_netem.c6
-rwxr-xr-xscripts/coccicheck13
-rwxr-xr-xscripts/depmod.sh6
-rw-r--r--scripts/mod/modpost.c9
-rw-r--r--scripts/package/builddeb12
-rw-r--r--sound/pci/hda/patch_realtek.c19
-rw-r--r--sound/soc/codecs/ak4642.c31
-rw-r--r--sound/soc/codecs/wm8962.c2
-rw-r--r--sound/usb/caiaq/audio.c5
-rw-r--r--sound/usb/card.h1
-rw-r--r--sound/usb/format.c4
-rw-r--r--sound/usb/quirks.c6
244 files changed, 1866 insertions, 1260 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index ed48d55662c1..3b5fe0c09c23 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -269,7 +269,6 @@ S: Orphan
269F: drivers/platform/x86/wmi.c 269F: drivers/platform/x86/wmi.c
270 270
271AD1889 ALSA SOUND DRIVER 271AD1889 ALSA SOUND DRIVER
272M: Kyle McMartin <kyle@mcmartin.ca>
273M: Thibaut Varene <T-Bone@parisc-linux.org> 272M: Thibaut Varene <T-Bone@parisc-linux.org>
274W: http://wiki.parisc-linux.org/AD1889 273W: http://wiki.parisc-linux.org/AD1889
275L: linux-parisc@vger.kernel.org 274L: linux-parisc@vger.kernel.org
@@ -3049,7 +3048,6 @@ F: drivers/hwspinlock/hwspinlock_*
3049F: include/linux/hwspinlock.h 3048F: include/linux/hwspinlock.h
3050 3049
3051HARMONY SOUND DRIVER 3050HARMONY SOUND DRIVER
3052M: Kyle McMartin <kyle@mcmartin.ca>
3053L: linux-parisc@vger.kernel.org 3051L: linux-parisc@vger.kernel.org
3054S: Maintained 3052S: Maintained
3055F: sound/parisc/harmony.* 3053F: sound/parisc/harmony.*
@@ -5000,9 +4998,8 @@ F: Documentation/blockdev/paride.txt
5000F: drivers/block/paride/ 4998F: drivers/block/paride/
5001 4999
5002PARISC ARCHITECTURE 5000PARISC ARCHITECTURE
5003M: Kyle McMartin <kyle@mcmartin.ca>
5004M: Helge Deller <deller@gmx.de>
5005M: "James E.J. Bottomley" <jejb@parisc-linux.org> 5001M: "James E.J. Bottomley" <jejb@parisc-linux.org>
5002M: Helge Deller <deller@gmx.de>
5006L: linux-parisc@vger.kernel.org 5003L: linux-parisc@vger.kernel.org
5007W: http://www.parisc-linux.org/ 5004W: http://www.parisc-linux.org/
5008Q: http://patchwork.kernel.org/project/linux-parisc/list/ 5005Q: http://patchwork.kernel.org/project/linux-parisc/list/
@@ -5861,7 +5858,7 @@ S: Maintained
5861F: drivers/mmc/host/sdhci-spear.c 5858F: drivers/mmc/host/sdhci-spear.c
5862 5859
5863SECURITY SUBSYSTEM 5860SECURITY SUBSYSTEM
5864M: James Morris <jmorris@namei.org> 5861M: James Morris <james.l.morris@oracle.com>
5865L: linux-security-module@vger.kernel.org (suggested Cc:) 5862L: linux-security-module@vger.kernel.org (suggested Cc:)
5866T: git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git 5863T: git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git
5867W: http://security.wiki.kernel.org/ 5864W: http://security.wiki.kernel.org/
@@ -5874,7 +5871,7 @@ S: Supported
5874 5871
5875SELINUX SECURITY MODULE 5872SELINUX SECURITY MODULE
5876M: Stephen Smalley <sds@tycho.nsa.gov> 5873M: Stephen Smalley <sds@tycho.nsa.gov>
5877M: James Morris <jmorris@namei.org> 5874M: James Morris <james.l.morris@oracle.com>
5878M: Eric Paris <eparis@parisplace.org> 5875M: Eric Paris <eparis@parisplace.org>
5879L: selinux@tycho.nsa.gov (subscribers-only, general discussion) 5876L: selinux@tycho.nsa.gov (subscribers-only, general discussion)
5880W: http://selinuxproject.org 5877W: http://selinuxproject.org
diff --git a/Makefile b/Makefile
index 4ddd641ab615..b61a9638b6fc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 3 2PATCHLEVEL = 3
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc5
5NAME = Saber-toothed Squirrel 5NAME = Saber-toothed Squirrel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c
index d1bcd7b13ebc..fb1f1cfce60c 100644
--- a/arch/arm/common/it8152.c
+++ b/arch/arm/common/it8152.c
@@ -320,13 +320,6 @@ err0:
320 return -EBUSY; 320 return -EBUSY;
321} 321}
322 322
323/*
324 * If we set up a device for bus mastering, we need to check the latency
325 * timer as we don't have even crappy BIOSes to set it properly.
326 * The implementation is from arch/i386/pci/i386.c
327 */
328unsigned int pcibios_max_latency = 255;
329
330/* ITE bridge requires setting latency timer to avoid early bus access 323/* ITE bridge requires setting latency timer to avoid early bus access
331 termination by PCI bus master devices 324 termination by PCI bus master devices
332*/ 325*/
diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
index d8e44a43047c..ff3ad2244824 100644
--- a/arch/arm/common/pl330.c
+++ b/arch/arm/common/pl330.c
@@ -1502,12 +1502,13 @@ int pl330_chan_ctrl(void *ch_id, enum pl330_chan_op op)
1502 struct pl330_thread *thrd = ch_id; 1502 struct pl330_thread *thrd = ch_id;
1503 struct pl330_dmac *pl330; 1503 struct pl330_dmac *pl330;
1504 unsigned long flags; 1504 unsigned long flags;
1505 int ret = 0, active = thrd->req_running; 1505 int ret = 0, active;
1506 1506
1507 if (!thrd || thrd->free || thrd->dmac->state == DYING) 1507 if (!thrd || thrd->free || thrd->dmac->state == DYING)
1508 return -EINVAL; 1508 return -EINVAL;
1509 1509
1510 pl330 = thrd->dmac; 1510 pl330 = thrd->dmac;
1511 active = thrd->req_running;
1511 1512
1512 spin_lock_irqsave(&pl330->lock, flags); 1513 spin_lock_irqsave(&pl330->lock, flags);
1513 1514
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 62f8095d46de..23371b17b23e 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -137,6 +137,11 @@
137 disable_irq 137 disable_irq
138 .endm 138 .endm
139 139
140 .macro save_and_disable_irqs_notrace, oldcpsr
141 mrs \oldcpsr, cpsr
142 disable_irq_notrace
143 .endm
144
140/* 145/*
141 * Restore interrupt state previously stored in a register. We don't 146 * Restore interrupt state previously stored in a register. We don't
142 * guarantee that this will preserve the flags. 147 * guarantee that this will preserve the flags.
diff --git a/arch/arm/include/asm/hardware/pl330.h b/arch/arm/include/asm/hardware/pl330.h
index 575fa8186ca0..c1821385abfa 100644
--- a/arch/arm/include/asm/hardware/pl330.h
+++ b/arch/arm/include/asm/hardware/pl330.h
@@ -41,7 +41,7 @@ enum pl330_dstcachectrl {
41 DCCTRL1, /* Bufferable only */ 41 DCCTRL1, /* Bufferable only */
42 DCCTRL2, /* Cacheable, but do not allocate */ 42 DCCTRL2, /* Cacheable, but do not allocate */
43 DCCTRL3, /* Cacheable and bufferable, but do not allocate */ 43 DCCTRL3, /* Cacheable and bufferable, but do not allocate */
44 DINVALID1 = 8, 44 DINVALID1, /* AWCACHE = 0x1000 */
45 DINVALID2, 45 DINVALID2,
46 DCCTRL6, /* Cacheable write-through, allocate on writes only */ 46 DCCTRL6, /* Cacheable write-through, allocate on writes only */
47 DCCTRL7, /* Cacheable write-back, allocate on writes only */ 47 DCCTRL7, /* Cacheable write-back, allocate on writes only */
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index ce280b8d613c..cb8d638924fd 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -22,6 +22,7 @@
22#include <asm/hw_breakpoint.h> 22#include <asm/hw_breakpoint.h>
23#include <asm/ptrace.h> 23#include <asm/ptrace.h>
24#include <asm/types.h> 24#include <asm/types.h>
25#include <asm/system.h>
25 26
26#ifdef __KERNEL__ 27#ifdef __KERNEL__
27#define STACK_TOP ((current->personality & ADDR_LIMIT_32BIT) ? \ 28#define STACK_TOP ((current->personality & ADDR_LIMIT_32BIT) ? \
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index e33870ff0ac0..ede6443c34d9 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -23,6 +23,7 @@
23#include <linux/perf_event.h> 23#include <linux/perf_event.h>
24#include <linux/hw_breakpoint.h> 24#include <linux/hw_breakpoint.h>
25#include <linux/regset.h> 25#include <linux/regset.h>
26#include <linux/audit.h>
26 27
27#include <asm/pgtable.h> 28#include <asm/pgtable.h>
28#include <asm/system.h> 29#include <asm/system.h>
@@ -904,6 +905,12 @@ long arch_ptrace(struct task_struct *child, long request,
904 return ret; 905 return ret;
905} 906}
906 907
908#ifdef __ARMEB__
909#define AUDIT_ARCH_NR AUDIT_ARCH_ARMEB
910#else
911#define AUDIT_ARCH_NR AUDIT_ARCH_ARM
912#endif
913
907asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) 914asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
908{ 915{
909 unsigned long ip; 916 unsigned long ip;
@@ -918,7 +925,7 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
918 if (!ip) 925 if (!ip)
919 audit_syscall_exit(regs); 926 audit_syscall_exit(regs);
920 else 927 else
921 audit_syscall_entry(AUDIT_ARCH_ARMEB, scno, regs->ARM_r0, 928 audit_syscall_entry(AUDIT_ARCH_NR, scno, regs->ARM_r0,
922 regs->ARM_r1, regs->ARM_r2, regs->ARM_r3); 929 regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
923 930
924 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 931 if (!test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 4285daa077b0..7a79b24597b2 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -129,7 +129,7 @@ static struct notifier_block twd_cpufreq_nb = {
129 129
130static int twd_cpufreq_init(void) 130static int twd_cpufreq_init(void)
131{ 131{
132 if (!IS_ERR(twd_clk)) 132 if (twd_evt && *__this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
133 return cpufreq_register_notifier(&twd_cpufreq_nb, 133 return cpufreq_register_notifier(&twd_cpufreq_nb,
134 CPUFREQ_TRANSITION_NOTIFIER); 134 CPUFREQ_TRANSITION_NOTIFIER);
135 135
diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index c005e2f5e383..57db2038b23c 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -108,6 +108,7 @@ void __init omap3xxx_voltagedomains_init(void)
108 * XXX Will depend on the process, validation, and binning 108 * XXX Will depend on the process, validation, and binning
109 * for the currently-running IC 109 * for the currently-running IC
110 */ 110 */
111#ifdef CONFIG_PM_OPP
111 if (cpu_is_omap3630()) { 112 if (cpu_is_omap3630()) {
112 omap3_voltdm_mpu.volt_data = omap36xx_vddmpu_volt_data; 113 omap3_voltdm_mpu.volt_data = omap36xx_vddmpu_volt_data;
113 omap3_voltdm_core.volt_data = omap36xx_vddcore_volt_data; 114 omap3_voltdm_core.volt_data = omap36xx_vddcore_volt_data;
@@ -115,6 +116,7 @@ void __init omap3xxx_voltagedomains_init(void)
115 omap3_voltdm_mpu.volt_data = omap34xx_vddmpu_volt_data; 116 omap3_voltdm_mpu.volt_data = omap34xx_vddmpu_volt_data;
116 omap3_voltdm_core.volt_data = omap34xx_vddcore_volt_data; 117 omap3_voltdm_core.volt_data = omap34xx_vddcore_volt_data;
117 } 118 }
119#endif
118 120
119 if (cpu_is_omap3517() || cpu_is_omap3505()) 121 if (cpu_is_omap3517() || cpu_is_omap3505())
120 voltdms = voltagedomains_am35xx; 122 voltdms = voltagedomains_am35xx;
diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
index 4e11d022595d..c3115f6853d4 100644
--- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
@@ -100,9 +100,11 @@ void __init omap44xx_voltagedomains_init(void)
100 * XXX Will depend on the process, validation, and binning 100 * XXX Will depend on the process, validation, and binning
101 * for the currently-running IC 101 * for the currently-running IC
102 */ 102 */
103#ifdef CONFIG_PM_OPP
103 omap4_voltdm_mpu.volt_data = omap44xx_vdd_mpu_volt_data; 104 omap4_voltdm_mpu.volt_data = omap44xx_vdd_mpu_volt_data;
104 omap4_voltdm_iva.volt_data = omap44xx_vdd_iva_volt_data; 105 omap4_voltdm_iva.volt_data = omap44xx_vdd_iva_volt_data;
105 omap4_voltdm_core.volt_data = omap44xx_vdd_core_volt_data; 106 omap4_voltdm_core.volt_data = omap44xx_vdd_core_volt_data;
107#endif
106 108
107 for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++) 109 for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++)
108 voltdm->sys_clk.name = sys_clk_name; 110 voltdm->sys_clk.name = sys_clk_name;
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index eff8a96c75ee..068b754bc348 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -30,6 +30,7 @@
30#include <linux/serial_sci.h> 30#include <linux/serial_sci.h>
31#include <linux/smsc911x.h> 31#include <linux/smsc911x.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/videodev2.h>
33#include <linux/input.h> 34#include <linux/input.h>
34#include <linux/input/sh_keysc.h> 35#include <linux/input/sh_keysc.h>
35#include <linux/mmc/host.h> 36#include <linux/mmc/host.h>
@@ -37,7 +38,6 @@
37#include <linux/mmc/sh_mobile_sdhi.h> 38#include <linux/mmc/sh_mobile_sdhi.h>
38#include <linux/mfd/tmio.h> 39#include <linux/mfd/tmio.h>
39#include <linux/sh_clk.h> 40#include <linux/sh_clk.h>
40#include <linux/dma-mapping.h>
41#include <video/sh_mobile_lcdc.h> 41#include <video/sh_mobile_lcdc.h>
42#include <video/sh_mipi_dsi.h> 42#include <video/sh_mipi_dsi.h>
43#include <sound/sh_fsi.h> 43#include <sound/sh_fsi.h>
@@ -159,19 +159,12 @@ static struct resource sh_mmcif_resources[] = {
159 }, 159 },
160}; 160};
161 161
162static struct sh_mmcif_dma sh_mmcif_dma = {
163 .chan_priv_rx = {
164 .slave_id = SHDMA_SLAVE_MMCIF_RX,
165 },
166 .chan_priv_tx = {
167 .slave_id = SHDMA_SLAVE_MMCIF_TX,
168 },
169};
170static struct sh_mmcif_plat_data sh_mmcif_platdata = { 162static struct sh_mmcif_plat_data sh_mmcif_platdata = {
171 .sup_pclk = 0, 163 .sup_pclk = 0,
172 .ocr = MMC_VDD_165_195, 164 .ocr = MMC_VDD_165_195,
173 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, 165 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
174 .dma = &sh_mmcif_dma, 166 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
167 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
175}; 168};
176 169
177static struct platform_device mmc_device = { 170static struct platform_device mmc_device = {
@@ -321,12 +314,11 @@ static struct resource mipidsi0_resources[] = {
321 }, 314 },
322}; 315};
323 316
324#define DSI0PHYCR 0xe615006c
325static int sh_mipi_set_dot_clock(struct platform_device *pdev, 317static int sh_mipi_set_dot_clock(struct platform_device *pdev,
326 void __iomem *base, 318 void __iomem *base,
327 int enable) 319 int enable)
328{ 320{
329 struct clk *pck; 321 struct clk *pck, *phy;
330 int ret; 322 int ret;
331 323
332 pck = clk_get(&pdev->dev, "dsip_clk"); 324 pck = clk_get(&pdev->dev, "dsip_clk");
@@ -335,18 +327,27 @@ static int sh_mipi_set_dot_clock(struct platform_device *pdev,
335 goto sh_mipi_set_dot_clock_pck_err; 327 goto sh_mipi_set_dot_clock_pck_err;
336 } 328 }
337 329
330 phy = clk_get(&pdev->dev, "dsiphy_clk");
331 if (IS_ERR(phy)) {
332 ret = PTR_ERR(phy);
333 goto sh_mipi_set_dot_clock_phy_err;
334 }
335
338 if (enable) { 336 if (enable) {
339 clk_set_rate(pck, clk_round_rate(pck, 24000000)); 337 clk_set_rate(pck, clk_round_rate(pck, 24000000));
340 __raw_writel(0x2a809010, DSI0PHYCR); 338 clk_set_rate(phy, clk_round_rate(pck, 510000000));
341 clk_enable(pck); 339 clk_enable(pck);
340 clk_enable(phy);
342 } else { 341 } else {
343 clk_disable(pck); 342 clk_disable(pck);
343 clk_disable(phy);
344 } 344 }
345 345
346 ret = 0; 346 ret = 0;
347 347
348 clk_put(phy);
349sh_mipi_set_dot_clock_phy_err:
348 clk_put(pck); 350 clk_put(pck);
349
350sh_mipi_set_dot_clock_pck_err: 351sh_mipi_set_dot_clock_pck_err:
351 return ret; 352 return ret;
352} 353}
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index aab0a349f759..eeb4d9664584 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -295,15 +295,6 @@ static struct resource sh_mmcif_resources[] = {
295 }, 295 },
296}; 296};
297 297
298static struct sh_mmcif_dma sh_mmcif_dma = {
299 .chan_priv_rx = {
300 .slave_id = SHDMA_SLAVE_MMCIF_RX,
301 },
302 .chan_priv_tx = {
303 .slave_id = SHDMA_SLAVE_MMCIF_TX,
304 },
305};
306
307static struct sh_mmcif_plat_data sh_mmcif_plat = { 298static struct sh_mmcif_plat_data sh_mmcif_plat = {
308 .sup_pclk = 0, 299 .sup_pclk = 0,
309 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 300 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -311,7 +302,8 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
311 MMC_CAP_8_BIT_DATA | 302 MMC_CAP_8_BIT_DATA |
312 MMC_CAP_NEEDS_POLL, 303 MMC_CAP_NEEDS_POLL,
313 .get_cd = slot_cn7_get_cd, 304 .get_cd = slot_cn7_get_cd,
314 .dma = &sh_mmcif_dma, 305 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
306 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
315}; 307};
316 308
317static struct platform_device sh_mmcif_device = { 309static struct platform_device sh_mmcif_device = {
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index 857ceeec1bb0..c8e7ca23fc06 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -143,11 +143,10 @@ static struct gpio_keys_button gpio_buttons[] = {
143static struct gpio_keys_platform_data gpio_key_info = { 143static struct gpio_keys_platform_data gpio_key_info = {
144 .buttons = gpio_buttons, 144 .buttons = gpio_buttons,
145 .nbuttons = ARRAY_SIZE(gpio_buttons), 145 .nbuttons = ARRAY_SIZE(gpio_buttons),
146 .poll_interval = 250, /* polled for now */
147}; 146};
148 147
149static struct platform_device gpio_keys_device = { 148static struct platform_device gpio_keys_device = {
150 .name = "gpio-keys-polled", /* polled for now */ 149 .name = "gpio-keys",
151 .id = -1, 150 .id = -1,
152 .dev = { 151 .dev = {
153 .platform_data = &gpio_key_info, 152 .platform_data = &gpio_key_info,
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 9b42fbd10f8e..a2813247b455 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -43,7 +43,6 @@
43#include <linux/smsc911x.h> 43#include <linux/smsc911x.h>
44#include <linux/sh_intc.h> 44#include <linux/sh_intc.h>
45#include <linux/tca6416_keypad.h> 45#include <linux/tca6416_keypad.h>
46#include <linux/usb/r8a66597.h>
47#include <linux/usb/renesas_usbhs.h> 46#include <linux/usb/renesas_usbhs.h>
48#include <linux/dma-mapping.h> 47#include <linux/dma-mapping.h>
49 48
@@ -145,11 +144,6 @@
145 * 1-2 short | VBUS 5V | Host 144 * 1-2 short | VBUS 5V | Host
146 * open | external VBUS | Function 145 * open | external VBUS | Function
147 * 146 *
148 * *1
149 * CN31 is used as
150 * CONFIG_USB_R8A66597_HCD Host
151 * CONFIG_USB_RENESAS_USBHS Function
152 *
153 * CAUTION 147 * CAUTION
154 * 148 *
155 * renesas_usbhs driver can use external interrupt mode 149 * renesas_usbhs driver can use external interrupt mode
@@ -161,15 +155,6 @@
161 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0", 155 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
162 * because Touchscreen is using IRQ7-PORT40. 156 * because Touchscreen is using IRQ7-PORT40.
163 * It is impossible to use IRQ7 demux on this board. 157 * It is impossible to use IRQ7 demux on this board.
164 *
165 * We can use external interrupt mode USB-Function on "USB1".
166 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
167 * But don't select both drivers in same time.
168 * These uses same IRQ number for request_irq(), and aren't supporting
169 * IRQF_SHARED / IORESOURCE_IRQ_SHAREABLE.
170 *
171 * Actually these are old/new version of USB driver.
172 * This mean its register will be broken if it supports shared IRQ,
173 */ 158 */
174 159
175/* 160/*
@@ -208,6 +193,16 @@
208 */ 193 */
209 194
210/* 195/*
196 * FSI - AK4642
197 *
198 * it needs amixer settings for playing
199 *
200 * amixer set "Headphone" on
201 * amixer set "HPOUTL Mixer DACH" on
202 * amixer set "HPOUTR Mixer DACH" on
203 */
204
205/*
211 * FIXME !! 206 * FIXME !!
212 * 207 *
213 * gpio_no_direction 208 * gpio_no_direction
@@ -676,51 +671,16 @@ static struct platform_device usbhs0_device = {
676 * Use J30 to select between Host and Function. This setting 671 * Use J30 to select between Host and Function. This setting
677 * can however not be detected by software. Hotplug of USBHS1 672 * can however not be detected by software. Hotplug of USBHS1
678 * is provided via IRQ8. 673 * is provided via IRQ8.
674 *
675 * Current USB1 works as "USB Host".
676 * - set J30 "short"
677 *
678 * If you want to use it as "USB gadget",
679 * - J30 "open"
680 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
681 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
679 */ 682 */
680#define IRQ8 evt2irq(0x0300) 683#define IRQ8 evt2irq(0x0300)
681
682/* USBHS1 USB Host support via r8a66597_hcd */
683static void usb1_host_port_power(int port, int power)
684{
685 if (!power) /* only power-on is supported for now */
686 return;
687
688 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
689 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
690}
691
692static struct r8a66597_platdata usb1_host_data = {
693 .on_chip = 1,
694 .port_power = usb1_host_port_power,
695};
696
697static struct resource usb1_host_resources[] = {
698 [0] = {
699 .name = "USBHS1",
700 .start = 0xe68b0000,
701 .end = 0xe68b00e6 - 1,
702 .flags = IORESOURCE_MEM,
703 },
704 [1] = {
705 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
706 .flags = IORESOURCE_IRQ,
707 },
708};
709
710static struct platform_device usb1_host_device = {
711 .name = "r8a66597_hcd",
712 .id = 1,
713 .dev = {
714 .dma_mask = NULL, /* not use dma */
715 .coherent_dma_mask = 0xffffffff,
716 .platform_data = &usb1_host_data,
717 },
718 .num_resources = ARRAY_SIZE(usb1_host_resources),
719 .resource = usb1_host_resources,
720};
721
722/* USBHS1 USB Function support via renesas_usbhs */
723
724#define USB_PHY_MODE (1 << 4) 684#define USB_PHY_MODE (1 << 4)
725#define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) 685#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
726#define USB_PHY_ON (1 << 1) 686#define USB_PHY_ON (1 << 1)
@@ -776,7 +736,7 @@ static void usbhs1_hardware_exit(struct platform_device *pdev)
776 736
777static int usbhs1_get_id(struct platform_device *pdev) 737static int usbhs1_get_id(struct platform_device *pdev)
778{ 738{
779 return USBHS_GADGET; 739 return USBHS_HOST;
780} 740}
781 741
782static u32 usbhs1_pipe_cfg[] = { 742static u32 usbhs1_pipe_cfg[] = {
@@ -807,7 +767,6 @@ static struct usbhs_private usbhs1_private = {
807 .hardware_exit = usbhs1_hardware_exit, 767 .hardware_exit = usbhs1_hardware_exit,
808 .get_id = usbhs1_get_id, 768 .get_id = usbhs1_get_id,
809 .phy_reset = usbhs_phy_reset, 769 .phy_reset = usbhs_phy_reset,
810 .get_vbus = usbhs_get_vbus,
811 }, 770 },
812 .driver_param = { 771 .driver_param = {
813 .buswait_bwait = 4, 772 .buswait_bwait = 4,
@@ -1184,15 +1143,6 @@ static struct resource sh_mmcif_resources[] = {
1184 }, 1143 },
1185}; 1144};
1186 1145
1187static struct sh_mmcif_dma sh_mmcif_dma = {
1188 .chan_priv_rx = {
1189 .slave_id = SHDMA_SLAVE_MMCIF_RX,
1190 },
1191 .chan_priv_tx = {
1192 .slave_id = SHDMA_SLAVE_MMCIF_TX,
1193 },
1194};
1195
1196static struct sh_mmcif_plat_data sh_mmcif_plat = { 1146static struct sh_mmcif_plat_data sh_mmcif_plat = {
1197 .sup_pclk = 0, 1147 .sup_pclk = 0,
1198 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 1148 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -1200,7 +1150,8 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
1200 MMC_CAP_8_BIT_DATA | 1150 MMC_CAP_8_BIT_DATA |
1201 MMC_CAP_NEEDS_POLL, 1151 MMC_CAP_NEEDS_POLL,
1202 .get_cd = slot_cn7_get_cd, 1152 .get_cd = slot_cn7_get_cd,
1203 .dma = &sh_mmcif_dma, 1153 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1154 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
1204}; 1155};
1205 1156
1206static struct platform_device sh_mmcif_device = { 1157static struct platform_device sh_mmcif_device = {
@@ -1311,7 +1262,6 @@ static struct platform_device *mackerel_devices[] __initdata = {
1311 &nor_flash_device, 1262 &nor_flash_device,
1312 &smc911x_device, 1263 &smc911x_device,
1313 &lcdc_device, 1264 &lcdc_device,
1314 &usb1_host_device,
1315 &usbhs1_device, 1265 &usbhs1_device,
1316 &usbhs0_device, 1266 &usbhs0_device,
1317 &leds_device, 1267 &leds_device,
@@ -1473,9 +1423,6 @@ static void __init mackerel_init(void)
1473 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ 1423 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1474 gpio_request(GPIO_FN_IDIN_1_113, NULL); 1424 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1475 1425
1476 /* USB phy tweak to make the r8a66597_hcd host driver work */
1477 __raw_writew(0x8a0a, 0xe6058130); /* USBCR4 */
1478
1479 /* enable FSI2 port A (ak4643) */ 1426 /* enable FSI2 port A (ak4643) */
1480 gpio_request(GPIO_FN_FSIAIBT, NULL); 1427 gpio_request(GPIO_FN_FSIAIBT, NULL);
1481 gpio_request(GPIO_FN_FSIAILR, NULL); 1428 gpio_request(GPIO_FN_FSIAILR, NULL);
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index afbead6a6e17..7727cca6136c 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -365,6 +365,114 @@ static struct clk div6_clks[DIV6_NR] = {
365 dsi_parent, ARRAY_SIZE(dsi_parent), 12, 3), 365 dsi_parent, ARRAY_SIZE(dsi_parent), 12, 3),
366}; 366};
367 367
368/* DSI DIV */
369static unsigned long dsiphy_recalc(struct clk *clk)
370{
371 u32 value;
372
373 value = __raw_readl(clk->mapping->base);
374
375 /* FIXME */
376 if (!(value & 0x000B8000))
377 return clk->parent->rate;
378
379 value &= 0x3f;
380 value += 1;
381
382 if ((value < 12) ||
383 (value > 33)) {
384 pr_err("DSIPHY has wrong value (%d)", value);
385 return 0;
386 }
387
388 return clk->parent->rate / value;
389}
390
391static long dsiphy_round_rate(struct clk *clk, unsigned long rate)
392{
393 return clk_rate_mult_range_round(clk, 12, 33, rate);
394}
395
396static void dsiphy_disable(struct clk *clk)
397{
398 u32 value;
399
400 value = __raw_readl(clk->mapping->base);
401 value &= ~0x000B8000;
402
403 __raw_writel(value , clk->mapping->base);
404}
405
406static int dsiphy_enable(struct clk *clk)
407{
408 u32 value;
409 int multi;
410
411 value = __raw_readl(clk->mapping->base);
412 multi = (value & 0x3f) + 1;
413
414 if ((multi < 12) || (multi > 33))
415 return -EIO;
416
417 __raw_writel(value | 0x000B8000, clk->mapping->base);
418
419 return 0;
420}
421
422static int dsiphy_set_rate(struct clk *clk, unsigned long rate)
423{
424 u32 value;
425 int idx;
426
427 idx = rate / clk->parent->rate;
428 if ((idx < 12) || (idx > 33))
429 return -EINVAL;
430
431 idx += -1;
432
433 value = __raw_readl(clk->mapping->base);
434 value = (value & ~0x3f) + idx;
435
436 __raw_writel(value, clk->mapping->base);
437
438 return 0;
439}
440
441static struct clk_ops dsiphy_clk_ops = {
442 .recalc = dsiphy_recalc,
443 .round_rate = dsiphy_round_rate,
444 .set_rate = dsiphy_set_rate,
445 .enable = dsiphy_enable,
446 .disable = dsiphy_disable,
447};
448
449static struct clk_mapping dsi0phy_clk_mapping = {
450 .phys = DSI0PHYCR,
451 .len = 4,
452};
453
454static struct clk_mapping dsi1phy_clk_mapping = {
455 .phys = DSI1PHYCR,
456 .len = 4,
457};
458
459static struct clk dsi0phy_clk = {
460 .ops = &dsiphy_clk_ops,
461 .parent = &div6_clks[DIV6_DSI0P], /* late install */
462 .mapping = &dsi0phy_clk_mapping,
463};
464
465static struct clk dsi1phy_clk = {
466 .ops = &dsiphy_clk_ops,
467 .parent = &div6_clks[DIV6_DSI1P], /* late install */
468 .mapping = &dsi1phy_clk_mapping,
469};
470
471static struct clk *late_main_clks[] = {
472 &dsi0phy_clk,
473 &dsi1phy_clk,
474};
475
368enum { MSTP001, 476enum { MSTP001,
369 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100, 477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
370 MSTP219, 478 MSTP219,
@@ -429,6 +537,8 @@ static struct clk_lookup lookups[] = {
429 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]), 537 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
430 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]), 538 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
431 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]), 539 CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
540 CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk),
541 CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk),
432 542
433 /* MSTP32 clocks */ 543 /* MSTP32 clocks */
434 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */ 544 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
@@ -504,6 +614,9 @@ void __init sh73a0_clock_init(void)
504 if (!ret) 614 if (!ret)
505 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 615 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
506 616
617 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
618 ret = clk_register(late_main_clks[k]);
619
507 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 620 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
508 621
509 if (!ret) 622 if (!ret)
diff --git a/arch/arm/mach-shmobile/include/mach/sh73a0.h b/arch/arm/mach-shmobile/include/mach/sh73a0.h
index 881d515a9686..cad57578ceed 100644
--- a/arch/arm/mach-shmobile/include/mach/sh73a0.h
+++ b/arch/arm/mach-shmobile/include/mach/sh73a0.h
@@ -515,8 +515,8 @@ enum {
515 SHDMA_SLAVE_MMCIF_RX, 515 SHDMA_SLAVE_MMCIF_RX,
516}; 516};
517 517
518/* PINT interrupts are located at Linux IRQ 768 and up */ 518/* PINT interrupts are located at Linux IRQ 800 and up */
519#define SH73A0_PINT0_IRQ(irq) ((irq) + 768) 519#define SH73A0_PINT0_IRQ(irq) ((irq) + 800)
520#define SH73A0_PINT1_IRQ(irq) ((irq) + 800) 520#define SH73A0_PINT1_IRQ(irq) ((irq) + 832)
521 521
522#endif /* __ASM_SH73A0_H__ */ 522#endif /* __ASM_SH73A0_H__ */
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index 1eda6b0b69e3..9857595eaa79 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/module.h>
22#include <linux/irq.h> 23#include <linux/irq.h>
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/sh_intc.h> 25#include <linux/sh_intc.h>
@@ -445,6 +446,7 @@ void __init sh73a0_init_irq(void)
445 setup_irq(gic_spi(1 + k), &sh73a0_irq_pin_cascade[k]); 446 setup_irq(gic_spi(1 + k), &sh73a0_irq_pin_cascade[k]);
446 447
447 n = intcs_evt2irq(to_intc_vect(gic_spi(1 + k))); 448 n = intcs_evt2irq(to_intc_vect(gic_spi(1 + k)));
449 WARN_ON(irq_alloc_desc_at(n, numa_node_id()) != n);
448 irq_set_chip_and_handler_name(n, &intca_gic_irq_chip, 450 irq_set_chip_and_handler_name(n, &intca_gic_irq_chip,
449 handle_level_irq, "level"); 451 handle_level_irq, "level");
450 set_irq_flags(n, IRQF_VALID); /* yuck */ 452 set_irq_flags(n, IRQF_VALID); /* yuck */
diff --git a/arch/arm/mach-shmobile/pfc-r8a7779.c b/arch/arm/mach-shmobile/pfc-r8a7779.c
index 963532f2b2c4..d14c9b048077 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7779.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7779.c
@@ -2120,7 +2120,7 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
2120 FN_AUDATA3, 0, 0, 0 } 2120 FN_AUDATA3, 0, 0, 0 }
2121 }, 2121 },
2122 { PINMUX_CFG_REG_VAR("IPSR4", 0xfffc0030, 32, 2122 { PINMUX_CFG_REG_VAR("IPSR4", 0xfffc0030, 32,
2123 3, 1, 1, 1, 1, 1, 1, 3, 3, 1, 2123 3, 1, 1, 1, 1, 1, 1, 3, 3,
2124 1, 1, 1, 1, 1, 1, 3, 3, 3, 2) { 2124 1, 1, 1, 1, 1, 1, 3, 3, 3, 2) {
2125 /* IP4_31_29 [3] */ 2125 /* IP4_31_29 [3] */
2126 FN_DU1_DB0, FN_VI2_DATA4_VI2_B4, FN_SCL2_B, FN_SD3_DAT0, 2126 FN_DU1_DB0, FN_VI2_DATA4_VI2_B4, FN_SCL2_B, FN_SD3_DAT0,
diff --git a/arch/arm/mach-shmobile/pfc-sh7372.c b/arch/arm/mach-shmobile/pfc-sh7372.c
index 1bd6585a6acf..336093f9210a 100644
--- a/arch/arm/mach-shmobile/pfc-sh7372.c
+++ b/arch/arm/mach-shmobile/pfc-sh7372.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <mach/irqs.h>
26#include <mach/sh7372.h> 27#include <mach/sh7372.h>
27 28
28#define CPU_ALL_PORT(fn, pfx, sfx) \ 29#define CPU_ALL_PORT(fn, pfx, sfx) \
@@ -1594,6 +1595,43 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1594 { }, 1595 { },
1595}; 1596};
1596 1597
1598#define EXT_IRQ16L(n) evt2irq(0x200 + ((n) << 5))
1599#define EXT_IRQ16H(n) evt2irq(0x3200 + (((n) - 16) << 5))
1600static struct pinmux_irq pinmux_irqs[] = {
1601 PINMUX_IRQ(EXT_IRQ16L(0), PORT6_FN0, PORT162_FN0),
1602 PINMUX_IRQ(EXT_IRQ16L(1), PORT12_FN0),
1603 PINMUX_IRQ(EXT_IRQ16L(2), PORT4_FN0, PORT5_FN0),
1604 PINMUX_IRQ(EXT_IRQ16L(3), PORT8_FN0, PORT16_FN0),
1605 PINMUX_IRQ(EXT_IRQ16L(4), PORT17_FN0, PORT163_FN0),
1606 PINMUX_IRQ(EXT_IRQ16L(5), PORT18_FN0),
1607 PINMUX_IRQ(EXT_IRQ16L(6), PORT39_FN0, PORT164_FN0),
1608 PINMUX_IRQ(EXT_IRQ16L(7), PORT40_FN0, PORT167_FN0),
1609 PINMUX_IRQ(EXT_IRQ16L(8), PORT41_FN0, PORT168_FN0),
1610 PINMUX_IRQ(EXT_IRQ16L(9), PORT42_FN0, PORT169_FN0),
1611 PINMUX_IRQ(EXT_IRQ16L(10), PORT65_FN0),
1612 PINMUX_IRQ(EXT_IRQ16L(11), PORT67_FN0),
1613 PINMUX_IRQ(EXT_IRQ16L(12), PORT80_FN0, PORT137_FN0),
1614 PINMUX_IRQ(EXT_IRQ16L(13), PORT81_FN0, PORT145_FN0),
1615 PINMUX_IRQ(EXT_IRQ16L(14), PORT82_FN0, PORT146_FN0),
1616 PINMUX_IRQ(EXT_IRQ16L(15), PORT83_FN0, PORT147_FN0),
1617 PINMUX_IRQ(EXT_IRQ16H(16), PORT84_FN0, PORT170_FN0),
1618 PINMUX_IRQ(EXT_IRQ16H(17), PORT85_FN0),
1619 PINMUX_IRQ(EXT_IRQ16H(18), PORT86_FN0),
1620 PINMUX_IRQ(EXT_IRQ16H(19), PORT87_FN0),
1621 PINMUX_IRQ(EXT_IRQ16H(20), PORT92_FN0),
1622 PINMUX_IRQ(EXT_IRQ16H(21), PORT93_FN0),
1623 PINMUX_IRQ(EXT_IRQ16H(22), PORT94_FN0),
1624 PINMUX_IRQ(EXT_IRQ16H(23), PORT95_FN0),
1625 PINMUX_IRQ(EXT_IRQ16H(24), PORT112_FN0),
1626 PINMUX_IRQ(EXT_IRQ16H(25), PORT119_FN0),
1627 PINMUX_IRQ(EXT_IRQ16H(26), PORT121_FN0, PORT172_FN0),
1628 PINMUX_IRQ(EXT_IRQ16H(27), PORT122_FN0, PORT180_FN0),
1629 PINMUX_IRQ(EXT_IRQ16H(28), PORT123_FN0, PORT181_FN0),
1630 PINMUX_IRQ(EXT_IRQ16H(29), PORT129_FN0, PORT182_FN0),
1631 PINMUX_IRQ(EXT_IRQ16H(30), PORT130_FN0, PORT183_FN0),
1632 PINMUX_IRQ(EXT_IRQ16H(31), PORT138_FN0, PORT184_FN0),
1633};
1634
1597static struct pinmux_info sh7372_pinmux_info = { 1635static struct pinmux_info sh7372_pinmux_info = {
1598 .name = "sh7372_pfc", 1636 .name = "sh7372_pfc",
1599 .reserved_id = PINMUX_RESERVED, 1637 .reserved_id = PINMUX_RESERVED,
@@ -1614,6 +1652,9 @@ static struct pinmux_info sh7372_pinmux_info = {
1614 1652
1615 .gpio_data = pinmux_data, 1653 .gpio_data = pinmux_data,
1616 .gpio_data_size = ARRAY_SIZE(pinmux_data), 1654 .gpio_data_size = ARRAY_SIZE(pinmux_data),
1655
1656 .gpio_irq = pinmux_irqs,
1657 .gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
1617}; 1658};
1618 1659
1619void sh7372_pinmux_init(void) 1660void sh7372_pinmux_init(void)
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 0d159d64a345..2d0d4212be41 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -80,7 +80,7 @@ int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
80 /* enable cache coherency */ 80 /* enable cache coherency */
81 modify_scu_cpu_psr(0, 3 << (cpu * 8)); 81 modify_scu_cpu_psr(0, 3 << (cpu * 8));
82 82
83 if (((__raw_readw(__io(PSTR)) >> (4 * cpu)) & 3) == 3) 83 if (((__raw_readl(__io(PSTR)) >> (4 * cpu)) & 3) == 3)
84 __raw_writel(1 << cpu, __io(WUPCR)); /* wake up */ 84 __raw_writel(1 << cpu, __io(WUPCR)); /* wake up */
85 else 85 else
86 __raw_writel(1 << cpu, __io(SRESCR)); /* reset */ 86 __raw_writel(1 << cpu, __io(SRESCR)); /* reset */
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 1a3ca2488164..7edef9121632 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -631,7 +631,8 @@ comment "Processor Features"
631 631
632config ARM_LPAE 632config ARM_LPAE
633 bool "Support for the Large Physical Address Extension" 633 bool "Support for the Large Physical Address Extension"
634 depends on MMU && CPU_V7 634 depends on MMU && CPU_32v7 && !CPU_32v6 && !CPU_32v5 && \
635 !CPU_32v4 && !CPU_32v3
635 help 636 help
636 Say Y if you have an ARMv7 processor supporting the LPAE page 637 Say Y if you have an ARMv7 processor supporting the LPAE page
637 table format and you would like to access memory beyond the 638 table format and you would like to access memory beyond the
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index 7a24d39661f0..a655d3da386d 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -55,7 +55,7 @@ loop1:
55 cmp r1, #2 @ see what cache we have at this level 55 cmp r1, #2 @ see what cache we have at this level
56 blt skip @ skip if no cache, or just i-cache 56 blt skip @ skip if no cache, or just i-cache
57#ifdef CONFIG_PREEMPT 57#ifdef CONFIG_PREEMPT
58 save_and_disable_irqs r9 @ make cssr&csidr read atomic 58 save_and_disable_irqs_notrace r9 @ make cssr&csidr read atomic
59#endif 59#endif
60 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr 60 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
61 isb @ isb to sych the new cssr&csidr 61 isb @ isb to sych the new cssr&csidr
diff --git a/arch/c6x/boot/Makefile b/arch/c6x/boot/Makefile
index ecca820e6041..6891257d514c 100644
--- a/arch/c6x/boot/Makefile
+++ b/arch/c6x/boot/Makefile
@@ -13,7 +13,7 @@ obj-y += linked_dtb.o
13endif 13endif
14 14
15$(obj)/%.dtb: $(src)/dts/%.dts FORCE 15$(obj)/%.dtb: $(src)/dts/%.dts FORCE
16 $(call cmd,dtc) 16 $(call if_changed_dep,dtc)
17 17
18quiet_cmd_cp = CP $< $@$2 18quiet_cmd_cp = CP $< $@$2
19 cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) 19 cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
diff --git a/arch/m68k/include/asm/mcf_pgtable.h b/arch/m68k/include/asm/mcf_pgtable.h
index 756bde4fb4f8..3c793682e5d9 100644
--- a/arch/m68k/include/asm/mcf_pgtable.h
+++ b/arch/m68k/include/asm/mcf_pgtable.h
@@ -78,7 +78,8 @@
78 | CF_PAGE_READABLE \ 78 | CF_PAGE_READABLE \
79 | CF_PAGE_WRITABLE \ 79 | CF_PAGE_WRITABLE \
80 | CF_PAGE_EXEC \ 80 | CF_PAGE_EXEC \
81 | CF_PAGE_SYSTEM) 81 | CF_PAGE_SYSTEM \
82 | CF_PAGE_SHARED)
82 83
83#define PAGE_COPY __pgprot(CF_PAGE_VALID \ 84#define PAGE_COPY __pgprot(CF_PAGE_VALID \
84 | CF_PAGE_ACCESSED \ 85 | CF_PAGE_ACCESSED \
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index babd5a97cdcb..875b800ef0dd 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -87,7 +87,7 @@ void __init paging_init(void)
87 87
88int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) 88int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
89{ 89{
90 unsigned long flags, mmuar; 90 unsigned long flags, mmuar, mmutr;
91 struct mm_struct *mm; 91 struct mm_struct *mm;
92 pgd_t *pgd; 92 pgd_t *pgd;
93 pmd_t *pmd; 93 pmd_t *pmd;
@@ -137,9 +137,10 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
137 if (!pte_dirty(*pte) && !KMAPAREA(mmuar)) 137 if (!pte_dirty(*pte) && !KMAPAREA(mmuar))
138 set_pte(pte, pte_wrprotect(*pte)); 138 set_pte(pte, pte_wrprotect(*pte));
139 139
140 mmu_write(MMUTR, (mmuar & PAGE_MASK) | (asid << MMUTR_IDN) | 140 mmutr = (mmuar & PAGE_MASK) | (asid << MMUTR_IDN) | MMUTR_V;
141 (((int)(pte->pte) & (int)CF_PAGE_MMUTR_MASK) 141 if ((mmuar < TASK_UNMAPPED_BASE) || (mmuar >= TASK_SIZE))
142 >> CF_PAGE_MMUTR_SHIFT) | MMUTR_V); 142 mmutr |= (pte->pte & CF_PAGE_MMUTR_MASK) >> CF_PAGE_MMUTR_SHIFT;
143 mmu_write(MMUTR, mmutr);
143 144
144 mmu_write(MMUDR, (pte_val(*pte) & PAGE_MASK) | 145 mmu_write(MMUDR, (pte_val(*pte) & PAGE_MASK) |
145 ((pte->pte) & CF_PAGE_MMUDR_MASK) | MMUDR_SZ_8KB | MMUDR_X); 146 ((pte->pte) & CF_PAGE_MMUDR_MASK) | MMUDR_SZ_8KB | MMUDR_X);
diff --git a/arch/m68k/platform/coldfire/entry.S b/arch/m68k/platform/coldfire/entry.S
index 863889fc31c9..281e38c2b6c7 100644
--- a/arch/m68k/platform/coldfire/entry.S
+++ b/arch/m68k/platform/coldfire/entry.S
@@ -136,7 +136,7 @@ Luser_return:
136 movel %sp,%d1 /* get thread_info pointer */ 136 movel %sp,%d1 /* get thread_info pointer */
137 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */ 137 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
138 movel %d1,%a0 138 movel %d1,%a0
139 movel %a0@(TINFO_FLAGS),%d1 /* get thread_info->flags */ 139 moveb %a0@(TINFO_FLAGS+3),%d1 /* thread_info->flags (low 8 bits) */
140 jne Lwork_to_do /* still work to do */ 140 jne Lwork_to_do /* still work to do */
141 141
142Lreturn: 142Lreturn:
@@ -148,8 +148,6 @@ Lwork_to_do:
148 btst #TIF_NEED_RESCHED,%d1 148 btst #TIF_NEED_RESCHED,%d1
149 jne reschedule 149 jne reschedule
150 150
151 /* GERG: do we need something here for TRACEing?? */
152
153Lsignal_return: 151Lsignal_return:
154 subql #4,%sp /* dummy return address */ 152 subql #4,%sp /* dummy return address */
155 SAVE_SWITCH_STACK 153 SAVE_SWITCH_STACK
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 4f80cf1ce77b..3e57a00b8cba 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1213,7 +1213,7 @@ do_user_signal: /* r10 contains MSR_KERNEL here */
1213 stw r3,_TRAP(r1) 1213 stw r3,_TRAP(r1)
12142: addi r3,r1,STACK_FRAME_OVERHEAD 12142: addi r3,r1,STACK_FRAME_OVERHEAD
1215 mr r4,r9 1215 mr r4,r9
1216 bl do_signal 1216 bl do_notify_resume
1217 REST_NVGPRS(r1) 1217 REST_NVGPRS(r1)
1218 b recheck 1218 b recheck
1219 1219
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index d834425186ae..866462cbe2d8 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -751,12 +751,16 @@ user_work:
751 751
752 andi. r0,r4,_TIF_NEED_RESCHED 752 andi. r0,r4,_TIF_NEED_RESCHED
753 beq 1f 753 beq 1f
754 li r5,1
755 TRACE_AND_RESTORE_IRQ(r5);
754 bl .schedule 756 bl .schedule
755 b .ret_from_except_lite 757 b .ret_from_except_lite
756 758
7571: bl .save_nvgprs 7591: bl .save_nvgprs
760 li r5,1
761 TRACE_AND_RESTORE_IRQ(r5);
758 addi r3,r1,STACK_FRAME_OVERHEAD 762 addi r3,r1,STACK_FRAME_OVERHEAD
759 bl .do_signal 763 bl .do_notify_resume
760 b .ret_from_except 764 b .ret_from_except
761 765
762unrecov_restore: 766unrecov_restore:
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3844ca7c5099..15c5a4f6de01 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -774,8 +774,8 @@ alignment_common:
774program_check_common: 774program_check_common:
775 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) 775 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
776 bl .save_nvgprs 776 bl .save_nvgprs
777 addi r3,r1,STACK_FRAME_OVERHEAD
778 DISABLE_INTS 777 DISABLE_INTS
778 addi r3,r1,STACK_FRAME_OVERHEAD
779 bl .program_check_exception 779 bl .program_check_exception
780 b .ret_from_except 780 b .ret_from_except
781 781
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 2300426e531a..ac6e437b1021 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/tracehook.h> 12#include <linux/tracehook.h>
13#include <linux/signal.h> 13#include <linux/signal.h>
14#include <linux/key.h>
14#include <asm/hw_breakpoint.h> 15#include <asm/hw_breakpoint.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/unistd.h> 17#include <asm/unistd.h>
@@ -113,8 +114,9 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
113 } 114 }
114} 115}
115 116
116static int do_signal_pending(sigset_t *oldset, struct pt_regs *regs) 117static int do_signal(struct pt_regs *regs)
117{ 118{
119 sigset_t *oldset;
118 siginfo_t info; 120 siginfo_t info;
119 int signr; 121 int signr;
120 struct k_sigaction ka; 122 struct k_sigaction ka;
@@ -123,7 +125,7 @@ static int do_signal_pending(sigset_t *oldset, struct pt_regs *regs)
123 125
124 if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK) 126 if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
125 oldset = &current->saved_sigmask; 127 oldset = &current->saved_sigmask;
126 else if (!oldset) 128 else
127 oldset = &current->blocked; 129 oldset = &current->blocked;
128 130
129 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 131 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
@@ -191,14 +193,16 @@ static int do_signal_pending(sigset_t *oldset, struct pt_regs *regs)
191 return ret; 193 return ret;
192} 194}
193 195
194void do_signal(struct pt_regs *regs, unsigned long thread_info_flags) 196void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
195{ 197{
196 if (thread_info_flags & _TIF_SIGPENDING) 198 if (thread_info_flags & _TIF_SIGPENDING)
197 do_signal_pending(NULL, regs); 199 do_signal(regs);
198 200
199 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 201 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
200 clear_thread_flag(TIF_NOTIFY_RESUME); 202 clear_thread_flag(TIF_NOTIFY_RESUME);
201 tracehook_notify_resume(regs); 203 tracehook_notify_resume(regs);
204 if (current->replacement_session_keyring)
205 key_replace_session_keyring();
202 } 206 }
203} 207}
204 208
diff --git a/arch/powerpc/kernel/signal.h b/arch/powerpc/kernel/signal.h
index 6c0ddfc0603e..8dde973aaaf5 100644
--- a/arch/powerpc/kernel/signal.h
+++ b/arch/powerpc/kernel/signal.h
@@ -12,7 +12,7 @@
12 12
13#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 13#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
14 14
15extern void do_signal(struct pt_regs *regs, unsigned long thread_info_flags); 15extern void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags);
16 16
17extern void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, 17extern void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
18 size_t frame_size, int is_32); 18 size_t frame_size, int is_32);
diff --git a/arch/powerpc/platforms/wsp/smp.c b/arch/powerpc/platforms/wsp/smp.c
index 71bd105f3863..0ba103ae83a5 100644
--- a/arch/powerpc/platforms/wsp/smp.c
+++ b/arch/powerpc/platforms/wsp/smp.c
@@ -71,7 +71,7 @@ int __devinit smp_a2_kick_cpu(int nr)
71 71
72static int __init smp_a2_probe(void) 72static int __init smp_a2_probe(void)
73{ 73{
74 return cpus_weight(cpu_possible_map); 74 return num_possible_cpus();
75} 75}
76 76
77static struct smp_ops_t a2_smp_ops = { 77static struct smp_ops_t a2_smp_ops = {
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 18c51df9fe06..ff605a39cf43 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -662,7 +662,7 @@ ENTRY(sys32_getresuid16_wrapper)
662ENTRY(sys32_poll_wrapper) 662ENTRY(sys32_poll_wrapper)
663 llgtr %r2,%r2 # struct pollfd * 663 llgtr %r2,%r2 # struct pollfd *
664 llgfr %r3,%r3 # unsigned int 664 llgfr %r3,%r3 # unsigned int
665 lgfr %r4,%r4 # long 665 lgfr %r4,%r4 # int
666 jg sys_poll # branch to system call 666 jg sys_poll # branch to system call
667 667
668ENTRY(sys32_setresgid16_wrapper) 668ENTRY(sys32_setresgid16_wrapper)
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 3201ae447990..4261aa799774 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -76,7 +76,6 @@ static void default_idle(void)
76 if (test_thread_flag(TIF_MCCK_PENDING)) { 76 if (test_thread_flag(TIF_MCCK_PENDING)) {
77 local_mcck_enable(); 77 local_mcck_enable();
78 local_irq_enable(); 78 local_irq_enable();
79 s390_handle_mcck();
80 return; 79 return;
81 } 80 }
82 trace_hardirqs_on(); 81 trace_hardirqs_on();
@@ -93,10 +92,12 @@ void cpu_idle(void)
93 for (;;) { 92 for (;;) {
94 tick_nohz_idle_enter(); 93 tick_nohz_idle_enter();
95 rcu_idle_enter(); 94 rcu_idle_enter();
96 while (!need_resched()) 95 while (!need_resched() && !test_thread_flag(TIF_MCCK_PENDING))
97 default_idle(); 96 default_idle();
98 rcu_idle_exit(); 97 rcu_idle_exit();
99 tick_nohz_idle_exit(); 98 tick_nohz_idle_exit();
99 if (test_thread_flag(TIF_MCCK_PENDING))
100 s390_handle_mcck();
100 preempt_enable_no_resched(); 101 preempt_enable_no_resched();
101 schedule(); 102 schedule();
102 preempt_disable(); 103 preempt_disable();
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index fa02f443f5f6..14da278febbf 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -113,11 +113,14 @@ static void fixup_clock_comparator(unsigned long long delta)
113static int s390_next_ktime(ktime_t expires, 113static int s390_next_ktime(ktime_t expires,
114 struct clock_event_device *evt) 114 struct clock_event_device *evt)
115{ 115{
116 struct timespec ts;
116 u64 nsecs; 117 u64 nsecs;
117 118
118 nsecs = ktime_to_ns(ktime_sub(expires, ktime_get_monotonic_offset())); 119 ts.tv_sec = ts.tv_nsec = 0;
120 monotonic_to_bootbased(&ts);
121 nsecs = ktime_to_ns(ktime_add(timespec_to_ktime(ts), expires));
119 do_div(nsecs, 125); 122 do_div(nsecs, 125);
120 S390_lowcore.clock_comparator = TOD_UNIX_EPOCH + (nsecs << 9); 123 S390_lowcore.clock_comparator = sched_clock_base_cc + (nsecs << 9);
121 set_clock_comparator(S390_lowcore.clock_comparator); 124 set_clock_comparator(S390_lowcore.clock_comparator);
122 return 0; 125 return 0;
123} 126}
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 9a4d02f64f16..51b0738e13d1 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -574,7 +574,7 @@ static inline void page_table_free_pgste(unsigned long *table)
574 page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 574 page = pfn_to_page(__pa(table) >> PAGE_SHIFT);
575 mp = (struct gmap_pgtable *) page->index; 575 mp = (struct gmap_pgtable *) page->index;
576 BUG_ON(!list_empty(&mp->mapper)); 576 BUG_ON(!list_empty(&mp->mapper));
577 pgtable_page_ctor(page); 577 pgtable_page_dtor(page);
578 atomic_set(&page->_mapcount, -1); 578 atomic_set(&page->_mapcount, -1);
579 kfree(mp); 579 kfree(mp);
580 __free_page(page); 580 __free_page(page);
diff --git a/arch/sh/boards/board-sh7757lcr.c b/arch/sh/boards/board-sh7757lcr.c
index 0838154dd216..24b1ee410daa 100644
--- a/arch/sh/boards/board-sh7757lcr.c
+++ b/arch/sh/boards/board-sh7757lcr.c
@@ -169,6 +169,11 @@ static struct resource sh_eth_giga1_resources[] = {
169 .end = 0xfee00fff, 169 .end = 0xfee00fff,
170 .flags = IORESOURCE_MEM, 170 .flags = IORESOURCE_MEM,
171 }, { 171 }, {
172 /* TSU */
173 .start = 0xfee01800,
174 .end = 0xfee01fff,
175 .flags = IORESOURCE_MEM,
176 }, {
172 .start = 316, 177 .start = 316,
173 .end = 316, 178 .end = 316,
174 .flags = IORESOURCE_IRQ, 179 .flags = IORESOURCE_IRQ,
@@ -210,20 +215,13 @@ static struct resource sh_mmcif_resources[] = {
210 }, 215 },
211}; 216};
212 217
213static struct sh_mmcif_dma sh7757lcr_mmcif_dma = {
214 .chan_priv_tx = {
215 .slave_id = SHDMA_SLAVE_MMCIF_TX,
216 },
217 .chan_priv_rx = {
218 .slave_id = SHDMA_SLAVE_MMCIF_RX,
219 }
220};
221
222static struct sh_mmcif_plat_data sh_mmcif_plat = { 218static struct sh_mmcif_plat_data sh_mmcif_plat = {
223 .dma = &sh7757lcr_mmcif_dma,
224 .sup_pclk = 0x0f, 219 .sup_pclk = 0x0f,
225 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 220 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
221 MMC_CAP_NONREMOVABLE,
226 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34, 222 .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
223 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
224 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
227}; 225};
228 226
229static struct platform_device sh_mmcif_device = { 227static struct platform_device sh_mmcif_device = {
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index 6418e95c2b6b..ebd0f818a25f 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/smsc911x.h> 23#include <linux/smsc911x.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/videodev2.h>
25#include <media/ov772x.h> 26#include <media/ov772x.h>
26#include <media/soc_camera.h> 27#include <media/soc_camera.h>
27#include <media/soc_camera_platform.h> 28#include <media/soc_camera_platform.h>
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 033ef2ba621f..cde7c0085ced 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -29,9 +29,11 @@
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/input/sh_keysc.h> 30#include <linux/input/sh_keysc.h>
31#include <linux/sh_eth.h> 31#include <linux/sh_eth.h>
32#include <linux/videodev2.h>
32#include <video/sh_mobile_lcdc.h> 33#include <video/sh_mobile_lcdc.h>
33#include <sound/sh_fsi.h> 34#include <sound/sh_fsi.h>
34#include <media/sh_mobile_ceu.h> 35#include <media/sh_mobile_ceu.h>
36#include <media/soc_camera.h>
35#include <media/tw9910.h> 37#include <media/tw9910.h>
36#include <media/mt9t112.h> 38#include <media/mt9t112.h>
37#include <asm/heartbeat.h> 39#include <asm/heartbeat.h>
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 2a18b06abdaf..5b382e1afaea 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -22,6 +22,7 @@
22#include <linux/input/sh_keysc.h> 22#include <linux/input/sh_keysc.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/usb/r8a66597.h> 24#include <linux/usb/r8a66597.h>
25#include <linux/videodev2.h>
25#include <media/rj54n1cb0c.h> 26#include <media/rj54n1cb0c.h>
26#include <media/soc_camera.h> 27#include <media/soc_camera.h>
27#include <media/sh_mobile_ceu.h> 28#include <media/sh_mobile_ceu.h>
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 68c3d6f42896..d37ba2720527 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -21,9 +21,11 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/videodev2.h>
24#include <video/sh_mobile_lcdc.h> 25#include <video/sh_mobile_lcdc.h>
25#include <media/sh_mobile_ceu.h> 26#include <media/sh_mobile_ceu.h>
26#include <media/ov772x.h> 27#include <media/ov772x.h>
28#include <media/soc_camera.h>
27#include <media/tw9910.h> 29#include <media/tw9910.h>
28#include <asm/clock.h> 30#include <asm/clock.h>
29#include <asm/machvec.h> 31#include <asm/machvec.h>
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 036fe1adaef1..2b07fc016950 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -24,6 +24,7 @@
24#include <linux/input/sh_keysc.h> 24#include <linux/input/sh_keysc.h>
25#include <linux/usb/r8a66597.h> 25#include <linux/usb/r8a66597.h>
26#include <linux/sh_eth.h> 26#include <linux/sh_eth.h>
27#include <linux/videodev2.h>
27#include <video/sh_mobile_lcdc.h> 28#include <video/sh_mobile_lcdc.h>
28#include <media/sh_mobile_ceu.h> 29#include <media/sh_mobile_ceu.h>
29#include <sound/sh_fsi.h> 30#include <sound/sh_fsi.h>
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index fa7b978cc727..fb8f14990743 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -74,7 +74,7 @@ struct pci_errors {
74 { SH4_PCIINT_MLCK, "master lock error" }, 74 { SH4_PCIINT_MLCK, "master lock error" },
75 { SH4_PCIINT_TABT, "target-target abort" }, 75 { SH4_PCIINT_TABT, "target-target abort" },
76 { SH4_PCIINT_TRET, "target retry time out" }, 76 { SH4_PCIINT_TRET, "target retry time out" },
77 { SH4_PCIINT_MFDE, "master function disable erorr" }, 77 { SH4_PCIINT_MFDE, "master function disable error" },
78 { SH4_PCIINT_PRTY, "address parity error" }, 78 { SH4_PCIINT_PRTY, "address parity error" },
79 { SH4_PCIINT_SERR, "SERR" }, 79 { SH4_PCIINT_SERR, "SERR" },
80 { SH4_PCIINT_TWDP, "data parity error for target write" }, 80 { SH4_PCIINT_TWDP, "data parity error for target write" },
diff --git a/arch/sh/include/asm/device.h b/arch/sh/include/asm/device.h
index a1c9c0daec10..071bcb4d4bfd 100644
--- a/arch/sh/include/asm/device.h
+++ b/arch/sh/include/asm/device.h
@@ -3,9 +3,10 @@
3 * 3 *
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6#ifndef __ASM_SH_DEVICE_H
7#define __ASM_SH_DEVICE_H
6 8
7struct dev_archdata { 9#include <asm-generic/device.h>
8};
9 10
10struct platform_device; 11struct platform_device;
11/* allocate contiguous memory chunk and fill in struct resource */ 12/* allocate contiguous memory chunk and fill in struct resource */
@@ -14,5 +15,4 @@ int platform_resource_setup_memory(struct platform_device *pdev,
14 15
15void plat_early_device_setup(void); 16void plat_early_device_setup(void);
16 17
17struct pdev_archdata { 18#endif /* __ASM_SH_DEVICE_H */
18};
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index b3c039a5064a..70bd96646f42 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -343,7 +343,7 @@ static struct clk_lookup lookups[] = {
343 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[HWBLK_CEU1]), 343 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[HWBLK_CEU1]),
344 CLKDEV_CON_ID("beu1", &mstp_clks[HWBLK_BEU1]), 344 CLKDEV_CON_ID("beu1", &mstp_clks[HWBLK_BEU1]),
345 CLKDEV_CON_ID("2ddmac0", &mstp_clks[HWBLK_2DDMAC]), 345 CLKDEV_CON_ID("2ddmac0", &mstp_clks[HWBLK_2DDMAC]),
346 CLKDEV_CON_ID("spu0", &mstp_clks[HWBLK_SPU]), 346 CLKDEV_DEV_ID("sh_fsi.0", &mstp_clks[HWBLK_SPU]),
347 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]), 347 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
348 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]), 348 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),
349 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU0]), 349 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU0]),
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
index a7b2da6b3a1a..2875e8be4f72 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
@@ -133,7 +133,7 @@ static struct resource spi0_resources[] = {
133 [0] = { 133 [0] = {
134 .start = 0xfe002000, 134 .start = 0xfe002000,
135 .end = 0xfe0020ff, 135 .end = 0xfe0020ff,
136 .flags = IORESOURCE_MEM, 136 .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
137 }, 137 },
138 [1] = { 138 [1] = {
139 .start = 86, 139 .start = 86,
@@ -661,6 +661,25 @@ static struct platform_device spi0_device = {
661 .resource = spi0_resources, 661 .resource = spi0_resources,
662}; 662};
663 663
664static struct resource spi1_resources[] = {
665 {
666 .start = 0xffd8ee70,
667 .end = 0xffd8eeff,
668 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
669 },
670 {
671 .start = 54,
672 .flags = IORESOURCE_IRQ,
673 },
674};
675
676static struct platform_device spi1_device = {
677 .name = "sh_spi",
678 .id = 1,
679 .num_resources = ARRAY_SIZE(spi1_resources),
680 .resource = spi1_resources,
681};
682
664static struct resource usb_ehci_resources[] = { 683static struct resource usb_ehci_resources[] = {
665 [0] = { 684 [0] = {
666 .start = 0xfe4f1000, 685 .start = 0xfe4f1000,
@@ -720,6 +739,7 @@ static struct platform_device *sh7757_devices[] __initdata = {
720 &dma2_device, 739 &dma2_device,
721 &dma3_device, 740 &dma3_device,
722 &spi0_device, 741 &spi0_device,
742 &spi1_device,
723 &usb_ehci_device, 743 &usb_ehci_device,
724 &usb_ohci_device, 744 &usb_ohci_device,
725}; 745};
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 3147a9a6fb8b..f624174bf239 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -63,7 +63,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
63 mp_ops->prepare_cpus(max_cpus); 63 mp_ops->prepare_cpus(max_cpus);
64 64
65#ifndef CONFIG_HOTPLUG_CPU 65#ifndef CONFIG_HOTPLUG_CPU
66 init_cpu_present(&cpu_possible_map); 66 init_cpu_present(cpu_possible_mask);
67#endif 67#endif
68} 68}
69 69
diff --git a/arch/sh/kernel/topology.c b/arch/sh/kernel/topology.c
index 4649a6ff0cfe..772caffba22f 100644
--- a/arch/sh/kernel/topology.c
+++ b/arch/sh/kernel/topology.c
@@ -27,7 +27,7 @@ static cpumask_t cpu_coregroup_map(unsigned int cpu)
27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it 27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it
28 * simple until we have a method for determining topology.. 28 * simple until we have a method for determining topology..
29 */ 29 */
30 return cpu_possible_map; 30 return *cpu_possible_mask;
31} 31}
32 32
33const struct cpumask *cpu_coregroup_mask(unsigned int cpu) 33const struct cpumask *cpu_coregroup_mask(unsigned int cpu)
diff --git a/arch/sh/mm/cache-sh2a.c b/arch/sh/mm/cache-sh2a.c
index ae08cbbfa569..949e2d3138a0 100644
--- a/arch/sh/mm/cache-sh2a.c
+++ b/arch/sh/mm/cache-sh2a.c
@@ -23,6 +23,7 @@
23#define MAX_OCACHE_PAGES 32 23#define MAX_OCACHE_PAGES 32
24#define MAX_ICACHE_PAGES 32 24#define MAX_ICACHE_PAGES 32
25 25
26#ifdef CONFIG_CACHE_WRITEBACK
26static void sh2a_flush_oc_line(unsigned long v, int way) 27static void sh2a_flush_oc_line(unsigned long v, int way)
27{ 28{
28 unsigned long addr = (v & 0x000007f0) | (way << 11); 29 unsigned long addr = (v & 0x000007f0) | (way << 11);
@@ -34,6 +35,7 @@ static void sh2a_flush_oc_line(unsigned long v, int way)
34 __raw_writel(data, CACHE_OC_ADDRESS_ARRAY | addr); 35 __raw_writel(data, CACHE_OC_ADDRESS_ARRAY | addr);
35 } 36 }
36} 37}
38#endif
37 39
38static void sh2a_invalidate_line(unsigned long cache_addr, unsigned long v) 40static void sh2a_invalidate_line(unsigned long cache_addr, unsigned long v)
39{ 41{
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index a850b4d8d14d..247904945d3f 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -29,10 +29,11 @@ extern unsigned int sig_xstate_size;
29extern void fpu_init(void); 29extern void fpu_init(void);
30extern void mxcsr_feature_mask_init(void); 30extern void mxcsr_feature_mask_init(void);
31extern int init_fpu(struct task_struct *child); 31extern int init_fpu(struct task_struct *child);
32extern void __math_state_restore(struct task_struct *);
33extern void math_state_restore(void); 32extern void math_state_restore(void);
34extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); 33extern int dump_fpu(struct pt_regs *, struct user_i387_struct *);
35 34
35DECLARE_PER_CPU(struct task_struct *, fpu_owner_task);
36
36extern user_regset_active_fn fpregs_active, xfpregs_active; 37extern user_regset_active_fn fpregs_active, xfpregs_active;
37extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get, 38extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get,
38 xstateregs_get; 39 xstateregs_get;
@@ -269,6 +270,16 @@ static inline int fpu_restore_checking(struct fpu *fpu)
269 270
270static inline int restore_fpu_checking(struct task_struct *tsk) 271static inline int restore_fpu_checking(struct task_struct *tsk)
271{ 272{
273 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
274 is pending. Clear the x87 state here by setting it to fixed
275 values. "m" is a random variable that should be in L1 */
276 alternative_input(
277 ASM_NOP8 ASM_NOP2,
278 "emms\n\t" /* clear stack tags */
279 "fildl %P[addr]", /* set F?P to defined value */
280 X86_FEATURE_FXSAVE_LEAK,
281 [addr] "m" (tsk->thread.fpu.has_fpu));
282
272 return fpu_restore_checking(&tsk->thread.fpu); 283 return fpu_restore_checking(&tsk->thread.fpu);
273} 284}
274 285
@@ -279,19 +290,21 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
279 */ 290 */
280static inline int __thread_has_fpu(struct task_struct *tsk) 291static inline int __thread_has_fpu(struct task_struct *tsk)
281{ 292{
282 return tsk->thread.has_fpu; 293 return tsk->thread.fpu.has_fpu;
283} 294}
284 295
285/* Must be paired with an 'stts' after! */ 296/* Must be paired with an 'stts' after! */
286static inline void __thread_clear_has_fpu(struct task_struct *tsk) 297static inline void __thread_clear_has_fpu(struct task_struct *tsk)
287{ 298{
288 tsk->thread.has_fpu = 0; 299 tsk->thread.fpu.has_fpu = 0;
300 percpu_write(fpu_owner_task, NULL);
289} 301}
290 302
291/* Must be paired with a 'clts' before! */ 303/* Must be paired with a 'clts' before! */
292static inline void __thread_set_has_fpu(struct task_struct *tsk) 304static inline void __thread_set_has_fpu(struct task_struct *tsk)
293{ 305{
294 tsk->thread.has_fpu = 1; 306 tsk->thread.fpu.has_fpu = 1;
307 percpu_write(fpu_owner_task, tsk);
295} 308}
296 309
297/* 310/*
@@ -336,30 +349,36 @@ typedef struct { int preload; } fpu_switch_t;
336 * We don't do that yet, so "fpu_lazy_restore()" always returns 349 * We don't do that yet, so "fpu_lazy_restore()" always returns
337 * false, but some day.. 350 * false, but some day..
338 */ 351 */
339#define fpu_lazy_restore(tsk) (0) 352static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu)
340#define fpu_lazy_state_intact(tsk) do { } while (0) 353{
354 return new == percpu_read_stable(fpu_owner_task) &&
355 cpu == new->thread.fpu.last_cpu;
356}
341 357
342static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct task_struct *new) 358static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct task_struct *new, int cpu)
343{ 359{
344 fpu_switch_t fpu; 360 fpu_switch_t fpu;
345 361
346 fpu.preload = tsk_used_math(new) && new->fpu_counter > 5; 362 fpu.preload = tsk_used_math(new) && new->fpu_counter > 5;
347 if (__thread_has_fpu(old)) { 363 if (__thread_has_fpu(old)) {
348 if (__save_init_fpu(old)) 364 if (!__save_init_fpu(old))
349 fpu_lazy_state_intact(old); 365 cpu = ~0;
350 __thread_clear_has_fpu(old); 366 old->thread.fpu.last_cpu = cpu;
351 old->fpu_counter++; 367 old->thread.fpu.has_fpu = 0; /* But leave fpu_owner_task! */
352 368
353 /* Don't change CR0.TS if we just switch! */ 369 /* Don't change CR0.TS if we just switch! */
354 if (fpu.preload) { 370 if (fpu.preload) {
371 new->fpu_counter++;
355 __thread_set_has_fpu(new); 372 __thread_set_has_fpu(new);
356 prefetch(new->thread.fpu.state); 373 prefetch(new->thread.fpu.state);
357 } else 374 } else
358 stts(); 375 stts();
359 } else { 376 } else {
360 old->fpu_counter = 0; 377 old->fpu_counter = 0;
378 old->thread.fpu.last_cpu = ~0;
361 if (fpu.preload) { 379 if (fpu.preload) {
362 if (fpu_lazy_restore(new)) 380 new->fpu_counter++;
381 if (fpu_lazy_restore(new, cpu))
363 fpu.preload = 0; 382 fpu.preload = 0;
364 else 383 else
365 prefetch(new->thread.fpu.state); 384 prefetch(new->thread.fpu.state);
@@ -377,8 +396,10 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta
377 */ 396 */
378static inline void switch_fpu_finish(struct task_struct *new, fpu_switch_t fpu) 397static inline void switch_fpu_finish(struct task_struct *new, fpu_switch_t fpu)
379{ 398{
380 if (fpu.preload) 399 if (fpu.preload) {
381 __math_state_restore(new); 400 if (unlikely(restore_fpu_checking(new)))
401 __thread_fpu_end(new);
402 }
382} 403}
383 404
384/* 405/*
@@ -451,8 +472,10 @@ static inline void kernel_fpu_begin(void)
451 __save_init_fpu(me); 472 __save_init_fpu(me);
452 __thread_clear_has_fpu(me); 473 __thread_clear_has_fpu(me);
453 /* We do 'stts()' in kernel_fpu_end() */ 474 /* We do 'stts()' in kernel_fpu_end() */
454 } else 475 } else {
476 percpu_write(fpu_owner_task, NULL);
455 clts(); 477 clts();
478 }
456} 479}
457 480
458static inline void kernel_fpu_end(void) 481static inline void kernel_fpu_end(void)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index f7c89e231c6c..58545c97d071 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -374,6 +374,8 @@ union thread_xstate {
374}; 374};
375 375
376struct fpu { 376struct fpu {
377 unsigned int last_cpu;
378 unsigned int has_fpu;
377 union thread_xstate *state; 379 union thread_xstate *state;
378}; 380};
379 381
@@ -454,7 +456,6 @@ struct thread_struct {
454 unsigned long trap_no; 456 unsigned long trap_no;
455 unsigned long error_code; 457 unsigned long error_code;
456 /* floating point and extended processor state */ 458 /* floating point and extended processor state */
457 unsigned long has_fpu;
458 struct fpu fpu; 459 struct fpu fpu;
459#ifdef CONFIG_X86_32 460#ifdef CONFIG_X86_32
460 /* Virtual 86 mode info */ 461 /* Virtual 86 mode info */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d43cad74f166..c0f7d68d318f 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1044,6 +1044,9 @@ DEFINE_PER_CPU(char *, irq_stack_ptr) =
1044 1044
1045DEFINE_PER_CPU(unsigned int, irq_count) = -1; 1045DEFINE_PER_CPU(unsigned int, irq_count) = -1;
1046 1046
1047DEFINE_PER_CPU(struct task_struct *, fpu_owner_task);
1048EXPORT_PER_CPU_SYMBOL(fpu_owner_task);
1049
1047/* 1050/*
1048 * Special IST stacks which the CPU switches to when it calls 1051 * Special IST stacks which the CPU switches to when it calls
1049 * an IST-marked descriptor entry. Up to 7 stacks (hardware 1052 * an IST-marked descriptor entry. Up to 7 stacks (hardware
@@ -1111,6 +1114,8 @@ void debug_stack_reset(void)
1111 1114
1112DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; 1115DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
1113EXPORT_PER_CPU_SYMBOL(current_task); 1116EXPORT_PER_CPU_SYMBOL(current_task);
1117DEFINE_PER_CPU(struct task_struct *, fpu_owner_task);
1118EXPORT_PER_CPU_SYMBOL(fpu_owner_task);
1114 1119
1115#ifdef CONFIG_CC_STACKPROTECTOR 1120#ifdef CONFIG_CC_STACKPROTECTOR
1116DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); 1121DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 80bfe1ab0031..c08d1ff12b7c 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -214,6 +214,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
214 214
215 task_user_gs(p) = get_user_gs(regs); 215 task_user_gs(p) = get_user_gs(regs);
216 216
217 p->fpu_counter = 0;
217 p->thread.io_bitmap_ptr = NULL; 218 p->thread.io_bitmap_ptr = NULL;
218 tsk = current; 219 tsk = current;
219 err = -ENOMEM; 220 err = -ENOMEM;
@@ -303,7 +304,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
303 304
304 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */ 305 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
305 306
306 fpu = switch_fpu_prepare(prev_p, next_p); 307 fpu = switch_fpu_prepare(prev_p, next_p, cpu);
307 308
308 /* 309 /*
309 * Reload esp0. 310 * Reload esp0.
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 1fd94bc4279d..cfa5c90c01db 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -286,6 +286,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
286 286
287 set_tsk_thread_flag(p, TIF_FORK); 287 set_tsk_thread_flag(p, TIF_FORK);
288 288
289 p->fpu_counter = 0;
289 p->thread.io_bitmap_ptr = NULL; 290 p->thread.io_bitmap_ptr = NULL;
290 291
291 savesegment(gs, p->thread.gsindex); 292 savesegment(gs, p->thread.gsindex);
@@ -388,7 +389,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
388 unsigned fsindex, gsindex; 389 unsigned fsindex, gsindex;
389 fpu_switch_t fpu; 390 fpu_switch_t fpu;
390 391
391 fpu = switch_fpu_prepare(prev_p, next_p); 392 fpu = switch_fpu_prepare(prev_p, next_p, cpu);
392 393
393 /* 394 /*
394 * Reload esp0, LDT and the page table pointer: 395 * Reload esp0, LDT and the page table pointer:
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 77da5b475ad2..4bbe04d96744 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -571,37 +571,6 @@ asmlinkage void __attribute__((weak)) smp_threshold_interrupt(void)
571} 571}
572 572
573/* 573/*
574 * This gets called with the process already owning the
575 * FPU state, and with CR0.TS cleared. It just needs to
576 * restore the FPU register state.
577 */
578void __math_state_restore(struct task_struct *tsk)
579{
580 /* We need a safe address that is cheap to find and that is already
581 in L1. We've just brought in "tsk->thread.has_fpu", so use that */
582#define safe_address (tsk->thread.has_fpu)
583
584 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
585 is pending. Clear the x87 state here by setting it to fixed
586 values. safe_address is a random variable that should be in L1 */
587 alternative_input(
588 ASM_NOP8 ASM_NOP2,
589 "emms\n\t" /* clear stack tags */
590 "fildl %P[addr]", /* set F?P to defined value */
591 X86_FEATURE_FXSAVE_LEAK,
592 [addr] "m" (safe_address));
593
594 /*
595 * Paranoid restore. send a SIGSEGV if we fail to restore the state.
596 */
597 if (unlikely(restore_fpu_checking(tsk))) {
598 __thread_fpu_end(tsk);
599 force_sig(SIGSEGV, tsk);
600 return;
601 }
602}
603
604/*
605 * 'math_state_restore()' saves the current math information in the 574 * 'math_state_restore()' saves the current math information in the
606 * old math state array, and gets the new ones from the current task 575 * old math state array, and gets the new ones from the current task
607 * 576 *
@@ -631,7 +600,14 @@ void math_state_restore(void)
631 } 600 }
632 601
633 __thread_fpu_begin(tsk); 602 __thread_fpu_begin(tsk);
634 __math_state_restore(tsk); 603 /*
604 * Paranoid restore. send a SIGSEGV if we fail to restore the state.
605 */
606 if (unlikely(restore_fpu_checking(tsk))) {
607 __thread_fpu_end(tsk);
608 force_sig(SIGSEGV, tsk);
609 return;
610 }
635 611
636 tsk->fpu_counter++; 612 tsk->fpu_counter++;
637} 613}
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 5d1d07645132..e8cd652d2017 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1206,9 +1206,9 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1206 1206
1207 out_unmap_both: 1207 out_unmap_both:
1208 pci_set_drvdata(dev, NULL); 1208 pci_set_drvdata(dev, NULL);
1209 pci_iounmap(dev, card->config_regs);
1210 out_unmap_config:
1211 pci_iounmap(dev, card->buffers); 1209 pci_iounmap(dev, card->buffers);
1210 out_unmap_config:
1211 pci_iounmap(dev, card->config_regs);
1212 out_release_regions: 1212 out_release_regions:
1213 pci_release_regions(dev); 1213 pci_release_regions(dev);
1214 out: 1214 out:
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index c1dc4d86c221..1f3c1a7d132a 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -41,6 +41,8 @@
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/version.h> 42#include <linux/version.h>
43 43
44#include <asm-generic/io-64-nonatomic-lo-hi.h>
45
44#define NVME_Q_DEPTH 1024 46#define NVME_Q_DEPTH 1024
45#define SQ_SIZE(depth) (depth * sizeof(struct nvme_command)) 47#define SQ_SIZE(depth) (depth * sizeof(struct nvme_command))
46#define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion)) 48#define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion))
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index 7dbc4a83c45c..78a666d1e5f5 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -1,7 +1,7 @@
1 1
2config CPU_IDLE 2config CPU_IDLE
3 bool "CPU idle PM support" 3 bool "CPU idle PM support"
4 default ACPI 4 default y if ACPI || PPC_PSERIES
5 help 5 help
6 CPU idle is a generic framework for supporting software-controlled 6 CPU idle is a generic framework for supporting software-controlled
7 idle processor power management. It includes modular cross-platform 7 idle processor power management. It includes modular cross-platform
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index aa08497a075a..73f55e2008c2 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -15,6 +15,8 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include "edac_core.h" 16#include "edac_core.h"
17 17
18#include <asm-generic/io-64-nonatomic-lo-hi.h>
19
18#define I3200_REVISION "1.1" 20#define I3200_REVISION "1.1"
19 21
20#define EDAC_MOD_STR "i3200_edac" 22#define EDAC_MOD_STR "i3200_edac"
@@ -101,19 +103,6 @@ struct i3200_priv {
101 103
102static int nr_channels; 104static int nr_channels;
103 105
104#ifndef readq
105static inline __u64 readq(const volatile void __iomem *addr)
106{
107 const volatile u32 __iomem *p = addr;
108 u32 low, high;
109
110 low = readl(p);
111 high = readl(p + 1);
112
113 return low + ((u64)high << 32);
114}
115#endif
116
117static int how_many_channels(struct pci_dev *pdev) 106static int how_many_channels(struct pci_dev *pdev)
118{ 107{
119 unsigned char capid0_8b; /* 8th byte of CAPID0 */ 108 unsigned char capid0_8b; /* 8th byte of CAPID0 */
diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c
index 661a03571d0c..d08a55896d50 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_core.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_core.c
@@ -193,6 +193,9 @@ int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv)
193 return err; 193 return err;
194 } 194 }
195 195
196 /* setup possible_clones. */
197 exynos_drm_encoder_setup(drm_dev);
198
196 /* 199 /*
197 * if any specific driver such as fimd or hdmi driver called 200 * if any specific driver such as fimd or hdmi driver called
198 * exynos_drm_subdrv_register() later than drm_load(), 201 * exynos_drm_subdrv_register() later than drm_load(),
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index e3861ac49295..de818831a511 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -307,9 +307,6 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
307 */ 307 */
308 event->pipe = exynos_crtc->pipe; 308 event->pipe = exynos_crtc->pipe;
309 309
310 list_add_tail(&event->base.link,
311 &dev_priv->pageflip_event_list);
312
313 ret = drm_vblank_get(dev, exynos_crtc->pipe); 310 ret = drm_vblank_get(dev, exynos_crtc->pipe);
314 if (ret) { 311 if (ret) {
315 DRM_DEBUG("failed to acquire vblank counter\n"); 312 DRM_DEBUG("failed to acquire vblank counter\n");
@@ -318,6 +315,9 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
318 goto out; 315 goto out;
319 } 316 }
320 317
318 list_add_tail(&event->base.link,
319 &dev_priv->pageflip_event_list);
320
321 crtc->fb = fb; 321 crtc->fb = fb;
322 ret = exynos_drm_crtc_update(crtc); 322 ret = exynos_drm_crtc_update(crtc);
323 if (ret) { 323 if (ret) {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 35889ca255e9..58820ebd3558 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -33,6 +33,7 @@
33 33
34#include "exynos_drm_drv.h" 34#include "exynos_drm_drv.h"
35#include "exynos_drm_crtc.h" 35#include "exynos_drm_crtc.h"
36#include "exynos_drm_encoder.h"
36#include "exynos_drm_fbdev.h" 37#include "exynos_drm_fbdev.h"
37#include "exynos_drm_fb.h" 38#include "exynos_drm_fb.h"
38#include "exynos_drm_gem.h" 39#include "exynos_drm_gem.h"
@@ -99,6 +100,9 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
99 if (ret) 100 if (ret)
100 goto err_vblank; 101 goto err_vblank;
101 102
103 /* setup possible_clones. */
104 exynos_drm_encoder_setup(dev);
105
102 /* 106 /*
103 * create and configure fb helper and also exynos specific 107 * create and configure fb helper and also exynos specific
104 * fbdev object. 108 * fbdev object.
@@ -141,16 +145,21 @@ static int exynos_drm_unload(struct drm_device *dev)
141} 145}
142 146
143static void exynos_drm_preclose(struct drm_device *dev, 147static void exynos_drm_preclose(struct drm_device *dev,
144 struct drm_file *file_priv) 148 struct drm_file *file)
145{ 149{
146 struct exynos_drm_private *dev_priv = dev->dev_private; 150 DRM_DEBUG_DRIVER("%s\n", __FILE__);
147 151
148 /* 152}
149 * drm framework frees all events at release time, 153
150 * so private event list should be cleared. 154static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
151 */ 155{
152 if (!list_empty(&dev_priv->pageflip_event_list)) 156 DRM_DEBUG_DRIVER("%s\n", __FILE__);
153 INIT_LIST_HEAD(&dev_priv->pageflip_event_list); 157
158 if (!file->driver_priv)
159 return;
160
161 kfree(file->driver_priv);
162 file->driver_priv = NULL;
154} 163}
155 164
156static void exynos_drm_lastclose(struct drm_device *dev) 165static void exynos_drm_lastclose(struct drm_device *dev)
@@ -195,6 +204,7 @@ static struct drm_driver exynos_drm_driver = {
195 .unload = exynos_drm_unload, 204 .unload = exynos_drm_unload,
196 .preclose = exynos_drm_preclose, 205 .preclose = exynos_drm_preclose,
197 .lastclose = exynos_drm_lastclose, 206 .lastclose = exynos_drm_lastclose,
207 .postclose = exynos_drm_postclose,
198 .get_vblank_counter = drm_vblank_count, 208 .get_vblank_counter = drm_vblank_count,
199 .enable_vblank = exynos_drm_crtc_enable_vblank, 209 .enable_vblank = exynos_drm_crtc_enable_vblank,
200 .disable_vblank = exynos_drm_crtc_disable_vblank, 210 .disable_vblank = exynos_drm_crtc_disable_vblank,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
index 86b93dde219a..ef4754f1519b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
@@ -195,6 +195,40 @@ static struct drm_encoder_funcs exynos_encoder_funcs = {
195 .destroy = exynos_drm_encoder_destroy, 195 .destroy = exynos_drm_encoder_destroy,
196}; 196};
197 197
198static unsigned int exynos_drm_encoder_clones(struct drm_encoder *encoder)
199{
200 struct drm_encoder *clone;
201 struct drm_device *dev = encoder->dev;
202 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
203 struct exynos_drm_display_ops *display_ops =
204 exynos_encoder->manager->display_ops;
205 unsigned int clone_mask = 0;
206 int cnt = 0;
207
208 list_for_each_entry(clone, &dev->mode_config.encoder_list, head) {
209 switch (display_ops->type) {
210 case EXYNOS_DISPLAY_TYPE_LCD:
211 case EXYNOS_DISPLAY_TYPE_HDMI:
212 clone_mask |= (1 << (cnt++));
213 break;
214 default:
215 continue;
216 }
217 }
218
219 return clone_mask;
220}
221
222void exynos_drm_encoder_setup(struct drm_device *dev)
223{
224 struct drm_encoder *encoder;
225
226 DRM_DEBUG_KMS("%s\n", __FILE__);
227
228 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
229 encoder->possible_clones = exynos_drm_encoder_clones(encoder);
230}
231
198struct drm_encoder * 232struct drm_encoder *
199exynos_drm_encoder_create(struct drm_device *dev, 233exynos_drm_encoder_create(struct drm_device *dev,
200 struct exynos_drm_manager *manager, 234 struct exynos_drm_manager *manager,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.h b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
index 97b087a51cb6..eb7d2316847e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
@@ -30,6 +30,7 @@
30 30
31struct exynos_drm_manager; 31struct exynos_drm_manager;
32 32
33void exynos_drm_encoder_setup(struct drm_device *dev);
33struct drm_encoder *exynos_drm_encoder_create(struct drm_device *dev, 34struct drm_encoder *exynos_drm_encoder_create(struct drm_device *dev,
34 struct exynos_drm_manager *mgr, 35 struct exynos_drm_manager *mgr,
35 unsigned int possible_crtcs); 36 unsigned int possible_crtcs);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index d7ae29d2f3d6..3508700e529b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -195,66 +195,6 @@ out:
195 return ret; 195 return ret;
196} 196}
197 197
198static bool
199exynos_drm_fbdev_is_samefb(struct drm_framebuffer *fb,
200 struct drm_fb_helper_surface_size *sizes)
201{
202 if (fb->width != sizes->surface_width)
203 return false;
204 if (fb->height != sizes->surface_height)
205 return false;
206 if (fb->bits_per_pixel != sizes->surface_bpp)
207 return false;
208 if (fb->depth != sizes->surface_depth)
209 return false;
210
211 return true;
212}
213
214static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper,
215 struct drm_fb_helper_surface_size *sizes)
216{
217 struct drm_device *dev = helper->dev;
218 struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper);
219 struct exynos_drm_gem_obj *exynos_gem_obj;
220 struct drm_framebuffer *fb = helper->fb;
221 struct drm_mode_fb_cmd2 mode_cmd = { 0 };
222 unsigned long size;
223
224 DRM_DEBUG_KMS("%s\n", __FILE__);
225
226 if (exynos_drm_fbdev_is_samefb(fb, sizes))
227 return 0;
228
229 mode_cmd.width = sizes->surface_width;
230 mode_cmd.height = sizes->surface_height;
231 mode_cmd.pitches[0] = sizes->surface_width * (sizes->surface_bpp >> 3);
232 mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
233 sizes->surface_depth);
234
235 if (exynos_fbdev->exynos_gem_obj)
236 exynos_drm_gem_destroy(exynos_fbdev->exynos_gem_obj);
237
238 if (fb->funcs->destroy)
239 fb->funcs->destroy(fb);
240
241 size = mode_cmd.pitches[0] * mode_cmd.height;
242 exynos_gem_obj = exynos_drm_gem_create(dev, size);
243 if (IS_ERR(exynos_gem_obj))
244 return PTR_ERR(exynos_gem_obj);
245
246 exynos_fbdev->exynos_gem_obj = exynos_gem_obj;
247
248 helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd,
249 &exynos_gem_obj->base);
250 if (IS_ERR_OR_NULL(helper->fb)) {
251 DRM_ERROR("failed to create drm framebuffer.\n");
252 return PTR_ERR(helper->fb);
253 }
254
255 return exynos_drm_fbdev_update(helper, helper->fb);
256}
257
258static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper, 198static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper,
259 struct drm_fb_helper_surface_size *sizes) 199 struct drm_fb_helper_surface_size *sizes)
260{ 200{
@@ -262,6 +202,10 @@ static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper,
262 202
263 DRM_DEBUG_KMS("%s\n", __FILE__); 203 DRM_DEBUG_KMS("%s\n", __FILE__);
264 204
205 /*
206 * with !helper->fb, it means that this funcion is called first time
207 * and after that, the helper->fb would be used as clone mode.
208 */
265 if (!helper->fb) { 209 if (!helper->fb) {
266 ret = exynos_drm_fbdev_create(helper, sizes); 210 ret = exynos_drm_fbdev_create(helper, sizes);
267 if (ret < 0) { 211 if (ret < 0) {
@@ -274,12 +218,6 @@ static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper,
274 * because register_framebuffer() should be called. 218 * because register_framebuffer() should be called.
275 */ 219 */
276 ret = 1; 220 ret = 1;
277 } else {
278 ret = exynos_drm_fbdev_recreate(helper, sizes);
279 if (ret < 0) {
280 DRM_ERROR("failed to reconfigure fbdev\n");
281 return ret;
282 }
283 } 221 }
284 222
285 return ret; 223 return ret;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index b6a737d196ae..0dbb32bb18a3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -604,7 +604,12 @@ static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc)
604 } 604 }
605 605
606 if (is_checked) { 606 if (is_checked) {
607 drm_vblank_put(drm_dev, crtc); 607 /*
608 * call drm_vblank_put only in case that drm_vblank_get was
609 * called.
610 */
611 if (atomic_read(&drm_dev->vblank_refcount[crtc]) > 0)
612 drm_vblank_put(drm_dev, crtc);
608 613
609 /* 614 /*
610 * don't off vblank if vblank_disable_allowed is 1, 615 * don't off vblank if vblank_disable_allowed is 1,
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index ac24cff39775..93846e810e38 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -712,7 +712,12 @@ static void mixer_finish_pageflip(struct drm_device *drm_dev, int crtc)
712 } 712 }
713 713
714 if (is_checked) 714 if (is_checked)
715 drm_vblank_put(drm_dev, crtc); 715 /*
716 * call drm_vblank_put only in case that drm_vblank_get was
717 * called.
718 */
719 if (atomic_read(&drm_dev->vblank_refcount[crtc]) > 0)
720 drm_vblank_put(drm_dev, crtc);
716 721
717 spin_unlock_irqrestore(&drm_dev->event_lock, flags); 722 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
718} 723}
@@ -779,15 +784,15 @@ static void mixer_win_reset(struct mixer_context *ctx)
779 mixer_reg_writemask(res, MXR_STATUS, MXR_STATUS_16_BURST, 784 mixer_reg_writemask(res, MXR_STATUS, MXR_STATUS_16_BURST,
780 MXR_STATUS_BURST_MASK); 785 MXR_STATUS_BURST_MASK);
781 786
782 /* setting default layer priority: layer1 > video > layer0 787 /* setting default layer priority: layer1 > layer0 > video
783 * because typical usage scenario would be 788 * because typical usage scenario would be
789 * layer1 - OSD
784 * layer0 - framebuffer 790 * layer0 - framebuffer
785 * video - video overlay 791 * video - video overlay
786 * layer1 - OSD
787 */ 792 */
788 val = MXR_LAYER_CFG_GRP0_VAL(1); 793 val = MXR_LAYER_CFG_GRP1_VAL(3);
789 val |= MXR_LAYER_CFG_VP_VAL(2); 794 val |= MXR_LAYER_CFG_GRP0_VAL(2);
790 val |= MXR_LAYER_CFG_GRP1_VAL(3); 795 val |= MXR_LAYER_CFG_VP_VAL(1);
791 mixer_reg_write(res, MXR_LAYER_CFG, val); 796 mixer_reg_write(res, MXR_LAYER_CFG, val);
792 797
793 /* setting background color */ 798 /* setting background color */
@@ -1044,7 +1049,7 @@ static int mixer_remove(struct platform_device *pdev)
1044 platform_get_drvdata(pdev); 1049 platform_get_drvdata(pdev);
1045 struct mixer_context *ctx = (struct mixer_context *)drm_hdmi_ctx->ctx; 1050 struct mixer_context *ctx = (struct mixer_context *)drm_hdmi_ctx->ctx;
1046 1051
1047 dev_info(dev, "remove sucessful\n"); 1052 dev_info(dev, "remove successful\n");
1048 1053
1049 mixer_resource_poweroff(ctx); 1054 mixer_resource_poweroff(ctx);
1050 mixer_resources_cleanup(ctx); 1055 mixer_resources_cleanup(ctx);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index c3afb783cb9d..03c53fcf8653 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3028,6 +3028,20 @@
3028#define DISP_TILE_SURFACE_SWIZZLING (1<<13) 3028#define DISP_TILE_SURFACE_SWIZZLING (1<<13)
3029#define DISP_FBC_WM_DIS (1<<15) 3029#define DISP_FBC_WM_DIS (1<<15)
3030 3030
3031/* GEN7 chicken */
3032#define GEN7_COMMON_SLICE_CHICKEN1 0x7010
3033# define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC ((1<<10) | (1<<26))
3034
3035#define GEN7_L3CNTLREG1 0xB01C
3036#define GEN7_WA_FOR_GEN7_L3_CONTROL 0x3C4FFF8C
3037
3038#define GEN7_L3_CHICKEN_MODE_REGISTER 0xB030
3039#define GEN7_WA_L3_CHICKEN_MODE 0x20000000
3040
3041/* WaCatErrorRejectionIssue */
3042#define GEN7_SQ_CHICKEN_MBCUNIT_CONFIG 0x9030
3043#define GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB (1<<11)
3044
3031/* PCH */ 3045/* PCH */
3032 3046
3033/* south display engine interrupt */ 3047/* south display engine interrupt */
@@ -3618,6 +3632,7 @@
3618#define GT_FIFO_NUM_RESERVED_ENTRIES 20 3632#define GT_FIFO_NUM_RESERVED_ENTRIES 20
3619 3633
3620#define GEN6_UCGCTL2 0x9404 3634#define GEN6_UCGCTL2 0x9404
3635# define GEN6_RCZUNIT_CLOCK_GATE_DISABLE (1 << 13)
3621# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12) 3636# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12)
3622# define GEN6_RCCUNIT_CLOCK_GATE_DISABLE (1 << 11) 3637# define GEN6_RCCUNIT_CLOCK_GATE_DISABLE (1 << 11)
3623 3638
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 00fbff5ddd81..f425b23e3803 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8184,8 +8184,8 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
8184 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */ 8184 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */
8185 8185
8186 if (intel_enable_rc6(dev_priv->dev)) 8186 if (intel_enable_rc6(dev_priv->dev))
8187 rc6_mask = GEN6_RC_CTL_RC6p_ENABLE | 8187 rc6_mask = GEN6_RC_CTL_RC6_ENABLE |
8188 GEN6_RC_CTL_RC6_ENABLE; 8188 (IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0;
8189 8189
8190 I915_WRITE(GEN6_RC_CONTROL, 8190 I915_WRITE(GEN6_RC_CONTROL,
8191 rc6_mask | 8191 rc6_mask |
@@ -8463,12 +8463,32 @@ static void ivybridge_init_clock_gating(struct drm_device *dev)
8463 I915_WRITE(WM2_LP_ILK, 0); 8463 I915_WRITE(WM2_LP_ILK, 0);
8464 I915_WRITE(WM1_LP_ILK, 0); 8464 I915_WRITE(WM1_LP_ILK, 0);
8465 8465
8466 /* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
8467 * This implements the WaDisableRCZUnitClockGating workaround.
8468 */
8469 I915_WRITE(GEN6_UCGCTL2, GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
8470
8466 I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE); 8471 I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE);
8467 8472
8468 I915_WRITE(IVB_CHICKEN3, 8473 I915_WRITE(IVB_CHICKEN3,
8469 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE | 8474 CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
8470 CHICKEN3_DGMG_DONE_FIX_DISABLE); 8475 CHICKEN3_DGMG_DONE_FIX_DISABLE);
8471 8476
8477 /* Apply the WaDisableRHWOOptimizationForRenderHang workaround. */
8478 I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
8479 GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
8480
8481 /* WaApplyL3ControlAndL3ChickenMode requires those two on Ivy Bridge */
8482 I915_WRITE(GEN7_L3CNTLREG1,
8483 GEN7_WA_FOR_GEN7_L3_CONTROL);
8484 I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER,
8485 GEN7_WA_L3_CHICKEN_MODE);
8486
8487 /* This is required by WaCatErrorRejectionIssue */
8488 I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
8489 I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
8490 GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
8491
8472 for_each_pipe(pipe) { 8492 for_each_pipe(pipe) {
8473 I915_WRITE(DSPCNTR(pipe), 8493 I915_WRITE(DSPCNTR(pipe),
8474 I915_READ(DSPCNTR(pipe)) | 8494 I915_READ(DSPCNTR(pipe)) |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 9be353b894cc..f58254a3fb01 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3223,6 +3223,7 @@ int evergreen_resume(struct radeon_device *rdev)
3223 r = evergreen_startup(rdev); 3223 r = evergreen_startup(rdev);
3224 if (r) { 3224 if (r) {
3225 DRM_ERROR("evergreen startup failed on resume\n"); 3225 DRM_ERROR("evergreen startup failed on resume\n");
3226 rdev->accel_working = false;
3226 return r; 3227 return r;
3227 } 3228 }
3228 3229
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index db09065e68fd..2509c505acb8 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1547,6 +1547,7 @@ int cayman_resume(struct radeon_device *rdev)
1547 r = cayman_startup(rdev); 1547 r = cayman_startup(rdev);
1548 if (r) { 1548 if (r) {
1549 DRM_ERROR("cayman startup failed on resume\n"); 1549 DRM_ERROR("cayman startup failed on resume\n");
1550 rdev->accel_working = false;
1550 return r; 1551 return r;
1551 } 1552 }
1552 return r; 1553 return r;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 18cd84fae99c..333cde9d4e7b 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3928,6 +3928,8 @@ static int r100_startup(struct radeon_device *rdev)
3928 3928
3929int r100_resume(struct radeon_device *rdev) 3929int r100_resume(struct radeon_device *rdev)
3930{ 3930{
3931 int r;
3932
3931 /* Make sur GART are not working */ 3933 /* Make sur GART are not working */
3932 if (rdev->flags & RADEON_IS_PCI) 3934 if (rdev->flags & RADEON_IS_PCI)
3933 r100_pci_gart_disable(rdev); 3935 r100_pci_gart_disable(rdev);
@@ -3947,7 +3949,11 @@ int r100_resume(struct radeon_device *rdev)
3947 radeon_surface_init(rdev); 3949 radeon_surface_init(rdev);
3948 3950
3949 rdev->accel_working = true; 3951 rdev->accel_working = true;
3950 return r100_startup(rdev); 3952 r = r100_startup(rdev);
3953 if (r) {
3954 rdev->accel_working = false;
3955 }
3956 return r;
3951} 3957}
3952 3958
3953int r100_suspend(struct radeon_device *rdev) 3959int r100_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 3fc0d29a5f39..6829638cca40 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -1431,6 +1431,8 @@ static int r300_startup(struct radeon_device *rdev)
1431 1431
1432int r300_resume(struct radeon_device *rdev) 1432int r300_resume(struct radeon_device *rdev)
1433{ 1433{
1434 int r;
1435
1434 /* Make sur GART are not working */ 1436 /* Make sur GART are not working */
1435 if (rdev->flags & RADEON_IS_PCIE) 1437 if (rdev->flags & RADEON_IS_PCIE)
1436 rv370_pcie_gart_disable(rdev); 1438 rv370_pcie_gart_disable(rdev);
@@ -1452,7 +1454,11 @@ int r300_resume(struct radeon_device *rdev)
1452 radeon_surface_init(rdev); 1454 radeon_surface_init(rdev);
1453 1455
1454 rdev->accel_working = true; 1456 rdev->accel_working = true;
1455 return r300_startup(rdev); 1457 r = r300_startup(rdev);
1458 if (r) {
1459 rdev->accel_working = false;
1460 }
1461 return r;
1456} 1462}
1457 1463
1458int r300_suspend(struct radeon_device *rdev) 1464int r300_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 666e28fe509c..b14323053bad 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -291,6 +291,8 @@ static int r420_startup(struct radeon_device *rdev)
291 291
292int r420_resume(struct radeon_device *rdev) 292int r420_resume(struct radeon_device *rdev)
293{ 293{
294 int r;
295
294 /* Make sur GART are not working */ 296 /* Make sur GART are not working */
295 if (rdev->flags & RADEON_IS_PCIE) 297 if (rdev->flags & RADEON_IS_PCIE)
296 rv370_pcie_gart_disable(rdev); 298 rv370_pcie_gart_disable(rdev);
@@ -316,7 +318,11 @@ int r420_resume(struct radeon_device *rdev)
316 radeon_surface_init(rdev); 318 radeon_surface_init(rdev);
317 319
318 rdev->accel_working = true; 320 rdev->accel_working = true;
319 return r420_startup(rdev); 321 r = r420_startup(rdev);
322 if (r) {
323 rdev->accel_working = false;
324 }
325 return r;
320} 326}
321 327
322int r420_suspend(struct radeon_device *rdev) 328int r420_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 4ae1615e752f..25084e824dbc 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -218,6 +218,8 @@ static int r520_startup(struct radeon_device *rdev)
218 218
219int r520_resume(struct radeon_device *rdev) 219int r520_resume(struct radeon_device *rdev)
220{ 220{
221 int r;
222
221 /* Make sur GART are not working */ 223 /* Make sur GART are not working */
222 if (rdev->flags & RADEON_IS_PCIE) 224 if (rdev->flags & RADEON_IS_PCIE)
223 rv370_pcie_gart_disable(rdev); 225 rv370_pcie_gart_disable(rdev);
@@ -237,7 +239,11 @@ int r520_resume(struct radeon_device *rdev)
237 radeon_surface_init(rdev); 239 radeon_surface_init(rdev);
238 240
239 rdev->accel_working = true; 241 rdev->accel_working = true;
240 return r520_startup(rdev); 242 r = r520_startup(rdev);
243 if (r) {
244 rdev->accel_working = false;
245 }
246 return r;
241} 247}
242 248
243int r520_init(struct radeon_device *rdev) 249int r520_init(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 4f08e5e6ee9d..fbcd84803b60 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2529,6 +2529,7 @@ int r600_resume(struct radeon_device *rdev)
2529 r = r600_startup(rdev); 2529 r = r600_startup(rdev);
2530 if (r) { 2530 if (r) {
2531 DRM_ERROR("r600 startup failed on resume\n"); 2531 DRM_ERROR("r600 startup failed on resume\n");
2532 rdev->accel_working = false;
2532 return r; 2533 return r;
2533 } 2534 }
2534 2535
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 9e72daeeddc6..1f53ae74ada1 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -3020,6 +3020,9 @@ radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
3020 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 3020 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3021 uint32_t bios_2_scratch; 3021 uint32_t bios_2_scratch;
3022 3022
3023 if (ASIC_IS_DCE4(rdev))
3024 return;
3025
3023 if (rdev->family >= CHIP_R600) 3026 if (rdev->family >= CHIP_R600)
3024 bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); 3027 bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH);
3025 else 3028 else
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 435a3d970ab8..e64bec488ed8 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -453,6 +453,10 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
453 int r; 453 int r;
454 454
455 radeon_mutex_lock(&rdev->cs_mutex); 455 radeon_mutex_lock(&rdev->cs_mutex);
456 if (!rdev->accel_working) {
457 radeon_mutex_unlock(&rdev->cs_mutex);
458 return -EBUSY;
459 }
456 /* initialize parser */ 460 /* initialize parser */
457 memset(&parser, 0, sizeof(struct radeon_cs_parser)); 461 memset(&parser, 0, sizeof(struct radeon_cs_parser));
458 parser.filp = filp; 462 parser.filp = filp;
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 30a4c5014c8b..92c9ea4751fb 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -500,8 +500,11 @@ static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
500int radeon_debugfs_ring_init(struct radeon_device *rdev) 500int radeon_debugfs_ring_init(struct radeon_device *rdev)
501{ 501{
502#if defined(CONFIG_DEBUG_FS) 502#if defined(CONFIG_DEBUG_FS)
503 return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list, 503 if (rdev->family >= CHIP_CAYMAN)
504 ARRAY_SIZE(radeon_debugfs_ring_info_list)); 504 return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list,
505 ARRAY_SIZE(radeon_debugfs_ring_info_list));
506 else
507 return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list, 1);
505#else 508#else
506 return 0; 509 return 0;
507#endif 510#endif
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index b0ce84a20a68..866a05be75f2 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -442,6 +442,8 @@ static int rs400_startup(struct radeon_device *rdev)
442 442
443int rs400_resume(struct radeon_device *rdev) 443int rs400_resume(struct radeon_device *rdev)
444{ 444{
445 int r;
446
445 /* Make sur GART are not working */ 447 /* Make sur GART are not working */
446 rs400_gart_disable(rdev); 448 rs400_gart_disable(rdev);
447 /* Resume clock before doing reset */ 449 /* Resume clock before doing reset */
@@ -462,7 +464,11 @@ int rs400_resume(struct radeon_device *rdev)
462 radeon_surface_init(rdev); 464 radeon_surface_init(rdev);
463 465
464 rdev->accel_working = true; 466 rdev->accel_working = true;
465 return rs400_startup(rdev); 467 r = rs400_startup(rdev);
468 if (r) {
469 rdev->accel_working = false;
470 }
471 return r;
466} 472}
467 473
468int rs400_suspend(struct radeon_device *rdev) 474int rs400_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index c05865e5521f..4fc700684dcd 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -876,6 +876,8 @@ static int rs600_startup(struct radeon_device *rdev)
876 876
877int rs600_resume(struct radeon_device *rdev) 877int rs600_resume(struct radeon_device *rdev)
878{ 878{
879 int r;
880
879 /* Make sur GART are not working */ 881 /* Make sur GART are not working */
880 rs600_gart_disable(rdev); 882 rs600_gart_disable(rdev);
881 /* Resume clock before doing reset */ 883 /* Resume clock before doing reset */
@@ -894,7 +896,11 @@ int rs600_resume(struct radeon_device *rdev)
894 radeon_surface_init(rdev); 896 radeon_surface_init(rdev);
895 897
896 rdev->accel_working = true; 898 rdev->accel_working = true;
897 return rs600_startup(rdev); 899 r = rs600_startup(rdev);
900 if (r) {
901 rdev->accel_working = false;
902 }
903 return r;
898} 904}
899 905
900int rs600_suspend(struct radeon_device *rdev) 906int rs600_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 4f24a0fa8c82..f68dff2fadcb 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -659,6 +659,8 @@ static int rs690_startup(struct radeon_device *rdev)
659 659
660int rs690_resume(struct radeon_device *rdev) 660int rs690_resume(struct radeon_device *rdev)
661{ 661{
662 int r;
663
662 /* Make sur GART are not working */ 664 /* Make sur GART are not working */
663 rs400_gart_disable(rdev); 665 rs400_gart_disable(rdev);
664 /* Resume clock before doing reset */ 666 /* Resume clock before doing reset */
@@ -677,7 +679,11 @@ int rs690_resume(struct radeon_device *rdev)
677 radeon_surface_init(rdev); 679 radeon_surface_init(rdev);
678 680
679 rdev->accel_working = true; 681 rdev->accel_working = true;
680 return rs690_startup(rdev); 682 r = rs690_startup(rdev);
683 if (r) {
684 rdev->accel_working = false;
685 }
686 return r;
681} 687}
682 688
683int rs690_suspend(struct radeon_device *rdev) 689int rs690_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 880637fd1946..959bf4483bea 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -424,6 +424,8 @@ static int rv515_startup(struct radeon_device *rdev)
424 424
425int rv515_resume(struct radeon_device *rdev) 425int rv515_resume(struct radeon_device *rdev)
426{ 426{
427 int r;
428
427 /* Make sur GART are not working */ 429 /* Make sur GART are not working */
428 if (rdev->flags & RADEON_IS_PCIE) 430 if (rdev->flags & RADEON_IS_PCIE)
429 rv370_pcie_gart_disable(rdev); 431 rv370_pcie_gart_disable(rdev);
@@ -443,7 +445,11 @@ int rv515_resume(struct radeon_device *rdev)
443 radeon_surface_init(rdev); 445 radeon_surface_init(rdev);
444 446
445 rdev->accel_working = true; 447 rdev->accel_working = true;
446 return rv515_startup(rdev); 448 r = rv515_startup(rdev);
449 if (r) {
450 rdev->accel_working = false;
451 }
452 return r;
447} 453}
448 454
449int rv515_suspend(struct radeon_device *rdev) 455int rv515_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index a1668b659ddd..c049c0c51841 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -1139,6 +1139,7 @@ int rv770_resume(struct radeon_device *rdev)
1139 r = rv770_startup(rdev); 1139 r = rv770_startup(rdev);
1140 if (r) { 1140 if (r) {
1141 DRM_ERROR("r600 startup failed on resume\n"); 1141 DRM_ERROR("r600 startup failed on resume\n");
1142 rdev->accel_working = false;
1142 return r; 1143 return r;
1143 } 1144 }
1144 1145
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index eedca3cf9968..dd87ae96c262 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -271,7 +271,7 @@ static int ads1015_probe(struct i2c_client *client,
271 continue; 271 continue;
272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); 272 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr);
273 if (err) 273 if (err)
274 goto exit_free; 274 goto exit_remove;
275 } 275 }
276 276
277 data->hwmon_dev = hwmon_device_register(&client->dev); 277 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -285,7 +285,6 @@ static int ads1015_probe(struct i2c_client *client,
285exit_remove: 285exit_remove:
286 for (k = 0; k < ADS1015_CHANNELS; ++k) 286 for (k = 0; k < ADS1015_CHANNELS; ++k)
287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); 287 device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
288exit_free:
289 kfree(data); 288 kfree(data);
290exit: 289exit:
291 return err; 290 return err;
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index f609b5727ba9..6bab2001ef3b 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -340,8 +340,6 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
340 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 340 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
341 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr)); 341 fanmode |= (1 << F75387_FAN_DUTY_MODE(nr));
342 data->pwm[nr] = 255; 342 data->pwm[nr] = 255;
343 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
344 data->pwm[nr]);
345 break; 343 break;
346 case 1: /* PWM */ 344 case 1: /* PWM */
347 fanmode |= (1 << F75387_FAN_MANU_MODE(nr)); 345 fanmode |= (1 << F75387_FAN_MANU_MODE(nr));
@@ -361,8 +359,6 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
361 case 0: /* full speed */ 359 case 0: /* full speed */
362 fanmode |= (3 << FAN_CTRL_MODE(nr)); 360 fanmode |= (3 << FAN_CTRL_MODE(nr));
363 data->pwm[nr] = 255; 361 data->pwm[nr] = 255;
364 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
365 data->pwm[nr]);
366 break; 362 break;
367 case 1: /* PWM */ 363 case 1: /* PWM */
368 fanmode |= (3 << FAN_CTRL_MODE(nr)); 364 fanmode |= (3 << FAN_CTRL_MODE(nr));
@@ -377,6 +373,9 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
377 373
378 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); 374 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
379 data->pwm_enable[nr] = val; 375 data->pwm_enable[nr] = val;
376 if (val == 0)
377 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
378 data->pwm[nr]);
380 return 0; 379 return 0;
381} 380}
382 381
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
index e10a092c603c..a6760bacd915 100644
--- a/drivers/hwmon/max6639.c
+++ b/drivers/hwmon/max6639.c
@@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END };
72 72
73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; 73static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 };
74 74
75#define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \ 75#define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \
76 (val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val))) 76 0 : (rpm_ranges[rpm_range] * 30) / (val))
77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) 77#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255)
78 78
79/* 79/*
@@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev,
333 return PTR_ERR(data); 333 return PTR_ERR(data);
334 334
335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], 335 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
336 data->ppr, data->rpm_range)); 336 data->rpm_range));
337} 337}
338 338
339static ssize_t show_alarm(struct device *dev, 339static ssize_t show_alarm(struct device *dev,
@@ -429,9 +429,9 @@ static int max6639_init_client(struct i2c_client *client)
429 struct max6639_data *data = i2c_get_clientdata(client); 429 struct max6639_data *data = i2c_get_clientdata(client);
430 struct max6639_platform_data *max6639_info = 430 struct max6639_platform_data *max6639_info =
431 client->dev.platform_data; 431 client->dev.platform_data;
432 int i = 0; 432 int i;
433 int rpm_range = 1; /* default: 4000 RPM */ 433 int rpm_range = 1; /* default: 4000 RPM */
434 int err = 0; 434 int err;
435 435
436 /* Reset chip to default values, see below for GCONFIG setup */ 436 /* Reset chip to default values, see below for GCONFIG setup */
437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, 437 err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG,
@@ -446,11 +446,6 @@ static int max6639_init_client(struct i2c_client *client)
446 else 446 else
447 data->ppr = 2; 447 data->ppr = 2;
448 data->ppr -= 1; 448 data->ppr -= 1;
449 err = i2c_smbus_write_byte_data(client,
450 MAX6639_REG_FAN_PPR(i),
451 data->ppr << 5);
452 if (err)
453 goto exit;
454 449
455 if (max6639_info) 450 if (max6639_info)
456 rpm_range = rpm_range_to_reg(max6639_info->rpm_range); 451 rpm_range = rpm_range_to_reg(max6639_info->rpm_range);
@@ -458,6 +453,13 @@ static int max6639_init_client(struct i2c_client *client)
458 453
459 for (i = 0; i < 2; i++) { 454 for (i = 0; i < 2; i++) {
460 455
456 /* Set Fan pulse per revolution */
457 err = i2c_smbus_write_byte_data(client,
458 MAX6639_REG_FAN_PPR(i),
459 data->ppr << 6);
460 if (err)
461 goto exit;
462
461 /* Fans config PWM, RPM */ 463 /* Fans config PWM, RPM */
462 err = i2c_smbus_write_byte_data(client, 464 err = i2c_smbus_write_byte_data(client,
463 MAX6639_REG_FAN_CONFIG1(i), 465 MAX6639_REG_FAN_CONFIG1(i),
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index beaf5a8d9c45..9b97a5b3cf3d 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -82,7 +82,7 @@ static int max34440_write_word_data(struct i2c_client *client, int page,
82 case PMBUS_VIRT_RESET_TEMP_HISTORY: 82 case PMBUS_VIRT_RESET_TEMP_HISTORY:
83 ret = pmbus_write_word_data(client, page, 83 ret = pmbus_write_word_data(client, page,
84 MAX34440_MFR_TEMPERATURE_PEAK, 84 MAX34440_MFR_TEMPERATURE_PEAK,
85 0xffff); 85 0x8000);
86 break; 86 break;
87 default: 87 default:
88 ret = -ENODATA; 88 ret = -ENODATA;
diff --git a/drivers/media/radio/wl128x/Kconfig b/drivers/media/radio/wl128x/Kconfig
index 86b28579f0c7..ea1e6545df36 100644
--- a/drivers/media/radio/wl128x/Kconfig
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -4,8 +4,8 @@
4menu "Texas Instruments WL128x FM driver (ST based)" 4menu "Texas Instruments WL128x FM driver (ST based)"
5config RADIO_WL128X 5config RADIO_WL128X
6 tristate "Texas Instruments WL128x FM Radio" 6 tristate "Texas Instruments WL128x FM Radio"
7 depends on VIDEO_V4L2 && RFKILL 7 depends on VIDEO_V4L2 && RFKILL && GPIOLIB
8 select TI_ST if NET && GPIOLIB 8 select TI_ST if NET
9 help 9 help
10 Choose Y here if you have this FM radio chip. 10 Choose Y here if you have this FM radio chip.
11 11
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 3aeb29a7ce11..7f26fdf2e54e 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -47,7 +47,7 @@
47#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" 47#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>"
48#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" 48#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display"
49#define MOD_NAME "imon" 49#define MOD_NAME "imon"
50#define MOD_VERSION "0.9.3" 50#define MOD_VERSION "0.9.4"
51 51
52#define DISPLAY_MINOR_BASE 144 52#define DISPLAY_MINOR_BASE 144
53#define DEVICE_NAME "lcd%d" 53#define DEVICE_NAME "lcd%d"
@@ -1658,9 +1658,17 @@ static void usb_rx_callback_intf0(struct urb *urb)
1658 return; 1658 return;
1659 1659
1660 ictx = (struct imon_context *)urb->context; 1660 ictx = (struct imon_context *)urb->context;
1661 if (!ictx || !ictx->dev_present_intf0) 1661 if (!ictx)
1662 return; 1662 return;
1663 1663
1664 /*
1665 * if we get a callback before we're done configuring the hardware, we
1666 * can't yet process the data, as there's nowhere to send it, but we
1667 * still need to submit a new rx URB to avoid wedging the hardware
1668 */
1669 if (!ictx->dev_present_intf0)
1670 goto out;
1671
1664 switch (urb->status) { 1672 switch (urb->status) {
1665 case -ENOENT: /* usbcore unlink successful! */ 1673 case -ENOENT: /* usbcore unlink successful! */
1666 return; 1674 return;
@@ -1678,6 +1686,7 @@ static void usb_rx_callback_intf0(struct urb *urb)
1678 break; 1686 break;
1679 } 1687 }
1680 1688
1689out:
1681 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); 1690 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC);
1682} 1691}
1683 1692
@@ -1690,9 +1699,17 @@ static void usb_rx_callback_intf1(struct urb *urb)
1690 return; 1699 return;
1691 1700
1692 ictx = (struct imon_context *)urb->context; 1701 ictx = (struct imon_context *)urb->context;
1693 if (!ictx || !ictx->dev_present_intf1) 1702 if (!ictx)
1694 return; 1703 return;
1695 1704
1705 /*
1706 * if we get a callback before we're done configuring the hardware, we
1707 * can't yet process the data, as there's nowhere to send it, but we
1708 * still need to submit a new rx URB to avoid wedging the hardware
1709 */
1710 if (!ictx->dev_present_intf1)
1711 goto out;
1712
1696 switch (urb->status) { 1713 switch (urb->status) {
1697 case -ENOENT: /* usbcore unlink successful! */ 1714 case -ENOENT: /* usbcore unlink successful! */
1698 return; 1715 return;
@@ -1710,6 +1727,7 @@ static void usb_rx_callback_intf1(struct urb *urb)
1710 break; 1727 break;
1711 } 1728 }
1712 1729
1730out:
1713 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); 1731 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC);
1714} 1732}
1715 1733
@@ -2242,7 +2260,7 @@ find_endpoint_failed:
2242 mutex_unlock(&ictx->lock); 2260 mutex_unlock(&ictx->lock);
2243 usb_free_urb(rx_urb); 2261 usb_free_urb(rx_urb);
2244rx_urb_alloc_failed: 2262rx_urb_alloc_failed:
2245 dev_err(ictx->dev, "unable to initialize intf0, err %d\n", ret); 2263 dev_err(ictx->dev, "unable to initialize intf1, err %d\n", ret);
2246 2264
2247 return NULL; 2265 return NULL;
2248} 2266}
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
index e5eb56a5b618..6510110f53d0 100644
--- a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -154,10 +154,20 @@ static int device_authorization(struct hdpvr_device *dev)
154 } 154 }
155#endif 155#endif
156 156
157 dev->fw_ver = dev->usbc_buf[1];
158
157 v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n", 159 v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n",
158 dev->usbc_buf[1], &dev->usbc_buf[2]); 160 dev->fw_ver, &dev->usbc_buf[2]);
161
162 if (dev->fw_ver > 0x15) {
163 dev->options.brightness = 0x80;
164 dev->options.contrast = 0x40;
165 dev->options.hue = 0xf;
166 dev->options.saturation = 0x40;
167 dev->options.sharpness = 0x80;
168 }
159 169
160 switch (dev->usbc_buf[1]) { 170 switch (dev->fw_ver) {
161 case HDPVR_FIRMWARE_VERSION: 171 case HDPVR_FIRMWARE_VERSION:
162 dev->flags &= ~HDPVR_FLAG_AC3_CAP; 172 dev->flags &= ~HDPVR_FLAG_AC3_CAP;
163 break; 173 break;
@@ -169,7 +179,7 @@ static int device_authorization(struct hdpvr_device *dev)
169 default: 179 default:
170 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might" 180 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might"
171 " not work.\n"); 181 " not work.\n");
172 if (dev->usbc_buf[1] >= HDPVR_FIRMWARE_VERSION_AC3) 182 if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3)
173 dev->flags |= HDPVR_FLAG_AC3_CAP; 183 dev->flags |= HDPVR_FLAG_AC3_CAP;
174 else 184 else
175 dev->flags &= ~HDPVR_FLAG_AC3_CAP; 185 dev->flags &= ~HDPVR_FLAG_AC3_CAP;
@@ -270,6 +280,8 @@ static const struct hdpvr_options hdpvr_default_options = {
270 .bitrate_mode = HDPVR_CONSTANT, 280 .bitrate_mode = HDPVR_CONSTANT,
271 .gop_mode = HDPVR_SIMPLE_IDR_GOP, 281 .gop_mode = HDPVR_SIMPLE_IDR_GOP,
272 .audio_codec = V4L2_MPEG_AUDIO_ENCODING_AAC, 282 .audio_codec = V4L2_MPEG_AUDIO_ENCODING_AAC,
283 /* original picture controls for firmware version <= 0x15 */
284 /* updated in device_authorization() for newer firmware */
273 .brightness = 0x86, 285 .brightness = 0x86,
274 .contrast = 0x80, 286 .contrast = 0x80,
275 .hue = 0x80, 287 .hue = 0x80,
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 087f7c08cb85..11ffe9cc1780 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -283,12 +283,13 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
283 283
284 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); 284 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00);
285 285
286 dev->status = STATUS_STREAMING;
287
286 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); 288 INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
287 queue_work(dev->workqueue, &dev->worker); 289 queue_work(dev->workqueue, &dev->worker);
288 290
289 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 291 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
290 "streaming started\n"); 292 "streaming started\n");
291 dev->status = STATUS_STREAMING;
292 293
293 return 0; 294 return 0;
294 } 295 }
@@ -722,21 +723,39 @@ static const s32 supported_v4l2_ctrls[] = {
722}; 723};
723 724
724static int fill_queryctrl(struct hdpvr_options *opt, struct v4l2_queryctrl *qc, 725static int fill_queryctrl(struct hdpvr_options *opt, struct v4l2_queryctrl *qc,
725 int ac3) 726 int ac3, int fw_ver)
726{ 727{
727 int err; 728 int err;
728 729
730 if (fw_ver > 0x15) {
731 switch (qc->id) {
732 case V4L2_CID_BRIGHTNESS:
733 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
734 case V4L2_CID_CONTRAST:
735 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40);
736 case V4L2_CID_SATURATION:
737 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40);
738 case V4L2_CID_HUE:
739 return v4l2_ctrl_query_fill(qc, 0x0, 0x1e, 1, 0xf);
740 case V4L2_CID_SHARPNESS:
741 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
742 }
743 } else {
744 switch (qc->id) {
745 case V4L2_CID_BRIGHTNESS:
746 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86);
747 case V4L2_CID_CONTRAST:
748 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
749 case V4L2_CID_SATURATION:
750 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
751 case V4L2_CID_HUE:
752 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
753 case V4L2_CID_SHARPNESS:
754 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
755 }
756 }
757
729 switch (qc->id) { 758 switch (qc->id) {
730 case V4L2_CID_BRIGHTNESS:
731 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86);
732 case V4L2_CID_CONTRAST:
733 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
734 case V4L2_CID_SATURATION:
735 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
736 case V4L2_CID_HUE:
737 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
738 case V4L2_CID_SHARPNESS:
739 return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80);
740 case V4L2_CID_MPEG_AUDIO_ENCODING: 759 case V4L2_CID_MPEG_AUDIO_ENCODING:
741 return v4l2_ctrl_query_fill( 760 return v4l2_ctrl_query_fill(
742 qc, V4L2_MPEG_AUDIO_ENCODING_AAC, 761 qc, V4L2_MPEG_AUDIO_ENCODING_AAC,
@@ -794,7 +813,8 @@ static int vidioc_queryctrl(struct file *file, void *private_data,
794 813
795 if (qc->id == supported_v4l2_ctrls[i]) 814 if (qc->id == supported_v4l2_ctrls[i])
796 return fill_queryctrl(&dev->options, qc, 815 return fill_queryctrl(&dev->options, qc,
797 dev->flags & HDPVR_FLAG_AC3_CAP); 816 dev->flags & HDPVR_FLAG_AC3_CAP,
817 dev->fw_ver);
798 818
799 if (qc->id < supported_v4l2_ctrls[i]) 819 if (qc->id < supported_v4l2_ctrls[i])
800 break; 820 break;
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
index d6439db1d18b..fea3c6926997 100644
--- a/drivers/media/video/hdpvr/hdpvr.h
+++ b/drivers/media/video/hdpvr/hdpvr.h
@@ -113,6 +113,7 @@ struct hdpvr_device {
113 /* usb control transfer buffer and lock */ 113 /* usb control transfer buffer and lock */
114 struct mutex usbc_mutex; 114 struct mutex usbc_mutex;
115 u8 *usbc_buf; 115 u8 *usbc_buf;
116 u8 fw_ver;
116}; 117};
117 118
118static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev) 119static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c
index a74a79701d34..eaabc27f0fa2 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -1407,7 +1407,7 @@ static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event)
1407static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc) 1407static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc)
1408{ 1408{
1409 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); 1409 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity);
1410 struct video_device *vdev = &ccdc->subdev.devnode; 1410 struct video_device *vdev = ccdc->subdev.devnode;
1411 struct v4l2_event event; 1411 struct v4l2_event event;
1412 1412
1413 memset(&event, 0, sizeof(event)); 1413 memset(&event, 0, sizeof(event));
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index ebbcfcafe29b..5e10472371ed 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -95,11 +95,16 @@ static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val)
95 spin_unlock_irqrestore(&priv->cmdreg_lock, flags); 95 spin_unlock_irqrestore(&priv->cmdreg_lock, flags);
96} 96}
97 97
98static int sja1000_is_absent(struct sja1000_priv *priv)
99{
100 return (priv->read_reg(priv, REG_MOD) == 0xFF);
101}
102
98static int sja1000_probe_chip(struct net_device *dev) 103static int sja1000_probe_chip(struct net_device *dev)
99{ 104{
100 struct sja1000_priv *priv = netdev_priv(dev); 105 struct sja1000_priv *priv = netdev_priv(dev);
101 106
102 if (priv->reg_base && (priv->read_reg(priv, 0) == 0xFF)) { 107 if (priv->reg_base && sja1000_is_absent(priv)) {
103 printk(KERN_INFO "%s: probing @0x%lX failed\n", 108 printk(KERN_INFO "%s: probing @0x%lX failed\n",
104 DRV_NAME, dev->base_addr); 109 DRV_NAME, dev->base_addr);
105 return 0; 110 return 0;
@@ -492,6 +497,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
492 while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) { 497 while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
493 n++; 498 n++;
494 status = priv->read_reg(priv, REG_SR); 499 status = priv->read_reg(priv, REG_SR);
500 /* check for absent controller due to hw unplug */
501 if (status == 0xFF && sja1000_is_absent(priv))
502 return IRQ_NONE;
495 503
496 if (isrc & IRQ_WUI) 504 if (isrc & IRQ_WUI)
497 netdev_warn(dev, "wakeup interrupt\n"); 505 netdev_warn(dev, "wakeup interrupt\n");
@@ -508,6 +516,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
508 while (status & SR_RBS) { 516 while (status & SR_RBS) {
509 sja1000_rx(dev); 517 sja1000_rx(dev);
510 status = priv->read_reg(priv, REG_SR); 518 status = priv->read_reg(priv, REG_SR);
519 /* check for absent controller */
520 if (status == 0xFF && sja1000_is_absent(priv))
521 return IRQ_NONE;
511 } 522 }
512 } 523 }
513 if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) { 524 if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index ccdf1f6e2f9f..0f21a9b4cdd4 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -2245,10 +2245,6 @@ static netdev_tx_t atl1c_xmit_frame(struct sk_buff *skb,
2245 dev_info(&adapter->pdev->dev, "tx locked\n"); 2245 dev_info(&adapter->pdev->dev, "tx locked\n");
2246 return NETDEV_TX_LOCKED; 2246 return NETDEV_TX_LOCKED;
2247 } 2247 }
2248 if (skb->mark == 0x01)
2249 type = atl1c_trans_high;
2250 else
2251 type = atl1c_trans_normal;
2252 2248
2253 if (atl1c_tpd_avail(adapter, type) < tpd_req) { 2249 if (atl1c_tpd_avail(adapter, type) < tpd_req) {
2254 /* no enough descriptor, just stop queue */ 2250 /* no enough descriptor, just stop queue */
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 66f53c797e3a..46b8b7d81633 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2338,7 +2338,7 @@ static inline int __init b44_pci_init(void)
2338 return err; 2338 return err;
2339} 2339}
2340 2340
2341static inline void __exit b44_pci_exit(void) 2341static inline void b44_pci_exit(void)
2342{ 2342{
2343#ifdef CONFIG_B44_PCI 2343#ifdef CONFIG_B44_PCI
2344 ssb_pcihost_unregister(&b44_pci_driver); 2344 ssb_pcihost_unregister(&b44_pci_driver);
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index df429959abdd..7b65716b8734 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -3616,7 +3616,11 @@ static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr,
3616 fl6.flowi6_oif = dst_addr->sin6_scope_id; 3616 fl6.flowi6_oif = dst_addr->sin6_scope_id;
3617 3617
3618 *dst = ip6_route_output(&init_net, NULL, &fl6); 3618 *dst = ip6_route_output(&init_net, NULL, &fl6);
3619 if (*dst) 3619 if ((*dst)->error) {
3620 dst_release(*dst);
3621 *dst = NULL;
3622 return -ENETUNREACH;
3623 } else
3620 return 0; 3624 return 0;
3621#endif 3625#endif
3622 3626
diff --git a/drivers/net/ethernet/cisco/enic/cq_enet_desc.h b/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
index c2c0680a1146..ac37cacc6136 100644
--- a/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
+++ b/drivers/net/ethernet/cisco/enic/cq_enet_desc.h
@@ -157,7 +157,7 @@ static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
157 CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0; 157 CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0;
158 *fcoe_enc_error = (desc->flags & 158 *fcoe_enc_error = (desc->flags &
159 CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0; 159 CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0;
160 *fcoe_eof = (u8)((desc->checksum_fcoe >> 160 *fcoe_eof = (u8)((le16_to_cpu(desc->checksum_fcoe) >>
161 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) & 161 CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) &
162 CQ_ENET_RQ_DESC_FCOE_EOF_MASK); 162 CQ_ENET_RQ_DESC_FCOE_EOF_MASK);
163 *checksum = 0; 163 *checksum = 0;
diff --git a/drivers/net/ethernet/cisco/enic/enic_pp.c b/drivers/net/ethernet/cisco/enic/enic_pp.c
index c758674643ce..dafea1ecb7b1 100644
--- a/drivers/net/ethernet/cisco/enic/enic_pp.c
+++ b/drivers/net/ethernet/cisco/enic/enic_pp.c
@@ -72,7 +72,7 @@ static int enic_set_port_profile(struct enic *enic, int vf)
72 struct enic_port_profile *pp; 72 struct enic_port_profile *pp;
73 struct vic_provinfo *vp; 73 struct vic_provinfo *vp;
74 const u8 oui[3] = VIC_PROVINFO_CISCO_OUI; 74 const u8 oui[3] = VIC_PROVINFO_CISCO_OUI;
75 const u16 os_type = htons(VIC_GENERIC_PROV_OS_TYPE_LINUX); 75 const __be16 os_type = htons(VIC_GENERIC_PROV_OS_TYPE_LINUX);
76 char uuid_str[38]; 76 char uuid_str[38];
77 char client_mac_str[18]; 77 char client_mac_str[18];
78 u8 *client_mac; 78 u8 *client_mac;
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 1b86d0b45f3c..4ea6580d3ae8 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -2328,19 +2328,11 @@ jme_change_mtu(struct net_device *netdev, int new_mtu)
2328 ((new_mtu) < IPV6_MIN_MTU)) 2328 ((new_mtu) < IPV6_MIN_MTU))
2329 return -EINVAL; 2329 return -EINVAL;
2330 2330
2331 if (new_mtu > 4000) {
2332 jme->reg_rxcs &= ~RXCS_FIFOTHNP;
2333 jme->reg_rxcs |= RXCS_FIFOTHNP_64QW;
2334 jme_restart_rx_engine(jme);
2335 } else {
2336 jme->reg_rxcs &= ~RXCS_FIFOTHNP;
2337 jme->reg_rxcs |= RXCS_FIFOTHNP_128QW;
2338 jme_restart_rx_engine(jme);
2339 }
2340 2331
2341 netdev->mtu = new_mtu; 2332 netdev->mtu = new_mtu;
2342 netdev_update_features(netdev); 2333 netdev_update_features(netdev);
2343 2334
2335 jme_restart_rx_engine(jme);
2344 jme_reset_link(jme); 2336 jme_reset_link(jme);
2345 2337
2346 return 0; 2338 return 0;
diff --git a/drivers/net/ethernet/jme.h b/drivers/net/ethernet/jme.h
index 4304072bd3c5..3efc897c9913 100644
--- a/drivers/net/ethernet/jme.h
+++ b/drivers/net/ethernet/jme.h
@@ -730,7 +730,7 @@ enum jme_rxcs_values {
730 RXCS_RETRYCNT_60 = 0x00000F00, 730 RXCS_RETRYCNT_60 = 0x00000F00,
731 731
732 RXCS_DEFAULT = RXCS_FIFOTHTP_128T | 732 RXCS_DEFAULT = RXCS_FIFOTHTP_128T |
733 RXCS_FIFOTHNP_128QW | 733 RXCS_FIFOTHNP_16QW |
734 RXCS_DMAREQSZ_128B | 734 RXCS_DMAREQSZ_128B |
735 RXCS_RETRYGAP_256ns | 735 RXCS_RETRYGAP_256ns |
736 RXCS_RETRYCNT_32, 736 RXCS_RETRYCNT_32,
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 8fa41f3082cf..9129ace02560 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1036,7 +1036,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector)
1036 struct mlx4_priv *priv = mlx4_priv(dev); 1036 struct mlx4_priv *priv = mlx4_priv(dev);
1037 int vec = 0, err = 0, i; 1037 int vec = 0, err = 0, i;
1038 1038
1039 spin_lock(&priv->msix_ctl.pool_lock); 1039 mutex_lock(&priv->msix_ctl.pool_lock);
1040 for (i = 0; !vec && i < dev->caps.comp_pool; i++) { 1040 for (i = 0; !vec && i < dev->caps.comp_pool; i++) {
1041 if (~priv->msix_ctl.pool_bm & 1ULL << i) { 1041 if (~priv->msix_ctl.pool_bm & 1ULL << i) {
1042 priv->msix_ctl.pool_bm |= 1ULL << i; 1042 priv->msix_ctl.pool_bm |= 1ULL << i;
@@ -1058,7 +1058,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector)
1058 eq_set_ci(&priv->eq_table.eq[vec], 1); 1058 eq_set_ci(&priv->eq_table.eq[vec], 1);
1059 } 1059 }
1060 } 1060 }
1061 spin_unlock(&priv->msix_ctl.pool_lock); 1061 mutex_unlock(&priv->msix_ctl.pool_lock);
1062 1062
1063 if (vec) { 1063 if (vec) {
1064 *vector = vec; 1064 *vector = vec;
@@ -1079,13 +1079,13 @@ void mlx4_release_eq(struct mlx4_dev *dev, int vec)
1079 if (likely(i >= 0)) { 1079 if (likely(i >= 0)) {
1080 /*sanity check , making sure were not trying to free irq's 1080 /*sanity check , making sure were not trying to free irq's
1081 Belonging to a legacy EQ*/ 1081 Belonging to a legacy EQ*/
1082 spin_lock(&priv->msix_ctl.pool_lock); 1082 mutex_lock(&priv->msix_ctl.pool_lock);
1083 if (priv->msix_ctl.pool_bm & 1ULL << i) { 1083 if (priv->msix_ctl.pool_bm & 1ULL << i) {
1084 free_irq(priv->eq_table.eq[vec].irq, 1084 free_irq(priv->eq_table.eq[vec].irq,
1085 &priv->eq_table.eq[vec]); 1085 &priv->eq_table.eq[vec]);
1086 priv->msix_ctl.pool_bm &= ~(1ULL << i); 1086 priv->msix_ctl.pool_bm &= ~(1ULL << i);
1087 } 1087 }
1088 spin_unlock(&priv->msix_ctl.pool_lock); 1088 mutex_unlock(&priv->msix_ctl.pool_lock);
1089 } 1089 }
1090 1090
1091} 1091}
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 8a21e10952ea..9ea7cabcaf3c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -685,7 +685,7 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
685 return err; 685 return err;
686} 686}
687 687
688static int mlx4_QUERY_PORT(struct mlx4_dev *dev, void *ptr, u8 port) 688int mlx4_QUERY_PORT(struct mlx4_dev *dev, void *ptr, u8 port)
689{ 689{
690 struct mlx4_cmd_mailbox *outbox = ptr; 690 struct mlx4_cmd_mailbox *outbox = ptr;
691 691
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 0809b7c3905c..5f15014713bc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -531,15 +531,14 @@ int mlx4_change_port_types(struct mlx4_dev *dev,
531 for (port = 0; port < dev->caps.num_ports; port++) { 531 for (port = 0; port < dev->caps.num_ports; port++) {
532 /* Change the port type only if the new type is different 532 /* Change the port type only if the new type is different
533 * from the current, and not set to Auto */ 533 * from the current, and not set to Auto */
534 if (port_types[port] != dev->caps.port_type[port + 1]) { 534 if (port_types[port] != dev->caps.port_type[port + 1])
535 change = 1; 535 change = 1;
536 dev->caps.port_type[port + 1] = port_types[port];
537 }
538 } 536 }
539 if (change) { 537 if (change) {
540 mlx4_unregister_device(dev); 538 mlx4_unregister_device(dev);
541 for (port = 1; port <= dev->caps.num_ports; port++) { 539 for (port = 1; port <= dev->caps.num_ports; port++) {
542 mlx4_CLOSE_PORT(dev, port); 540 mlx4_CLOSE_PORT(dev, port);
541 dev->caps.port_type[port] = port_types[port - 1];
543 err = mlx4_SET_PORT(dev, port); 542 err = mlx4_SET_PORT(dev, port);
544 if (err) { 543 if (err) {
545 mlx4_err(dev, "Failed to set port %d, " 544 mlx4_err(dev, "Failed to set port %d, "
@@ -986,6 +985,9 @@ static int map_bf_area(struct mlx4_dev *dev)
986 resource_size_t bf_len; 985 resource_size_t bf_len;
987 int err = 0; 986 int err = 0;
988 987
988 if (!dev->caps.bf_reg_size)
989 return -ENXIO;
990
989 bf_start = pci_resource_start(dev->pdev, 2) + 991 bf_start = pci_resource_start(dev->pdev, 2) +
990 (dev->caps.num_uars << PAGE_SHIFT); 992 (dev->caps.num_uars << PAGE_SHIFT);
991 bf_len = pci_resource_len(dev->pdev, 2) - 993 bf_len = pci_resource_len(dev->pdev, 2) -
@@ -1823,7 +1825,7 @@ slave_start:
1823 goto err_master_mfunc; 1825 goto err_master_mfunc;
1824 1826
1825 priv->msix_ctl.pool_bm = 0; 1827 priv->msix_ctl.pool_bm = 0;
1826 spin_lock_init(&priv->msix_ctl.pool_lock); 1828 mutex_init(&priv->msix_ctl.pool_lock);
1827 1829
1828 mlx4_enable_msi_x(dev); 1830 mlx4_enable_msi_x(dev);
1829 if ((mlx4_is_mfunc(dev)) && 1831 if ((mlx4_is_mfunc(dev)) &&
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 276c7f72bd83..5da51b99dbb8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -697,7 +697,7 @@ struct mlx4_sense {
697 697
698struct mlx4_msix_ctl { 698struct mlx4_msix_ctl {
699 u64 pool_bm; 699 u64 pool_bm;
700 spinlock_t pool_lock; 700 struct mutex pool_lock;
701}; 701};
702 702
703struct mlx4_steer { 703struct mlx4_steer {
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 8deeef98280c..25a80d71fb2a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -304,7 +304,7 @@ static int mlx4_HW2SW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
304 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); 304 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED);
305} 305}
306 306
307static int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align, 307int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align,
308 u32 *base_mridx) 308 u32 *base_mridx)
309{ 309{
310 struct mlx4_priv *priv = mlx4_priv(dev); 310 struct mlx4_priv *priv = mlx4_priv(dev);
@@ -320,14 +320,14 @@ static int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align,
320} 320}
321EXPORT_SYMBOL_GPL(mlx4_mr_reserve_range); 321EXPORT_SYMBOL_GPL(mlx4_mr_reserve_range);
322 322
323static void mlx4_mr_release_range(struct mlx4_dev *dev, u32 base_mridx, int cnt) 323void mlx4_mr_release_range(struct mlx4_dev *dev, u32 base_mridx, int cnt)
324{ 324{
325 struct mlx4_priv *priv = mlx4_priv(dev); 325 struct mlx4_priv *priv = mlx4_priv(dev);
326 mlx4_bitmap_free_range(&priv->mr_table.mpt_bitmap, base_mridx, cnt); 326 mlx4_bitmap_free_range(&priv->mr_table.mpt_bitmap, base_mridx, cnt);
327} 327}
328EXPORT_SYMBOL_GPL(mlx4_mr_release_range); 328EXPORT_SYMBOL_GPL(mlx4_mr_release_range);
329 329
330static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, 330int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd,
331 u64 iova, u64 size, u32 access, int npages, 331 u64 iova, u64 size, u32 access, int npages,
332 int page_shift, struct mlx4_mr *mr) 332 int page_shift, struct mlx4_mr *mr)
333{ 333{
@@ -457,7 +457,7 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
457} 457}
458EXPORT_SYMBOL_GPL(mlx4_mr_alloc); 458EXPORT_SYMBOL_GPL(mlx4_mr_alloc);
459 459
460static void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) 460void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr)
461{ 461{
462 int err; 462 int err;
463 463
@@ -852,7 +852,7 @@ err_free:
852} 852}
853EXPORT_SYMBOL_GPL(mlx4_fmr_alloc); 853EXPORT_SYMBOL_GPL(mlx4_fmr_alloc);
854 854
855static int mlx4_fmr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, 855int mlx4_fmr_alloc_reserved(struct mlx4_dev *dev, u32 mridx,
856 u32 pd, u32 access, int max_pages, 856 u32 pd, u32 access, int max_pages,
857 int max_maps, u8 page_shift, struct mlx4_fmr *fmr) 857 int max_maps, u8 page_shift, struct mlx4_fmr *fmr)
858{ 858{
@@ -954,7 +954,7 @@ int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
954} 954}
955EXPORT_SYMBOL_GPL(mlx4_fmr_free); 955EXPORT_SYMBOL_GPL(mlx4_fmr_free);
956 956
957static int mlx4_fmr_free_reserved(struct mlx4_dev *dev, struct mlx4_fmr *fmr) 957int mlx4_fmr_free_reserved(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
958{ 958{
959 if (fmr->maps) 959 if (fmr->maps)
960 return -EBUSY; 960 return -EBUSY;
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 10d57983df05..b8104d9f4081 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1544,7 +1544,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1544 1544
1545 netdev->irq = platform_get_irq(pdev, 0); 1545 netdev->irq = platform_get_irq(pdev, 0);
1546 1546
1547 if (netdev->irq < 0) { 1547 if ((int)netdev->irq < 0) {
1548 err = netdev->irq; 1548 err = netdev->irq;
1549 goto err_get_irq; 1549 goto err_get_irq;
1550 } 1550 }
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
index 506d24669956..1ba290d0c21c 100644
--- a/drivers/net/ethernet/sfc/rx.c
+++ b/drivers/net/ethernet/sfc/rx.c
@@ -155,11 +155,10 @@ static int efx_init_rx_buffers_skb(struct efx_rx_queue *rx_queue)
155 if (unlikely(!skb)) 155 if (unlikely(!skb))
156 return -ENOMEM; 156 return -ENOMEM;
157 157
158 /* Adjust the SKB for padding and checksum */ 158 /* Adjust the SKB for padding */
159 skb_reserve(skb, NET_IP_ALIGN); 159 skb_reserve(skb, NET_IP_ALIGN);
160 rx_buf->len = skb_len - NET_IP_ALIGN; 160 rx_buf->len = skb_len - NET_IP_ALIGN;
161 rx_buf->flags = 0; 161 rx_buf->flags = 0;
162 skb->ip_summed = CHECKSUM_UNNECESSARY;
163 162
164 rx_buf->dma_addr = pci_map_single(efx->pci_dev, 163 rx_buf->dma_addr = pci_map_single(efx->pci_dev,
165 skb->data, rx_buf->len, 164 skb->data, rx_buf->len,
@@ -496,6 +495,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel,
496 495
497 EFX_BUG_ON_PARANOID(!(rx_buf->flags & EFX_RX_PKT_CSUMMED)); 496 EFX_BUG_ON_PARANOID(!(rx_buf->flags & EFX_RX_PKT_CSUMMED));
498 rx_buf->u.skb = NULL; 497 rx_buf->u.skb = NULL;
498 skb->ip_summed = CHECKSUM_UNNECESSARY;
499 499
500 gro_result = napi_gro_receive(napi, skb); 500 gro_result = napi_gro_receive(napi, skb);
501 } 501 }
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 6d74cb7aaae8..174a3348f676 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1008,7 +1008,7 @@ static void emac_rx_handler(void *token, int len, int status)
1008 int ret; 1008 int ret;
1009 1009
1010 /* free and bail if we are shutting down */ 1010 /* free and bail if we are shutting down */
1011 if (unlikely(!netif_running(ndev) || !netif_carrier_ok(ndev))) { 1011 if (unlikely(!netif_running(ndev))) {
1012 dev_kfree_skb_any(skb); 1012 dev_kfree_skb_any(skb);
1013 return; 1013 return;
1014 } 1014 }
@@ -1037,7 +1037,9 @@ static void emac_rx_handler(void *token, int len, int status)
1037recycle: 1037recycle:
1038 ret = cpdma_chan_submit(priv->rxchan, skb, skb->data, 1038 ret = cpdma_chan_submit(priv->rxchan, skb, skb->data,
1039 skb_tailroom(skb), GFP_KERNEL); 1039 skb_tailroom(skb), GFP_KERNEL);
1040 if (WARN_ON(ret < 0)) 1040
1041 WARN_ON(ret == -ENOMEM);
1042 if (unlikely(ret < 0))
1041 dev_kfree_skb_any(skb); 1043 dev_kfree_skb_any(skb);
1042} 1044}
1043 1045
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index c81f136ae670..0856e1b7a849 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -30,16 +30,16 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32 32
33MODULE_DESCRIPTION("ICPlus IP175C/IP101A/IC1001 PHY drivers"); 33MODULE_DESCRIPTION("ICPlus IP175C/IP101A/IP101G/IC1001 PHY drivers");
34MODULE_AUTHOR("Michael Barkowski"); 34MODULE_AUTHOR("Michael Barkowski");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
37/* IP101A/IP1001 */ 37/* IP101A/G - IP1001 */
38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */ 38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */
39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */ 39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */
40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */ 40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
42#define IP101A_APS_ON 2 /* IP101A APS Mode bit */ 42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
43 43
44static int ip175c_config_init(struct phy_device *phydev) 44static int ip175c_config_init(struct phy_device *phydev)
45{ 45{
@@ -98,20 +98,24 @@ static int ip175c_config_init(struct phy_device *phydev)
98 98
99static int ip1xx_reset(struct phy_device *phydev) 99static int ip1xx_reset(struct phy_device *phydev)
100{ 100{
101 int err, bmcr; 101 int bmcr;
102 102
103 /* Software Reset PHY */ 103 /* Software Reset PHY */
104 bmcr = phy_read(phydev, MII_BMCR); 104 bmcr = phy_read(phydev, MII_BMCR);
105 if (bmcr < 0)
106 return bmcr;
105 bmcr |= BMCR_RESET; 107 bmcr |= BMCR_RESET;
106 err = phy_write(phydev, MII_BMCR, bmcr); 108 bmcr = phy_write(phydev, MII_BMCR, bmcr);
107 if (err < 0) 109 if (bmcr < 0)
108 return err; 110 return bmcr;
109 111
110 do { 112 do {
111 bmcr = phy_read(phydev, MII_BMCR); 113 bmcr = phy_read(phydev, MII_BMCR);
114 if (bmcr < 0)
115 return bmcr;
112 } while (bmcr & BMCR_RESET); 116 } while (bmcr & BMCR_RESET);
113 117
114 return err; 118 return 0;
115} 119}
116 120
117static int ip1001_config_init(struct phy_device *phydev) 121static int ip1001_config_init(struct phy_device *phydev)
@@ -124,7 +128,10 @@ static int ip1001_config_init(struct phy_device *phydev)
124 128
125 /* Enable Auto Power Saving mode */ 129 /* Enable Auto Power Saving mode */
126 c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2); 130 c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2);
131 if (c < 0)
132 return c;
127 c |= IP1001_APS_ON; 133 c |= IP1001_APS_ON;
134 c = phy_write(phydev, IP1001_SPEC_CTRL_STATUS_2, c);
128 if (c < 0) 135 if (c < 0)
129 return c; 136 return c;
130 137
@@ -132,14 +139,19 @@ static int ip1001_config_init(struct phy_device *phydev)
132 /* Additional delay (2ns) used to adjust RX clock phase 139 /* Additional delay (2ns) used to adjust RX clock phase
133 * at RGMII interface */ 140 * at RGMII interface */
134 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 141 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
142 if (c < 0)
143 return c;
144
135 c |= IP1001_PHASE_SEL_MASK; 145 c |= IP1001_PHASE_SEL_MASK;
136 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); 146 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
147 if (c < 0)
148 return c;
137 } 149 }
138 150
139 return c; 151 return 0;
140} 152}
141 153
142static int ip101a_config_init(struct phy_device *phydev) 154static int ip101a_g_config_init(struct phy_device *phydev)
143{ 155{
144 int c; 156 int c;
145 157
@@ -149,7 +161,7 @@ static int ip101a_config_init(struct phy_device *phydev)
149 161
150 /* Enable Auto Power Saving mode */ 162 /* Enable Auto Power Saving mode */
151 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 163 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
152 c |= IP101A_APS_ON; 164 c |= IP101A_G_APS_ON;
153 return c; 165 return c;
154} 166}
155 167
@@ -191,6 +203,7 @@ static struct phy_driver ip1001_driver = {
191 .phy_id_mask = 0x0ffffff0, 203 .phy_id_mask = 0x0ffffff0,
192 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause | 204 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause |
193 SUPPORTED_Asym_Pause, 205 SUPPORTED_Asym_Pause,
206 .flags = PHY_HAS_INTERRUPT,
194 .config_init = &ip1001_config_init, 207 .config_init = &ip1001_config_init,
195 .config_aneg = &genphy_config_aneg, 208 .config_aneg = &genphy_config_aneg,
196 .read_status = &genphy_read_status, 209 .read_status = &genphy_read_status,
@@ -199,13 +212,14 @@ static struct phy_driver ip1001_driver = {
199 .driver = { .owner = THIS_MODULE,}, 212 .driver = { .owner = THIS_MODULE,},
200}; 213};
201 214
202static struct phy_driver ip101a_driver = { 215static struct phy_driver ip101a_g_driver = {
203 .phy_id = 0x02430c54, 216 .phy_id = 0x02430c54,
204 .name = "ICPlus IP101A", 217 .name = "ICPlus IP101A/G",
205 .phy_id_mask = 0x0ffffff0, 218 .phy_id_mask = 0x0ffffff0,
206 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause | 219 .features = PHY_BASIC_FEATURES | SUPPORTED_Pause |
207 SUPPORTED_Asym_Pause, 220 SUPPORTED_Asym_Pause,
208 .config_init = &ip101a_config_init, 221 .flags = PHY_HAS_INTERRUPT,
222 .config_init = &ip101a_g_config_init,
209 .config_aneg = &genphy_config_aneg, 223 .config_aneg = &genphy_config_aneg,
210 .read_status = &genphy_read_status, 224 .read_status = &genphy_read_status,
211 .suspend = genphy_suspend, 225 .suspend = genphy_suspend,
@@ -221,7 +235,7 @@ static int __init icplus_init(void)
221 if (ret < 0) 235 if (ret < 0)
222 return -ENODEV; 236 return -ENODEV;
223 237
224 ret = phy_driver_register(&ip101a_driver); 238 ret = phy_driver_register(&ip101a_g_driver);
225 if (ret < 0) 239 if (ret < 0)
226 return -ENODEV; 240 return -ENODEV;
227 241
@@ -231,7 +245,7 @@ static int __init icplus_init(void)
231static void __exit icplus_exit(void) 245static void __exit icplus_exit(void)
232{ 246{
233 phy_driver_unregister(&ip1001_driver); 247 phy_driver_unregister(&ip1001_driver);
234 phy_driver_unregister(&ip101a_driver); 248 phy_driver_unregister(&ip101a_g_driver);
235 phy_driver_unregister(&ip175c_driver); 249 phy_driver_unregister(&ip175c_driver);
236} 250}
237 251
@@ -241,6 +255,7 @@ module_exit(icplus_exit);
241static struct mdio_device_id __maybe_unused icplus_tbl[] = { 255static struct mdio_device_id __maybe_unused icplus_tbl[] = {
242 { 0x02430d80, 0x0ffffff0 }, 256 { 0x02430d80, 0x0ffffff0 },
243 { 0x02430d90, 0x0ffffff0 }, 257 { 0x02430d90, 0x0ffffff0 },
258 { 0x02430c54, 0x0ffffff0 },
244 { } 259 { }
245}; 260};
246 261
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 93a86397af36..6d4d2ebb0a8a 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2024,14 +2024,22 @@ ppp_mp_reconstruct(struct ppp *ppp)
2024 continue; 2024 continue;
2025 } 2025 }
2026 if (PPP_MP_CB(p)->sequence != seq) { 2026 if (PPP_MP_CB(p)->sequence != seq) {
2027 u32 oldseq;
2027 /* Fragment `seq' is missing. If it is after 2028 /* Fragment `seq' is missing. If it is after
2028 minseq, it might arrive later, so stop here. */ 2029 minseq, it might arrive later, so stop here. */
2029 if (seq_after(seq, minseq)) 2030 if (seq_after(seq, minseq))
2030 break; 2031 break;
2031 /* Fragment `seq' is lost, keep going. */ 2032 /* Fragment `seq' is lost, keep going. */
2032 lost = 1; 2033 lost = 1;
2034 oldseq = seq;
2033 seq = seq_before(minseq, PPP_MP_CB(p)->sequence)? 2035 seq = seq_before(minseq, PPP_MP_CB(p)->sequence)?
2034 minseq + 1: PPP_MP_CB(p)->sequence; 2036 minseq + 1: PPP_MP_CB(p)->sequence;
2037
2038 if (ppp->debug & 1)
2039 netdev_printk(KERN_DEBUG, ppp->dev,
2040 "lost frag %u..%u\n",
2041 oldseq, seq-1);
2042
2035 goto again; 2043 goto again;
2036 } 2044 }
2037 2045
@@ -2076,6 +2084,10 @@ ppp_mp_reconstruct(struct ppp *ppp)
2076 struct sk_buff *tmp2; 2084 struct sk_buff *tmp2;
2077 2085
2078 skb_queue_reverse_walk_from_safe(list, p, tmp2) { 2086 skb_queue_reverse_walk_from_safe(list, p, tmp2) {
2087 if (ppp->debug & 1)
2088 netdev_printk(KERN_DEBUG, ppp->dev,
2089 "discarding frag %u\n",
2090 PPP_MP_CB(p)->sequence);
2079 __skb_unlink(p, list); 2091 __skb_unlink(p, list);
2080 kfree_skb(p); 2092 kfree_skb(p);
2081 } 2093 }
@@ -2091,6 +2103,17 @@ ppp_mp_reconstruct(struct ppp *ppp)
2091 /* If we have discarded any fragments, 2103 /* If we have discarded any fragments,
2092 signal a receive error. */ 2104 signal a receive error. */
2093 if (PPP_MP_CB(head)->sequence != ppp->nextseq) { 2105 if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
2106 skb_queue_walk_safe(list, p, tmp) {
2107 if (p == head)
2108 break;
2109 if (ppp->debug & 1)
2110 netdev_printk(KERN_DEBUG, ppp->dev,
2111 "discarding frag %u\n",
2112 PPP_MP_CB(p)->sequence);
2113 __skb_unlink(p, list);
2114 kfree_skb(p);
2115 }
2116
2094 if (ppp->debug & 1) 2117 if (ppp->debug & 1)
2095 netdev_printk(KERN_DEBUG, ppp->dev, 2118 netdev_printk(KERN_DEBUG, ppp->dev,
2096 " missed pkts %u..%u\n", 2119 " missed pkts %u..%u\n",
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 41a61efc331e..90a30026a931 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -573,6 +573,13 @@ static const struct usb_device_id products [] = {
573 .driver_info = 0, 573 .driver_info = 0,
574}, 574},
575 575
576/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
577{
578 USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
579 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
580 .driver_info = 0,
581},
582
576/* 583/*
577 * WHITELIST!!! 584 * WHITELIST!!!
578 * 585 *
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 304fe78ff60e..e1324b4a0f66 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1632,7 +1632,7 @@ static int hso_get_count(struct tty_struct *tty,
1632 struct hso_serial *serial = get_serial_by_tty(tty); 1632 struct hso_serial *serial = get_serial_by_tty(tty);
1633 struct hso_tiocmget *tiocmget = serial->tiocmget; 1633 struct hso_tiocmget *tiocmget = serial->tiocmget;
1634 1634
1635 memset(&icount, 0, sizeof(struct serial_icounter_struct)); 1635 memset(icount, 0, sizeof(struct serial_icounter_struct));
1636 1636
1637 if (!tiocmget) 1637 if (!tiocmget)
1638 return -ENOENT; 1638 return -ENOENT;
diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c
index f701d4127087..c3197ce0e2ad 100644
--- a/drivers/net/usb/zaurus.c
+++ b/drivers/net/usb/zaurus.c
@@ -316,6 +316,11 @@ static const struct usb_device_id products [] = {
316 ZAURUS_MASTER_INTERFACE, 316 ZAURUS_MASTER_INTERFACE,
317 .driver_info = ZAURUS_PXA_INFO, 317 .driver_info = ZAURUS_PXA_INFO,
318}, { 318}, {
319 /* C-750/C-760/C-860/SL-C3000 PDA in MDLM mode */
320 USB_DEVICE_AND_INTERFACE_INFO(0x04DD, 0x9031, USB_CLASS_COMM,
321 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
322 .driver_info = (unsigned long) &bogus_mdlm_info,
323}, {
319 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 324 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
320 | USB_DEVICE_ID_MATCH_DEVICE, 325 | USB_DEVICE_ID_MATCH_DEVICE,
321 .idVendor = 0x04DD, 326 .idVendor = 0x04DD,
@@ -349,6 +354,13 @@ static const struct usb_device_id products [] = {
349 ZAURUS_MASTER_INTERFACE, 354 ZAURUS_MASTER_INTERFACE,
350 .driver_info = OLYMPUS_MXL_INFO, 355 .driver_info = OLYMPUS_MXL_INFO,
351}, 356},
357
358/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
359{
360 USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
361 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
362 .driver_info = (unsigned long) &bogus_mdlm_info,
363},
352 { }, // END 364 { }, // END
353}; 365};
354MODULE_DEVICE_TABLE(usb, products); 366MODULE_DEVICE_TABLE(usb, products);
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index e1562e8acba5..adf527e27583 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -837,8 +837,8 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
837 /* for simplicity, don't copy L4 headers */ 837 /* for simplicity, don't copy L4 headers */
838 ctx->l4_hdr_size = 0; 838 ctx->l4_hdr_size = 0;
839 } 839 }
840 ctx->copy_size = ctx->eth_ip_hdr_size + 840 ctx->copy_size = min(ctx->eth_ip_hdr_size +
841 ctx->l4_hdr_size; 841 ctx->l4_hdr_size, skb->len);
842 } else { 842 } else {
843 ctx->eth_ip_hdr_size = 0; 843 ctx->eth_ip_hdr_size = 0;
844 ctx->l4_hdr_size = 0; 844 ctx->l4_hdr_size = 0;
diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 42a7d603c870..7481146a5b47 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -33,6 +33,8 @@
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <asm/bios_ebda.h> 34#include <asm/bios_ebda.h>
35 35
36#include <asm-generic/io-64-nonatomic-lo-hi.h>
37
36static bool force; 38static bool force;
37module_param(force, bool, 0); 39module_param(force, bool, 0);
38MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); 40MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
@@ -83,19 +85,6 @@ static void __iomem *rtl_cmd_addr;
83static u8 rtl_cmd_type; 85static u8 rtl_cmd_type;
84static u8 rtl_cmd_width; 86static u8 rtl_cmd_width;
85 87
86#ifndef readq
87static inline __u64 readq(const volatile void __iomem *addr)
88{
89 const volatile u32 __iomem *p = addr;
90 u32 low, high;
91
92 low = readl(p);
93 high = readl(p + 1);
94
95 return low + ((u64)high << 32);
96}
97#endif
98
99static void __iomem *rtl_port_map(phys_addr_t addr, unsigned long len) 88static void __iomem *rtl_port_map(phys_addr_t addr, unsigned long len)
100{ 89{
101 if (rtl_cmd_type == RTL_ADDR_TYPE_MMIO) 90 if (rtl_cmd_type == RTL_ADDR_TYPE_MMIO)
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 809a3ae943c6..88a98cff5a44 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -77,6 +77,8 @@
77#include <asm/processor.h> 77#include <asm/processor.h>
78#include "intel_ips.h" 78#include "intel_ips.h"
79 79
80#include <asm-generic/io-64-nonatomic-lo-hi.h>
81
80#define PCI_DEVICE_ID_INTEL_THERMAL_SENSOR 0x3b32 82#define PCI_DEVICE_ID_INTEL_THERMAL_SENSOR 0x3b32
81 83
82/* 84/*
@@ -344,19 +346,6 @@ struct ips_driver {
344static bool 346static bool
345ips_gpu_turbo_enabled(struct ips_driver *ips); 347ips_gpu_turbo_enabled(struct ips_driver *ips);
346 348
347#ifndef readq
348static inline __u64 readq(const volatile void __iomem *addr)
349{
350 const volatile u32 __iomem *p = addr;
351 u32 low, high;
352
353 low = readl(p);
354 high = readl(p + 1);
355
356 return low + ((u64)high << 32);
357}
358#endif
359
360/** 349/**
361 * ips_cpu_busy - is CPU busy? 350 * ips_cpu_busy - is CPU busy?
362 * @ips: IPS driver struct 351 * @ips: IPS driver struct
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 934458ad55e5..e71a50d4b221 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -87,6 +87,7 @@ struct raw3215_info {
87 struct tty_struct *tty; /* pointer to tty structure if present */ 87 struct tty_struct *tty; /* pointer to tty structure if present */
88 struct raw3215_req *queued_read; /* pointer to queued read requests */ 88 struct raw3215_req *queued_read; /* pointer to queued read requests */
89 struct raw3215_req *queued_write;/* pointer to queued write requests */ 89 struct raw3215_req *queued_write;/* pointer to queued write requests */
90 struct tasklet_struct tlet; /* tasklet to invoke tty_wakeup */
90 wait_queue_head_t empty_wait; /* wait queue for flushing */ 91 wait_queue_head_t empty_wait; /* wait queue for flushing */
91 struct timer_list timer; /* timer for delayed output */ 92 struct timer_list timer; /* timer for delayed output */
92 int line_pos; /* position on the line (for tabs) */ 93 int line_pos; /* position on the line (for tabs) */
@@ -334,19 +335,23 @@ static inline void raw3215_try_io(struct raw3215_info *raw)
334} 335}
335 336
336/* 337/*
338 * Call tty_wakeup from tasklet context
339 */
340static void raw3215_wakeup(unsigned long data)
341{
342 struct raw3215_info *raw = (struct raw3215_info *) data;
343 tty_wakeup(raw->tty);
344}
345
346/*
337 * Try to start the next IO and wake up processes waiting on the tty. 347 * Try to start the next IO and wake up processes waiting on the tty.
338 */ 348 */
339static void raw3215_next_io(struct raw3215_info *raw) 349static void raw3215_next_io(struct raw3215_info *raw)
340{ 350{
341 struct tty_struct *tty;
342
343 raw3215_mk_write_req(raw); 351 raw3215_mk_write_req(raw);
344 raw3215_try_io(raw); 352 raw3215_try_io(raw);
345 tty = raw->tty; 353 if (raw->tty && RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE)
346 if (tty != NULL && 354 tasklet_schedule(&raw->tlet);
347 RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) {
348 tty_wakeup(tty);
349 }
350} 355}
351 356
352/* 357/*
@@ -682,6 +687,7 @@ static int raw3215_probe (struct ccw_device *cdev)
682 return -ENOMEM; 687 return -ENOMEM;
683 } 688 }
684 init_waitqueue_head(&raw->empty_wait); 689 init_waitqueue_head(&raw->empty_wait);
690 tasklet_init(&raw->tlet, raw3215_wakeup, (unsigned long) raw);
685 691
686 dev_set_drvdata(&cdev->dev, raw); 692 dev_set_drvdata(&cdev->dev, raw);
687 cdev->handler = raw3215_irq; 693 cdev->handler = raw3215_irq;
@@ -901,6 +907,7 @@ static int __init con3215_init(void)
901 907
902 raw->flags |= RAW3215_FIXED; 908 raw->flags |= RAW3215_FIXED;
903 init_waitqueue_head(&raw->empty_wait); 909 init_waitqueue_head(&raw->empty_wait);
910 tasklet_init(&raw->tlet, raw3215_wakeup, (unsigned long) raw);
904 911
905 /* Request the console irq */ 912 /* Request the console irq */
906 if (raw3215_startup(raw) != 0) { 913 if (raw3215_startup(raw) != 0) {
@@ -966,6 +973,7 @@ static void tty3215_close(struct tty_struct *tty, struct file * filp)
966 tty->closing = 1; 973 tty->closing = 1;
967 /* Shutdown the terminal */ 974 /* Shutdown the terminal */
968 raw3215_shutdown(raw); 975 raw3215_shutdown(raw);
976 tasklet_kill(&raw->tlet);
969 tty->closing = 0; 977 tty->closing = 0;
970 raw->tty = NULL; 978 raw->tty = NULL;
971} 979}
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 53a31c753cb1..20c4557f5abd 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -364,10 +364,7 @@ static void release_controller(struct kref *kref)
364 struct rdac_controller *ctlr; 364 struct rdac_controller *ctlr;
365 ctlr = container_of(kref, struct rdac_controller, kref); 365 ctlr = container_of(kref, struct rdac_controller, kref);
366 366
367 flush_workqueue(kmpath_rdacd);
368 spin_lock(&list_lock);
369 list_del(&ctlr->node); 367 list_del(&ctlr->node);
370 spin_unlock(&list_lock);
371 kfree(ctlr); 368 kfree(ctlr);
372} 369}
373 370
@@ -376,20 +373,17 @@ static struct rdac_controller *get_controller(int index, char *array_name,
376{ 373{
377 struct rdac_controller *ctlr, *tmp; 374 struct rdac_controller *ctlr, *tmp;
378 375
379 spin_lock(&list_lock);
380
381 list_for_each_entry(tmp, &ctlr_list, node) { 376 list_for_each_entry(tmp, &ctlr_list, node) {
382 if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) && 377 if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) &&
383 (tmp->index == index) && 378 (tmp->index == index) &&
384 (tmp->host == sdev->host)) { 379 (tmp->host == sdev->host)) {
385 kref_get(&tmp->kref); 380 kref_get(&tmp->kref);
386 spin_unlock(&list_lock);
387 return tmp; 381 return tmp;
388 } 382 }
389 } 383 }
390 ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC); 384 ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC);
391 if (!ctlr) 385 if (!ctlr)
392 goto done; 386 return NULL;
393 387
394 /* initialize fields of controller */ 388 /* initialize fields of controller */
395 memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN); 389 memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN);
@@ -405,8 +399,7 @@ static struct rdac_controller *get_controller(int index, char *array_name,
405 INIT_WORK(&ctlr->ms_work, send_mode_select); 399 INIT_WORK(&ctlr->ms_work, send_mode_select);
406 INIT_LIST_HEAD(&ctlr->ms_head); 400 INIT_LIST_HEAD(&ctlr->ms_head);
407 list_add(&ctlr->node, &ctlr_list); 401 list_add(&ctlr->node, &ctlr_list);
408done: 402
409 spin_unlock(&list_lock);
410 return ctlr; 403 return ctlr;
411} 404}
412 405
@@ -517,9 +510,12 @@ static int initialize_controller(struct scsi_device *sdev,
517 index = 0; 510 index = 0;
518 else 511 else
519 index = 1; 512 index = 1;
513
514 spin_lock(&list_lock);
520 h->ctlr = get_controller(index, array_name, array_id, sdev); 515 h->ctlr = get_controller(index, array_name, array_id, sdev);
521 if (!h->ctlr) 516 if (!h->ctlr)
522 err = SCSI_DH_RES_TEMP_UNAVAIL; 517 err = SCSI_DH_RES_TEMP_UNAVAIL;
518 spin_unlock(&list_lock);
523 } 519 }
524 return err; 520 return err;
525} 521}
@@ -906,7 +902,9 @@ static int rdac_bus_attach(struct scsi_device *sdev)
906 return 0; 902 return 0;
907 903
908clean_ctlr: 904clean_ctlr:
905 spin_lock(&list_lock);
909 kref_put(&h->ctlr->kref, release_controller); 906 kref_put(&h->ctlr->kref, release_controller);
907 spin_unlock(&list_lock);
910 908
911failed: 909failed:
912 kfree(scsi_dh_data); 910 kfree(scsi_dh_data);
@@ -921,14 +919,19 @@ static void rdac_bus_detach( struct scsi_device *sdev )
921 struct rdac_dh_data *h; 919 struct rdac_dh_data *h;
922 unsigned long flags; 920 unsigned long flags;
923 921
924 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
925 scsi_dh_data = sdev->scsi_dh_data; 922 scsi_dh_data = sdev->scsi_dh_data;
923 h = (struct rdac_dh_data *) scsi_dh_data->buf;
924 if (h->ctlr && h->ctlr->ms_queued)
925 flush_workqueue(kmpath_rdacd);
926
927 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
926 sdev->scsi_dh_data = NULL; 928 sdev->scsi_dh_data = NULL;
927 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); 929 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
928 930
929 h = (struct rdac_dh_data *) scsi_dh_data->buf; 931 spin_lock(&list_lock);
930 if (h->ctlr) 932 if (h->ctlr)
931 kref_put(&h->ctlr->kref, release_controller); 933 kref_put(&h->ctlr->kref, release_controller);
934 spin_unlock(&list_lock);
932 kfree(scsi_dh_data); 935 kfree(scsi_dh_data);
933 module_put(THIS_MODULE); 936 module_put(THIS_MODULE);
934 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); 937 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 67b169b7a5be..b538f0883fd2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4613,11 +4613,13 @@ static int __ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd)
4613 ENTER; 4613 ENTER;
4614 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata; 4614 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
4615 4615
4616 dev_err(&ioa_cfg->pdev->dev, 4616 if (!ioa_cfg->in_reset_reload) {
4617 "Adapter being reset as a result of error recovery.\n"); 4617 dev_err(&ioa_cfg->pdev->dev,
4618 "Adapter being reset as a result of error recovery.\n");
4618 4619
4619 if (WAIT_FOR_DUMP == ioa_cfg->sdt_state) 4620 if (WAIT_FOR_DUMP == ioa_cfg->sdt_state)
4620 ioa_cfg->sdt_state = GET_DUMP; 4621 ioa_cfg->sdt_state = GET_DUMP;
4622 }
4621 4623
4622 rc = ipr_reset_reload(ioa_cfg, IPR_SHUTDOWN_ABBREV); 4624 rc = ipr_reset_reload(ioa_cfg, IPR_SHUTDOWN_ABBREV);
4623 4625
@@ -4907,7 +4909,7 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
4907 struct ipr_ioa_cfg *ioa_cfg; 4909 struct ipr_ioa_cfg *ioa_cfg;
4908 struct ipr_resource_entry *res; 4910 struct ipr_resource_entry *res;
4909 struct ipr_cmd_pkt *cmd_pkt; 4911 struct ipr_cmd_pkt *cmd_pkt;
4910 u32 ioasc; 4912 u32 ioasc, int_reg;
4911 int op_found = 0; 4913 int op_found = 0;
4912 4914
4913 ENTER; 4915 ENTER;
@@ -4920,7 +4922,17 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
4920 */ 4922 */
4921 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead) 4923 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead)
4922 return FAILED; 4924 return FAILED;
4923 if (!res || !ipr_is_gscsi(res)) 4925 if (!res)
4926 return FAILED;
4927
4928 /*
4929 * If we are aborting a timed out op, chances are that the timeout was caused
4930 * by a still not detected EEH error. In such cases, reading a register will
4931 * trigger the EEH recovery infrastructure.
4932 */
4933 int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
4934
4935 if (!ipr_is_gscsi(res))
4924 return FAILED; 4936 return FAILED;
4925 4937
4926 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4938 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 1a65d6514237..418391b1c361 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1848,9 +1848,11 @@ static enum sci_status sci_oem_parameters_set(struct isci_host *ihost)
1848 if (state == SCIC_RESET || 1848 if (state == SCIC_RESET ||
1849 state == SCIC_INITIALIZING || 1849 state == SCIC_INITIALIZING ||
1850 state == SCIC_INITIALIZED) { 1850 state == SCIC_INITIALIZED) {
1851 u8 oem_version = pci_info->orom ? pci_info->orom->hdr.version :
1852 ISCI_ROM_VER_1_0;
1851 1853
1852 if (sci_oem_parameters_validate(&ihost->oem_parameters, 1854 if (sci_oem_parameters_validate(&ihost->oem_parameters,
1853 pci_info->orom->hdr.version)) 1855 oem_version))
1854 return SCI_FAILURE_INVALID_PARAMETER_VALUE; 1856 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
1855 1857
1856 return SCI_SUCCESS; 1858 return SCI_SUCCESS;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 0b2c95583660..a78036f5e1a6 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -4548,7 +4548,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
4548 printk(MPT2SAS_ERR_FMT "%s: pci error recovery reset\n", 4548 printk(MPT2SAS_ERR_FMT "%s: pci error recovery reset\n",
4549 ioc->name, __func__); 4549 ioc->name, __func__);
4550 r = 0; 4550 r = 0;
4551 goto out; 4551 goto out_unlocked;
4552 } 4552 }
4553 4553
4554 if (mpt2sas_fwfault_debug) 4554 if (mpt2sas_fwfault_debug)
@@ -4604,6 +4604,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
4604 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); 4604 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
4605 mutex_unlock(&ioc->reset_in_progress_mutex); 4605 mutex_unlock(&ioc->reset_in_progress_mutex);
4606 4606
4607 out_unlocked:
4607 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name, 4608 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name,
4608 __func__)); 4609 __func__));
4609 return r; 4610 return r;
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index a2f1b3043dfb..9f41b3b4358f 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1036,8 +1036,7 @@ qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
1036 vha->device_flags & DFLG_NO_CABLE) 1036 vha->device_flags & DFLG_NO_CABLE)
1037 len = snprintf(buf, PAGE_SIZE, "Link Down\n"); 1037 len = snprintf(buf, PAGE_SIZE, "Link Down\n");
1038 else if (atomic_read(&vha->loop_state) != LOOP_READY || 1038 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
1039 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1039 qla2x00_reset_active(vha))
1040 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1041 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); 1040 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n");
1042 else { 1041 else {
1043 len = snprintf(buf, PAGE_SIZE, "Link Up - "); 1042 len = snprintf(buf, PAGE_SIZE, "Link Up - ");
@@ -1359,8 +1358,7 @@ qla2x00_thermal_temp_show(struct device *dev,
1359 return snprintf(buf, PAGE_SIZE, "\n"); 1358 return snprintf(buf, PAGE_SIZE, "\n");
1360 1359
1361 temp = frac = 0; 1360 temp = frac = 0;
1362 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1361 if (qla2x00_reset_active(vha))
1363 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1364 ql_log(ql_log_warn, vha, 0x707b, 1362 ql_log(ql_log_warn, vha, 0x707b,
1365 "ISP reset active.\n"); 1363 "ISP reset active.\n");
1366 else if (!vha->hw->flags.eeh_busy) 1364 else if (!vha->hw->flags.eeh_busy)
@@ -1379,8 +1377,7 @@ qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1379 int rval = QLA_FUNCTION_FAILED; 1377 int rval = QLA_FUNCTION_FAILED;
1380 uint16_t state[5]; 1378 uint16_t state[5];
1381 1379
1382 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) || 1380 if (qla2x00_reset_active(vha))
1383 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1384 ql_log(ql_log_warn, vha, 0x707c, 1381 ql_log(ql_log_warn, vha, 0x707c,
1385 "ISP reset active.\n"); 1382 "ISP reset active.\n");
1386 else if (!vha->hw->flags.eeh_busy) 1383 else if (!vha->hw->flags.eeh_busy)
@@ -1693,9 +1690,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1693 if (IS_FWI2_CAPABLE(ha)) { 1690 if (IS_FWI2_CAPABLE(ha)) {
1694 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); 1691 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1695 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && 1692 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1696 !test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) && 1693 !qla2x00_reset_active(vha) && !ha->dpc_active) {
1697 !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
1698 !ha->dpc_active) {
1699 /* Must be in a 'READY' state for statistics retrieval. */ 1694 /* Must be in a 'READY' state for statistics retrieval. */
1700 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, 1695 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1701 stats, stats_dma); 1696 stats, stats_dma);
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index b1d0f936bf2d..1682e2e4201d 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -108,13 +108,6 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
108 goto exit_fcp_prio_cfg; 108 goto exit_fcp_prio_cfg;
109 } 109 }
110 110
111 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
112 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
113 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
114 ret = -EBUSY;
115 goto exit_fcp_prio_cfg;
116 }
117
118 /* Get the sub command */ 111 /* Get the sub command */
119 oper = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1]; 112 oper = bsg_job->request->rqst_data.h_vendor.vendor_cmd[1];
120 113
@@ -646,13 +639,6 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
646 dma_addr_t rsp_data_dma; 639 dma_addr_t rsp_data_dma;
647 uint32_t rsp_data_len; 640 uint32_t rsp_data_len;
648 641
649 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
650 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
651 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
652 ql_log(ql_log_warn, vha, 0x7018, "Abort active or needed.\n");
653 return -EBUSY;
654 }
655
656 if (!vha->flags.online) { 642 if (!vha->flags.online) {
657 ql_log(ql_log_warn, vha, 0x7019, "Host is not online.\n"); 643 ql_log(ql_log_warn, vha, 0x7019, "Host is not online.\n");
658 return -EIO; 644 return -EIO;
@@ -874,13 +860,6 @@ qla84xx_reset(struct fc_bsg_job *bsg_job)
874 int rval = 0; 860 int rval = 0;
875 uint32_t flag; 861 uint32_t flag;
876 862
877 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
878 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
879 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
880 ql_log(ql_log_warn, vha, 0x702e, "Abort active or needed.\n");
881 return -EBUSY;
882 }
883
884 if (!IS_QLA84XX(ha)) { 863 if (!IS_QLA84XX(ha)) {
885 ql_dbg(ql_dbg_user, vha, 0x702f, "Not 84xx, exiting.\n"); 864 ql_dbg(ql_dbg_user, vha, 0x702f, "Not 84xx, exiting.\n");
886 return -EINVAL; 865 return -EINVAL;
@@ -922,11 +901,6 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
922 uint32_t flag; 901 uint32_t flag;
923 uint32_t fw_ver; 902 uint32_t fw_ver;
924 903
925 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
926 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
927 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags))
928 return -EBUSY;
929
930 if (!IS_QLA84XX(ha)) { 904 if (!IS_QLA84XX(ha)) {
931 ql_dbg(ql_dbg_user, vha, 0x7032, 905 ql_dbg(ql_dbg_user, vha, 0x7032,
932 "Not 84xx, exiting.\n"); 906 "Not 84xx, exiting.\n");
@@ -1036,14 +1010,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
1036 uint32_t data_len = 0; 1010 uint32_t data_len = 0;
1037 uint32_t dma_direction = DMA_NONE; 1011 uint32_t dma_direction = DMA_NONE;
1038 1012
1039 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1040 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1041 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1042 ql_log(ql_log_warn, vha, 0x7039,
1043 "Abort active or needed.\n");
1044 return -EBUSY;
1045 }
1046
1047 if (!IS_QLA84XX(ha)) { 1013 if (!IS_QLA84XX(ha)) {
1048 ql_log(ql_log_warn, vha, 0x703a, 1014 ql_log(ql_log_warn, vha, 0x703a,
1049 "Not 84xx, exiting.\n"); 1015 "Not 84xx, exiting.\n");
@@ -1246,13 +1212,6 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
1246 1212
1247 bsg_job->reply->reply_payload_rcv_len = 0; 1213 bsg_job->reply->reply_payload_rcv_len = 0;
1248 1214
1249 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
1250 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1251 test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
1252 ql_log(ql_log_warn, vha, 0x7045, "abort active or needed.\n");
1253 return -EBUSY;
1254 }
1255
1256 if (!IS_IIDMA_CAPABLE(vha->hw)) { 1215 if (!IS_IIDMA_CAPABLE(vha->hw)) {
1257 ql_log(ql_log_info, vha, 0x7046, "iiDMA not supported.\n"); 1216 ql_log(ql_log_info, vha, 0x7046, "iiDMA not supported.\n");
1258 return -EINVAL; 1217 return -EINVAL;
@@ -1668,6 +1627,15 @@ qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
1668 vha = shost_priv(host); 1627 vha = shost_priv(host);
1669 } 1628 }
1670 1629
1630 if (qla2x00_reset_active(vha)) {
1631 ql_dbg(ql_dbg_user, vha, 0x709f,
1632 "BSG: ISP abort active/needed -- cmd=%d.\n",
1633 bsg_job->request->msgcode);
1634 bsg_job->reply->result = (DID_ERROR << 16);
1635 bsg_job->job_done(bsg_job);
1636 return -EBUSY;
1637 }
1638
1671 ql_dbg(ql_dbg_user, vha, 0x7000, 1639 ql_dbg(ql_dbg_user, vha, 0x7000,
1672 "Entered %s msgcode=0x%x.\n", __func__, bsg_job->request->msgcode); 1640 "Entered %s msgcode=0x%x.\n", __func__, bsg_job->request->msgcode);
1673 1641
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 7c54624b5b13..45cbf0ba624d 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -19,7 +19,8 @@
19 * | DPC Thread | 0x401c | | 19 * | DPC Thread | 0x401c | |
20 * | Async Events | 0x5057 | 0x5052 | 20 * | Async Events | 0x5057 | 0x5052 |
21 * | Timer Routines | 0x6011 | 0x600e,0x600f | 21 * | Timer Routines | 0x6011 | 0x600e,0x600f |
22 * | User Space Interactions | 0x709e | | 22 * | User Space Interactions | 0x709e | 0x7018,0x702e |
23 * | | | 0x7039,0x7045 |
23 * | Task Management | 0x803c | 0x8025-0x8026 | 24 * | Task Management | 0x803c | 0x8025-0x8026 |
24 * | | | 0x800b,0x8039 | 25 * | | | 0x800b,0x8039 |
25 * | AER/EEH | 0x900f | | 26 * | AER/EEH | 0x900f | |
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index a6a4eebce4a8..af1003f9de1e 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -44,6 +44,7 @@
44 * ISP2100 HBAs. 44 * ISP2100 HBAs.
45 */ 45 */
46#define MAILBOX_REGISTER_COUNT_2100 8 46#define MAILBOX_REGISTER_COUNT_2100 8
47#define MAILBOX_REGISTER_COUNT_2200 24
47#define MAILBOX_REGISTER_COUNT 32 48#define MAILBOX_REGISTER_COUNT 32
48 49
49#define QLA2200A_RISC_ROM_VER 4 50#define QLA2200A_RISC_ROM_VER 4
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 9902834e0b74..7cc4f36cd539 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -131,3 +131,16 @@ qla2x00_hba_err_chk_enabled(srb_t *sp)
131 } 131 }
132 return 0; 132 return 0;
133} 133}
134
135static inline int
136qla2x00_reset_active(scsi_qla_host_t *vha)
137{
138 scsi_qla_host_t *base_vha = pci_get_drvdata(vha->hw->pdev);
139
140 /* Test appropriate base-vha and vha flags. */
141 return test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) ||
142 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
143 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
144 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
145 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
146}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index e804585cc59c..349843ea32f6 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2090,7 +2090,6 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
2090 break; 2090 break;
2091 case CT_IOCB_TYPE: 2091 case CT_IOCB_TYPE:
2092 qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); 2092 qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE);
2093 clear_bit(MBX_INTERRUPT, &vha->hw->mbx_cmd_flags);
2094 break; 2093 break;
2095 case ELS_IOCB_TYPE: 2094 case ELS_IOCB_TYPE:
2096 qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); 2095 qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 34344d3f8658..08f1d01bdc1c 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -342,6 +342,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
342 342
343 set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); 343 set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
344 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 344 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
345 /* Allow next mbx cmd to come in. */
346 complete(&ha->mbx_cmd_comp);
345 if (ha->isp_ops->abort_isp(vha)) { 347 if (ha->isp_ops->abort_isp(vha)) {
346 /* Failed. retry later. */ 348 /* Failed. retry later. */
347 set_bit(ISP_ABORT_NEEDED, 349 set_bit(ISP_ABORT_NEEDED,
@@ -350,6 +352,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
350 clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); 352 clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags);
351 ql_dbg(ql_dbg_mbx, base_vha, 0x101f, 353 ql_dbg(ql_dbg_mbx, base_vha, 0x101f,
352 "Finished abort_isp.\n"); 354 "Finished abort_isp.\n");
355 goto mbx_done;
353 } 356 }
354 } 357 }
355 } 358 }
@@ -358,6 +361,7 @@ premature_exit:
358 /* Allow next mbx cmd to come in. */ 361 /* Allow next mbx cmd to come in. */
359 complete(&ha->mbx_cmd_comp); 362 complete(&ha->mbx_cmd_comp);
360 363
364mbx_done:
361 if (rval) { 365 if (rval) {
362 ql_dbg(ql_dbg_mbx, base_vha, 0x1020, 366 ql_dbg(ql_dbg_mbx, base_vha, 0x1020,
363 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, cmd=%x ****.\n", 367 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, cmd=%x ****.\n",
@@ -2581,7 +2585,8 @@ qla2x00_stop_firmware(scsi_qla_host_t *vha)
2581 ql_dbg(ql_dbg_mbx, vha, 0x10a1, "Entered %s.\n", __func__); 2585 ql_dbg(ql_dbg_mbx, vha, 0x10a1, "Entered %s.\n", __func__);
2582 2586
2583 mcp->mb[0] = MBC_STOP_FIRMWARE; 2587 mcp->mb[0] = MBC_STOP_FIRMWARE;
2584 mcp->out_mb = MBX_0; 2588 mcp->mb[1] = 0;
2589 mcp->out_mb = MBX_1|MBX_0;
2585 mcp->in_mb = MBX_0; 2590 mcp->in_mb = MBX_0;
2586 mcp->tov = 5; 2591 mcp->tov = 5;
2587 mcp->flags = 0; 2592 mcp->flags = 0;
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 1cd46cd7ff90..270ba3130fde 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -1165,19 +1165,6 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
1165 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xfeffffff); 1165 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xfeffffff);
1166 else 1166 else
1167 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xffffffff); 1167 qla82xx_wr_32(ha, QLA82XX_ROMUSB_GLB_SW_RESET, 0xffffffff);
1168
1169 /* reset ms */
1170 val = qla82xx_rd_32(ha, QLA82XX_CRB_QDR_NET + 0xe4);
1171 val |= (1 << 1);
1172 qla82xx_wr_32(ha, QLA82XX_CRB_QDR_NET + 0xe4, val);
1173 msleep(20);
1174
1175 /* unreset ms */
1176 val = qla82xx_rd_32(ha, QLA82XX_CRB_QDR_NET + 0xe4);
1177 val &= ~(1 << 1);
1178 qla82xx_wr_32(ha, QLA82XX_CRB_QDR_NET + 0xe4, val);
1179 msleep(20);
1180
1181 qla82xx_rom_unlock(ha); 1168 qla82xx_rom_unlock(ha);
1182 1169
1183 /* Read the signature value from the flash. 1170 /* Read the signature value from the flash.
@@ -3392,7 +3379,7 @@ void qla82xx_watchdog(scsi_qla_host_t *vha)
3392 QLA82XX_CRB_PEG_NET_3 + 0x3c), 3379 QLA82XX_CRB_PEG_NET_3 + 0x3c),
3393 qla82xx_rd_32(ha, 3380 qla82xx_rd_32(ha,
3394 QLA82XX_CRB_PEG_NET_4 + 0x3c)); 3381 QLA82XX_CRB_PEG_NET_4 + 0x3c));
3395 if (LSW(MSB(halt_status)) == 0x67) 3382 if (((halt_status & 0x1fffff00) >> 8) == 0x67)
3396 ql_log(ql_log_warn, vha, 0xb052, 3383 ql_log(ql_log_warn, vha, 0xb052,
3397 "Firmware aborted with " 3384 "Firmware aborted with "
3398 "error code 0x00006700. Device is " 3385 "error code 0x00006700. Device is "
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4ed1e4a96b95..036030c95339 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -625,6 +625,12 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
625 cmd->result = DID_NO_CONNECT << 16; 625 cmd->result = DID_NO_CONNECT << 16;
626 goto qc24_fail_command; 626 goto qc24_fail_command;
627 } 627 }
628
629 if (!fcport) {
630 cmd->result = DID_NO_CONNECT << 16;
631 goto qc24_fail_command;
632 }
633
628 if (atomic_read(&fcport->state) != FCS_ONLINE) { 634 if (atomic_read(&fcport->state) != FCS_ONLINE) {
629 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || 635 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
630 atomic_read(&base_vha->loop_state) == LOOP_DEAD) { 636 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
@@ -877,6 +883,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
877 883
878 spin_unlock_irqrestore(&ha->hardware_lock, flags); 884 spin_unlock_irqrestore(&ha->hardware_lock, flags);
879 if (ha->isp_ops->abort_command(sp)) { 885 if (ha->isp_ops->abort_command(sp)) {
886 ret = FAILED;
880 ql_dbg(ql_dbg_taskm, vha, 0x8003, 887 ql_dbg(ql_dbg_taskm, vha, 0x8003,
881 "Abort command mbx failed cmd=%p.\n", cmd); 888 "Abort command mbx failed cmd=%p.\n", cmd);
882 } else { 889 } else {
@@ -1124,7 +1131,6 @@ static int
1124qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 1131qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1125{ 1132{
1126 scsi_qla_host_t *vha = shost_priv(cmd->device->host); 1133 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1127 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
1128 struct qla_hw_data *ha = vha->hw; 1134 struct qla_hw_data *ha = vha->hw;
1129 int ret = FAILED; 1135 int ret = FAILED;
1130 unsigned int id, lun; 1136 unsigned int id, lun;
@@ -1133,15 +1139,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1133 id = cmd->device->id; 1139 id = cmd->device->id;
1134 lun = cmd->device->lun; 1140 lun = cmd->device->lun;
1135 1141
1136 if (!fcport) {
1137 return ret;
1138 }
1139
1140 ret = fc_block_scsi_eh(cmd);
1141 if (ret != 0)
1142 return ret;
1143 ret = FAILED;
1144
1145 ql_log(ql_log_info, vha, 0x8018, 1142 ql_log(ql_log_info, vha, 0x8018,
1146 "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); 1143 "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun);
1147 1144
@@ -2047,7 +2044,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2047 ha->nvram_data_off = ~0; 2044 ha->nvram_data_off = ~0;
2048 ha->isp_ops = &qla2100_isp_ops; 2045 ha->isp_ops = &qla2100_isp_ops;
2049 } else if (IS_QLA2200(ha)) { 2046 } else if (IS_QLA2200(ha)) {
2050 ha->mbx_count = MAILBOX_REGISTER_COUNT; 2047 ha->mbx_count = MAILBOX_REGISTER_COUNT_2200;
2051 req_length = REQUEST_ENTRY_CNT_2200; 2048 req_length = REQUEST_ENTRY_CNT_2200;
2052 rsp_length = RESPONSE_ENTRY_CNT_2100; 2049 rsp_length = RESPONSE_ENTRY_CNT_2100;
2053 ha->max_loop_id = SNS_LAST_LOOP_ID_2100; 2050 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 23f33a6d52d7..29d780c38040 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.12-k" 10#define QLA2XXX_VERSION "8.03.07.13-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_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 78f1111158d7..65253dfbe962 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -10,6 +10,8 @@
10#include "ql4_def.h" 10#include "ql4_def.h"
11#include "ql4_glbl.h" 11#include "ql4_glbl.h"
12 12
13#include <asm-generic/io-64-nonatomic-lo-hi.h>
14
13#define MASK(n) DMA_BIT_MASK(n) 15#define MASK(n) DMA_BIT_MASK(n)
14#define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff)) 16#define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff))
15#define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff)) 17#define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff))
@@ -655,27 +657,6 @@ static int qla4_8xxx_pci_is_same_window(struct scsi_qla_host *ha,
655 return 0; 657 return 0;
656} 658}
657 659
658#ifndef readq
659static inline __u64 readq(const volatile void __iomem *addr)
660{
661 const volatile u32 __iomem *p = addr;
662 u32 low, high;
663
664 low = readl(p);
665 high = readl(p + 1);
666
667 return low + ((u64)high << 32);
668}
669#endif
670
671#ifndef writeq
672static inline void writeq(__u64 val, volatile void __iomem *addr)
673{
674 writel(val, addr);
675 writel(val >> 32, addr+4);
676}
677#endif
678
679static int qla4_8xxx_pci_mem_read_direct(struct scsi_qla_host *ha, 660static int qla4_8xxx_pci_mem_read_direct(struct scsi_qla_host *ha,
680 u64 off, void *data, int size) 661 u64 off, void *data, int size)
681{ 662{
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index bf8bf79e6a1f..c4670642d023 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/pm_runtime.h> 8#include <linux/pm_runtime.h>
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/async.h>
10 11
11#include <scsi/scsi.h> 12#include <scsi/scsi.h>
12#include <scsi/scsi_device.h> 13#include <scsi/scsi_device.h>
@@ -92,6 +93,19 @@ static int scsi_bus_resume_common(struct device *dev)
92 return err; 93 return err;
93} 94}
94 95
96static int scsi_bus_prepare(struct device *dev)
97{
98 if (scsi_is_sdev_device(dev)) {
99 /* sd probing uses async_schedule. Wait until it finishes. */
100 async_synchronize_full();
101
102 } else if (scsi_is_host_device(dev)) {
103 /* Wait until async scanning is finished */
104 scsi_complete_async_scans();
105 }
106 return 0;
107}
108
95static int scsi_bus_suspend(struct device *dev) 109static int scsi_bus_suspend(struct device *dev)
96{ 110{
97 return scsi_bus_suspend_common(dev, PMSG_SUSPEND); 111 return scsi_bus_suspend_common(dev, PMSG_SUSPEND);
@@ -110,6 +124,7 @@ static int scsi_bus_poweroff(struct device *dev)
110#else /* CONFIG_PM_SLEEP */ 124#else /* CONFIG_PM_SLEEP */
111 125
112#define scsi_bus_resume_common NULL 126#define scsi_bus_resume_common NULL
127#define scsi_bus_prepare NULL
113#define scsi_bus_suspend NULL 128#define scsi_bus_suspend NULL
114#define scsi_bus_freeze NULL 129#define scsi_bus_freeze NULL
115#define scsi_bus_poweroff NULL 130#define scsi_bus_poweroff NULL
@@ -218,6 +233,7 @@ void scsi_autopm_put_host(struct Scsi_Host *shost)
218#endif /* CONFIG_PM_RUNTIME */ 233#endif /* CONFIG_PM_RUNTIME */
219 234
220const struct dev_pm_ops scsi_bus_pm_ops = { 235const struct dev_pm_ops scsi_bus_pm_ops = {
236 .prepare = scsi_bus_prepare,
221 .suspend = scsi_bus_suspend, 237 .suspend = scsi_bus_suspend,
222 .resume = scsi_bus_resume_common, 238 .resume = scsi_bus_resume_common,
223 .freeze = scsi_bus_freeze, 239 .freeze = scsi_bus_freeze,
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 68eadd1c67fd..be4fa6d179b1 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -109,6 +109,7 @@ extern void scsi_exit_procfs(void);
109#endif /* CONFIG_PROC_FS */ 109#endif /* CONFIG_PROC_FS */
110 110
111/* scsi_scan.c */ 111/* scsi_scan.c */
112extern int scsi_complete_async_scans(void);
112extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, 113extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
113 unsigned int, unsigned int, int); 114 unsigned int, unsigned int, int);
114extern void scsi_forget_host(struct Scsi_Host *); 115extern void scsi_forget_host(struct Scsi_Host *);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 89da43f73c00..29c4c0480976 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1815,6 +1815,7 @@ static void scsi_finish_async_scan(struct async_scan_data *data)
1815 } 1815 }
1816 spin_unlock(&async_scan_lock); 1816 spin_unlock(&async_scan_lock);
1817 1817
1818 scsi_autopm_put_host(shost);
1818 scsi_host_put(shost); 1819 scsi_host_put(shost);
1819 kfree(data); 1820 kfree(data);
1820} 1821}
@@ -1841,7 +1842,6 @@ static int do_scan_async(void *_data)
1841 1842
1842 do_scsi_scan_host(shost); 1843 do_scsi_scan_host(shost);
1843 scsi_finish_async_scan(data); 1844 scsi_finish_async_scan(data);
1844 scsi_autopm_put_host(shost);
1845 return 0; 1845 return 0;
1846} 1846}
1847 1847
@@ -1869,7 +1869,7 @@ void scsi_scan_host(struct Scsi_Host *shost)
1869 p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); 1869 p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
1870 if (IS_ERR(p)) 1870 if (IS_ERR(p))
1871 do_scan_async(data); 1871 do_scan_async(data);
1872 /* scsi_autopm_put_host(shost) is called in do_scan_async() */ 1872 /* scsi_autopm_put_host(shost) is called in scsi_finish_async_scan() */
1873} 1873}
1874EXPORT_SYMBOL(scsi_scan_host); 1874EXPORT_SYMBOL(scsi_scan_host);
1875 1875
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index 45fee368b092..92d314a73f69 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -190,7 +190,7 @@ static int __init sh_clk_init_parent(struct clk *clk)
190 return -EINVAL; 190 return -EINVAL;
191 } 191 }
192 192
193 clk->parent = clk->parent_table[val]; 193 clk_reparent(clk, clk->parent_table[val]);
194 if (!clk->parent) { 194 if (!clk->parent) {
195 pr_err("sh_clk_init_parent: unable to set parent"); 195 pr_err("sh_clk_init_parent: unable to set parent");
196 return -EINVAL; 196 return -EINVAL;
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index d136b8f4c8a7..81e2c0d9c17d 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -187,7 +187,10 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
187 return -ENODEV; 187 return -ENODEV;
188 dev->current_state = PCI_D0; 188 dev->current_state = PCI_D0;
189 189
190 if (!dev->irq) { 190 /* The xHCI driver supports MSI and MSI-X,
191 * so don't fail if the BIOS doesn't provide a legacy IRQ.
192 */
193 if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) {
191 dev_err(&dev->dev, 194 dev_err(&dev->dev,
192 "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", 195 "Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
193 pci_name(dev)); 196 pci_name(dev));
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index eb19cba34ac9..e1282328fc27 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2447,8 +2447,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
2447 && device_can_wakeup(&hcd->self.root_hub->dev)) 2447 && device_can_wakeup(&hcd->self.root_hub->dev))
2448 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); 2448 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
2449 2449
2450 /* enable irqs just before we start the controller */ 2450 /* enable irqs just before we start the controller,
2451 if (usb_hcd_is_primary_hcd(hcd)) { 2451 * if the BIOS provides legacy PCI irqs.
2452 */
2453 if (usb_hcd_is_primary_hcd(hcd) && irqnum) {
2452 retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); 2454 retval = usb_hcd_request_irqs(hcd, irqnum, irqflags);
2453 if (retval) 2455 if (retval)
2454 goto err_request_irq; 2456 goto err_request_irq;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a0613d8f9be7..265c2f675d04 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -705,10 +705,26 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
705 if (type == HUB_INIT3) 705 if (type == HUB_INIT3)
706 goto init3; 706 goto init3;
707 707
708 /* After a resume, port power should still be on. 708 /* The superspeed hub except for root hub has to use Hub Depth
709 * value as an offset into the route string to locate the bits
710 * it uses to determine the downstream port number. So hub driver
711 * should send a set hub depth request to superspeed hub after
712 * the superspeed hub is set configuration in initialization or
713 * reset procedure.
714 *
715 * After a resume, port power should still be on.
709 * For any other type of activation, turn it on. 716 * For any other type of activation, turn it on.
710 */ 717 */
711 if (type != HUB_RESUME) { 718 if (type != HUB_RESUME) {
719 if (hdev->parent && hub_is_superspeed(hdev)) {
720 ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
721 HUB_SET_DEPTH, USB_RT_HUB,
722 hdev->level - 1, 0, NULL, 0,
723 USB_CTRL_SET_TIMEOUT);
724 if (ret < 0)
725 dev_err(hub->intfdev,
726 "set hub depth failed\n");
727 }
712 728
713 /* Speed up system boot by using a delayed_work for the 729 /* Speed up system boot by using a delayed_work for the
714 * hub's initial power-up delays. This is pretty awkward 730 * hub's initial power-up delays. This is pretty awkward
@@ -987,18 +1003,6 @@ static int hub_configure(struct usb_hub *hub,
987 goto fail; 1003 goto fail;
988 } 1004 }
989 1005
990 if (hub_is_superspeed(hdev) && (hdev->parent != NULL)) {
991 ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
992 HUB_SET_DEPTH, USB_RT_HUB,
993 hdev->level - 1, 0, NULL, 0,
994 USB_CTRL_SET_TIMEOUT);
995
996 if (ret < 0) {
997 message = "can't set hub depth";
998 goto fail;
999 }
1000 }
1001
1002 /* Request the entire hub descriptor. 1006 /* Request the entire hub descriptor.
1003 * hub->descriptor can handle USB_MAXCHILDREN ports, 1007 * hub->descriptor can handle USB_MAXCHILDREN ports,
1004 * but the hub can/will return fewer bytes here. 1008 * but the hub can/will return fewer bytes here.
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index ac53a662a6a3..7732d69e49e0 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -872,7 +872,17 @@ static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
872 */ 872 */
873 if (pdev->vendor == 0x184e) /* vendor Netlogic */ 873 if (pdev->vendor == 0x184e) /* vendor Netlogic */
874 return; 874 return;
875 if (pdev->class != PCI_CLASS_SERIAL_USB_UHCI &&
876 pdev->class != PCI_CLASS_SERIAL_USB_OHCI &&
877 pdev->class != PCI_CLASS_SERIAL_USB_EHCI &&
878 pdev->class != PCI_CLASS_SERIAL_USB_XHCI)
879 return;
875 880
881 if (pci_enable_device(pdev) < 0) {
882 dev_warn(&pdev->dev, "Can't enable PCI device, "
883 "BIOS handoff failed.\n");
884 return;
885 }
876 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI) 886 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
877 quirk_usb_handoff_uhci(pdev); 887 quirk_usb_handoff_uhci(pdev);
878 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI) 888 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI)
@@ -881,5 +891,6 @@ static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
881 quirk_usb_disable_ehci(pdev); 891 quirk_usb_disable_ehci(pdev);
882 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI) 892 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
883 quirk_usb_handoff_xhci(pdev); 893 quirk_usb_handoff_xhci(pdev);
894 pci_disable_device(pdev);
884} 895}
885DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff); 896DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 35e257f79c7b..557b6f32db86 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -93,7 +93,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
93 */ 93 */
94 memset(port_removable, 0, sizeof(port_removable)); 94 memset(port_removable, 0, sizeof(port_removable));
95 for (i = 0; i < ports; i++) { 95 for (i = 0; i < ports; i++) {
96 portsc = xhci_readl(xhci, xhci->usb3_ports[i]); 96 portsc = xhci_readl(xhci, xhci->usb2_ports[i]);
97 /* If a device is removable, PORTSC reports a 0, same as in the 97 /* If a device is removable, PORTSC reports a 0, same as in the
98 * hub descriptor DeviceRemovable bits. 98 * hub descriptor DeviceRemovable bits.
99 */ 99 */
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 36cbe2226a44..383fc857491c 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1126,26 +1126,42 @@ static unsigned int xhci_parse_exponent_interval(struct usb_device *udev,
1126} 1126}
1127 1127
1128/* 1128/*
1129 * Convert bInterval expressed in frames (in 1-255 range) to exponent of 1129 * Convert bInterval expressed in microframes (in 1-255 range) to exponent of
1130 * microframes, rounded down to nearest power of 2. 1130 * microframes, rounded down to nearest power of 2.
1131 */ 1131 */
1132static unsigned int xhci_parse_frame_interval(struct usb_device *udev, 1132static unsigned int xhci_microframes_to_exponent(struct usb_device *udev,
1133 struct usb_host_endpoint *ep) 1133 struct usb_host_endpoint *ep, unsigned int desc_interval,
1134 unsigned int min_exponent, unsigned int max_exponent)
1134{ 1135{
1135 unsigned int interval; 1136 unsigned int interval;
1136 1137
1137 interval = fls(8 * ep->desc.bInterval) - 1; 1138 interval = fls(desc_interval) - 1;
1138 interval = clamp_val(interval, 3, 10); 1139 interval = clamp_val(interval, min_exponent, max_exponent);
1139 if ((1 << interval) != 8 * ep->desc.bInterval) 1140 if ((1 << interval) != desc_interval)
1140 dev_warn(&udev->dev, 1141 dev_warn(&udev->dev,
1141 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n", 1142 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n",
1142 ep->desc.bEndpointAddress, 1143 ep->desc.bEndpointAddress,
1143 1 << interval, 1144 1 << interval,
1144 8 * ep->desc.bInterval); 1145 desc_interval);
1145 1146
1146 return interval; 1147 return interval;
1147} 1148}
1148 1149
1150static unsigned int xhci_parse_microframe_interval(struct usb_device *udev,
1151 struct usb_host_endpoint *ep)
1152{
1153 return xhci_microframes_to_exponent(udev, ep,
1154 ep->desc.bInterval, 0, 15);
1155}
1156
1157
1158static unsigned int xhci_parse_frame_interval(struct usb_device *udev,
1159 struct usb_host_endpoint *ep)
1160{
1161 return xhci_microframes_to_exponent(udev, ep,
1162 ep->desc.bInterval * 8, 3, 10);
1163}
1164
1149/* Return the polling or NAK interval. 1165/* Return the polling or NAK interval.
1150 * 1166 *
1151 * The polling interval is expressed in "microframes". If xHCI's Interval field 1167 * The polling interval is expressed in "microframes". If xHCI's Interval field
@@ -1164,7 +1180,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1164 /* Max NAK rate */ 1180 /* Max NAK rate */
1165 if (usb_endpoint_xfer_control(&ep->desc) || 1181 if (usb_endpoint_xfer_control(&ep->desc) ||
1166 usb_endpoint_xfer_bulk(&ep->desc)) { 1182 usb_endpoint_xfer_bulk(&ep->desc)) {
1167 interval = ep->desc.bInterval; 1183 interval = xhci_parse_microframe_interval(udev, ep);
1168 break; 1184 break;
1169 } 1185 }
1170 /* Fall through - SS and HS isoc/int have same decoding */ 1186 /* Fall through - SS and HS isoc/int have same decoding */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6bbe3c3a7111..c939f5fdef9e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -352,6 +352,11 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
352 /* hcd->irq is -1, we have MSI */ 352 /* hcd->irq is -1, we have MSI */
353 return 0; 353 return 0;
354 354
355 if (!pdev->irq) {
356 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n");
357 return -EINVAL;
358 }
359
355 /* fall back to legacy interrupt*/ 360 /* fall back to legacy interrupt*/
356 ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, 361 ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
357 hcd->irq_descr, hcd); 362 hcd->irq_descr, hcd);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 8dbf51a43c45..08a5575724cd 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -136,6 +136,8 @@ static const struct usb_device_id id_table[] = {
136 { USB_DEVICE(0x16DC, 0x0011) }, /* W-IE-NE-R Plein & Baus GmbH RCM Remote Control for MARATON Power Supply */ 136 { USB_DEVICE(0x16DC, 0x0011) }, /* W-IE-NE-R Plein & Baus GmbH RCM Remote Control for MARATON Power Supply */
137 { USB_DEVICE(0x16DC, 0x0012) }, /* W-IE-NE-R Plein & Baus GmbH MPOD Multi Channel Power Supply */ 137 { USB_DEVICE(0x16DC, 0x0012) }, /* W-IE-NE-R Plein & Baus GmbH MPOD Multi Channel Power Supply */
138 { USB_DEVICE(0x16DC, 0x0015) }, /* W-IE-NE-R Plein & Baus GmbH CML Control, Monitoring and Data Logger */ 138 { USB_DEVICE(0x16DC, 0x0015) }, /* W-IE-NE-R Plein & Baus GmbH CML Control, Monitoring and Data Logger */
139 { USB_DEVICE(0x17A8, 0x0001) }, /* Kamstrup Optical Eye/3-wire */
140 { USB_DEVICE(0x17A8, 0x0005) }, /* Kamstrup M-Bus Master MultiPort 250D */
139 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */ 141 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
140 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ 142 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
141 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 143 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 39ed1f46cec0..b54afceb9611 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -788,7 +788,6 @@ static const struct usb_device_id option_ids[] = {
788 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff), 788 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff),
789 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 789 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
790 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) }, 790 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) },
791 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) },
792 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) }, 791 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) },
793 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) }, 792 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) },
794 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff), 793 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff),
@@ -803,7 +802,6 @@ static const struct usb_device_id option_ids[] = {
803 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) }, 802 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) },
804 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff), 803 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff),
805 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 804 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
806 /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0026, 0xff, 0xff, 0xff) }, */
807 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) }, 805 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) },
808 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) }, 806 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) },
809 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) }, 807 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) },
@@ -828,7 +826,6 @@ static const struct usb_device_id option_ids[] = {
828 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) }, 826 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) },
829 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff), 827 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff),
830 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 828 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
831 /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0053, 0xff, 0xff, 0xff) }, */
832 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) }, 829 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) },
833 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff), 830 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff),
834 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 831 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
@@ -836,7 +833,6 @@ static const struct usb_device_id option_ids[] = {
836 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) }, 833 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) },
837 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff), 834 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff),
838 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 835 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
839 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
840 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) }, 836 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) },
841 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) }, 837 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) },
842 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff), 838 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff),
@@ -846,7 +842,6 @@ static const struct usb_device_id option_ids[] = {
846 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) }, 842 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) },
847 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) }, 843 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) },
848 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) }, 844 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) },
849 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
850 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) }, 845 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) },
851 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) }, 846 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) },
852 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) }, 847 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) },
@@ -865,8 +860,6 @@ static const struct usb_device_id option_ids[] = {
865 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0095, 0xff, 0xff, 0xff) }, 860 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0095, 0xff, 0xff, 0xff) },
866 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0096, 0xff, 0xff, 0xff) }, 861 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0096, 0xff, 0xff, 0xff) },
867 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0097, 0xff, 0xff, 0xff) }, 862 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0097, 0xff, 0xff, 0xff) },
868 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0098, 0xff, 0xff, 0xff) },
869 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0099, 0xff, 0xff, 0xff) },
870 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff), 863 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff),
871 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 864 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) }, 865 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) },
@@ -887,28 +880,18 @@ static const struct usb_device_id option_ids[] = {
887 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, 880 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) }, 881 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) },
889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0145, 0xff, 0xff, 0xff) }, 882 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0145, 0xff, 0xff, 0xff) },
890 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0146, 0xff, 0xff, 0xff) },
891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
892 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0148, 0xff, 0xff, 0xff) }, 883 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0148, 0xff, 0xff, 0xff) },
893 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0149, 0xff, 0xff, 0xff) },
894 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0150, 0xff, 0xff, 0xff) },
895 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0151, 0xff, 0xff, 0xff) }, 884 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0151, 0xff, 0xff, 0xff) },
896 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
897 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) }, 885 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) },
898 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) }, 886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) },
899 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, 887 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
900 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff) }, 888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff) },
901 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, 889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) },
902 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, 890 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
903 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0160, 0xff, 0xff, 0xff) },
904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, 891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
905 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, 892 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
906 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) }, 893 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) },
907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 894 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
908 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
910 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) },
911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) },
912 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) }, 895 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) },
913 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) }, 896 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) },
914 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 897 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
@@ -1083,127 +1066,27 @@ static const struct usb_device_id option_ids[] = {
1083 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1066 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
1084 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1067 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
1085 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1068 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
1086 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff) }, 1069 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
1087 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff) }, 1070 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
1088 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1403, 0xff, 0xff, 0xff) }, 1071 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
1089 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1404, 0xff, 0xff, 0xff) }, 1072
1090 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1405, 0xff, 0xff, 0xff) },
1091 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1406, 0xff, 0xff, 0xff) },
1092 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1407, 0xff, 0xff, 0xff) },
1093 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1408, 0xff, 0xff, 0xff) },
1094 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1409, 0xff, 0xff, 0xff) },
1095 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1410, 0xff, 0xff, 0xff) },
1096 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1411, 0xff, 0xff, 0xff) },
1097 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1412, 0xff, 0xff, 0xff) },
1098 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1413, 0xff, 0xff, 0xff) },
1099 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1414, 0xff, 0xff, 0xff) },
1100 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1415, 0xff, 0xff, 0xff) },
1101 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1416, 0xff, 0xff, 0xff) },
1102 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1417, 0xff, 0xff, 0xff) },
1103 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1418, 0xff, 0xff, 0xff) },
1104 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1419, 0xff, 0xff, 0xff) },
1105 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1420, 0xff, 0xff, 0xff) },
1106 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1421, 0xff, 0xff, 0xff) },
1107 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1422, 0xff, 0xff, 0xff) },
1108 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1423, 0xff, 0xff, 0xff) },
1109 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff) },
1110 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff) },
1111 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff) },
1112 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1427, 0xff, 0xff, 0xff) },
1113 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1428, 0xff, 0xff, 0xff) },
1114 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1429, 0xff, 0xff, 0xff) },
1115 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1430, 0xff, 0xff, 0xff) },
1116 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1431, 0xff, 0xff, 0xff) },
1117 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1432, 0xff, 0xff, 0xff) },
1118 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1433, 0xff, 0xff, 0xff) },
1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1434, 0xff, 0xff, 0xff) },
1120 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1435, 0xff, 0xff, 0xff) },
1121 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1436, 0xff, 0xff, 0xff) },
1122 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1437, 0xff, 0xff, 0xff) },
1123 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1438, 0xff, 0xff, 0xff) },
1124 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1439, 0xff, 0xff, 0xff) },
1125 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1440, 0xff, 0xff, 0xff) },
1126 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1441, 0xff, 0xff, 0xff) },
1127 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1442, 0xff, 0xff, 0xff) },
1128 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1443, 0xff, 0xff, 0xff) },
1129 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1444, 0xff, 0xff, 0xff) },
1130 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1445, 0xff, 0xff, 0xff) },
1131 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1446, 0xff, 0xff, 0xff) },
1132 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1447, 0xff, 0xff, 0xff) },
1133 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1448, 0xff, 0xff, 0xff) },
1134 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1449, 0xff, 0xff, 0xff) },
1135 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1450, 0xff, 0xff, 0xff) },
1136 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1451, 0xff, 0xff, 0xff) },
1137 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1452, 0xff, 0xff, 0xff) },
1138 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1453, 0xff, 0xff, 0xff) },
1139 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1454, 0xff, 0xff, 0xff) },
1140 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1455, 0xff, 0xff, 0xff) },
1141 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1456, 0xff, 0xff, 0xff) },
1142 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1457, 0xff, 0xff, 0xff) },
1143 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1458, 0xff, 0xff, 0xff) },
1144 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1459, 0xff, 0xff, 0xff) },
1145 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1460, 0xff, 0xff, 0xff) },
1146 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1461, 0xff, 0xff, 0xff) },
1147 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1462, 0xff, 0xff, 0xff) },
1148 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1463, 0xff, 0xff, 0xff) },
1149 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1464, 0xff, 0xff, 0xff) },
1150 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1465, 0xff, 0xff, 0xff) },
1151 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1466, 0xff, 0xff, 0xff) },
1152 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1467, 0xff, 0xff, 0xff) },
1153 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1468, 0xff, 0xff, 0xff) },
1154 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1469, 0xff, 0xff, 0xff) },
1155 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1470, 0xff, 0xff, 0xff) },
1156 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1471, 0xff, 0xff, 0xff) },
1157 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1472, 0xff, 0xff, 0xff) },
1158 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1473, 0xff, 0xff, 0xff) },
1159 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1474, 0xff, 0xff, 0xff) },
1160 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1475, 0xff, 0xff, 0xff) },
1161 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1476, 0xff, 0xff, 0xff) },
1162 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1477, 0xff, 0xff, 0xff) },
1163 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1478, 0xff, 0xff, 0xff) },
1164 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1479, 0xff, 0xff, 0xff) },
1165 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1480, 0xff, 0xff, 0xff) },
1166 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1481, 0xff, 0xff, 0xff) },
1167 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1482, 0xff, 0xff, 0xff) },
1168 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1483, 0xff, 0xff, 0xff) },
1169 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1484, 0xff, 0xff, 0xff) },
1170 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1485, 0xff, 0xff, 0xff) },
1171 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1486, 0xff, 0xff, 0xff) },
1172 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1487, 0xff, 0xff, 0xff) },
1173 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1488, 0xff, 0xff, 0xff) },
1174 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1489, 0xff, 0xff, 0xff) },
1175 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1490, 0xff, 0xff, 0xff) },
1176 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1491, 0xff, 0xff, 0xff) },
1177 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1492, 0xff, 0xff, 0xff) },
1178 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1493, 0xff, 0xff, 0xff) },
1179 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1494, 0xff, 0xff, 0xff) },
1180 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1495, 0xff, 0xff, 0xff) },
1181 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1496, 0xff, 0xff, 0xff) },
1182 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1497, 0xff, 0xff, 0xff) },
1183 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1498, 0xff, 0xff, 0xff) },
1184 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1499, 0xff, 0xff, 0xff) },
1185 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1500, 0xff, 0xff, 0xff) },
1186 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1501, 0xff, 0xff, 0xff) },
1187 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1502, 0xff, 0xff, 0xff) },
1188 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1503, 0xff, 0xff, 0xff) },
1189 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1504, 0xff, 0xff, 0xff) },
1190 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1505, 0xff, 0xff, 0xff) },
1191 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1506, 0xff, 0xff, 0xff) },
1192 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1507, 0xff, 0xff, 0xff) },
1193 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1508, 0xff, 0xff, 0xff) },
1194 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1509, 0xff, 0xff, 0xff) },
1195 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1510, 0xff, 0xff, 0xff) },
1196 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */ 1073 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */
1197 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) }, 1074 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) },
1198 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) }, 1075 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
1199 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) }, 1076 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) },
1200 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, 1077 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
1201 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 1078 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
1079 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
1202 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) }, 1080 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
1081 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) },
1203 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) }, 1082 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
1204 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 1083 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
1205 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, 1084 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
1206 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, 1085 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) },
1086 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
1087 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) },
1088 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) },
1089
1207 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 1090 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
1208 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, 1091 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
1209 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 1092 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 8468eb769a29..75b838eff178 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -165,7 +165,7 @@ static unsigned int product_5052_count;
165/* the array dimension is the number of default entries plus */ 165/* the array dimension is the number of default entries plus */
166/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 166/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
167/* null entry */ 167/* null entry */
168static struct usb_device_id ti_id_table_3410[13+TI_EXTRA_VID_PID_COUNT+1] = { 168static struct usb_device_id ti_id_table_3410[14+TI_EXTRA_VID_PID_COUNT+1] = {
169 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 169 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
170 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 170 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
171 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 171 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -179,6 +179,7 @@ static struct usb_device_id ti_id_table_3410[13+TI_EXTRA_VID_PID_COUNT+1] = {
179 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 179 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
180 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, 180 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
181 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, 181 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
182 { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
182}; 183};
183 184
184static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = { 185static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -188,7 +189,7 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
188 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 189 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
189}; 190};
190 191
191static struct usb_device_id ti_id_table_combined[17+2*TI_EXTRA_VID_PID_COUNT+1] = { 192static struct usb_device_id ti_id_table_combined[18+2*TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 194 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
194 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 195 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -206,6 +207,7 @@ static struct usb_device_id ti_id_table_combined[17+2*TI_EXTRA_VID_PID_COUNT+1]
206 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 207 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
207 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, 208 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
208 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, 209 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
210 { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
209 { } 211 { }
210}; 212};
211 213
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index 2aac1953993b..f140f1b9d5c0 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -49,6 +49,10 @@
49#define MTS_MT9234ZBA_PRODUCT_ID 0xF115 49#define MTS_MT9234ZBA_PRODUCT_ID 0xF115
50#define MTS_MT9234ZBAOLD_PRODUCT_ID 0x0319 50#define MTS_MT9234ZBAOLD_PRODUCT_ID 0x0319
51 51
52/* Abbott Diabetics vendor and product ids */
53#define ABBOTT_VENDOR_ID 0x1a61
54#define ABBOTT_PRODUCT_ID 0x3410
55
52/* Commands */ 56/* Commands */
53#define TI_GET_VERSION 0x01 57#define TI_GET_VERSION 0x01
54#define TI_GET_PORT_STATUS 0x02 58#define TI_GET_PORT_STATUS 0x02
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 3dd7da9fd504..db51ba16dc07 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -788,15 +788,19 @@ static void quiesce_and_remove_host(struct us_data *us)
788 struct Scsi_Host *host = us_to_host(us); 788 struct Scsi_Host *host = us_to_host(us);
789 789
790 /* If the device is really gone, cut short reset delays */ 790 /* If the device is really gone, cut short reset delays */
791 if (us->pusb_dev->state == USB_STATE_NOTATTACHED) 791 if (us->pusb_dev->state == USB_STATE_NOTATTACHED) {
792 set_bit(US_FLIDX_DISCONNECTING, &us->dflags); 792 set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
793 wake_up(&us->delay_wait);
794 }
793 795
794 /* Prevent SCSI-scanning (if it hasn't started yet) 796 /* Prevent SCSI scanning (if it hasn't started yet)
795 * and wait for the SCSI-scanning thread to stop. 797 * or wait for the SCSI-scanning routine to stop.
796 */ 798 */
797 set_bit(US_FLIDX_DONT_SCAN, &us->dflags); 799 cancel_delayed_work_sync(&us->scan_dwork);
798 wake_up(&us->delay_wait); 800
799 wait_for_completion(&us->scanning_done); 801 /* Balance autopm calls if scanning was cancelled */
802 if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags))
803 usb_autopm_put_interface_no_suspend(us->pusb_intf);
800 804
801 /* Removing the host will perform an orderly shutdown: caches 805 /* Removing the host will perform an orderly shutdown: caches
802 * synchronized, disks spun down, etc. 806 * synchronized, disks spun down, etc.
@@ -823,53 +827,28 @@ static void release_everything(struct us_data *us)
823 scsi_host_put(us_to_host(us)); 827 scsi_host_put(us_to_host(us));
824} 828}
825 829
826/* Thread to carry out delayed SCSI-device scanning */ 830/* Delayed-work routine to carry out SCSI-device scanning */
827static int usb_stor_scan_thread(void * __us) 831static void usb_stor_scan_dwork(struct work_struct *work)
828{ 832{
829 struct us_data *us = (struct us_data *)__us; 833 struct us_data *us = container_of(work, struct us_data,
834 scan_dwork.work);
830 struct device *dev = &us->pusb_intf->dev; 835 struct device *dev = &us->pusb_intf->dev;
831 836
832 dev_dbg(dev, "device found\n"); 837 dev_dbg(dev, "starting scan\n");
833
834 set_freezable();
835 838
836 /* 839 /* For bulk-only devices, determine the max LUN value */
837 * Wait for the timeout to expire or for a disconnect 840 if (us->protocol == USB_PR_BULK && !(us->fflags & US_FL_SINGLE_LUN)) {
838 * 841 mutex_lock(&us->dev_mutex);
839 * We can't freeze in this thread or we risk causing khubd to 842 us->max_lun = usb_stor_Bulk_max_lun(us);
840 * fail to freeze, but we can't be non-freezable either. Nor can 843 mutex_unlock(&us->dev_mutex);
841 * khubd freeze while waiting for scanning to complete as it may
842 * hold the device lock, causing a hang when suspending devices.
843 * So instead of using wait_event_freezable(), explicitly test
844 * for (DONT_SCAN || freezing) in interruptible wait and proceed
845 * if any of DONT_SCAN, freezing or timeout has happened.
846 */
847 if (delay_use > 0) {
848 dev_dbg(dev, "waiting for device to settle "
849 "before scanning\n");
850 wait_event_interruptible_timeout(us->delay_wait,
851 test_bit(US_FLIDX_DONT_SCAN, &us->dflags) ||
852 freezing(current), delay_use * HZ);
853 } 844 }
845 scsi_scan_host(us_to_host(us));
846 dev_dbg(dev, "scan complete\n");
854 847
855 /* If the device is still connected, perform the scanning */ 848 /* Should we unbind if no devices were detected? */
856 if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
857
858 /* For bulk-only devices, determine the max LUN value */
859 if (us->protocol == USB_PR_BULK &&
860 !(us->fflags & US_FL_SINGLE_LUN)) {
861 mutex_lock(&us->dev_mutex);
862 us->max_lun = usb_stor_Bulk_max_lun(us);
863 mutex_unlock(&us->dev_mutex);
864 }
865 scsi_scan_host(us_to_host(us));
866 dev_dbg(dev, "scan complete\n");
867
868 /* Should we unbind if no devices were detected? */
869 }
870 849
871 usb_autopm_put_interface(us->pusb_intf); 850 usb_autopm_put_interface(us->pusb_intf);
872 complete_and_exit(&us->scanning_done, 0); 851 clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
873} 852}
874 853
875static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf) 854static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
@@ -916,7 +895,7 @@ int usb_stor_probe1(struct us_data **pus,
916 init_completion(&us->cmnd_ready); 895 init_completion(&us->cmnd_ready);
917 init_completion(&(us->notify)); 896 init_completion(&(us->notify));
918 init_waitqueue_head(&us->delay_wait); 897 init_waitqueue_head(&us->delay_wait);
919 init_completion(&us->scanning_done); 898 INIT_DELAYED_WORK(&us->scan_dwork, usb_stor_scan_dwork);
920 899
921 /* Associate the us_data structure with the USB device */ 900 /* Associate the us_data structure with the USB device */
922 result = associate_dev(us, intf); 901 result = associate_dev(us, intf);
@@ -947,7 +926,6 @@ EXPORT_SYMBOL_GPL(usb_stor_probe1);
947/* Second part of general USB mass-storage probing */ 926/* Second part of general USB mass-storage probing */
948int usb_stor_probe2(struct us_data *us) 927int usb_stor_probe2(struct us_data *us)
949{ 928{
950 struct task_struct *th;
951 int result; 929 int result;
952 struct device *dev = &us->pusb_intf->dev; 930 struct device *dev = &us->pusb_intf->dev;
953 931
@@ -988,20 +966,14 @@ int usb_stor_probe2(struct us_data *us)
988 goto BadDevice; 966 goto BadDevice;
989 } 967 }
990 968
991 /* Start up the thread for delayed SCSI-device scanning */ 969 /* Submit the delayed_work for SCSI-device scanning */
992 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan");
993 if (IS_ERR(th)) {
994 dev_warn(dev,
995 "Unable to start the device-scanning thread\n");
996 complete(&us->scanning_done);
997 quiesce_and_remove_host(us);
998 result = PTR_ERR(th);
999 goto BadDevice;
1000 }
1001
1002 usb_autopm_get_interface_no_resume(us->pusb_intf); 970 usb_autopm_get_interface_no_resume(us->pusb_intf);
1003 wake_up_process(th); 971 set_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
1004 972
973 if (delay_use > 0)
974 dev_dbg(dev, "waiting for device to settle before scanning\n");
975 queue_delayed_work(system_freezable_wq, &us->scan_dwork,
976 delay_use * HZ);
1005 return 0; 977 return 0;
1006 978
1007 /* We come here if there are any problems */ 979 /* We come here if there are any problems */
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 7b0f2113632e..75f70f04f37b 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -47,6 +47,7 @@
47#include <linux/blkdev.h> 47#include <linux/blkdev.h>
48#include <linux/completion.h> 48#include <linux/completion.h>
49#include <linux/mutex.h> 49#include <linux/mutex.h>
50#include <linux/workqueue.h>
50#include <scsi/scsi_host.h> 51#include <scsi/scsi_host.h>
51 52
52struct us_data; 53struct us_data;
@@ -72,7 +73,7 @@ struct us_unusual_dev {
72#define US_FLIDX_DISCONNECTING 3 /* disconnect in progress */ 73#define US_FLIDX_DISCONNECTING 3 /* disconnect in progress */
73#define US_FLIDX_RESETTING 4 /* device reset in progress */ 74#define US_FLIDX_RESETTING 4 /* device reset in progress */
74#define US_FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */ 75#define US_FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */
75#define US_FLIDX_DONT_SCAN 6 /* don't scan (disconnect) */ 76#define US_FLIDX_SCAN_PENDING 6 /* scanning not yet done */
76#define US_FLIDX_REDO_READ10 7 /* redo READ(10) command */ 77#define US_FLIDX_REDO_READ10 7 /* redo READ(10) command */
77#define US_FLIDX_READ10_WORKED 8 /* previous READ(10) succeeded */ 78#define US_FLIDX_READ10_WORKED 8 /* previous READ(10) succeeded */
78 79
@@ -147,8 +148,8 @@ struct us_data {
147 /* mutual exclusion and synchronization structures */ 148 /* mutual exclusion and synchronization structures */
148 struct completion cmnd_ready; /* to sleep thread on */ 149 struct completion cmnd_ready; /* to sleep thread on */
149 struct completion notify; /* thread begin/end */ 150 struct completion notify; /* thread begin/end */
150 wait_queue_head_t delay_wait; /* wait during scan, reset */ 151 wait_queue_head_t delay_wait; /* wait during reset */
151 struct completion scanning_done; /* wait for scan thread */ 152 struct delayed_work scan_dwork; /* for async scanning */
152 153
153 /* subdriver information */ 154 /* subdriver information */
154 void *extra; /* Any extra data */ 155 void *extra; /* Any extra data */
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index f9975100d56d..3a3fdc62c75b 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -1061,7 +1061,7 @@ static struct pvr2_board {
1061 int (*init)(void); 1061 int (*init)(void);
1062 void (*exit)(void); 1062 void (*exit)(void);
1063 char name[16]; 1063 char name[16];
1064} board_driver[] = { 1064} board_driver[] __refdata = {
1065#ifdef CONFIG_SH_DREAMCAST 1065#ifdef CONFIG_SH_DREAMCAST
1066 { pvr2fb_dc_init, pvr2fb_dc_exit, "Sega DC PVR2" }, 1066 { pvr2fb_dc_init, pvr2fb_dc_exit, "Sega DC PVR2" },
1067#endif 1067#endif
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index d8d8e7ba6a1e..eb1cc92cd67d 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -110,6 +110,7 @@ struct autofs_sb_info {
110 int sub_version; 110 int sub_version;
111 int min_proto; 111 int min_proto;
112 int max_proto; 112 int max_proto;
113 int compat_daemon;
113 unsigned long exp_timeout; 114 unsigned long exp_timeout;
114 unsigned int type; 115 unsigned int type;
115 int reghost_enabled; 116 int reghost_enabled;
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 76741d8d7786..85f1fcdb30e7 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -385,6 +385,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
385 sbi->pipefd = pipefd; 385 sbi->pipefd = pipefd;
386 sbi->pipe = pipe; 386 sbi->pipe = pipe;
387 sbi->catatonic = 0; 387 sbi->catatonic = 0;
388 sbi->compat_daemon = is_compat_task();
388 } 389 }
389out: 390out:
390 mutex_unlock(&sbi->wq_mutex); 391 mutex_unlock(&sbi->wq_mutex);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 450f529a4eae..1feb68ecef95 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -124,6 +124,7 @@ start:
124 /* Negative dentry - try next */ 124 /* Negative dentry - try next */
125 if (!simple_positive(q)) { 125 if (!simple_positive(q)) {
126 spin_unlock(&p->d_lock); 126 spin_unlock(&p->d_lock);
127 lock_set_subclass(&q->d_lock.dep_map, 0, _RET_IP_);
127 p = q; 128 p = q;
128 goto again; 129 goto again;
129 } 130 }
@@ -186,6 +187,7 @@ again:
186 /* Negative dentry - try next */ 187 /* Negative dentry - try next */
187 if (!simple_positive(ret)) { 188 if (!simple_positive(ret)) {
188 spin_unlock(&p->d_lock); 189 spin_unlock(&p->d_lock);
190 lock_set_subclass(&ret->d_lock.dep_map, 0, _RET_IP_);
189 p = ret; 191 p = ret;
190 goto again; 192 goto again;
191 } 193 }
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index e16980b00b8d..06858d955120 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -19,6 +19,7 @@
19#include <linux/parser.h> 19#include <linux/parser.h>
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21#include <linux/magic.h> 21#include <linux/magic.h>
22#include <linux/compat.h>
22#include "autofs_i.h" 23#include "autofs_i.h"
23#include <linux/module.h> 24#include <linux/module.h>
24 25
@@ -224,6 +225,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
224 set_autofs_type_indirect(&sbi->type); 225 set_autofs_type_indirect(&sbi->type);
225 sbi->min_proto = 0; 226 sbi->min_proto = 0;
226 sbi->max_proto = 0; 227 sbi->max_proto = 0;
228 sbi->compat_daemon = is_compat_task();
227 mutex_init(&sbi->wq_mutex); 229 mutex_init(&sbi->wq_mutex);
228 mutex_init(&sbi->pipe_mutex); 230 mutex_init(&sbi->pipe_mutex);
229 spin_lock_init(&sbi->fs_lock); 231 spin_lock_init(&sbi->fs_lock);
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index da8876d38a7b..9c098db43344 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -91,7 +91,24 @@ static int autofs4_write(struct autofs_sb_info *sbi,
91 91
92 return (bytes > 0); 92 return (bytes > 0);
93} 93}
94 94
95/*
96 * The autofs_v5 packet was misdesigned.
97 *
98 * The packets are identical on x86-32 and x86-64, but have different
99 * alignment. Which means that 'sizeof()' will give different results.
100 * Fix it up for the case of running 32-bit user mode on a 64-bit kernel.
101 */
102static noinline size_t autofs_v5_packet_size(struct autofs_sb_info *sbi)
103{
104 size_t pktsz = sizeof(struct autofs_v5_packet);
105#if defined(CONFIG_X86_64) && defined(CONFIG_COMPAT)
106 if (sbi->compat_daemon > 0)
107 pktsz -= 4;
108#endif
109 return pktsz;
110}
111
95static void autofs4_notify_daemon(struct autofs_sb_info *sbi, 112static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
96 struct autofs_wait_queue *wq, 113 struct autofs_wait_queue *wq,
97 int type) 114 int type)
@@ -155,8 +172,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
155 { 172 {
156 struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet; 173 struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet;
157 174
158 pktsz = sizeof(*packet); 175 pktsz = autofs_v5_packet_size(sbi);
159
160 packet->wait_queue_token = wq->wait_queue_token; 176 packet->wait_queue_token = wq->wait_queue_token;
161 packet->len = wq->name.len; 177 packet->len = wq->name.len;
162 memcpy(packet->name, wq->name.name, wq->name.len); 178 memcpy(packet->name, wq->name.name, wq->name.len);
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 633c701a287d..98f6bf10bbd4 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -892,6 +892,8 @@ static char *iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
892 if (eb != eb_in) 892 if (eb != eb_in)
893 free_extent_buffer(eb); 893 free_extent_buffer(eb);
894 ret = inode_ref_info(parent, 0, fs_root, path, &found_key); 894 ret = inode_ref_info(parent, 0, fs_root, path, &found_key);
895 if (ret > 0)
896 ret = -ENOENT;
895 if (ret) 897 if (ret)
896 break; 898 break;
897 next_inum = found_key.offset; 899 next_inum = found_key.offset;
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index b669a7d8e499..d986824bb2b4 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -644,7 +644,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
644static int btrfsic_process_superblock(struct btrfsic_state *state, 644static int btrfsic_process_superblock(struct btrfsic_state *state,
645 struct btrfs_fs_devices *fs_devices) 645 struct btrfs_fs_devices *fs_devices)
646{ 646{
647 int ret; 647 int ret = 0;
648 struct btrfs_super_block *selected_super; 648 struct btrfs_super_block *selected_super;
649 struct list_head *dev_head = &fs_devices->devices; 649 struct list_head *dev_head = &fs_devices->devices;
650 struct btrfs_device *device; 650 struct btrfs_device *device;
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 14f1c5a0b2d2..d02c27cd14c7 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
588 page_offset(bio->bi_io_vec->bv_page), 588 page_offset(bio->bi_io_vec->bv_page),
589 PAGE_CACHE_SIZE); 589 PAGE_CACHE_SIZE);
590 read_unlock(&em_tree->lock); 590 read_unlock(&em_tree->lock);
591 if (!em)
592 return -EIO;
591 593
592 compressed_len = em->block_len; 594 compressed_len = em->block_len;
593 cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); 595 cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 27ebe61d3ccc..80b6486fd5e6 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -886,7 +886,7 @@ struct btrfs_block_rsv {
886 u64 reserved; 886 u64 reserved;
887 struct btrfs_space_info *space_info; 887 struct btrfs_space_info *space_info;
888 spinlock_t lock; 888 spinlock_t lock;
889 unsigned int full:1; 889 unsigned int full;
890}; 890};
891 891
892/* 892/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 811d9f918b1c..534266fe505f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2260,6 +2260,12 @@ int open_ctree(struct super_block *sb,
2260 goto fail_sb_buffer; 2260 goto fail_sb_buffer;
2261 } 2261 }
2262 2262
2263 if (sectorsize < PAGE_SIZE) {
2264 printk(KERN_WARNING "btrfs: Incompatible sector size "
2265 "found on %s\n", sb->s_id);
2266 goto fail_sb_buffer;
2267 }
2268
2263 mutex_lock(&fs_info->chunk_mutex); 2269 mutex_lock(&fs_info->chunk_mutex);
2264 ret = btrfs_read_sys_array(tree_root); 2270 ret = btrfs_read_sys_array(tree_root);
2265 mutex_unlock(&fs_info->chunk_mutex); 2271 mutex_unlock(&fs_info->chunk_mutex);
@@ -2301,6 +2307,12 @@ int open_ctree(struct super_block *sb,
2301 2307
2302 btrfs_close_extra_devices(fs_devices); 2308 btrfs_close_extra_devices(fs_devices);
2303 2309
2310 if (!fs_devices->latest_bdev) {
2311 printk(KERN_CRIT "btrfs: failed to read devices on %s\n",
2312 sb->s_id);
2313 goto fail_tree_roots;
2314 }
2315
2304retry_root_backup: 2316retry_root_backup:
2305 blocksize = btrfs_level_size(tree_root, 2317 blocksize = btrfs_level_size(tree_root,
2306 btrfs_super_root_level(disk_super)); 2318 btrfs_super_root_level(disk_super));
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 283af7a676a3..37e0a800d34e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3312,7 +3312,8 @@ commit_trans:
3312 } 3312 }
3313 data_sinfo->bytes_may_use += bytes; 3313 data_sinfo->bytes_may_use += bytes;
3314 trace_btrfs_space_reservation(root->fs_info, "space_info", 3314 trace_btrfs_space_reservation(root->fs_info, "space_info",
3315 (u64)data_sinfo, bytes, 1); 3315 (u64)(unsigned long)data_sinfo,
3316 bytes, 1);
3316 spin_unlock(&data_sinfo->lock); 3317 spin_unlock(&data_sinfo->lock);
3317 3318
3318 return 0; 3319 return 0;
@@ -3333,7 +3334,8 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes)
3333 spin_lock(&data_sinfo->lock); 3334 spin_lock(&data_sinfo->lock);
3334 data_sinfo->bytes_may_use -= bytes; 3335 data_sinfo->bytes_may_use -= bytes;
3335 trace_btrfs_space_reservation(root->fs_info, "space_info", 3336 trace_btrfs_space_reservation(root->fs_info, "space_info",
3336 (u64)data_sinfo, bytes, 0); 3337 (u64)(unsigned long)data_sinfo,
3338 bytes, 0);
3337 spin_unlock(&data_sinfo->lock); 3339 spin_unlock(&data_sinfo->lock);
3338} 3340}
3339 3341
@@ -3611,12 +3613,15 @@ static int may_commit_transaction(struct btrfs_root *root,
3611 if (space_info != delayed_rsv->space_info) 3613 if (space_info != delayed_rsv->space_info)
3612 return -ENOSPC; 3614 return -ENOSPC;
3613 3615
3616 spin_lock(&space_info->lock);
3614 spin_lock(&delayed_rsv->lock); 3617 spin_lock(&delayed_rsv->lock);
3615 if (delayed_rsv->size < bytes) { 3618 if (space_info->bytes_pinned + delayed_rsv->size < bytes) {
3616 spin_unlock(&delayed_rsv->lock); 3619 spin_unlock(&delayed_rsv->lock);
3620 spin_unlock(&space_info->lock);
3617 return -ENOSPC; 3621 return -ENOSPC;
3618 } 3622 }
3619 spin_unlock(&delayed_rsv->lock); 3623 spin_unlock(&delayed_rsv->lock);
3624 spin_unlock(&space_info->lock);
3620 3625
3621commit: 3626commit:
3622 trans = btrfs_join_transaction(root); 3627 trans = btrfs_join_transaction(root);
@@ -3695,9 +3700,9 @@ again:
3695 if (used + orig_bytes <= space_info->total_bytes) { 3700 if (used + orig_bytes <= space_info->total_bytes) {
3696 space_info->bytes_may_use += orig_bytes; 3701 space_info->bytes_may_use += orig_bytes;
3697 trace_btrfs_space_reservation(root->fs_info, 3702 trace_btrfs_space_reservation(root->fs_info,
3698 "space_info", 3703 "space_info",
3699 (u64)space_info, 3704 (u64)(unsigned long)space_info,
3700 orig_bytes, 1); 3705 orig_bytes, 1);
3701 ret = 0; 3706 ret = 0;
3702 } else { 3707 } else {
3703 /* 3708 /*
@@ -3766,9 +3771,9 @@ again:
3766 if (used + num_bytes < space_info->total_bytes + avail) { 3771 if (used + num_bytes < space_info->total_bytes + avail) {
3767 space_info->bytes_may_use += orig_bytes; 3772 space_info->bytes_may_use += orig_bytes;
3768 trace_btrfs_space_reservation(root->fs_info, 3773 trace_btrfs_space_reservation(root->fs_info,
3769 "space_info", 3774 "space_info",
3770 (u64)space_info, 3775 (u64)(unsigned long)space_info,
3771 orig_bytes, 1); 3776 orig_bytes, 1);
3772 ret = 0; 3777 ret = 0;
3773 } else { 3778 } else {
3774 wait_ordered = true; 3779 wait_ordered = true;
@@ -3913,8 +3918,8 @@ static void block_rsv_release_bytes(struct btrfs_fs_info *fs_info,
3913 spin_lock(&space_info->lock); 3918 spin_lock(&space_info->lock);
3914 space_info->bytes_may_use -= num_bytes; 3919 space_info->bytes_may_use -= num_bytes;
3915 trace_btrfs_space_reservation(fs_info, "space_info", 3920 trace_btrfs_space_reservation(fs_info, "space_info",
3916 (u64)space_info, 3921 (u64)(unsigned long)space_info,
3917 num_bytes, 0); 3922 num_bytes, 0);
3918 space_info->reservation_progress++; 3923 space_info->reservation_progress++;
3919 spin_unlock(&space_info->lock); 3924 spin_unlock(&space_info->lock);
3920 } 3925 }
@@ -4105,7 +4110,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info)
4105 num_bytes += div64_u64(data_used + meta_used, 50); 4110 num_bytes += div64_u64(data_used + meta_used, 50);
4106 4111
4107 if (num_bytes * 3 > meta_used) 4112 if (num_bytes * 3 > meta_used)
4108 num_bytes = div64_u64(meta_used, 3); 4113 num_bytes = div64_u64(meta_used, 3) * 2;
4109 4114
4110 return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10); 4115 return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10);
4111} 4116}
@@ -4132,14 +4137,14 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
4132 block_rsv->reserved += num_bytes; 4137 block_rsv->reserved += num_bytes;
4133 sinfo->bytes_may_use += num_bytes; 4138 sinfo->bytes_may_use += num_bytes;
4134 trace_btrfs_space_reservation(fs_info, "space_info", 4139 trace_btrfs_space_reservation(fs_info, "space_info",
4135 (u64)sinfo, num_bytes, 1); 4140 (u64)(unsigned long)sinfo, num_bytes, 1);
4136 } 4141 }
4137 4142
4138 if (block_rsv->reserved >= block_rsv->size) { 4143 if (block_rsv->reserved >= block_rsv->size) {
4139 num_bytes = block_rsv->reserved - block_rsv->size; 4144 num_bytes = block_rsv->reserved - block_rsv->size;
4140 sinfo->bytes_may_use -= num_bytes; 4145 sinfo->bytes_may_use -= num_bytes;
4141 trace_btrfs_space_reservation(fs_info, "space_info", 4146 trace_btrfs_space_reservation(fs_info, "space_info",
4142 (u64)sinfo, num_bytes, 0); 4147 (u64)(unsigned long)sinfo, num_bytes, 0);
4143 sinfo->reservation_progress++; 4148 sinfo->reservation_progress++;
4144 block_rsv->reserved = block_rsv->size; 4149 block_rsv->reserved = block_rsv->size;
4145 block_rsv->full = 1; 4150 block_rsv->full = 1;
@@ -4192,7 +4197,8 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
4192 if (!trans->bytes_reserved) 4197 if (!trans->bytes_reserved)
4193 return; 4198 return;
4194 4199
4195 trace_btrfs_space_reservation(root->fs_info, "transaction", (u64)trans, 4200 trace_btrfs_space_reservation(root->fs_info, "transaction",
4201 (u64)(unsigned long)trans,
4196 trans->bytes_reserved, 0); 4202 trans->bytes_reserved, 0);
4197 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); 4203 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved);
4198 trans->bytes_reserved = 0; 4204 trans->bytes_reserved = 0;
@@ -4710,9 +4716,9 @@ static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
4710 space_info->bytes_reserved += num_bytes; 4716 space_info->bytes_reserved += num_bytes;
4711 if (reserve == RESERVE_ALLOC) { 4717 if (reserve == RESERVE_ALLOC) {
4712 trace_btrfs_space_reservation(cache->fs_info, 4718 trace_btrfs_space_reservation(cache->fs_info,
4713 "space_info", 4719 "space_info",
4714 (u64)space_info, 4720 (u64)(unsigned long)space_info,
4715 num_bytes, 0); 4721 num_bytes, 0);
4716 space_info->bytes_may_use -= num_bytes; 4722 space_info->bytes_may_use -= num_bytes;
4717 } 4723 }
4718 } 4724 }
@@ -7886,9 +7892,16 @@ int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range)
7886 u64 start; 7892 u64 start;
7887 u64 end; 7893 u64 end;
7888 u64 trimmed = 0; 7894 u64 trimmed = 0;
7895 u64 total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
7889 int ret = 0; 7896 int ret = 0;
7890 7897
7891 cache = btrfs_lookup_block_group(fs_info, range->start); 7898 /*
7899 * try to trim all FS space, our block group may start from non-zero.
7900 */
7901 if (range->len == total_bytes)
7902 cache = btrfs_lookup_first_block_group(fs_info, range->start);
7903 else
7904 cache = btrfs_lookup_block_group(fs_info, range->start);
7892 7905
7893 while (cache) { 7906 while (cache) {
7894 if (cache->key.objectid >= (range->start + range->len)) { 7907 if (cache->key.objectid >= (range->start + range->len)) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fcf77e1ded40..a55fbe6252de 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -513,6 +513,15 @@ hit_next:
513 WARN_ON(state->end < start); 513 WARN_ON(state->end < start);
514 last_end = state->end; 514 last_end = state->end;
515 515
516 if (state->end < end && !need_resched())
517 next_node = rb_next(&state->rb_node);
518 else
519 next_node = NULL;
520
521 /* the state doesn't have the wanted bits, go ahead */
522 if (!(state->state & bits))
523 goto next;
524
516 /* 525 /*
517 * | ---- desired range ---- | 526 * | ---- desired range ---- |
518 * | state | or 527 * | state | or
@@ -565,20 +574,15 @@ hit_next:
565 goto out; 574 goto out;
566 } 575 }
567 576
568 if (state->end < end && prealloc && !need_resched())
569 next_node = rb_next(&state->rb_node);
570 else
571 next_node = NULL;
572
573 set |= clear_state_bit(tree, state, &bits, wake); 577 set |= clear_state_bit(tree, state, &bits, wake);
578next:
574 if (last_end == (u64)-1) 579 if (last_end == (u64)-1)
575 goto out; 580 goto out;
576 start = last_end + 1; 581 start = last_end + 1;
577 if (start <= end && next_node) { 582 if (start <= end && next_node) {
578 state = rb_entry(next_node, struct extent_state, 583 state = rb_entry(next_node, struct extent_state,
579 rb_node); 584 rb_node);
580 if (state->start == start) 585 goto hit_next;
581 goto hit_next;
582 } 586 }
583 goto search_again; 587 goto search_again;
584 588
@@ -961,8 +965,6 @@ hit_next:
961 965
962 set_state_bits(tree, state, &bits); 966 set_state_bits(tree, state, &bits);
963 clear_state_bit(tree, state, &clear_bits, 0); 967 clear_state_bit(tree, state, &clear_bits, 0);
964
965 merge_state(tree, state);
966 if (last_end == (u64)-1) 968 if (last_end == (u64)-1)
967 goto out; 969 goto out;
968 970
@@ -1007,7 +1009,6 @@ hit_next:
1007 if (state->end <= end) { 1009 if (state->end <= end) {
1008 set_state_bits(tree, state, &bits); 1010 set_state_bits(tree, state, &bits);
1009 clear_state_bit(tree, state, &clear_bits, 0); 1011 clear_state_bit(tree, state, &clear_bits, 0);
1010 merge_state(tree, state);
1011 if (last_end == (u64)-1) 1012 if (last_end == (u64)-1)
1012 goto out; 1013 goto out;
1013 start = last_end + 1; 1014 start = last_end + 1;
@@ -1068,8 +1069,6 @@ hit_next:
1068 1069
1069 set_state_bits(tree, prealloc, &bits); 1070 set_state_bits(tree, prealloc, &bits);
1070 clear_state_bit(tree, prealloc, &clear_bits, 0); 1071 clear_state_bit(tree, prealloc, &clear_bits, 0);
1071
1072 merge_state(tree, prealloc);
1073 prealloc = NULL; 1072 prealloc = NULL;
1074 goto out; 1073 goto out;
1075 } 1074 }
@@ -2154,13 +2153,46 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
2154 "this_mirror=%d, num_copies=%d, in_validation=%d\n", read_mode, 2153 "this_mirror=%d, num_copies=%d, in_validation=%d\n", read_mode,
2155 failrec->this_mirror, num_copies, failrec->in_validation); 2154 failrec->this_mirror, num_copies, failrec->in_validation);
2156 2155
2157 tree->ops->submit_bio_hook(inode, read_mode, bio, failrec->this_mirror, 2156 ret = tree->ops->submit_bio_hook(inode, read_mode, bio,
2158 failrec->bio_flags, 0); 2157 failrec->this_mirror,
2159 return 0; 2158 failrec->bio_flags, 0);
2159 return ret;
2160} 2160}
2161 2161
2162/* lots and lots of room for performance fixes in the end_bio funcs */ 2162/* lots and lots of room for performance fixes in the end_bio funcs */
2163 2163
2164int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
2165{
2166 int uptodate = (err == 0);
2167 struct extent_io_tree *tree;
2168 int ret;
2169
2170 tree = &BTRFS_I(page->mapping->host)->io_tree;
2171
2172 if (tree->ops && tree->ops->writepage_end_io_hook) {
2173 ret = tree->ops->writepage_end_io_hook(page, start,
2174 end, NULL, uptodate);
2175 if (ret)
2176 uptodate = 0;
2177 }
2178
2179 if (!uptodate && tree->ops &&
2180 tree->ops->writepage_io_failed_hook) {
2181 ret = tree->ops->writepage_io_failed_hook(NULL, page,
2182 start, end, NULL);
2183 /* Writeback already completed */
2184 if (ret == 0)
2185 return 1;
2186 }
2187
2188 if (!uptodate) {
2189 clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS);
2190 ClearPageUptodate(page);
2191 SetPageError(page);
2192 }
2193 return 0;
2194}
2195
2164/* 2196/*
2165 * after a writepage IO is done, we need to: 2197 * after a writepage IO is done, we need to:
2166 * clear the uptodate bits on error 2198 * clear the uptodate bits on error
@@ -2172,13 +2204,11 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
2172 */ 2204 */
2173static void end_bio_extent_writepage(struct bio *bio, int err) 2205static void end_bio_extent_writepage(struct bio *bio, int err)
2174{ 2206{
2175 int uptodate = err == 0;
2176 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 2207 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
2177 struct extent_io_tree *tree; 2208 struct extent_io_tree *tree;
2178 u64 start; 2209 u64 start;
2179 u64 end; 2210 u64 end;
2180 int whole_page; 2211 int whole_page;
2181 int ret;
2182 2212
2183 do { 2213 do {
2184 struct page *page = bvec->bv_page; 2214 struct page *page = bvec->bv_page;
@@ -2195,28 +2225,9 @@ static void end_bio_extent_writepage(struct bio *bio, int err)
2195 2225
2196 if (--bvec >= bio->bi_io_vec) 2226 if (--bvec >= bio->bi_io_vec)
2197 prefetchw(&bvec->bv_page->flags); 2227 prefetchw(&bvec->bv_page->flags);
2198 if (tree->ops && tree->ops->writepage_end_io_hook) {
2199 ret = tree->ops->writepage_end_io_hook(page, start,
2200 end, NULL, uptodate);
2201 if (ret)
2202 uptodate = 0;
2203 }
2204
2205 if (!uptodate && tree->ops &&
2206 tree->ops->writepage_io_failed_hook) {
2207 ret = tree->ops->writepage_io_failed_hook(bio, page,
2208 start, end, NULL);
2209 if (ret == 0) {
2210 uptodate = (err == 0);
2211 continue;
2212 }
2213 }
2214 2228
2215 if (!uptodate) { 2229 if (end_extent_writepage(page, err, start, end))
2216 clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS); 2230 continue;
2217 ClearPageUptodate(page);
2218 SetPageError(page);
2219 }
2220 2231
2221 if (whole_page) 2232 if (whole_page)
2222 end_page_writeback(page); 2233 end_page_writeback(page);
@@ -2779,9 +2790,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2779 delalloc_start = delalloc_end + 1; 2790 delalloc_start = delalloc_end + 1;
2780 continue; 2791 continue;
2781 } 2792 }
2782 tree->ops->fill_delalloc(inode, page, delalloc_start, 2793 ret = tree->ops->fill_delalloc(inode, page,
2783 delalloc_end, &page_started, 2794 delalloc_start,
2784 &nr_written); 2795 delalloc_end,
2796 &page_started,
2797 &nr_written);
2798 BUG_ON(ret);
2785 /* 2799 /*
2786 * delalloc_end is already one less than the total 2800 * delalloc_end is already one less than the total
2787 * length, so we don't subtract one from 2801 * length, so we don't subtract one from
@@ -2818,8 +2832,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2818 if (tree->ops && tree->ops->writepage_start_hook) { 2832 if (tree->ops && tree->ops->writepage_start_hook) {
2819 ret = tree->ops->writepage_start_hook(page, start, 2833 ret = tree->ops->writepage_start_hook(page, start,
2820 page_end); 2834 page_end);
2821 if (ret == -EAGAIN) { 2835 if (ret) {
2822 redirty_page_for_writepage(wbc, page); 2836 /* Fixup worker will requeue */
2837 if (ret == -EBUSY)
2838 wbc->pages_skipped++;
2839 else
2840 redirty_page_for_writepage(wbc, page);
2823 update_nr_written(page, wbc, nr_written); 2841 update_nr_written(page, wbc, nr_written);
2824 unlock_page(page); 2842 unlock_page(page);
2825 ret = 0; 2843 ret = 0;
@@ -3289,7 +3307,7 @@ int try_release_extent_mapping(struct extent_map_tree *map,
3289 len = end - start + 1; 3307 len = end - start + 1;
3290 write_lock(&map->lock); 3308 write_lock(&map->lock);
3291 em = lookup_extent_mapping(map, start, len); 3309 em = lookup_extent_mapping(map, start, len);
3292 if (IS_ERR_OR_NULL(em)) { 3310 if (!em) {
3293 write_unlock(&map->lock); 3311 write_unlock(&map->lock);
3294 break; 3312 break;
3295 } 3313 }
@@ -3853,10 +3871,9 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
3853 num_pages = num_extent_pages(eb->start, eb->len); 3871 num_pages = num_extent_pages(eb->start, eb->len);
3854 clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); 3872 clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
3855 3873
3856 if (eb_straddles_pages(eb)) { 3874 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1,
3857 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, 3875 cached_state, GFP_NOFS);
3858 cached_state, GFP_NOFS); 3876
3859 }
3860 for (i = 0; i < num_pages; i++) { 3877 for (i = 0; i < num_pages; i++) {
3861 page = extent_buffer_page(eb, i); 3878 page = extent_buffer_page(eb, i);
3862 if (page) 3879 if (page)
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index bc6a042cb6fc..cecc3518c121 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -319,4 +319,5 @@ struct btrfs_mapping_tree;
319int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start, 319int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
320 u64 length, u64 logical, struct page *page, 320 u64 length, u64 logical, struct page *page,
321 int mirror_num); 321 int mirror_num);
322int end_extent_writepage(struct page *page, int err, u64 start, u64 end);
322#endif 323#endif
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
index 33a7890b1f40..1195f09761fe 100644
--- a/fs/btrfs/extent_map.h
+++ b/fs/btrfs/extent_map.h
@@ -26,8 +26,8 @@ struct extent_map {
26 unsigned long flags; 26 unsigned long flags;
27 struct block_device *bdev; 27 struct block_device *bdev;
28 atomic_t refs; 28 atomic_t refs;
29 unsigned int in_tree:1; 29 unsigned int in_tree;
30 unsigned int compress_type:4; 30 unsigned int compress_type;
31}; 31};
32 32
33struct extent_map_tree { 33struct extent_map_tree {
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 859ba2dd8890..e8d06b6b9194 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1605,6 +1605,14 @@ static long btrfs_fallocate(struct file *file, int mode,
1605 return -EOPNOTSUPP; 1605 return -EOPNOTSUPP;
1606 1606
1607 /* 1607 /*
1608 * Make sure we have enough space before we do the
1609 * allocation.
1610 */
1611 ret = btrfs_check_data_free_space(inode, len);
1612 if (ret)
1613 return ret;
1614
1615 /*
1608 * wait for ordered IO before we have any locks. We'll loop again 1616 * wait for ordered IO before we have any locks. We'll loop again
1609 * below with the locks held. 1617 * below with the locks held.
1610 */ 1618 */
@@ -1667,27 +1675,12 @@ static long btrfs_fallocate(struct file *file, int mode,
1667 if (em->block_start == EXTENT_MAP_HOLE || 1675 if (em->block_start == EXTENT_MAP_HOLE ||
1668 (cur_offset >= inode->i_size && 1676 (cur_offset >= inode->i_size &&
1669 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { 1677 !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
1670
1671 /*
1672 * Make sure we have enough space before we do the
1673 * allocation.
1674 */
1675 ret = btrfs_check_data_free_space(inode, last_byte -
1676 cur_offset);
1677 if (ret) {
1678 free_extent_map(em);
1679 break;
1680 }
1681
1682 ret = btrfs_prealloc_file_range(inode, mode, cur_offset, 1678 ret = btrfs_prealloc_file_range(inode, mode, cur_offset,
1683 last_byte - cur_offset, 1679 last_byte - cur_offset,
1684 1 << inode->i_blkbits, 1680 1 << inode->i_blkbits,
1685 offset + len, 1681 offset + len,
1686 &alloc_hint); 1682 &alloc_hint);
1687 1683
1688 /* Let go of our reservation. */
1689 btrfs_free_reserved_data_space(inode, last_byte -
1690 cur_offset);
1691 if (ret < 0) { 1684 if (ret < 0) {
1692 free_extent_map(em); 1685 free_extent_map(em);
1693 break; 1686 break;
@@ -1715,6 +1708,8 @@ static long btrfs_fallocate(struct file *file, int mode,
1715 &cached_state, GFP_NOFS); 1708 &cached_state, GFP_NOFS);
1716out: 1709out:
1717 mutex_unlock(&inode->i_mutex); 1710 mutex_unlock(&inode->i_mutex);
1711 /* Let go of our reservation. */
1712 btrfs_free_reserved_data_space(inode, len);
1718 return ret; 1713 return ret;
1719} 1714}
1720 1715
@@ -1761,7 +1756,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
1761 start - root->sectorsize, 1756 start - root->sectorsize,
1762 root->sectorsize, 0); 1757 root->sectorsize, 0);
1763 if (IS_ERR(em)) { 1758 if (IS_ERR(em)) {
1764 ret = -ENXIO; 1759 ret = PTR_ERR(em);
1765 goto out; 1760 goto out;
1766 } 1761 }
1767 last_end = em->start + em->len; 1762 last_end = em->start + em->len;
@@ -1773,7 +1768,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
1773 while (1) { 1768 while (1) {
1774 em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0); 1769 em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0);
1775 if (IS_ERR(em)) { 1770 if (IS_ERR(em)) {
1776 ret = -ENXIO; 1771 ret = PTR_ERR(em);
1777 break; 1772 break;
1778 } 1773 }
1779 1774
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index c2f20594c9f7..710ea380c7ed 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -777,6 +777,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
777 spin_lock(&block_group->lock); 777 spin_lock(&block_group->lock);
778 if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) { 778 if (block_group->disk_cache_state != BTRFS_DC_WRITTEN) {
779 spin_unlock(&block_group->lock); 779 spin_unlock(&block_group->lock);
780 btrfs_free_path(path);
780 goto out; 781 goto out;
781 } 782 }
782 spin_unlock(&block_group->lock); 783 spin_unlock(&block_group->lock);
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 213ffa86ce1b..ee15d88b33d2 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -438,7 +438,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
438 trans->bytes_reserved); 438 trans->bytes_reserved);
439 if (ret) 439 if (ret)
440 goto out; 440 goto out;
441 trace_btrfs_space_reservation(root->fs_info, "ino_cache", (u64)trans, 441 trace_btrfs_space_reservation(root->fs_info, "ino_cache",
442 (u64)(unsigned long)trans,
442 trans->bytes_reserved, 1); 443 trans->bytes_reserved, 1);
443again: 444again:
444 inode = lookup_free_ino_inode(root, path); 445 inode = lookup_free_ino_inode(root, path);
@@ -500,7 +501,8 @@ again:
500out_put: 501out_put:
501 iput(inode); 502 iput(inode);
502out_release: 503out_release:
503 trace_btrfs_space_reservation(root->fs_info, "ino_cache", (u64)trans, 504 trace_btrfs_space_reservation(root->fs_info, "ino_cache",
505 (u64)(unsigned long)trans,
504 trans->bytes_reserved, 0); 506 trans->bytes_reserved, 0);
505 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); 507 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved);
506out: 508out:
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 32214fe0f7e3..892b34785ccc 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1555,6 +1555,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
1555 struct inode *inode; 1555 struct inode *inode;
1556 u64 page_start; 1556 u64 page_start;
1557 u64 page_end; 1557 u64 page_end;
1558 int ret;
1558 1559
1559 fixup = container_of(work, struct btrfs_writepage_fixup, work); 1560 fixup = container_of(work, struct btrfs_writepage_fixup, work);
1560 page = fixup->page; 1561 page = fixup->page;
@@ -1582,12 +1583,21 @@ again:
1582 page_end, &cached_state, GFP_NOFS); 1583 page_end, &cached_state, GFP_NOFS);
1583 unlock_page(page); 1584 unlock_page(page);
1584 btrfs_start_ordered_extent(inode, ordered, 1); 1585 btrfs_start_ordered_extent(inode, ordered, 1);
1586 btrfs_put_ordered_extent(ordered);
1585 goto again; 1587 goto again;
1586 } 1588 }
1587 1589
1588 BUG(); 1590 ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
1591 if (ret) {
1592 mapping_set_error(page->mapping, ret);
1593 end_extent_writepage(page, ret, page_start, page_end);
1594 ClearPageChecked(page);
1595 goto out;
1596 }
1597
1589 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); 1598 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state);
1590 ClearPageChecked(page); 1599 ClearPageChecked(page);
1600 set_page_dirty(page);
1591out: 1601out:
1592 unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end, 1602 unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end,
1593 &cached_state, GFP_NOFS); 1603 &cached_state, GFP_NOFS);
@@ -1630,7 +1640,7 @@ static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end)
1630 fixup->work.func = btrfs_writepage_fixup_worker; 1640 fixup->work.func = btrfs_writepage_fixup_worker;
1631 fixup->page = page; 1641 fixup->page = page;
1632 btrfs_queue_worker(&root->fs_info->fixup_workers, &fixup->work); 1642 btrfs_queue_worker(&root->fs_info->fixup_workers, &fixup->work);
1633 return -EAGAIN; 1643 return -EBUSY;
1634} 1644}
1635 1645
1636static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, 1646static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
@@ -4575,7 +4585,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4575 ret = btrfs_insert_dir_item(trans, root, name, name_len, 4585 ret = btrfs_insert_dir_item(trans, root, name, name_len,
4576 parent_inode, &key, 4586 parent_inode, &key,
4577 btrfs_inode_type(inode), index); 4587 btrfs_inode_type(inode), index);
4578 BUG_ON(ret); 4588 if (ret)
4589 goto fail_dir_item;
4579 4590
4580 btrfs_i_size_write(parent_inode, parent_inode->i_size + 4591 btrfs_i_size_write(parent_inode, parent_inode->i_size +
4581 name_len * 2); 4592 name_len * 2);
@@ -4583,6 +4594,23 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4583 ret = btrfs_update_inode(trans, root, parent_inode); 4594 ret = btrfs_update_inode(trans, root, parent_inode);
4584 } 4595 }
4585 return ret; 4596 return ret;
4597
4598fail_dir_item:
4599 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
4600 u64 local_index;
4601 int err;
4602 err = btrfs_del_root_ref(trans, root->fs_info->tree_root,
4603 key.objectid, root->root_key.objectid,
4604 parent_ino, &local_index, name, name_len);
4605
4606 } else if (add_backref) {
4607 u64 local_index;
4608 int err;
4609
4610 err = btrfs_del_inode_ref(trans, root, name, name_len,
4611 ino, parent_ino, &local_index);
4612 }
4613 return ret;
4586} 4614}
4587 4615
4588static int btrfs_add_nondir(struct btrfs_trans_handle *trans, 4616static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
@@ -6696,8 +6724,10 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
6696 int err; 6724 int err;
6697 u64 index = 0; 6725 u64 index = 0;
6698 6726
6699 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid, 6727 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2,
6700 new_dirid, S_IFDIR | 0700, &index); 6728 new_dirid, new_dirid,
6729 S_IFDIR | (~current_umask() & S_IRWXUGO),
6730 &index);
6701 if (IS_ERR(inode)) 6731 if (IS_ERR(inode))
6702 return PTR_ERR(inode); 6732 return PTR_ERR(inode);
6703 inode->i_op = &btrfs_dir_inode_operations; 6733 inode->i_op = &btrfs_dir_inode_operations;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 03bb62a9ee24..d8b54715c2de 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -861,6 +861,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
861 int i_done; 861 int i_done;
862 struct btrfs_ordered_extent *ordered; 862 struct btrfs_ordered_extent *ordered;
863 struct extent_state *cached_state = NULL; 863 struct extent_state *cached_state = NULL;
864 struct extent_io_tree *tree;
864 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); 865 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
865 866
866 if (isize == 0) 867 if (isize == 0)
@@ -871,18 +872,34 @@ static int cluster_pages_for_defrag(struct inode *inode,
871 num_pages << PAGE_CACHE_SHIFT); 872 num_pages << PAGE_CACHE_SHIFT);
872 if (ret) 873 if (ret)
873 return ret; 874 return ret;
874again:
875 ret = 0;
876 i_done = 0; 875 i_done = 0;
876 tree = &BTRFS_I(inode)->io_tree;
877 877
878 /* step one, lock all the pages */ 878 /* step one, lock all the pages */
879 for (i = 0; i < num_pages; i++) { 879 for (i = 0; i < num_pages; i++) {
880 struct page *page; 880 struct page *page;
881again:
881 page = find_or_create_page(inode->i_mapping, 882 page = find_or_create_page(inode->i_mapping,
882 start_index + i, mask); 883 start_index + i, mask);
883 if (!page) 884 if (!page)
884 break; 885 break;
885 886
887 page_start = page_offset(page);
888 page_end = page_start + PAGE_CACHE_SIZE - 1;
889 while (1) {
890 lock_extent(tree, page_start, page_end, GFP_NOFS);
891 ordered = btrfs_lookup_ordered_extent(inode,
892 page_start);
893 unlock_extent(tree, page_start, page_end, GFP_NOFS);
894 if (!ordered)
895 break;
896
897 unlock_page(page);
898 btrfs_start_ordered_extent(inode, ordered, 1);
899 btrfs_put_ordered_extent(ordered);
900 lock_page(page);
901 }
902
886 if (!PageUptodate(page)) { 903 if (!PageUptodate(page)) {
887 btrfs_readpage(NULL, page); 904 btrfs_readpage(NULL, page);
888 lock_page(page); 905 lock_page(page);
@@ -893,15 +910,22 @@ again:
893 break; 910 break;
894 } 911 }
895 } 912 }
913
896 isize = i_size_read(inode); 914 isize = i_size_read(inode);
897 file_end = (isize - 1) >> PAGE_CACHE_SHIFT; 915 file_end = (isize - 1) >> PAGE_CACHE_SHIFT;
898 if (!isize || page->index > file_end || 916 if (!isize || page->index > file_end) {
899 page->mapping != inode->i_mapping) {
900 /* whoops, we blew past eof, skip this page */ 917 /* whoops, we blew past eof, skip this page */
901 unlock_page(page); 918 unlock_page(page);
902 page_cache_release(page); 919 page_cache_release(page);
903 break; 920 break;
904 } 921 }
922
923 if (page->mapping != inode->i_mapping) {
924 unlock_page(page);
925 page_cache_release(page);
926 goto again;
927 }
928
905 pages[i] = page; 929 pages[i] = page;
906 i_done++; 930 i_done++;
907 } 931 }
@@ -924,25 +948,6 @@ again:
924 lock_extent_bits(&BTRFS_I(inode)->io_tree, 948 lock_extent_bits(&BTRFS_I(inode)->io_tree,
925 page_start, page_end - 1, 0, &cached_state, 949 page_start, page_end - 1, 0, &cached_state,
926 GFP_NOFS); 950 GFP_NOFS);
927 ordered = btrfs_lookup_first_ordered_extent(inode, page_end - 1);
928 if (ordered &&
929 ordered->file_offset + ordered->len > page_start &&
930 ordered->file_offset < page_end) {
931 btrfs_put_ordered_extent(ordered);
932 unlock_extent_cached(&BTRFS_I(inode)->io_tree,
933 page_start, page_end - 1,
934 &cached_state, GFP_NOFS);
935 for (i = 0; i < i_done; i++) {
936 unlock_page(pages[i]);
937 page_cache_release(pages[i]);
938 }
939 btrfs_wait_ordered_range(inode, page_start,
940 page_end - page_start);
941 goto again;
942 }
943 if (ordered)
944 btrfs_put_ordered_extent(ordered);
945
946 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, 951 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
947 page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC | 952 page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC |
948 EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, 953 EXTENT_DO_ACCOUNTING, 0, 0, &cached_state,
@@ -1327,6 +1332,12 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
1327 goto out; 1332 goto out;
1328 } 1333 }
1329 1334
1335 if (name[0] == '.' &&
1336 (namelen == 1 || (name[1] == '.' && namelen == 2))) {
1337 ret = -EEXIST;
1338 goto out;
1339 }
1340
1330 if (subvol) { 1341 if (subvol) {
1331 ret = btrfs_mksubvol(&file->f_path, name, namelen, 1342 ret = btrfs_mksubvol(&file->f_path, name, namelen,
1332 NULL, transid, readonly); 1343 NULL, transid, readonly);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 9770cc5bfb76..abc0fbffa510 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1367,7 +1367,8 @@ out:
1367} 1367}
1368 1368
1369static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev, 1369static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
1370 u64 chunk_tree, u64 chunk_objectid, u64 chunk_offset, u64 length) 1370 u64 chunk_tree, u64 chunk_objectid, u64 chunk_offset, u64 length,
1371 u64 dev_offset)
1371{ 1372{
1372 struct btrfs_mapping_tree *map_tree = 1373 struct btrfs_mapping_tree *map_tree =
1373 &sdev->dev->dev_root->fs_info->mapping_tree; 1374 &sdev->dev->dev_root->fs_info->mapping_tree;
@@ -1391,7 +1392,8 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
1391 goto out; 1392 goto out;
1392 1393
1393 for (i = 0; i < map->num_stripes; ++i) { 1394 for (i = 0; i < map->num_stripes; ++i) {
1394 if (map->stripes[i].dev == sdev->dev) { 1395 if (map->stripes[i].dev == sdev->dev &&
1396 map->stripes[i].physical == dev_offset) {
1395 ret = scrub_stripe(sdev, map, i, chunk_offset, length); 1397 ret = scrub_stripe(sdev, map, i, chunk_offset, length);
1396 if (ret) 1398 if (ret)
1397 goto out; 1399 goto out;
@@ -1487,7 +1489,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
1487 break; 1489 break;
1488 } 1490 }
1489 ret = scrub_chunk(sdev, chunk_tree, chunk_objectid, 1491 ret = scrub_chunk(sdev, chunk_tree, chunk_objectid,
1490 chunk_offset, length); 1492 chunk_offset, length, found_key.offset);
1491 btrfs_put_block_group(cache); 1493 btrfs_put_block_group(cache);
1492 if (ret) 1494 if (ret)
1493 break; 1495 break;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 287a6728b1ad..04b77e3ceb7a 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -327,7 +327,8 @@ again:
327 327
328 if (num_bytes) { 328 if (num_bytes) {
329 trace_btrfs_space_reservation(root->fs_info, "transaction", 329 trace_btrfs_space_reservation(root->fs_info, "transaction",
330 (u64)h, num_bytes, 1); 330 (u64)(unsigned long)h,
331 num_bytes, 1);
331 h->block_rsv = &root->fs_info->trans_block_rsv; 332 h->block_rsv = &root->fs_info->trans_block_rsv;
332 h->bytes_reserved = num_bytes; 333 h->bytes_reserved = num_bytes;
333 } 334 }
@@ -915,7 +916,11 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
915 dentry->d_name.name, dentry->d_name.len, 916 dentry->d_name.name, dentry->d_name.len,
916 parent_inode, &key, 917 parent_inode, &key,
917 BTRFS_FT_DIR, index); 918 BTRFS_FT_DIR, index);
918 BUG_ON(ret); 919 if (ret) {
920 pending->error = -EEXIST;
921 dput(parent);
922 goto fail;
923 }
919 924
920 btrfs_i_size_write(parent_inode, parent_inode->i_size + 925 btrfs_i_size_write(parent_inode, parent_inode->i_size +
921 dentry->d_name.len * 2); 926 dentry->d_name.len * 2);
@@ -993,12 +998,9 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
993{ 998{
994 struct btrfs_pending_snapshot *pending; 999 struct btrfs_pending_snapshot *pending;
995 struct list_head *head = &trans->transaction->pending_snapshots; 1000 struct list_head *head = &trans->transaction->pending_snapshots;
996 int ret;
997 1001
998 list_for_each_entry(pending, head, list) { 1002 list_for_each_entry(pending, head, list)
999 ret = create_pending_snapshot(trans, fs_info, pending); 1003 create_pending_snapshot(trans, fs_info, pending);
1000 BUG_ON(ret);
1001 }
1002 return 0; 1004 return 0;
1003} 1005}
1004 1006
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0b4e2af7954d..ef41f285a475 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -459,12 +459,23 @@ int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
459{ 459{
460 struct btrfs_device *device, *next; 460 struct btrfs_device *device, *next;
461 461
462 struct block_device *latest_bdev = NULL;
463 u64 latest_devid = 0;
464 u64 latest_transid = 0;
465
462 mutex_lock(&uuid_mutex); 466 mutex_lock(&uuid_mutex);
463again: 467again:
464 /* This is the initialized path, it is safe to release the devices. */ 468 /* This is the initialized path, it is safe to release the devices. */
465 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) { 469 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
466 if (device->in_fs_metadata) 470 if (device->in_fs_metadata) {
471 if (!latest_transid ||
472 device->generation > latest_transid) {
473 latest_devid = device->devid;
474 latest_transid = device->generation;
475 latest_bdev = device->bdev;
476 }
467 continue; 477 continue;
478 }
468 479
469 if (device->bdev) { 480 if (device->bdev) {
470 blkdev_put(device->bdev, device->mode); 481 blkdev_put(device->bdev, device->mode);
@@ -487,6 +498,10 @@ again:
487 goto again; 498 goto again;
488 } 499 }
489 500
501 fs_devices->latest_bdev = latest_bdev;
502 fs_devices->latest_devid = latest_devid;
503 fs_devices->latest_trans = latest_transid;
504
490 mutex_unlock(&uuid_mutex); 505 mutex_unlock(&uuid_mutex);
491 return 0; 506 return 0;
492} 507}
@@ -1953,7 +1968,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
1953 em = lookup_extent_mapping(em_tree, chunk_offset, 1); 1968 em = lookup_extent_mapping(em_tree, chunk_offset, 1);
1954 read_unlock(&em_tree->lock); 1969 read_unlock(&em_tree->lock);
1955 1970
1956 BUG_ON(em->start > chunk_offset || 1971 BUG_ON(!em || em->start > chunk_offset ||
1957 em->start + em->len < chunk_offset); 1972 em->start + em->len < chunk_offset);
1958 map = (struct map_lookup *)em->bdev; 1973 map = (struct map_lookup *)em->bdev;
1959 1974
@@ -4356,6 +4371,20 @@ int btrfs_read_sys_array(struct btrfs_root *root)
4356 return -ENOMEM; 4371 return -ENOMEM;
4357 btrfs_set_buffer_uptodate(sb); 4372 btrfs_set_buffer_uptodate(sb);
4358 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); 4373 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0);
4374 /*
4375 * The sb extent buffer is artifical and just used to read the system array.
4376 * btrfs_set_buffer_uptodate() call does not properly mark all it's
4377 * pages up-to-date when the page is larger: extent does not cover the
4378 * whole page and consequently check_page_uptodate does not find all
4379 * the page's extents up-to-date (the hole beyond sb),
4380 * write_extent_buffer then triggers a WARN_ON.
4381 *
4382 * Regular short extents go through mark_extent_buffer_dirty/writeback cycle,
4383 * but sb spans only this function. Add an explicit SetPageUptodate call
4384 * to silence the warning eg. on PowerPC 64.
4385 */
4386 if (PAGE_CACHE_SIZE > BTRFS_SUPER_INFO_SIZE)
4387 SetPageUptodate(sb->first_page);
4359 4388
4360 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE); 4389 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE);
4361 array_size = btrfs_super_sys_array_size(super_copy); 4390 array_size = btrfs_super_sys_array_size(super_copy);
diff --git a/fs/compat.c b/fs/compat.c
index fa9d721ecfee..07880bae28a9 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -131,41 +131,35 @@ asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_tim
131 131
132static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf) 132static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
133{ 133{
134 compat_ino_t ino = stat->ino; 134 struct compat_stat tmp;
135 typeof(ubuf->st_uid) uid = 0;
136 typeof(ubuf->st_gid) gid = 0;
137 int err;
138 135
139 SET_UID(uid, stat->uid); 136 if (!old_valid_dev(stat->dev) || !old_valid_dev(stat->rdev))
140 SET_GID(gid, stat->gid); 137 return -EOVERFLOW;
141 138
142 if ((u64) stat->size > MAX_NON_LFS || 139 memset(&tmp, 0, sizeof(tmp));
143 !old_valid_dev(stat->dev) || 140 tmp.st_dev = old_encode_dev(stat->dev);
144 !old_valid_dev(stat->rdev)) 141 tmp.st_ino = stat->ino;
142 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
145 return -EOVERFLOW; 143 return -EOVERFLOW;
146 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino) 144 tmp.st_mode = stat->mode;
145 tmp.st_nlink = stat->nlink;
146 if (tmp.st_nlink != stat->nlink)
147 return -EOVERFLOW; 147 return -EOVERFLOW;
148 148 SET_UID(tmp.st_uid, stat->uid);
149 if (clear_user(ubuf, sizeof(*ubuf))) 149 SET_GID(tmp.st_gid, stat->gid);
150 return -EFAULT; 150 tmp.st_rdev = old_encode_dev(stat->rdev);
151 151 if ((u64) stat->size > MAX_NON_LFS)
152 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev); 152 return -EOVERFLOW;
153 err |= __put_user(ino, &ubuf->st_ino); 153 tmp.st_size = stat->size;
154 err |= __put_user(stat->mode, &ubuf->st_mode); 154 tmp.st_atime = stat->atime.tv_sec;
155 err |= __put_user(stat->nlink, &ubuf->st_nlink); 155 tmp.st_atime_nsec = stat->atime.tv_nsec;
156 err |= __put_user(uid, &ubuf->st_uid); 156 tmp.st_mtime = stat->mtime.tv_sec;
157 err |= __put_user(gid, &ubuf->st_gid); 157 tmp.st_mtime_nsec = stat->mtime.tv_nsec;
158 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev); 158 tmp.st_ctime = stat->ctime.tv_sec;
159 err |= __put_user(stat->size, &ubuf->st_size); 159 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
160 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime); 160 tmp.st_blocks = stat->blocks;
161 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec); 161 tmp.st_blksize = stat->blksize;
162 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime); 162 return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
163 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
164 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
165 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
166 err |= __put_user(stat->blksize, &ubuf->st_blksize);
167 err |= __put_user(stat->blocks, &ubuf->st_blocks);
168 return err;
169} 163}
170 164
171asmlinkage long compat_sys_newstat(const char __user * filename, 165asmlinkage long compat_sys_newstat(const char __user * filename,
diff --git a/fs/dcache.c b/fs/dcache.c
index 16a53cc2cc02..fe19ac13f75f 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2968,7 +2968,7 @@ __setup("dhash_entries=", set_dhash_entries);
2968 2968
2969static void __init dcache_init_early(void) 2969static void __init dcache_init_early(void)
2970{ 2970{
2971 int loop; 2971 unsigned int loop;
2972 2972
2973 /* If hashes are distributed across NUMA nodes, defer 2973 /* If hashes are distributed across NUMA nodes, defer
2974 * hash allocation until vmalloc space is available. 2974 * hash allocation until vmalloc space is available.
@@ -2986,13 +2986,13 @@ static void __init dcache_init_early(void)
2986 &d_hash_mask, 2986 &d_hash_mask,
2987 0); 2987 0);
2988 2988
2989 for (loop = 0; loop < (1 << d_hash_shift); loop++) 2989 for (loop = 0; loop < (1U << d_hash_shift); loop++)
2990 INIT_HLIST_BL_HEAD(dentry_hashtable + loop); 2990 INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
2991} 2991}
2992 2992
2993static void __init dcache_init(void) 2993static void __init dcache_init(void)
2994{ 2994{
2995 int loop; 2995 unsigned int loop;
2996 2996
2997 /* 2997 /*
2998 * A constructor could be added for stable state like the lists, 2998 * A constructor could be added for stable state like the lists,
@@ -3016,7 +3016,7 @@ static void __init dcache_init(void)
3016 &d_hash_mask, 3016 &d_hash_mask,
3017 0); 3017 0);
3018 3018
3019 for (loop = 0; loop < (1 << d_hash_shift); loop++) 3019 for (loop = 0; loop < (1U << d_hash_shift); loop++)
3020 INIT_HLIST_BL_HEAD(dentry_hashtable + loop); 3020 INIT_HLIST_BL_HEAD(dentry_hashtable + loop);
3021} 3021}
3022 3022
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 4a588dbd11bf..f4aadd15b613 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -173,7 +173,7 @@ void inode_dio_wait(struct inode *inode)
173 if (atomic_read(&inode->i_dio_count)) 173 if (atomic_read(&inode->i_dio_count))
174 __inode_dio_wait(inode); 174 __inode_dio_wait(inode);
175} 175}
176EXPORT_SYMBOL_GPL(inode_dio_wait); 176EXPORT_SYMBOL(inode_dio_wait);
177 177
178/* 178/*
179 * inode_dio_done - signal finish of a direct I/O requests 179 * inode_dio_done - signal finish of a direct I/O requests
@@ -187,7 +187,7 @@ void inode_dio_done(struct inode *inode)
187 if (atomic_dec_and_test(&inode->i_dio_count)) 187 if (atomic_dec_and_test(&inode->i_dio_count))
188 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); 188 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
189} 189}
190EXPORT_SYMBOL_GPL(inode_dio_done); 190EXPORT_SYMBOL(inode_dio_done);
191 191
192/* 192/*
193 * How many pages are in the queue? 193 * How many pages are in the queue?
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index aabdfc38cf24..ea54cdef04dd 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -320,6 +320,11 @@ static inline int ep_is_linked(struct list_head *p)
320 return !list_empty(p); 320 return !list_empty(p);
321} 321}
322 322
323static inline struct eppoll_entry *ep_pwq_from_wait(wait_queue_t *p)
324{
325 return container_of(p, struct eppoll_entry, wait);
326}
327
323/* Get the "struct epitem" from a wait queue pointer */ 328/* Get the "struct epitem" from a wait queue pointer */
324static inline struct epitem *ep_item_from_wait(wait_queue_t *p) 329static inline struct epitem *ep_item_from_wait(wait_queue_t *p)
325{ 330{
@@ -467,6 +472,18 @@ static void ep_poll_safewake(wait_queue_head_t *wq)
467 put_cpu(); 472 put_cpu();
468} 473}
469 474
475static void ep_remove_wait_queue(struct eppoll_entry *pwq)
476{
477 wait_queue_head_t *whead;
478
479 rcu_read_lock();
480 /* If it is cleared by POLLFREE, it should be rcu-safe */
481 whead = rcu_dereference(pwq->whead);
482 if (whead)
483 remove_wait_queue(whead, &pwq->wait);
484 rcu_read_unlock();
485}
486
470/* 487/*
471 * This function unregisters poll callbacks from the associated file 488 * This function unregisters poll callbacks from the associated file
472 * descriptor. Must be called with "mtx" held (or "epmutex" if called from 489 * descriptor. Must be called with "mtx" held (or "epmutex" if called from
@@ -481,7 +498,7 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
481 pwq = list_first_entry(lsthead, struct eppoll_entry, llink); 498 pwq = list_first_entry(lsthead, struct eppoll_entry, llink);
482 499
483 list_del(&pwq->llink); 500 list_del(&pwq->llink);
484 remove_wait_queue(pwq->whead, &pwq->wait); 501 ep_remove_wait_queue(pwq);
485 kmem_cache_free(pwq_cache, pwq); 502 kmem_cache_free(pwq_cache, pwq);
486 } 503 }
487} 504}
@@ -842,6 +859,17 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
842 struct epitem *epi = ep_item_from_wait(wait); 859 struct epitem *epi = ep_item_from_wait(wait);
843 struct eventpoll *ep = epi->ep; 860 struct eventpoll *ep = epi->ep;
844 861
862 if ((unsigned long)key & POLLFREE) {
863 ep_pwq_from_wait(wait)->whead = NULL;
864 /*
865 * whead = NULL above can race with ep_remove_wait_queue()
866 * which can do another remove_wait_queue() after us, so we
867 * can't use __remove_wait_queue(). whead->lock is held by
868 * the caller.
869 */
870 list_del_init(&wait->task_list);
871 }
872
845 spin_lock_irqsave(&ep->lock, flags); 873 spin_lock_irqsave(&ep->lock, flags);
846 874
847 /* 875 /*
diff --git a/fs/inode.c b/fs/inode.c
index fb10d86ffad7..d3ebdbe723d0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1651,7 +1651,7 @@ __setup("ihash_entries=", set_ihash_entries);
1651 */ 1651 */
1652void __init inode_init_early(void) 1652void __init inode_init_early(void)
1653{ 1653{
1654 int loop; 1654 unsigned int loop;
1655 1655
1656 /* If hashes are distributed across NUMA nodes, defer 1656 /* If hashes are distributed across NUMA nodes, defer
1657 * hash allocation until vmalloc space is available. 1657 * hash allocation until vmalloc space is available.
@@ -1669,13 +1669,13 @@ void __init inode_init_early(void)
1669 &i_hash_mask, 1669 &i_hash_mask,
1670 0); 1670 0);
1671 1671
1672 for (loop = 0; loop < (1 << i_hash_shift); loop++) 1672 for (loop = 0; loop < (1U << i_hash_shift); loop++)
1673 INIT_HLIST_HEAD(&inode_hashtable[loop]); 1673 INIT_HLIST_HEAD(&inode_hashtable[loop]);
1674} 1674}
1675 1675
1676void __init inode_init(void) 1676void __init inode_init(void)
1677{ 1677{
1678 int loop; 1678 unsigned int loop;
1679 1679
1680 /* inode slab cache */ 1680 /* inode slab cache */
1681 inode_cachep = kmem_cache_create("inode_cache", 1681 inode_cachep = kmem_cache_create("inode_cache",
@@ -1699,7 +1699,7 @@ void __init inode_init(void)
1699 &i_hash_mask, 1699 &i_hash_mask,
1700 0); 1700 0);
1701 1701
1702 for (loop = 0; loop < (1 << i_hash_shift); loop++) 1702 for (loop = 0; loop < (1U << i_hash_shift); loop++)
1703 INIT_HLIST_HEAD(&inode_hashtable[loop]); 1703 INIT_HLIST_HEAD(&inode_hashtable[loop]);
1704} 1704}
1705 1705
diff --git a/fs/namei.c b/fs/namei.c
index 208c6aa4a989..a780ea515c47 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1095,8 +1095,10 @@ static struct dentry *d_inode_lookup(struct dentry *parent, struct dentry *dentr
1095 struct dentry *old; 1095 struct dentry *old;
1096 1096
1097 /* Don't create child dentry for a dead directory. */ 1097 /* Don't create child dentry for a dead directory. */
1098 if (unlikely(IS_DEADDIR(inode))) 1098 if (unlikely(IS_DEADDIR(inode))) {
1099 dput(dentry);
1099 return ERR_PTR(-ENOENT); 1100 return ERR_PTR(-ENOENT);
1101 }
1100 1102
1101 old = inode->i_op->lookup(inode, dentry, nd); 1103 old = inode->i_op->lookup(inode, dentry, nd);
1102 if (unlikely(old)) { 1104 if (unlikely(old)) {
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f0c849c98fe4..ec9f6ef6c5dd 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3575,8 +3575,8 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
3575 } 3575 }
3576 if (npages > 1) { 3576 if (npages > 1) {
3577 /* for decoding across pages */ 3577 /* for decoding across pages */
3578 args.acl_scratch = alloc_page(GFP_KERNEL); 3578 res.acl_scratch = alloc_page(GFP_KERNEL);
3579 if (!args.acl_scratch) 3579 if (!res.acl_scratch)
3580 goto out_free; 3580 goto out_free;
3581 } 3581 }
3582 args.acl_len = npages * PAGE_SIZE; 3582 args.acl_len = npages * PAGE_SIZE;
@@ -3612,8 +3612,8 @@ out_free:
3612 for (i = 0; i < npages; i++) 3612 for (i = 0; i < npages; i++)
3613 if (pages[i]) 3613 if (pages[i])
3614 __free_page(pages[i]); 3614 __free_page(pages[i]);
3615 if (args.acl_scratch) 3615 if (res.acl_scratch)
3616 __free_page(args.acl_scratch); 3616 __free_page(res.acl_scratch);
3617 return ret; 3617 return ret;
3618} 3618}
3619 3619
@@ -4883,8 +4883,10 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
4883 clp->cl_rpcclient->cl_auth->au_flavor); 4883 clp->cl_rpcclient->cl_auth->au_flavor);
4884 4884
4885 res.server_scope = kzalloc(sizeof(struct server_scope), GFP_KERNEL); 4885 res.server_scope = kzalloc(sizeof(struct server_scope), GFP_KERNEL);
4886 if (unlikely(!res.server_scope)) 4886 if (unlikely(!res.server_scope)) {
4887 return -ENOMEM; 4887 status = -ENOMEM;
4888 goto out;
4889 }
4888 4890
4889 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); 4891 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
4890 if (!status) 4892 if (!status)
@@ -4901,12 +4903,13 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
4901 clp->server_scope = NULL; 4903 clp->server_scope = NULL;
4902 } 4904 }
4903 4905
4904 if (!clp->server_scope) 4906 if (!clp->server_scope) {
4905 clp->server_scope = res.server_scope; 4907 clp->server_scope = res.server_scope;
4906 else 4908 goto out;
4907 kfree(res.server_scope); 4909 }
4908 } 4910 }
4909 4911 kfree(res.server_scope);
4912out:
4910 dprintk("<-- %s status= %d\n", __func__, status); 4913 dprintk("<-- %s status= %d\n", __func__, status);
4911 return status; 4914 return status;
4912} 4915}
@@ -5008,37 +5011,53 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
5008 return status; 5011 return status;
5009} 5012}
5010 5013
5014static struct nfs4_slot *nfs4_alloc_slots(u32 max_slots, gfp_t gfp_flags)
5015{
5016 return kcalloc(max_slots, sizeof(struct nfs4_slot), gfp_flags);
5017}
5018
5019static void nfs4_add_and_init_slots(struct nfs4_slot_table *tbl,
5020 struct nfs4_slot *new,
5021 u32 max_slots,
5022 u32 ivalue)
5023{
5024 struct nfs4_slot *old = NULL;
5025 u32 i;
5026
5027 spin_lock(&tbl->slot_tbl_lock);
5028 if (new) {
5029 old = tbl->slots;
5030 tbl->slots = new;
5031 tbl->max_slots = max_slots;
5032 }
5033 tbl->highest_used_slotid = -1; /* no slot is currently used */
5034 for (i = 0; i < tbl->max_slots; i++)
5035 tbl->slots[i].seq_nr = ivalue;
5036 spin_unlock(&tbl->slot_tbl_lock);
5037 kfree(old);
5038}
5039
5011/* 5040/*
5012 * Reset a slot table 5041 * (re)Initialise a slot table
5013 */ 5042 */
5014static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs, 5043static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
5015 int ivalue) 5044 u32 ivalue)
5016{ 5045{
5017 struct nfs4_slot *new = NULL; 5046 struct nfs4_slot *new = NULL;
5018 int i; 5047 int ret = -ENOMEM;
5019 int ret = 0;
5020 5048
5021 dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__, 5049 dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__,
5022 max_reqs, tbl->max_slots); 5050 max_reqs, tbl->max_slots);
5023 5051
5024 /* Does the newly negotiated max_reqs match the existing slot table? */ 5052 /* Does the newly negotiated max_reqs match the existing slot table? */
5025 if (max_reqs != tbl->max_slots) { 5053 if (max_reqs != tbl->max_slots) {
5026 ret = -ENOMEM; 5054 new = nfs4_alloc_slots(max_reqs, GFP_NOFS);
5027 new = kmalloc(max_reqs * sizeof(struct nfs4_slot),
5028 GFP_NOFS);
5029 if (!new) 5055 if (!new)
5030 goto out; 5056 goto out;
5031 ret = 0;
5032 kfree(tbl->slots);
5033 } 5057 }
5034 spin_lock(&tbl->slot_tbl_lock); 5058 ret = 0;
5035 if (new) { 5059
5036 tbl->slots = new; 5060 nfs4_add_and_init_slots(tbl, new, max_reqs, ivalue);
5037 tbl->max_slots = max_reqs;
5038 }
5039 for (i = 0; i < tbl->max_slots; ++i)
5040 tbl->slots[i].seq_nr = ivalue;
5041 spin_unlock(&tbl->slot_tbl_lock);
5042 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, 5061 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
5043 tbl, tbl->slots, tbl->max_slots); 5062 tbl, tbl->slots, tbl->max_slots);
5044out: 5063out:
@@ -5061,36 +5080,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session)
5061} 5080}
5062 5081
5063/* 5082/*
5064 * Initialize slot table
5065 */
5066static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
5067 int max_slots, int ivalue)
5068{
5069 struct nfs4_slot *slot;
5070 int ret = -ENOMEM;
5071
5072 BUG_ON(max_slots > NFS4_MAX_SLOT_TABLE);
5073
5074 dprintk("--> %s: max_reqs=%u\n", __func__, max_slots);
5075
5076 slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_NOFS);
5077 if (!slot)
5078 goto out;
5079 ret = 0;
5080
5081 spin_lock(&tbl->slot_tbl_lock);
5082 tbl->max_slots = max_slots;
5083 tbl->slots = slot;
5084 tbl->highest_used_slotid = -1; /* no slot is currently used */
5085 spin_unlock(&tbl->slot_tbl_lock);
5086 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
5087 tbl, tbl->slots, tbl->max_slots);
5088out:
5089 dprintk("<-- %s: return %d\n", __func__, ret);
5090 return ret;
5091}
5092
5093/*
5094 * Initialize or reset the forechannel and backchannel tables 5083 * Initialize or reset the forechannel and backchannel tables
5095 */ 5084 */
5096static int nfs4_setup_session_slot_tables(struct nfs4_session *ses) 5085static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
@@ -5101,25 +5090,16 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
5101 dprintk("--> %s\n", __func__); 5090 dprintk("--> %s\n", __func__);
5102 /* Fore channel */ 5091 /* Fore channel */
5103 tbl = &ses->fc_slot_table; 5092 tbl = &ses->fc_slot_table;
5104 if (tbl->slots == NULL) { 5093 status = nfs4_realloc_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
5105 status = nfs4_init_slot_table(tbl, ses->fc_attrs.max_reqs, 1); 5094 if (status) /* -ENOMEM */
5106 if (status) /* -ENOMEM */ 5095 return status;
5107 return status;
5108 } else {
5109 status = nfs4_reset_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
5110 if (status)
5111 return status;
5112 }
5113 /* Back channel */ 5096 /* Back channel */
5114 tbl = &ses->bc_slot_table; 5097 tbl = &ses->bc_slot_table;
5115 if (tbl->slots == NULL) { 5098 status = nfs4_realloc_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
5116 status = nfs4_init_slot_table(tbl, ses->bc_attrs.max_reqs, 0); 5099 if (status && tbl->slots == NULL)
5117 if (status) 5100 /* Fore and back channel share a connection so get
5118 /* Fore and back channel share a connection so get 5101 * both slot tables or neither */
5119 * both slot tables or neither */ 5102 nfs4_destroy_slot_tables(ses);
5120 nfs4_destroy_slot_tables(ses);
5121 } else
5122 status = nfs4_reset_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
5123 return status; 5103 return status;
5124} 5104}
5125 5105
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index a53f33b4ac3a..45392032e7bd 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1132,6 +1132,8 @@ void nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4
1132{ 1132{
1133 struct nfs_client *clp = server->nfs_client; 1133 struct nfs_client *clp = server->nfs_client;
1134 1134
1135 if (test_and_clear_bit(NFS_DELEGATED_STATE, &state->flags))
1136 nfs_async_inode_return_delegation(state->inode, &state->stateid);
1135 nfs4_state_mark_reclaim_nograce(clp, state); 1137 nfs4_state_mark_reclaim_nograce(clp, state);
1136 nfs4_schedule_state_manager(clp); 1138 nfs4_schedule_state_manager(clp);
1137} 1139}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 95e92e438407..33bd8d0f745d 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -2522,7 +2522,6 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2522 2522
2523 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, 2523 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2524 args->acl_pages, args->acl_pgbase, args->acl_len); 2524 args->acl_pages, args->acl_pgbase, args->acl_len);
2525 xdr_set_scratch_buffer(xdr, page_address(args->acl_scratch), PAGE_SIZE);
2526 2525
2527 encode_nops(&hdr); 2526 encode_nops(&hdr);
2528} 2527}
@@ -6032,6 +6031,10 @@ nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
6032 struct compound_hdr hdr; 6031 struct compound_hdr hdr;
6033 int status; 6032 int status;
6034 6033
6034 if (res->acl_scratch != NULL) {
6035 void *p = page_address(res->acl_scratch);
6036 xdr_set_scratch_buffer(xdr, p, PAGE_SIZE);
6037 }
6035 status = decode_compound_hdr(xdr, &hdr); 6038 status = decode_compound_hdr(xdr, &hdr);
6036 if (status) 6039 if (status)
6037 goto out; 6040 goto out;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index be244692550d..a9856e3eaaf0 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1053,7 +1053,7 @@ static int ocfs2_rename(struct inode *old_dir,
1053 handle_t *handle = NULL; 1053 handle_t *handle = NULL;
1054 struct buffer_head *old_dir_bh = NULL; 1054 struct buffer_head *old_dir_bh = NULL;
1055 struct buffer_head *new_dir_bh = NULL; 1055 struct buffer_head *new_dir_bh = NULL;
1056 nlink_t old_dir_nlink = old_dir->i_nlink; 1056 u32 old_dir_nlink = old_dir->i_nlink;
1057 struct ocfs2_dinode *old_di; 1057 struct ocfs2_dinode *old_di;
1058 struct ocfs2_dir_lookup_result old_inode_dot_dot_res = { NULL, }; 1058 struct ocfs2_dir_lookup_result old_inode_dot_dot_res = { NULL, };
1059 struct ocfs2_dir_lookup_result target_lookup_res = { NULL, }; 1059 struct ocfs2_dir_lookup_result target_lookup_res = { NULL, };
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 7898cd688a00..fc2c4388d126 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -292,11 +292,26 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
292 } 292 }
293} 293}
294 294
295/* Return 1 if 'cmd' will block on frozen filesystem */
296static int quotactl_cmd_write(int cmd)
297{
298 switch (cmd) {
299 case Q_GETFMT:
300 case Q_GETINFO:
301 case Q_SYNC:
302 case Q_XGETQSTAT:
303 case Q_XGETQUOTA:
304 case Q_XQUOTASYNC:
305 return 0;
306 }
307 return 1;
308}
309
295/* 310/*
296 * look up a superblock on which quota ops will be performed 311 * look up a superblock on which quota ops will be performed
297 * - use the name of a block device to find the superblock thereon 312 * - use the name of a block device to find the superblock thereon
298 */ 313 */
299static struct super_block *quotactl_block(const char __user *special) 314static struct super_block *quotactl_block(const char __user *special, int cmd)
300{ 315{
301#ifdef CONFIG_BLOCK 316#ifdef CONFIG_BLOCK
302 struct block_device *bdev; 317 struct block_device *bdev;
@@ -309,7 +324,10 @@ static struct super_block *quotactl_block(const char __user *special)
309 putname(tmp); 324 putname(tmp);
310 if (IS_ERR(bdev)) 325 if (IS_ERR(bdev))
311 return ERR_CAST(bdev); 326 return ERR_CAST(bdev);
312 sb = get_super(bdev); 327 if (quotactl_cmd_write(cmd))
328 sb = get_super_thawed(bdev);
329 else
330 sb = get_super(bdev);
313 bdput(bdev); 331 bdput(bdev);
314 if (!sb) 332 if (!sb)
315 return ERR_PTR(-ENODEV); 333 return ERR_PTR(-ENODEV);
@@ -361,7 +379,7 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
361 pathp = &path; 379 pathp = &path;
362 } 380 }
363 381
364 sb = quotactl_block(special); 382 sb = quotactl_block(special, cmds);
365 if (IS_ERR(sb)) { 383 if (IS_ERR(sb)) {
366 ret = PTR_ERR(sb); 384 ret = PTR_ERR(sb);
367 goto out; 385 goto out;
diff --git a/fs/select.c b/fs/select.c
index d33418fdc858..e782258d0de3 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -912,7 +912,7 @@ static long do_restart_poll(struct restart_block *restart_block)
912} 912}
913 913
914SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, 914SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
915 long, timeout_msecs) 915 int, timeout_msecs)
916{ 916{
917 struct timespec end_time, *to = NULL; 917 struct timespec end_time, *to = NULL;
918 int ret; 918 int ret;
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 492465b451dd..7ae2a574cb25 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -30,6 +30,21 @@
30#include <linux/signalfd.h> 30#include <linux/signalfd.h>
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32 32
33void signalfd_cleanup(struct sighand_struct *sighand)
34{
35 wait_queue_head_t *wqh = &sighand->signalfd_wqh;
36 /*
37 * The lockless check can race with remove_wait_queue() in progress,
38 * but in this case its caller should run under rcu_read_lock() and
39 * sighand_cachep is SLAB_DESTROY_BY_RCU, we can safely return.
40 */
41 if (likely(!waitqueue_active(wqh)))
42 return;
43
44 /* wait_queue_t->func(POLLFREE) should do remove_wait_queue() */
45 wake_up_poll(wqh, POLLHUP | POLLFREE);
46}
47
33struct signalfd_ctx { 48struct signalfd_ctx {
34 sigset_t sigmask; 49 sigset_t sigmask;
35}; 50};
diff --git a/fs/super.c b/fs/super.c
index 6015c02296b7..6277ec6cb60a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -634,6 +634,28 @@ rescan:
634EXPORT_SYMBOL(get_super); 634EXPORT_SYMBOL(get_super);
635 635
636/** 636/**
637 * get_super_thawed - get thawed superblock of a device
638 * @bdev: device to get the superblock for
639 *
640 * Scans the superblock list and finds the superblock of the file system
641 * mounted on the device. The superblock is returned once it is thawed
642 * (or immediately if it was not frozen). %NULL is returned if no match
643 * is found.
644 */
645struct super_block *get_super_thawed(struct block_device *bdev)
646{
647 while (1) {
648 struct super_block *s = get_super(bdev);
649 if (!s || s->s_frozen == SB_UNFROZEN)
650 return s;
651 up_read(&s->s_umount);
652 vfs_check_frozen(s, SB_FREEZE_WRITE);
653 put_super(s);
654 }
655}
656EXPORT_SYMBOL(get_super_thawed);
657
658/**
637 * get_active_super - get an active reference to the superblock of a device 659 * get_active_super - get an active reference to the superblock of a device
638 * @bdev: device to get the superblock for 660 * @bdev: device to get the superblock for
639 * 661 *
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index cbcb7bea38e2..53db20ee3e77 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -139,10 +139,10 @@ xfs_qm_adjust_dqtimers(
139 139
140 if (!d->d_btimer) { 140 if (!d->d_btimer) {
141 if ((d->d_blk_softlimit && 141 if ((d->d_blk_softlimit &&
142 (be64_to_cpu(d->d_bcount) >= 142 (be64_to_cpu(d->d_bcount) >
143 be64_to_cpu(d->d_blk_softlimit))) || 143 be64_to_cpu(d->d_blk_softlimit))) ||
144 (d->d_blk_hardlimit && 144 (d->d_blk_hardlimit &&
145 (be64_to_cpu(d->d_bcount) >= 145 (be64_to_cpu(d->d_bcount) >
146 be64_to_cpu(d->d_blk_hardlimit)))) { 146 be64_to_cpu(d->d_blk_hardlimit)))) {
147 d->d_btimer = cpu_to_be32(get_seconds() + 147 d->d_btimer = cpu_to_be32(get_seconds() +
148 mp->m_quotainfo->qi_btimelimit); 148 mp->m_quotainfo->qi_btimelimit);
@@ -151,10 +151,10 @@ xfs_qm_adjust_dqtimers(
151 } 151 }
152 } else { 152 } else {
153 if ((!d->d_blk_softlimit || 153 if ((!d->d_blk_softlimit ||
154 (be64_to_cpu(d->d_bcount) < 154 (be64_to_cpu(d->d_bcount) <=
155 be64_to_cpu(d->d_blk_softlimit))) && 155 be64_to_cpu(d->d_blk_softlimit))) &&
156 (!d->d_blk_hardlimit || 156 (!d->d_blk_hardlimit ||
157 (be64_to_cpu(d->d_bcount) < 157 (be64_to_cpu(d->d_bcount) <=
158 be64_to_cpu(d->d_blk_hardlimit)))) { 158 be64_to_cpu(d->d_blk_hardlimit)))) {
159 d->d_btimer = 0; 159 d->d_btimer = 0;
160 } 160 }
@@ -162,10 +162,10 @@ xfs_qm_adjust_dqtimers(
162 162
163 if (!d->d_itimer) { 163 if (!d->d_itimer) {
164 if ((d->d_ino_softlimit && 164 if ((d->d_ino_softlimit &&
165 (be64_to_cpu(d->d_icount) >= 165 (be64_to_cpu(d->d_icount) >
166 be64_to_cpu(d->d_ino_softlimit))) || 166 be64_to_cpu(d->d_ino_softlimit))) ||
167 (d->d_ino_hardlimit && 167 (d->d_ino_hardlimit &&
168 (be64_to_cpu(d->d_icount) >= 168 (be64_to_cpu(d->d_icount) >
169 be64_to_cpu(d->d_ino_hardlimit)))) { 169 be64_to_cpu(d->d_ino_hardlimit)))) {
170 d->d_itimer = cpu_to_be32(get_seconds() + 170 d->d_itimer = cpu_to_be32(get_seconds() +
171 mp->m_quotainfo->qi_itimelimit); 171 mp->m_quotainfo->qi_itimelimit);
@@ -174,10 +174,10 @@ xfs_qm_adjust_dqtimers(
174 } 174 }
175 } else { 175 } else {
176 if ((!d->d_ino_softlimit || 176 if ((!d->d_ino_softlimit ||
177 (be64_to_cpu(d->d_icount) < 177 (be64_to_cpu(d->d_icount) <=
178 be64_to_cpu(d->d_ino_softlimit))) && 178 be64_to_cpu(d->d_ino_softlimit))) &&
179 (!d->d_ino_hardlimit || 179 (!d->d_ino_hardlimit ||
180 (be64_to_cpu(d->d_icount) < 180 (be64_to_cpu(d->d_icount) <=
181 be64_to_cpu(d->d_ino_hardlimit)))) { 181 be64_to_cpu(d->d_ino_hardlimit)))) {
182 d->d_itimer = 0; 182 d->d_itimer = 0;
183 } 183 }
@@ -185,10 +185,10 @@ xfs_qm_adjust_dqtimers(
185 185
186 if (!d->d_rtbtimer) { 186 if (!d->d_rtbtimer) {
187 if ((d->d_rtb_softlimit && 187 if ((d->d_rtb_softlimit &&
188 (be64_to_cpu(d->d_rtbcount) >= 188 (be64_to_cpu(d->d_rtbcount) >
189 be64_to_cpu(d->d_rtb_softlimit))) || 189 be64_to_cpu(d->d_rtb_softlimit))) ||
190 (d->d_rtb_hardlimit && 190 (d->d_rtb_hardlimit &&
191 (be64_to_cpu(d->d_rtbcount) >= 191 (be64_to_cpu(d->d_rtbcount) >
192 be64_to_cpu(d->d_rtb_hardlimit)))) { 192 be64_to_cpu(d->d_rtb_hardlimit)))) {
193 d->d_rtbtimer = cpu_to_be32(get_seconds() + 193 d->d_rtbtimer = cpu_to_be32(get_seconds() +
194 mp->m_quotainfo->qi_rtbtimelimit); 194 mp->m_quotainfo->qi_rtbtimelimit);
@@ -197,10 +197,10 @@ xfs_qm_adjust_dqtimers(
197 } 197 }
198 } else { 198 } else {
199 if ((!d->d_rtb_softlimit || 199 if ((!d->d_rtb_softlimit ||
200 (be64_to_cpu(d->d_rtbcount) < 200 (be64_to_cpu(d->d_rtbcount) <=
201 be64_to_cpu(d->d_rtb_softlimit))) && 201 be64_to_cpu(d->d_rtb_softlimit))) &&
202 (!d->d_rtb_hardlimit || 202 (!d->d_rtb_hardlimit ||
203 (be64_to_cpu(d->d_rtbcount) < 203 (be64_to_cpu(d->d_rtbcount) <=
204 be64_to_cpu(d->d_rtb_hardlimit)))) { 204 be64_to_cpu(d->d_rtb_hardlimit)))) {
205 d->d_rtbtimer = 0; 205 d->d_rtbtimer = 0;
206 } 206 }
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 15ff5392fb65..0ed9ee77937c 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1981,7 +1981,7 @@ xfs_qm_dqcheck(
1981 1981
1982 if (!errs && ddq->d_id) { 1982 if (!errs && ddq->d_id) {
1983 if (ddq->d_blk_softlimit && 1983 if (ddq->d_blk_softlimit &&
1984 be64_to_cpu(ddq->d_bcount) >= 1984 be64_to_cpu(ddq->d_bcount) >
1985 be64_to_cpu(ddq->d_blk_softlimit)) { 1985 be64_to_cpu(ddq->d_blk_softlimit)) {
1986 if (!ddq->d_btimer) { 1986 if (!ddq->d_btimer) {
1987 if (flags & XFS_QMOPT_DOWARN) 1987 if (flags & XFS_QMOPT_DOWARN)
@@ -1992,7 +1992,7 @@ xfs_qm_dqcheck(
1992 } 1992 }
1993 } 1993 }
1994 if (ddq->d_ino_softlimit && 1994 if (ddq->d_ino_softlimit &&
1995 be64_to_cpu(ddq->d_icount) >= 1995 be64_to_cpu(ddq->d_icount) >
1996 be64_to_cpu(ddq->d_ino_softlimit)) { 1996 be64_to_cpu(ddq->d_ino_softlimit)) {
1997 if (!ddq->d_itimer) { 1997 if (!ddq->d_itimer) {
1998 if (flags & XFS_QMOPT_DOWARN) 1998 if (flags & XFS_QMOPT_DOWARN)
@@ -2003,7 +2003,7 @@ xfs_qm_dqcheck(
2003 } 2003 }
2004 } 2004 }
2005 if (ddq->d_rtb_softlimit && 2005 if (ddq->d_rtb_softlimit &&
2006 be64_to_cpu(ddq->d_rtbcount) >= 2006 be64_to_cpu(ddq->d_rtbcount) >
2007 be64_to_cpu(ddq->d_rtb_softlimit)) { 2007 be64_to_cpu(ddq->d_rtb_softlimit)) {
2008 if (!ddq->d_rtbtimer) { 2008 if (!ddq->d_rtbtimer) {
2009 if (flags & XFS_QMOPT_DOWARN) 2009 if (flags & XFS_QMOPT_DOWARN)
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index eafbcff81f3a..711a86e39ff0 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -813,11 +813,11 @@ xfs_qm_export_dquot(
813 (XFS_IS_OQUOTA_ENFORCED(mp) && 813 (XFS_IS_OQUOTA_ENFORCED(mp) &&
814 (dst->d_flags & (FS_PROJ_QUOTA | FS_GROUP_QUOTA)))) && 814 (dst->d_flags & (FS_PROJ_QUOTA | FS_GROUP_QUOTA)))) &&
815 dst->d_id != 0) { 815 dst->d_id != 0) {
816 if (((int) dst->d_bcount >= (int) dst->d_blk_softlimit) && 816 if (((int) dst->d_bcount > (int) dst->d_blk_softlimit) &&
817 (dst->d_blk_softlimit > 0)) { 817 (dst->d_blk_softlimit > 0)) {
818 ASSERT(dst->d_btimer != 0); 818 ASSERT(dst->d_btimer != 0);
819 } 819 }
820 if (((int) dst->d_icount >= (int) dst->d_ino_softlimit) && 820 if (((int) dst->d_icount > (int) dst->d_ino_softlimit) &&
821 (dst->d_ino_softlimit > 0)) { 821 (dst->d_ino_softlimit > 0)) {
822 ASSERT(dst->d_itimer != 0); 822 ASSERT(dst->d_itimer != 0);
823 } 823 }
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 329b06aba1c2..7adcdf15ae0c 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1151,8 +1151,8 @@ xfs_trans_add_item(
1151{ 1151{
1152 struct xfs_log_item_desc *lidp; 1152 struct xfs_log_item_desc *lidp;
1153 1153
1154 ASSERT(lip->li_mountp = tp->t_mountp); 1154 ASSERT(lip->li_mountp == tp->t_mountp);
1155 ASSERT(lip->li_ailp = tp->t_mountp->m_ail); 1155 ASSERT(lip->li_ailp == tp->t_mountp->m_ail);
1156 1156
1157 lidp = kmem_zone_zalloc(xfs_log_item_desc_zone, KM_SLEEP | KM_NOFS); 1157 lidp = kmem_zone_zalloc(xfs_log_item_desc_zone, KM_SLEEP | KM_NOFS);
1158 1158
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 4d00ee67792d..c4ba366d24e6 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -649,12 +649,12 @@ xfs_trans_dqresv(
649 * nblks. 649 * nblks.
650 */ 650 */
651 if (hardlimit > 0ULL && 651 if (hardlimit > 0ULL &&
652 hardlimit <= nblks + *resbcountp) { 652 hardlimit < nblks + *resbcountp) {
653 xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN); 653 xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
654 goto error_return; 654 goto error_return;
655 } 655 }
656 if (softlimit > 0ULL && 656 if (softlimit > 0ULL &&
657 softlimit <= nblks + *resbcountp) { 657 softlimit < nblks + *resbcountp) {
658 if ((timer != 0 && get_seconds() > timer) || 658 if ((timer != 0 && get_seconds() > timer) ||
659 (warns != 0 && warns >= warnlimit)) { 659 (warns != 0 && warns >= warnlimit)) {
660 xfs_quota_warn(mp, dqp, 660 xfs_quota_warn(mp, dqp,
@@ -677,11 +677,13 @@ xfs_trans_dqresv(
677 if (!softlimit) 677 if (!softlimit)
678 softlimit = q->qi_isoftlimit; 678 softlimit = q->qi_isoftlimit;
679 679
680 if (hardlimit > 0ULL && count >= hardlimit) { 680 if (hardlimit > 0ULL &&
681 hardlimit < ninos + count) {
681 xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN); 682 xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
682 goto error_return; 683 goto error_return;
683 } 684 }
684 if (softlimit > 0ULL && count >= softlimit) { 685 if (softlimit > 0ULL &&
686 softlimit < ninos + count) {
685 if ((timer != 0 && get_seconds() > timer) || 687 if ((timer != 0 && get_seconds() > timer) ||
686 (warns != 0 && warns >= warnlimit)) { 688 (warns != 0 && warns >= warnlimit)) {
687 xfs_quota_warn(mp, dqp, 689 xfs_quota_warn(mp, dqp,
diff --git a/include/asm-generic/io-64-nonatomic-hi-lo.h b/include/asm-generic/io-64-nonatomic-hi-lo.h
new file mode 100644
index 000000000000..a6806a94250d
--- /dev/null
+++ b/include/asm-generic/io-64-nonatomic-hi-lo.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_IO_64_NONATOMIC_HI_LO_H_
2#define _ASM_IO_64_NONATOMIC_HI_LO_H_
3
4#include <linux/io.h>
5#include <asm-generic/int-ll64.h>
6
7#ifndef readq
8static inline __u64 readq(const volatile void __iomem *addr)
9{
10 const volatile u32 __iomem *p = addr;
11 u32 low, high;
12
13 high = readl(p + 1);
14 low = readl(p);
15
16 return low + ((u64)high << 32);
17}
18#endif
19
20#ifndef writeq
21static inline void writeq(__u64 val, volatile void __iomem *addr)
22{
23 writel(val >> 32, addr + 4);
24 writel(val, addr);
25}
26#endif
27
28#endif /* _ASM_IO_64_NONATOMIC_HI_LO_H_ */
diff --git a/include/asm-generic/io-64-nonatomic-lo-hi.h b/include/asm-generic/io-64-nonatomic-lo-hi.h
new file mode 100644
index 000000000000..ca546b1ff8b5
--- /dev/null
+++ b/include/asm-generic/io-64-nonatomic-lo-hi.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_IO_64_NONATOMIC_LO_HI_H_
2#define _ASM_IO_64_NONATOMIC_LO_HI_H_
3
4#include <linux/io.h>
5#include <asm-generic/int-ll64.h>
6
7#ifndef readq
8static inline __u64 readq(const volatile void __iomem *addr)
9{
10 const volatile u32 __iomem *p = addr;
11 u32 low, high;
12
13 low = readl(p);
14 high = readl(p + 1);
15
16 return low + ((u64)high << 32);
17}
18#endif
19
20#ifndef writeq
21static inline void writeq(__u64 val, volatile void __iomem *addr)
22{
23 writel(val, addr);
24 writel(val >> 32, addr + 4);
25}
26#endif
27
28#endif /* _ASM_IO_64_NONATOMIC_LO_HI_H_ */
diff --git a/include/asm-generic/poll.h b/include/asm-generic/poll.h
index 44bce836d350..9ce7f44aebd2 100644
--- a/include/asm-generic/poll.h
+++ b/include/asm-generic/poll.h
@@ -28,6 +28,8 @@
28#define POLLRDHUP 0x2000 28#define POLLRDHUP 0x2000
29#endif 29#endif
30 30
31#define POLLFREE 0x4000 /* currently only for epoll */
32
31struct pollfd { 33struct pollfd {
32 int fd; 34 int fd;
33 short events; 35 short events;
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 41c9f6515f46..7e05fcee75a1 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -561,5 +561,9 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
561 unsigned long liovcnt, const struct compat_iovec __user *rvec, 561 unsigned long liovcnt, const struct compat_iovec __user *rvec,
562 unsigned long riovcnt, unsigned long flags); 562 unsigned long riovcnt, unsigned long flags);
563 563
564#else
565
566#define is_compat_task() (0)
567
564#endif /* CONFIG_COMPAT */ 568#endif /* CONFIG_COMPAT */
565#endif /* _LINUX_COMPAT_H */ 569#endif /* _LINUX_COMPAT_H */
diff --git a/include/linux/digsig.h b/include/linux/digsig.h
index b01558b15814..6f85a070bb45 100644
--- a/include/linux/digsig.h
+++ b/include/linux/digsig.h
@@ -30,7 +30,7 @@ enum digest_algo {
30 30
31struct pubkey_hdr { 31struct pubkey_hdr {
32 uint8_t version; /* key format version */ 32 uint8_t version; /* key format version */
33 time_t timestamp; /* key made, always 0 for now */ 33 uint32_t timestamp; /* key made, always 0 for now */
34 uint8_t algo; 34 uint8_t algo;
35 uint8_t nmpi; 35 uint8_t nmpi;
36 char mpi[0]; 36 char mpi[0];
@@ -38,7 +38,7 @@ struct pubkey_hdr {
38 38
39struct signature_hdr { 39struct signature_hdr {
40 uint8_t version; /* signature format version */ 40 uint8_t version; /* signature format version */
41 time_t timestamp; /* signature made */ 41 uint32_t timestamp; /* signature made */
42 uint8_t algo; 42 uint8_t algo;
43 uint8_t hash; 43 uint8_t hash;
44 uint8_t keyid[8]; 44 uint8_t keyid[8];
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 386da09f229d..69cd5bb640f5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2496,6 +2496,7 @@ extern void get_filesystem(struct file_system_type *fs);
2496extern void put_filesystem(struct file_system_type *fs); 2496extern void put_filesystem(struct file_system_type *fs);
2497extern struct file_system_type *get_fs_type(const char *name); 2497extern struct file_system_type *get_fs_type(const char *name);
2498extern struct super_block *get_super(struct block_device *); 2498extern struct super_block *get_super(struct block_device *);
2499extern struct super_block *get_super_thawed(struct block_device *);
2499extern struct super_block *get_active_super(struct block_device *bdev); 2500extern struct super_block *get_active_super(struct block_device *bdev);
2500extern void drop_super(struct super_block *sb); 2501extern void drop_super(struct super_block *sb);
2501extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2502extern void iterate_supers(void (*)(struct super_block *, void *), void *);
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index c52d4b5f872a..4b24ff453aee 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -137,6 +137,7 @@ enum {
137 IFLA_AF_SPEC, 137 IFLA_AF_SPEC,
138 IFLA_GROUP, /* Group the device belongs to */ 138 IFLA_GROUP, /* Group the device belongs to */
139 IFLA_NET_NS_FD, 139 IFLA_NET_NS_FD,
140 IFLA_EXT_MASK, /* Extended info mask, VFs, etc */
140 __IFLA_MAX 141 __IFLA_MAX
141}; 142};
142 143
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 8797ed16feb2..4dd5bd6994a8 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -285,8 +285,8 @@ struct ebt_table {
285 struct module *me; 285 struct module *me;
286}; 286};
287 287
288#define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \ 288#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
289 ~(__alignof__(struct ebt_replace)-1)) 289 ~(__alignof__(struct _xt_align)-1))
290extern struct ebt_table *ebt_register_table(struct net *net, 290extern struct ebt_table *ebt_register_table(struct net *net,
291 const struct ebt_table *table); 291 const struct ebt_table *table);
292extern void ebt_unregister_table(struct net *net, struct ebt_table *table); 292extern void ebt_unregister_table(struct net *net, struct ebt_table *table);
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index a764cef06b73..d6ba9a12591e 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -614,7 +614,6 @@ struct nfs_getaclargs {
614 size_t acl_len; 614 size_t acl_len;
615 unsigned int acl_pgbase; 615 unsigned int acl_pgbase;
616 struct page ** acl_pages; 616 struct page ** acl_pages;
617 struct page * acl_scratch;
618 struct nfs4_sequence_args seq_args; 617 struct nfs4_sequence_args seq_args;
619}; 618};
620 619
@@ -624,6 +623,7 @@ struct nfs_getaclres {
624 size_t acl_len; 623 size_t acl_len;
625 size_t acl_data_offset; 624 size_t acl_data_offset;
626 int acl_flags; 625 int acl_flags;
626 struct page * acl_scratch;
627 struct nfs4_sequence_res seq_res; 627 struct nfs4_sequence_res seq_res;
628}; 628};
629 629
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 8e872ead88b5..577592ea0ea0 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -602,6 +602,9 @@ struct tcamsg {
602#define TCA_ACT_TAB 1 /* attr type must be >=1 */ 602#define TCA_ACT_TAB 1 /* attr type must be >=1 */
603#define TCAA_MAX 1 603#define TCAA_MAX 1
604 604
605/* New extended info filters for IFLA_EXT_MASK */
606#define RTEXT_FILTER_VF (1 << 0)
607
605/* End of information exported to user level */ 608/* End of information exported to user level */
606 609
607#ifdef __KERNEL__ 610#ifdef __KERNEL__
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
index 3ff4961da9b5..247399b2979a 100644
--- a/include/linux/signalfd.h
+++ b/include/linux/signalfd.h
@@ -61,13 +61,16 @@ static inline void signalfd_notify(struct task_struct *tsk, int sig)
61 wake_up(&tsk->sighand->signalfd_wqh); 61 wake_up(&tsk->sighand->signalfd_wqh);
62} 62}
63 63
64extern void signalfd_cleanup(struct sighand_struct *sighand);
65
64#else /* CONFIG_SIGNALFD */ 66#else /* CONFIG_SIGNALFD */
65 67
66static inline void signalfd_notify(struct task_struct *tsk, int sig) { } 68static inline void signalfd_notify(struct task_struct *tsk, int sig) { }
67 69
70static inline void signalfd_cleanup(struct sighand_struct *sighand) { }
71
68#endif /* CONFIG_SIGNALFD */ 72#endif /* CONFIG_SIGNALFD */
69 73
70#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
71 75
72#endif /* _LINUX_SIGNALFD_H */ 76#endif /* _LINUX_SIGNALFD_H */
73
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 06a4c0fd7bef..79ef8209bbb7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1486,6 +1486,16 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1486} 1486}
1487#endif /* NET_SKBUFF_DATA_USES_OFFSET */ 1487#endif /* NET_SKBUFF_DATA_USES_OFFSET */
1488 1488
1489static inline void skb_mac_header_rebuild(struct sk_buff *skb)
1490{
1491 if (skb_mac_header_was_set(skb)) {
1492 const unsigned char *old_mac = skb_mac_header(skb);
1493
1494 skb_set_mac_header(skb, -skb->mac_len);
1495 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
1496 }
1497}
1498
1489static inline int skb_checksum_start_offset(const struct sk_buff *skb) 1499static inline int skb_checksum_start_offset(const struct sk_buff *skb)
1490{ 1500{
1491 return skb->csum_start - skb_headroom(skb); 1501 return skb->csum_start - skb_headroom(skb);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 515669fa3c1d..8ec1153ff57b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -624,7 +624,7 @@ asmlinkage long sys_socketpair(int, int, int, int __user *);
624asmlinkage long sys_socketcall(int call, unsigned long __user *args); 624asmlinkage long sys_socketcall(int call, unsigned long __user *args);
625asmlinkage long sys_listen(int, int); 625asmlinkage long sys_listen(int, int);
626asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds, 626asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
627 long timeout); 627 int timeout);
628asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, 628asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
629 fd_set __user *exp, struct timeval __user *tvp); 629 fd_set __user *exp, struct timeval __user *tvp);
630asmlinkage long sys_old_select(struct sel_arg_struct __user *arg); 630asmlinkage long sys_old_select(struct sel_arg_struct __user *arg);
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
index 31fdb4c6ee3d..0b83acd3360a 100644
--- a/include/linux/usb/ch11.h
+++ b/include/linux/usb/ch11.h
@@ -61,12 +61,6 @@
61#define USB_PORT_FEAT_TEST 21 61#define USB_PORT_FEAT_TEST 21
62#define USB_PORT_FEAT_INDICATOR 22 62#define USB_PORT_FEAT_INDICATOR 22
63#define USB_PORT_FEAT_C_PORT_L1 23 63#define USB_PORT_FEAT_C_PORT_L1 23
64#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
65#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
66#define USB_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27
67#define USB_PORT_FEAT_BH_PORT_RESET 28
68#define USB_PORT_FEAT_C_BH_PORT_RESET 29
69#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
70 64
71/* 65/*
72 * Port feature selectors added by USB 3.0 spec. 66 * Port feature selectors added by USB 3.0 spec.
@@ -75,8 +69,8 @@
75#define USB_PORT_FEAT_LINK_STATE 5 69#define USB_PORT_FEAT_LINK_STATE 5
76#define USB_PORT_FEAT_U1_TIMEOUT 23 70#define USB_PORT_FEAT_U1_TIMEOUT 23
77#define USB_PORT_FEAT_U2_TIMEOUT 24 71#define USB_PORT_FEAT_U2_TIMEOUT 24
78#define USB_PORT_FEAT_C_LINK_STATE 25 72#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
79#define USB_PORT_FEAT_C_CONFIG_ERR 26 73#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
80#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27 74#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
81#define USB_PORT_FEAT_BH_PORT_RESET 28 75#define USB_PORT_FEAT_BH_PORT_RESET 28
82#define USB_PORT_FEAT_C_BH_PORT_RESET 29 76#define USB_PORT_FEAT_C_BH_PORT_RESET 29
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 8a2b0ae7dbd2..ab86036bbf0c 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -209,7 +209,7 @@ extern struct nf_conntrack_tuple_hash *
209__nf_conntrack_find(struct net *net, u16 zone, 209__nf_conntrack_find(struct net *net, u16 zone,
210 const struct nf_conntrack_tuple *tuple); 210 const struct nf_conntrack_tuple *tuple);
211 211
212extern void nf_conntrack_hash_insert(struct nf_conn *ct); 212extern int nf_conntrack_hash_check_insert(struct nf_conn *ct);
213extern void nf_ct_delete_from_lists(struct nf_conn *ct); 213extern void nf_ct_delete_from_lists(struct nf_conn *ct);
214extern void nf_ct_insert_dying_list(struct nf_conn *ct); 214extern void nf_ct_insert_dying_list(struct nf_conn *ct);
215 215
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 678f1ffaf843..370293901971 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -6,7 +6,7 @@
6 6
7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *); 7typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *);
8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); 8typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
9typedef u16 (*rtnl_calcit_func)(struct sk_buff *); 9typedef u16 (*rtnl_calcit_func)(struct sk_buff *, struct nlmsghdr *);
10 10
11extern int __rtnl_register(int protocol, int msgtype, 11extern int __rtnl_register(int protocol, int msgtype,
12 rtnl_doit_func, rtnl_dumpit_func, 12 rtnl_doit_func, rtnl_dumpit_func,
diff --git a/kernel/fork.c b/kernel/fork.c
index b77fd559c78e..e2cd3e2a5ae8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -66,6 +66,7 @@
66#include <linux/user-return-notifier.h> 66#include <linux/user-return-notifier.h>
67#include <linux/oom.h> 67#include <linux/oom.h>
68#include <linux/khugepaged.h> 68#include <linux/khugepaged.h>
69#include <linux/signalfd.h>
69 70
70#include <asm/pgtable.h> 71#include <asm/pgtable.h>
71#include <asm/pgalloc.h> 72#include <asm/pgalloc.h>
@@ -935,8 +936,10 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)
935 936
936void __cleanup_sighand(struct sighand_struct *sighand) 937void __cleanup_sighand(struct sighand_struct *sighand)
937{ 938{
938 if (atomic_dec_and_test(&sighand->count)) 939 if (atomic_dec_and_test(&sighand->count)) {
940 signalfd_cleanup(sighand);
939 kmem_cache_free(sighand_cachep, sighand); 941 kmem_cache_free(sighand_cachep, sighand);
942 }
940} 943}
941 944
942 945
diff --git a/kernel/pid.c b/kernel/pid.c
index ce8e00deaccb..9f08dfabaf13 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -543,12 +543,12 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns)
543 */ 543 */
544void __init pidhash_init(void) 544void __init pidhash_init(void)
545{ 545{
546 int i, pidhash_size; 546 unsigned int i, pidhash_size;
547 547
548 pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18, 548 pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,
549 HASH_EARLY | HASH_SMALL, 549 HASH_EARLY | HASH_SMALL,
550 &pidhash_shift, NULL, 4096); 550 &pidhash_shift, NULL, 4096);
551 pidhash_size = 1 << pidhash_shift; 551 pidhash_size = 1U << pidhash_shift;
552 552
553 for (i = 0; i < pidhash_size; i++) 553 for (i = 0; i < pidhash_size; i++)
554 INIT_HLIST_HEAD(&pid_hash[i]); 554 INIT_HLIST_HEAD(&pid_hash[i]);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6728a7ae6f2d..228d6461c12a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4414,6 +4414,9 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
4414 */ 4414 */
4415 BUG_ON(!thresholds); 4415 BUG_ON(!thresholds);
4416 4416
4417 if (!thresholds->primary)
4418 goto unlock;
4419
4417 usage = mem_cgroup_usage(memcg, type == _MEMSWAP); 4420 usage = mem_cgroup_usage(memcg, type == _MEMSWAP);
4418 4421
4419 /* Check if a threshold crossed before removing */ 4422 /* Check if a threshold crossed before removing */
@@ -4462,7 +4465,7 @@ swap_buffers:
4462 4465
4463 /* To be sure that nobody uses thresholds */ 4466 /* To be sure that nobody uses thresholds */
4464 synchronize_rcu(); 4467 synchronize_rcu();
4465 4468unlock:
4466 mutex_unlock(&memcg->thresholds_lock); 4469 mutex_unlock(&memcg->thresholds_lock);
4467} 4470}
4468 4471
diff --git a/mm/nommu.c b/mm/nommu.c
index b982290fd962..f59e170fceb4 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -696,9 +696,11 @@ static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma)
696 if (vma->vm_file) { 696 if (vma->vm_file) {
697 mapping = vma->vm_file->f_mapping; 697 mapping = vma->vm_file->f_mapping;
698 698
699 mutex_lock(&mapping->i_mmap_mutex);
699 flush_dcache_mmap_lock(mapping); 700 flush_dcache_mmap_lock(mapping);
700 vma_prio_tree_insert(vma, &mapping->i_mmap); 701 vma_prio_tree_insert(vma, &mapping->i_mmap);
701 flush_dcache_mmap_unlock(mapping); 702 flush_dcache_mmap_unlock(mapping);
703 mutex_unlock(&mapping->i_mmap_mutex);
702 } 704 }
703 705
704 /* add the VMA to the tree */ 706 /* add the VMA to the tree */
@@ -760,9 +762,11 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
760 if (vma->vm_file) { 762 if (vma->vm_file) {
761 mapping = vma->vm_file->f_mapping; 763 mapping = vma->vm_file->f_mapping;
762 764
765 mutex_lock(&mapping->i_mmap_mutex);
763 flush_dcache_mmap_lock(mapping); 766 flush_dcache_mmap_lock(mapping);
764 vma_prio_tree_remove(vma, &mapping->i_mmap); 767 vma_prio_tree_remove(vma, &mapping->i_mmap);
765 flush_dcache_mmap_unlock(mapping); 768 flush_dcache_mmap_unlock(mapping);
769 mutex_unlock(&mapping->i_mmap_mutex);
766 } 770 }
767 771
768 /* remove from the MM's tree and list */ 772 /* remove from the MM's tree and list */
@@ -775,8 +779,6 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
775 779
776 if (vma->vm_next) 780 if (vma->vm_next)
777 vma->vm_next->vm_prev = vma->vm_prev; 781 vma->vm_next->vm_prev = vma->vm_prev;
778
779 vma->vm_mm = NULL;
780} 782}
781 783
782/* 784/*
@@ -2052,6 +2054,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2052 high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 2054 high = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
2053 2055
2054 down_write(&nommu_region_sem); 2056 down_write(&nommu_region_sem);
2057 mutex_lock(&inode->i_mapping->i_mmap_mutex);
2055 2058
2056 /* search for VMAs that fall within the dead zone */ 2059 /* search for VMAs that fall within the dead zone */
2057 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap, 2060 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
@@ -2059,6 +2062,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2059 /* found one - only interested if it's shared out of the page 2062 /* found one - only interested if it's shared out of the page
2060 * cache */ 2063 * cache */
2061 if (vma->vm_flags & VM_SHARED) { 2064 if (vma->vm_flags & VM_SHARED) {
2065 mutex_unlock(&inode->i_mapping->i_mmap_mutex);
2062 up_write(&nommu_region_sem); 2066 up_write(&nommu_region_sem);
2063 return -ETXTBSY; /* not quite true, but near enough */ 2067 return -ETXTBSY; /* not quite true, but near enough */
2064 } 2068 }
@@ -2086,6 +2090,7 @@ int nommu_shrink_inode_mappings(struct inode *inode, size_t size,
2086 } 2090 }
2087 } 2091 }
2088 2092
2093 mutex_unlock(&inode->i_mapping->i_mmap_mutex);
2089 up_write(&nommu_region_sem); 2094 up_write(&nommu_region_sem);
2090 return 0; 2095 return 0;
2091} 2096}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d2186ecb36f7..a13ded1938f0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5236,6 +5236,7 @@ void *__init alloc_large_system_hash(const char *tablename,
5236 max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4; 5236 max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4;
5237 do_div(max, bucketsize); 5237 do_div(max, bucketsize);
5238 } 5238 }
5239 max = min(max, 0x80000000ULL);
5239 5240
5240 if (numentries > max) 5241 if (numentries > max)
5241 numentries = max; 5242 numentries = max;
diff --git a/net/atm/clip.c b/net/atm/clip.c
index ef95a30306fa..5de42ea309bc 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -46,8 +46,8 @@
46 46
47static struct net_device *clip_devs; 47static struct net_device *clip_devs;
48static struct atm_vcc *atmarpd; 48static struct atm_vcc *atmarpd;
49static struct neigh_table clip_tbl;
50static struct timer_list idle_timer; 49static struct timer_list idle_timer;
50static const struct neigh_ops clip_neigh_ops;
51 51
52static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip) 52static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
53{ 53{
@@ -123,6 +123,8 @@ static int neigh_check_cb(struct neighbour *n)
123 struct atmarp_entry *entry = neighbour_priv(n); 123 struct atmarp_entry *entry = neighbour_priv(n);
124 struct clip_vcc *cv; 124 struct clip_vcc *cv;
125 125
126 if (n->ops != &clip_neigh_ops)
127 return 0;
126 for (cv = entry->vccs; cv; cv = cv->next) { 128 for (cv = entry->vccs; cv; cv = cv->next) {
127 unsigned long exp = cv->last_use + cv->idle_timeout; 129 unsigned long exp = cv->last_use + cv->idle_timeout;
128 130
@@ -154,10 +156,10 @@ static int neigh_check_cb(struct neighbour *n)
154 156
155static void idle_timer_check(unsigned long dummy) 157static void idle_timer_check(unsigned long dummy)
156{ 158{
157 write_lock(&clip_tbl.lock); 159 write_lock(&arp_tbl.lock);
158 __neigh_for_each_release(&clip_tbl, neigh_check_cb); 160 __neigh_for_each_release(&arp_tbl, neigh_check_cb);
159 mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ); 161 mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ);
160 write_unlock(&clip_tbl.lock); 162 write_unlock(&arp_tbl.lock);
161} 163}
162 164
163static int clip_arp_rcv(struct sk_buff *skb) 165static int clip_arp_rcv(struct sk_buff *skb)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index f98ec444133a..0a68045782d1 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -826,6 +826,8 @@ next_elt:
826 write_unlock_bh(&tbl->lock); 826 write_unlock_bh(&tbl->lock);
827 cond_resched(); 827 cond_resched();
828 write_lock_bh(&tbl->lock); 828 write_lock_bh(&tbl->lock);
829 nht = rcu_dereference_protected(tbl->nht,
830 lockdep_is_held(&tbl->lock));
829 } 831 }
830 /* Cycle through all hash buckets every base_reachable_time/2 ticks. 832 /* Cycle through all hash buckets every base_reachable_time/2 ticks.
831 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 833 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7aef62e53113..5cf39cd7da85 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -60,7 +60,6 @@ struct rtnl_link {
60}; 60};
61 61
62static DEFINE_MUTEX(rtnl_mutex); 62static DEFINE_MUTEX(rtnl_mutex);
63static u16 min_ifinfo_dump_size;
64 63
65void rtnl_lock(void) 64void rtnl_lock(void)
66{ 65{
@@ -724,10 +723,11 @@ static void copy_rtnl_link_stats64(void *v, const struct rtnl_link_stats64 *b)
724} 723}
725 724
726/* All VF info */ 725/* All VF info */
727static inline int rtnl_vfinfo_size(const struct net_device *dev) 726static inline int rtnl_vfinfo_size(const struct net_device *dev,
727 u32 ext_filter_mask)
728{ 728{
729 if (dev->dev.parent && dev_is_pci(dev->dev.parent)) { 729 if (dev->dev.parent && dev_is_pci(dev->dev.parent) &&
730 730 (ext_filter_mask & RTEXT_FILTER_VF)) {
731 int num_vfs = dev_num_vf(dev->dev.parent); 731 int num_vfs = dev_num_vf(dev->dev.parent);
732 size_t size = nla_total_size(sizeof(struct nlattr)); 732 size_t size = nla_total_size(sizeof(struct nlattr));
733 size += nla_total_size(num_vfs * sizeof(struct nlattr)); 733 size += nla_total_size(num_vfs * sizeof(struct nlattr));
@@ -766,7 +766,8 @@ static size_t rtnl_port_size(const struct net_device *dev)
766 return port_self_size; 766 return port_self_size;
767} 767}
768 768
769static noinline size_t if_nlmsg_size(const struct net_device *dev) 769static noinline size_t if_nlmsg_size(const struct net_device *dev,
770 u32 ext_filter_mask)
770{ 771{
771 return NLMSG_ALIGN(sizeof(struct ifinfomsg)) 772 return NLMSG_ALIGN(sizeof(struct ifinfomsg))
772 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ 773 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
@@ -784,8 +785,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev)
784 + nla_total_size(4) /* IFLA_MASTER */ 785 + nla_total_size(4) /* IFLA_MASTER */
785 + nla_total_size(1) /* IFLA_OPERSTATE */ 786 + nla_total_size(1) /* IFLA_OPERSTATE */
786 + nla_total_size(1) /* IFLA_LINKMODE */ 787 + nla_total_size(1) /* IFLA_LINKMODE */
787 + nla_total_size(4) /* IFLA_NUM_VF */ 788 + nla_total_size(ext_filter_mask
788 + rtnl_vfinfo_size(dev) /* IFLA_VFINFO_LIST */ 789 & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */
790 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
789 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ 791 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
790 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ 792 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
791 + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */ 793 + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */
@@ -868,7 +870,7 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev)
868 870
869static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, 871static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
870 int type, u32 pid, u32 seq, u32 change, 872 int type, u32 pid, u32 seq, u32 change,
871 unsigned int flags) 873 unsigned int flags, u32 ext_filter_mask)
872{ 874{
873 struct ifinfomsg *ifm; 875 struct ifinfomsg *ifm;
874 struct nlmsghdr *nlh; 876 struct nlmsghdr *nlh;
@@ -941,10 +943,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
941 goto nla_put_failure; 943 goto nla_put_failure;
942 copy_rtnl_link_stats64(nla_data(attr), stats); 944 copy_rtnl_link_stats64(nla_data(attr), stats);
943 945
944 if (dev->dev.parent) 946 if (dev->dev.parent && (ext_filter_mask & RTEXT_FILTER_VF))
945 NLA_PUT_U32(skb, IFLA_NUM_VF, dev_num_vf(dev->dev.parent)); 947 NLA_PUT_U32(skb, IFLA_NUM_VF, dev_num_vf(dev->dev.parent));
946 948
947 if (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent) { 949 if (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent
950 && (ext_filter_mask & RTEXT_FILTER_VF)) {
948 int i; 951 int i;
949 952
950 struct nlattr *vfinfo, *vf; 953 struct nlattr *vfinfo, *vf;
@@ -1048,6 +1051,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1048 struct net_device *dev; 1051 struct net_device *dev;
1049 struct hlist_head *head; 1052 struct hlist_head *head;
1050 struct hlist_node *node; 1053 struct hlist_node *node;
1054 struct nlattr *tb[IFLA_MAX+1];
1055 u32 ext_filter_mask = 0;
1051 1056
1052 s_h = cb->args[0]; 1057 s_h = cb->args[0];
1053 s_idx = cb->args[1]; 1058 s_idx = cb->args[1];
@@ -1055,6 +1060,12 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1055 rcu_read_lock(); 1060 rcu_read_lock();
1056 cb->seq = net->dev_base_seq; 1061 cb->seq = net->dev_base_seq;
1057 1062
1063 nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
1064 ifla_policy);
1065
1066 if (tb[IFLA_EXT_MASK])
1067 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1068
1058 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { 1069 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
1059 idx = 0; 1070 idx = 0;
1060 head = &net->dev_index_head[h]; 1071 head = &net->dev_index_head[h];
@@ -1064,7 +1075,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1064 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, 1075 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
1065 NETLINK_CB(cb->skb).pid, 1076 NETLINK_CB(cb->skb).pid,
1066 cb->nlh->nlmsg_seq, 0, 1077 cb->nlh->nlmsg_seq, 0,
1067 NLM_F_MULTI) <= 0) 1078 NLM_F_MULTI,
1079 ext_filter_mask) <= 0)
1068 goto out; 1080 goto out;
1069 1081
1070 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 1082 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -1100,6 +1112,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1100 [IFLA_VF_PORTS] = { .type = NLA_NESTED }, 1112 [IFLA_VF_PORTS] = { .type = NLA_NESTED },
1101 [IFLA_PORT_SELF] = { .type = NLA_NESTED }, 1113 [IFLA_PORT_SELF] = { .type = NLA_NESTED },
1102 [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1114 [IFLA_AF_SPEC] = { .type = NLA_NESTED },
1115 [IFLA_EXT_MASK] = { .type = NLA_U32 },
1103}; 1116};
1104EXPORT_SYMBOL(ifla_policy); 1117EXPORT_SYMBOL(ifla_policy);
1105 1118
@@ -1509,8 +1522,6 @@ errout:
1509 1522
1510 if (send_addr_notify) 1523 if (send_addr_notify)
1511 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); 1524 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
1512 min_ifinfo_dump_size = max_t(u16, if_nlmsg_size(dev),
1513 min_ifinfo_dump_size);
1514 1525
1515 return err; 1526 return err;
1516} 1527}
@@ -1842,6 +1853,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1842 struct net_device *dev = NULL; 1853 struct net_device *dev = NULL;
1843 struct sk_buff *nskb; 1854 struct sk_buff *nskb;
1844 int err; 1855 int err;
1856 u32 ext_filter_mask = 0;
1845 1857
1846 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 1858 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
1847 if (err < 0) 1859 if (err < 0)
@@ -1850,6 +1862,9 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1850 if (tb[IFLA_IFNAME]) 1862 if (tb[IFLA_IFNAME])
1851 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); 1863 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
1852 1864
1865 if (tb[IFLA_EXT_MASK])
1866 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1867
1853 ifm = nlmsg_data(nlh); 1868 ifm = nlmsg_data(nlh);
1854 if (ifm->ifi_index > 0) 1869 if (ifm->ifi_index > 0)
1855 dev = __dev_get_by_index(net, ifm->ifi_index); 1870 dev = __dev_get_by_index(net, ifm->ifi_index);
@@ -1861,12 +1876,12 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1861 if (dev == NULL) 1876 if (dev == NULL)
1862 return -ENODEV; 1877 return -ENODEV;
1863 1878
1864 nskb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL); 1879 nskb = nlmsg_new(if_nlmsg_size(dev, ext_filter_mask), GFP_KERNEL);
1865 if (nskb == NULL) 1880 if (nskb == NULL)
1866 return -ENOBUFS; 1881 return -ENOBUFS;
1867 1882
1868 err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).pid, 1883 err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).pid,
1869 nlh->nlmsg_seq, 0, 0); 1884 nlh->nlmsg_seq, 0, 0, ext_filter_mask);
1870 if (err < 0) { 1885 if (err < 0) {
1871 /* -EMSGSIZE implies BUG in if_nlmsg_size */ 1886 /* -EMSGSIZE implies BUG in if_nlmsg_size */
1872 WARN_ON(err == -EMSGSIZE); 1887 WARN_ON(err == -EMSGSIZE);
@@ -1877,8 +1892,31 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1877 return err; 1892 return err;
1878} 1893}
1879 1894
1880static u16 rtnl_calcit(struct sk_buff *skb) 1895static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
1881{ 1896{
1897 struct net *net = sock_net(skb->sk);
1898 struct net_device *dev;
1899 struct nlattr *tb[IFLA_MAX+1];
1900 u32 ext_filter_mask = 0;
1901 u16 min_ifinfo_dump_size = 0;
1902
1903 nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, ifla_policy);
1904
1905 if (tb[IFLA_EXT_MASK])
1906 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
1907
1908 if (!ext_filter_mask)
1909 return NLMSG_GOODSIZE;
1910 /*
1911 * traverse the list of net devices and compute the minimum
1912 * buffer size based upon the filter mask.
1913 */
1914 list_for_each_entry(dev, &net->dev_base_head, dev_list) {
1915 min_ifinfo_dump_size = max_t(u16, min_ifinfo_dump_size,
1916 if_nlmsg_size(dev,
1917 ext_filter_mask));
1918 }
1919
1882 return min_ifinfo_dump_size; 1920 return min_ifinfo_dump_size;
1883} 1921}
1884 1922
@@ -1913,13 +1951,11 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
1913 int err = -ENOBUFS; 1951 int err = -ENOBUFS;
1914 size_t if_info_size; 1952 size_t if_info_size;
1915 1953
1916 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL); 1954 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
1917 if (skb == NULL) 1955 if (skb == NULL)
1918 goto errout; 1956 goto errout;
1919 1957
1920 min_ifinfo_dump_size = max_t(u16, if_info_size, min_ifinfo_dump_size); 1958 err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0, 0);
1921
1922 err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0);
1923 if (err < 0) { 1959 if (err < 0) {
1924 /* -EMSGSIZE implies BUG in if_nlmsg_size() */ 1960 /* -EMSGSIZE implies BUG in if_nlmsg_size() */
1925 WARN_ON(err == -EMSGSIZE); 1961 WARN_ON(err == -EMSGSIZE);
@@ -1977,7 +2013,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1977 return -EOPNOTSUPP; 2013 return -EOPNOTSUPP;
1978 calcit = rtnl_get_calcit(family, type); 2014 calcit = rtnl_get_calcit(family, type);
1979 if (calcit) 2015 if (calcit)
1980 min_dump_alloc = calcit(skb); 2016 min_dump_alloc = calcit(skb, nlh);
1981 2017
1982 __rtnl_unlock(); 2018 __rtnl_unlock();
1983 rtnl = net->rtnl; 2019 rtnl = net->rtnl;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index b59414a0c1ee..6ef66af12291 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -65,7 +65,7 @@
65 it is infeasible task. The most general solutions would be 65 it is infeasible task. The most general solutions would be
66 to keep skb->encapsulation counter (sort of local ttl), 66 to keep skb->encapsulation counter (sort of local ttl),
67 and silently drop packet when it expires. It is a good 67 and silently drop packet when it expires. It is a good
68 solution, but it supposes maintaing new variable in ALL 68 solution, but it supposes maintaining new variable in ALL
69 skb, even if no tunneling is used. 69 skb, even if no tunneling is used.
70 70
71 Current solution: xmit_recursion breaks dead loops. This is a percpu 71 Current solution: xmit_recursion breaks dead loops. This is a percpu
@@ -91,14 +91,14 @@
91 91
92 One of them is to parse packet trying to detect inner encapsulation 92 One of them is to parse packet trying to detect inner encapsulation
93 made by our node. It is difficult or even impossible, especially, 93 made by our node. It is difficult or even impossible, especially,
94 taking into account fragmentation. TO be short, tt is not solution at all. 94 taking into account fragmentation. TO be short, ttl is not solution at all.
95 95
96 Current solution: The solution was UNEXPECTEDLY SIMPLE. 96 Current solution: The solution was UNEXPECTEDLY SIMPLE.
97 We force DF flag on tunnels with preconfigured hop limit, 97 We force DF flag on tunnels with preconfigured hop limit,
98 that is ALL. :-) Well, it does not remove the problem completely, 98 that is ALL. :-) Well, it does not remove the problem completely,
99 but exponential growth of network traffic is changed to linear 99 but exponential growth of network traffic is changed to linear
100 (branches, that exceed pmtu are pruned) and tunnel mtu 100 (branches, that exceed pmtu are pruned) and tunnel mtu
101 fastly degrades to value <68, where looping stops. 101 rapidly degrades to value <68, where looping stops.
102 Yes, it is not good if there exists a router in the loop, 102 Yes, it is not good if there exists a router in the loop,
103 which does not force DF, even when encapsulating packets have DF set. 103 which does not force DF, even when encapsulating packets have DF set.
104 But it is not our problem! Nobody could accuse us, we made 104 But it is not our problem! Nobody could accuse us, we made
@@ -457,8 +457,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
457 GRE tunnels with enabled checksum. Tell them "thank you". 457 GRE tunnels with enabled checksum. Tell them "thank you".
458 458
459 Well, I wonder, rfc1812 was written by Cisco employee, 459 Well, I wonder, rfc1812 was written by Cisco employee,
460 what the hell these idiots break standrads established 460 what the hell these idiots break standards established
461 by themself??? 461 by themselves???
462 */ 462 */
463 463
464 const struct iphdr *iph = (const struct iphdr *)skb->data; 464 const struct iphdr *iph = (const struct iphdr *)skb->data;
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index cfc82cf339f6..4398a45a9600 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -631,6 +631,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
631 631
632 pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num); 632 pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);
633 633
634 err = -EOPNOTSUPP;
634 if (flags & MSG_OOB) 635 if (flags & MSG_OOB)
635 goto out; 636 goto out;
636 637
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 37755ccc0e96..22ef5f9fd2ff 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3240,7 +3240,8 @@ void __init tcp_init(void)
3240{ 3240{
3241 struct sk_buff *skb = NULL; 3241 struct sk_buff *skb = NULL;
3242 unsigned long limit; 3242 unsigned long limit;
3243 int i, max_share, cnt; 3243 int max_share, cnt;
3244 unsigned int i;
3244 unsigned long jiffy = jiffies; 3245 unsigned long jiffy = jiffies;
3245 3246
3246 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); 3247 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));
@@ -3283,7 +3284,7 @@ void __init tcp_init(void)
3283 &tcp_hashinfo.bhash_size, 3284 &tcp_hashinfo.bhash_size,
3284 NULL, 3285 NULL,
3285 64 * 1024); 3286 64 * 1024);
3286 tcp_hashinfo.bhash_size = 1 << tcp_hashinfo.bhash_size; 3287 tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;
3287 for (i = 0; i < tcp_hashinfo.bhash_size; i++) { 3288 for (i = 0; i < tcp_hashinfo.bhash_size; i++) {
3288 spin_lock_init(&tcp_hashinfo.bhash[i].lock); 3289 spin_lock_init(&tcp_hashinfo.bhash[i].lock);
3289 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); 3290 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 63418185f524..e3db3f915114 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -110,10 +110,7 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
110 110
111 skb_push(skb, sizeof(*iph)); 111 skb_push(skb, sizeof(*iph));
112 skb_reset_network_header(skb); 112 skb_reset_network_header(skb);
113 113 skb_mac_header_rebuild(skb);
114 memmove(skb->data - skb->mac_len, skb_mac_header(skb),
115 skb->mac_len);
116 skb_set_mac_header(skb, -skb->mac_len);
117 114
118 xfrm4_beet_make_header(skb); 115 xfrm4_beet_make_header(skb);
119 116
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index 534972e114ac..ed4bf11ef9f4 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -66,7 +66,6 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
66 66
67static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) 67static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
68{ 68{
69 const unsigned char *old_mac;
70 int err = -EINVAL; 69 int err = -EINVAL;
71 70
72 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP) 71 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP)
@@ -84,10 +83,9 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
84 if (!(x->props.flags & XFRM_STATE_NOECN)) 83 if (!(x->props.flags & XFRM_STATE_NOECN))
85 ipip_ecn_decapsulate(skb); 84 ipip_ecn_decapsulate(skb);
86 85
87 old_mac = skb_mac_header(skb);
88 skb_set_mac_header(skb, -skb->mac_len);
89 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
90 skb_reset_network_header(skb); 86 skb_reset_network_header(skb);
87 skb_mac_header_rebuild(skb);
88
91 err = 0; 89 err = 0;
92 90
93out: 91out:
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index c7e95c8c579f..5aa3981a3922 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1926,8 +1926,10 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
1926 }; 1926 };
1927 1927
1928 dst = ip6_route_output(net, NULL, &fl6); 1928 dst = ip6_route_output(net, NULL, &fl6);
1929 if (!dst) 1929 if (dst->error) {
1930 dst_release(dst);
1930 goto out_free; 1931 goto out_free;
1932 }
1931 1933
1932 skb_dst_drop(skb); 1934 skb_dst_drop(skb);
1933 skb_dst_set(skb, dst); 1935 skb_dst_set(skb, dst);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 8d817018c188..3dcdb81ec3e8 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1550,9 +1550,10 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1550 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex); 1550 &saddr_buf, &ipv6_hdr(skb)->saddr, dev->ifindex);
1551 1551
1552 dst = ip6_route_output(net, NULL, &fl6); 1552 dst = ip6_route_output(net, NULL, &fl6);
1553 if (dst == NULL) 1553 if (dst->error) {
1554 dst_release(dst);
1554 return; 1555 return;
1555 1556 }
1556 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0); 1557 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1557 if (IS_ERR(dst)) 1558 if (IS_ERR(dst))
1558 return; 1559 return;
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index a81ce9450750..9949a356d62c 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -80,7 +80,6 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
80static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb) 80static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
81{ 81{
82 struct ipv6hdr *ip6h; 82 struct ipv6hdr *ip6h;
83 const unsigned char *old_mac;
84 int size = sizeof(struct ipv6hdr); 83 int size = sizeof(struct ipv6hdr);
85 int err; 84 int err;
86 85
@@ -90,10 +89,7 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
90 89
91 __skb_push(skb, size); 90 __skb_push(skb, size);
92 skb_reset_network_header(skb); 91 skb_reset_network_header(skb);
93 92 skb_mac_header_rebuild(skb);
94 old_mac = skb_mac_header(skb);
95 skb_set_mac_header(skb, -skb->mac_len);
96 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
97 93
98 xfrm6_beet_make_header(skb); 94 xfrm6_beet_make_header(skb);
99 95
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 261e6e6f487e..9f2095b19ad0 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -63,7 +63,6 @@ static int xfrm6_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
63static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) 63static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
64{ 64{
65 int err = -EINVAL; 65 int err = -EINVAL;
66 const unsigned char *old_mac;
67 66
68 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPV6) 67 if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPV6)
69 goto out; 68 goto out;
@@ -80,10 +79,9 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
80 if (!(x->props.flags & XFRM_STATE_NOECN)) 79 if (!(x->props.flags & XFRM_STATE_NOECN))
81 ipip6_ecn_decapsulate(skb); 80 ipip6_ecn_decapsulate(skb);
82 81
83 old_mac = skb_mac_header(skb);
84 skb_set_mac_header(skb, -skb->mac_len);
85 memmove(skb_mac_header(skb), old_mac, skb->mac_len);
86 skb_reset_network_header(skb); 82 skb_reset_network_header(skb);
83 skb_mac_header_rebuild(skb);
84
87 err = 0; 85 err = 0;
88 86
89out: 87out:
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 611c3359b94d..2555816e7788 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -232,6 +232,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
232 __be16 dport = 0; /* destination port to forward */ 232 __be16 dport = 0; /* destination port to forward */
233 unsigned int flags; 233 unsigned int flags;
234 struct ip_vs_conn_param param; 234 struct ip_vs_conn_param param;
235 const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) };
235 union nf_inet_addr snet; /* source network of the client, 236 union nf_inet_addr snet; /* source network of the client,
236 after masking */ 237 after masking */
237 238
@@ -267,7 +268,6 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
267 { 268 {
268 int protocol = iph.protocol; 269 int protocol = iph.protocol;
269 const union nf_inet_addr *vaddr = &iph.daddr; 270 const union nf_inet_addr *vaddr = &iph.daddr;
270 const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) };
271 __be16 vport = 0; 271 __be16 vport = 0;
272 272
273 if (dst_port == svc->port) { 273 if (dst_port == svc->port) {
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 76613f5a55c0..ed86a3be678e 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -404,19 +404,49 @@ static void __nf_conntrack_hash_insert(struct nf_conn *ct,
404 &net->ct.hash[repl_hash]); 404 &net->ct.hash[repl_hash]);
405} 405}
406 406
407void nf_conntrack_hash_insert(struct nf_conn *ct) 407int
408nf_conntrack_hash_check_insert(struct nf_conn *ct)
408{ 409{
409 struct net *net = nf_ct_net(ct); 410 struct net *net = nf_ct_net(ct);
410 unsigned int hash, repl_hash; 411 unsigned int hash, repl_hash;
412 struct nf_conntrack_tuple_hash *h;
413 struct hlist_nulls_node *n;
411 u16 zone; 414 u16 zone;
412 415
413 zone = nf_ct_zone(ct); 416 zone = nf_ct_zone(ct);
414 hash = hash_conntrack(net, zone, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 417 hash = hash_conntrack(net, zone,
415 repl_hash = hash_conntrack(net, zone, &ct->tuplehash[IP_CT_DIR_REPLY].tuple); 418 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
419 repl_hash = hash_conntrack(net, zone,
420 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
421
422 spin_lock_bh(&nf_conntrack_lock);
416 423
424 /* See if there's one in the list already, including reverse */
425 hlist_nulls_for_each_entry(h, n, &net->ct.hash[hash], hnnode)
426 if (nf_ct_tuple_equal(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
427 &h->tuple) &&
428 zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))
429 goto out;
430 hlist_nulls_for_each_entry(h, n, &net->ct.hash[repl_hash], hnnode)
431 if (nf_ct_tuple_equal(&ct->tuplehash[IP_CT_DIR_REPLY].tuple,
432 &h->tuple) &&
433 zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))
434 goto out;
435
436 add_timer(&ct->timeout);
437 nf_conntrack_get(&ct->ct_general);
417 __nf_conntrack_hash_insert(ct, hash, repl_hash); 438 __nf_conntrack_hash_insert(ct, hash, repl_hash);
439 NF_CT_STAT_INC(net, insert);
440 spin_unlock_bh(&nf_conntrack_lock);
441
442 return 0;
443
444out:
445 NF_CT_STAT_INC(net, insert_failed);
446 spin_unlock_bh(&nf_conntrack_lock);
447 return -EEXIST;
418} 448}
419EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert); 449EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert);
420 450
421/* Confirm a connection given skb; places it in hash table */ 451/* Confirm a connection given skb; places it in hash table */
422int 452int
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 28d0312d890a..04fb409623d2 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1404,15 +1404,12 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1404 nf_ct_protonum(ct)); 1404 nf_ct_protonum(ct));
1405 if (helper == NULL) { 1405 if (helper == NULL) {
1406 rcu_read_unlock(); 1406 rcu_read_unlock();
1407 spin_unlock_bh(&nf_conntrack_lock);
1408#ifdef CONFIG_MODULES 1407#ifdef CONFIG_MODULES
1409 if (request_module("nfct-helper-%s", helpname) < 0) { 1408 if (request_module("nfct-helper-%s", helpname) < 0) {
1410 spin_lock_bh(&nf_conntrack_lock);
1411 err = -EOPNOTSUPP; 1409 err = -EOPNOTSUPP;
1412 goto err1; 1410 goto err1;
1413 } 1411 }
1414 1412
1415 spin_lock_bh(&nf_conntrack_lock);
1416 rcu_read_lock(); 1413 rcu_read_lock();
1417 helper = __nf_conntrack_helper_find(helpname, 1414 helper = __nf_conntrack_helper_find(helpname,
1418 nf_ct_l3num(ct), 1415 nf_ct_l3num(ct),
@@ -1505,8 +1502,10 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1505 if (tstamp) 1502 if (tstamp)
1506 tstamp->start = ktime_to_ns(ktime_get_real()); 1503 tstamp->start = ktime_to_ns(ktime_get_real());
1507 1504
1508 add_timer(&ct->timeout); 1505 err = nf_conntrack_hash_check_insert(ct);
1509 nf_conntrack_hash_insert(ct); 1506 if (err < 0)
1507 goto err2;
1508
1510 rcu_read_unlock(); 1509 rcu_read_unlock();
1511 1510
1512 return ct; 1511 return ct;
@@ -1527,6 +1526,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1527 struct nf_conntrack_tuple otuple, rtuple; 1526 struct nf_conntrack_tuple otuple, rtuple;
1528 struct nf_conntrack_tuple_hash *h = NULL; 1527 struct nf_conntrack_tuple_hash *h = NULL;
1529 struct nfgenmsg *nfmsg = nlmsg_data(nlh); 1528 struct nfgenmsg *nfmsg = nlmsg_data(nlh);
1529 struct nf_conn *ct;
1530 u_int8_t u3 = nfmsg->nfgen_family; 1530 u_int8_t u3 = nfmsg->nfgen_family;
1531 u16 zone; 1531 u16 zone;
1532 int err; 1532 int err;
@@ -1547,27 +1547,22 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1547 return err; 1547 return err;
1548 } 1548 }
1549 1549
1550 spin_lock_bh(&nf_conntrack_lock);
1551 if (cda[CTA_TUPLE_ORIG]) 1550 if (cda[CTA_TUPLE_ORIG])
1552 h = __nf_conntrack_find(net, zone, &otuple); 1551 h = nf_conntrack_find_get(net, zone, &otuple);
1553 else if (cda[CTA_TUPLE_REPLY]) 1552 else if (cda[CTA_TUPLE_REPLY])
1554 h = __nf_conntrack_find(net, zone, &rtuple); 1553 h = nf_conntrack_find_get(net, zone, &rtuple);
1555 1554
1556 if (h == NULL) { 1555 if (h == NULL) {
1557 err = -ENOENT; 1556 err = -ENOENT;
1558 if (nlh->nlmsg_flags & NLM_F_CREATE) { 1557 if (nlh->nlmsg_flags & NLM_F_CREATE) {
1559 struct nf_conn *ct;
1560 enum ip_conntrack_events events; 1558 enum ip_conntrack_events events;
1561 1559
1562 ct = ctnetlink_create_conntrack(net, zone, cda, &otuple, 1560 ct = ctnetlink_create_conntrack(net, zone, cda, &otuple,
1563 &rtuple, u3); 1561 &rtuple, u3);
1564 if (IS_ERR(ct)) { 1562 if (IS_ERR(ct))
1565 err = PTR_ERR(ct); 1563 return PTR_ERR(ct);
1566 goto out_unlock; 1564
1567 }
1568 err = 0; 1565 err = 0;
1569 nf_conntrack_get(&ct->ct_general);
1570 spin_unlock_bh(&nf_conntrack_lock);
1571 if (test_bit(IPS_EXPECTED_BIT, &ct->status)) 1566 if (test_bit(IPS_EXPECTED_BIT, &ct->status))
1572 events = IPCT_RELATED; 1567 events = IPCT_RELATED;
1573 else 1568 else
@@ -1582,23 +1577,19 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1582 ct, NETLINK_CB(skb).pid, 1577 ct, NETLINK_CB(skb).pid,
1583 nlmsg_report(nlh)); 1578 nlmsg_report(nlh));
1584 nf_ct_put(ct); 1579 nf_ct_put(ct);
1585 } else 1580 }
1586 spin_unlock_bh(&nf_conntrack_lock);
1587 1581
1588 return err; 1582 return err;
1589 } 1583 }
1590 /* implicit 'else' */ 1584 /* implicit 'else' */
1591 1585
1592 /* We manipulate the conntrack inside the global conntrack table lock,
1593 * so there's no need to increase the refcount */
1594 err = -EEXIST; 1586 err = -EEXIST;
1587 ct = nf_ct_tuplehash_to_ctrack(h);
1595 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) { 1588 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) {
1596 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); 1589 spin_lock_bh(&nf_conntrack_lock);
1597
1598 err = ctnetlink_change_conntrack(ct, cda); 1590 err = ctnetlink_change_conntrack(ct, cda);
1591 spin_unlock_bh(&nf_conntrack_lock);
1599 if (err == 0) { 1592 if (err == 0) {
1600 nf_conntrack_get(&ct->ct_general);
1601 spin_unlock_bh(&nf_conntrack_lock);
1602 nf_conntrack_eventmask_report((1 << IPCT_REPLY) | 1593 nf_conntrack_eventmask_report((1 << IPCT_REPLY) |
1603 (1 << IPCT_ASSURED) | 1594 (1 << IPCT_ASSURED) |
1604 (1 << IPCT_HELPER) | 1595 (1 << IPCT_HELPER) |
@@ -1607,15 +1598,10 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1607 (1 << IPCT_MARK), 1598 (1 << IPCT_MARK),
1608 ct, NETLINK_CB(skb).pid, 1599 ct, NETLINK_CB(skb).pid,
1609 nlmsg_report(nlh)); 1600 nlmsg_report(nlh));
1610 nf_ct_put(ct); 1601 }
1611 } else
1612 spin_unlock_bh(&nf_conntrack_lock);
1613
1614 return err;
1615 } 1602 }
1616 1603
1617out_unlock: 1604 nf_ct_put(ct);
1618 spin_unlock_bh(&nf_conntrack_lock);
1619 return err; 1605 return err;
1620} 1606}
1621 1607
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index b3a7db678b8d..ce60cf0f6c11 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -203,6 +203,27 @@ err:
203 return status; 203 return status;
204} 204}
205 205
206#ifdef CONFIG_BRIDGE_NETFILTER
207/* When called from bridge netfilter, skb->data must point to MAC header
208 * before calling skb_gso_segment(). Else, original MAC header is lost
209 * and segmented skbs will be sent to wrong destination.
210 */
211static void nf_bridge_adjust_skb_data(struct sk_buff *skb)
212{
213 if (skb->nf_bridge)
214 __skb_push(skb, skb->network_header - skb->mac_header);
215}
216
217static void nf_bridge_adjust_segmented_data(struct sk_buff *skb)
218{
219 if (skb->nf_bridge)
220 __skb_pull(skb, skb->network_header - skb->mac_header);
221}
222#else
223#define nf_bridge_adjust_skb_data(s) do {} while (0)
224#define nf_bridge_adjust_segmented_data(s) do {} while (0)
225#endif
226
206int nf_queue(struct sk_buff *skb, 227int nf_queue(struct sk_buff *skb,
207 struct list_head *elem, 228 struct list_head *elem,
208 u_int8_t pf, unsigned int hook, 229 u_int8_t pf, unsigned int hook,
@@ -212,7 +233,7 @@ int nf_queue(struct sk_buff *skb,
212 unsigned int queuenum) 233 unsigned int queuenum)
213{ 234{
214 struct sk_buff *segs; 235 struct sk_buff *segs;
215 int err; 236 int err = -EINVAL;
216 unsigned int queued; 237 unsigned int queued;
217 238
218 if (!skb_is_gso(skb)) 239 if (!skb_is_gso(skb))
@@ -228,23 +249,25 @@ int nf_queue(struct sk_buff *skb,
228 break; 249 break;
229 } 250 }
230 251
252 nf_bridge_adjust_skb_data(skb);
231 segs = skb_gso_segment(skb, 0); 253 segs = skb_gso_segment(skb, 0);
232 /* Does not use PTR_ERR to limit the number of error codes that can be 254 /* Does not use PTR_ERR to limit the number of error codes that can be
233 * returned by nf_queue. For instance, callers rely on -ECANCELED to mean 255 * returned by nf_queue. For instance, callers rely on -ECANCELED to mean
234 * 'ignore this hook'. 256 * 'ignore this hook'.
235 */ 257 */
236 if (IS_ERR(segs)) 258 if (IS_ERR(segs))
237 return -EINVAL; 259 goto out_err;
238
239 queued = 0; 260 queued = 0;
240 err = 0; 261 err = 0;
241 do { 262 do {
242 struct sk_buff *nskb = segs->next; 263 struct sk_buff *nskb = segs->next;
243 264
244 segs->next = NULL; 265 segs->next = NULL;
245 if (err == 0) 266 if (err == 0) {
267 nf_bridge_adjust_segmented_data(segs);
246 err = __nf_queue(segs, elem, pf, hook, indev, 268 err = __nf_queue(segs, elem, pf, hook, indev,
247 outdev, okfn, queuenum); 269 outdev, okfn, queuenum);
270 }
248 if (err == 0) 271 if (err == 0)
249 queued++; 272 queued++;
250 else 273 else
@@ -252,11 +275,12 @@ int nf_queue(struct sk_buff *skb,
252 segs = nskb; 275 segs = nskb;
253 } while (segs); 276 } while (segs);
254 277
255 /* also free orig skb if only some segments were queued */ 278 if (queued) {
256 if (unlikely(err && queued))
257 err = 0;
258 if (err == 0)
259 kfree_skb(skb); 279 kfree_skb(skb);
280 return 0;
281 }
282 out_err:
283 nf_bridge_adjust_segmented_data(skb);
260 return err; 284 return err;
261} 285}
262 286
diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index 3aae66facf9f..4d5057902839 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -152,9 +152,10 @@ tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info)
152 fl6.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) | 152 fl6.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) |
153 (iph->flow_lbl[1] << 8) | iph->flow_lbl[2]; 153 (iph->flow_lbl[1] << 8) | iph->flow_lbl[2];
154 dst = ip6_route_output(net, NULL, &fl6); 154 dst = ip6_route_output(net, NULL, &fl6);
155 if (dst == NULL) 155 if (dst->error) {
156 dst_release(dst);
156 return false; 157 return false;
157 158 }
158 skb_dst_drop(skb); 159 skb_dst_drop(skb);
159 skb_dst_set(skb, dst); 160 skb_dst_set(skb, dst);
160 skb->dev = dst->dev; 161 skb->dev = dst->dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index e83d61ca78ca..5da548fa7ae9 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -501,9 +501,8 @@ tfifo_dequeue:
501 501
502 /* if more time remaining? */ 502 /* if more time remaining? */
503 if (cb->time_to_send <= psched_get_time()) { 503 if (cb->time_to_send <= psched_get_time()) {
504 skb = qdisc_dequeue_tail(sch); 504 __skb_unlink(skb, &sch->q);
505 if (unlikely(!skb)) 505 sch->qstats.backlog -= qdisc_pkt_len(skb);
506 goto qdisc_dequeue;
507 506
508#ifdef CONFIG_NET_CLS_ACT 507#ifdef CONFIG_NET_CLS_ACT
509 /* 508 /*
@@ -539,7 +538,6 @@ deliver:
539 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send); 538 qdisc_watchdog_schedule(&q->watchdog, cb->time_to_send);
540 } 539 }
541 540
542qdisc_dequeue:
543 if (q->qdisc) { 541 if (q->qdisc) {
544 skb = q->qdisc->ops->dequeue(q->qdisc); 542 skb = q->qdisc->ops->dequeue(q->qdisc);
545 if (skb) 543 if (skb)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 3c2776466d87..823e972149e5 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -9,15 +9,10 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
9# FLAGS="-ignore_unknown_options -very_quiet" 9# FLAGS="-ignore_unknown_options -very_quiet"
10# OPTIONS=$* 10# OPTIONS=$*
11 11
12 if [ "$KBUILD_EXTMOD" = "" ] ; then 12# Workaround for Coccinelle < 0.2.3
13 # Workaround for Coccinelle < 0.2.3 13 FLAGS="-I $srctree/include -very_quiet"
14 FLAGS="-I $srctree/include -very_quiet" 14 shift $(( $# - 1 ))
15 shift $(( $# - 1 )) 15 OPTIONS=$1
16 OPTIONS=$1
17 else
18 echo M= is not currently supported when C=1 or C=2
19 exit 1
20 fi
21else 16else
22 ONLINE=0 17 ONLINE=0
23 FLAGS="-very_quiet" 18 FLAGS="-very_quiet"
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index a27235685949..2ae481703141 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -9,12 +9,6 @@ fi
9DEPMOD=$1 9DEPMOD=$1
10KERNELRELEASE=$2 10KERNELRELEASE=$2
11 11
12if ! "$DEPMOD" -V 2>/dev/null | grep -q module-init-tools; then
13 echo "Warning: you may need to install module-init-tools" >&2
14 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt" >&2
15 sleep 1
16fi
17
18if ! test -r System.map -a -x "$DEPMOD"; then 12if ! test -r System.map -a -x "$DEPMOD"; then
19 exit 0 13 exit 0
20fi 14fi
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2bd594e6d1b4..9adb667dd31a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1494,6 +1494,13 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1494 return 0; 1494 return 0;
1495} 1495}
1496 1496
1497#ifndef R_ARM_CALL
1498#define R_ARM_CALL 28
1499#endif
1500#ifndef R_ARM_JUMP24
1501#define R_ARM_JUMP24 29
1502#endif
1503
1497static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1504static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1498{ 1505{
1499 unsigned int r_typ = ELF_R_TYPE(r->r_info); 1506 unsigned int r_typ = ELF_R_TYPE(r->r_info);
@@ -1505,6 +1512,8 @@ static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1505 (elf->symtab_start + ELF_R_SYM(r->r_info)); 1512 (elf->symtab_start + ELF_R_SYM(r->r_info));
1506 break; 1513 break;
1507 case R_ARM_PC24: 1514 case R_ARM_PC24:
1515 case R_ARM_CALL:
1516 case R_ARM_JUMP24:
1508 /* From ARM ABI: ((S + A) | T) - P */ 1517 /* From ARM ABI: ((S + A) | T) - P */
1509 r->r_addend = (int)(long)(elf->hdr + 1518 r->r_addend = (int)(long)(elf->hdr +
1510 sechdr->sh_offset + 1519 sechdr->sh_offset +
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index f6cbc3ddb68b..3c6c0b14c807 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -238,14 +238,14 @@ EOF
238fi 238fi
239 239
240# Build header package 240# Build header package
241(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$) 241(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
242(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> /tmp/files$$) 242(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
243(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$) 243(cd $objtree; find .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
244destdir=$kernel_headers_dir/usr/src/linux-headers-$version 244destdir=$kernel_headers_dir/usr/src/linux-headers-$version
245mkdir -p "$destdir" 245mkdir -p "$destdir"
246(cd $srctree; tar -c -f - -T /tmp/files$$) | (cd $destdir; tar -xf -) 246(cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
247(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -) 247(cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -)
248rm -f /tmp/files$$ /tmp/objfiles$$ 248rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
249arch=$(dpkg --print-architecture) 249arch=$(dpkg --print-architecture)
250 250
251cat <<EOF >> debian/control 251cat <<EOF >> debian/control
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 1358987c49d8..3647baa9bfed 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -80,6 +80,8 @@ enum {
80 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ 80 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
81}; 81};
82 82
83#define MAX_VOL_NIDS 0x40
84
83struct alc_spec { 85struct alc_spec {
84 /* codec parameterization */ 86 /* codec parameterization */
85 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 87 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -118,8 +120,8 @@ struct alc_spec {
118 const hda_nid_t *capsrc_nids; 120 const hda_nid_t *capsrc_nids;
119 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 121 hda_nid_t dig_in_nid; /* digital-in NID; optional */
120 hda_nid_t mixer_nid; /* analog-mixer NID */ 122 hda_nid_t mixer_nid; /* analog-mixer NID */
121 DECLARE_BITMAP(vol_ctls, 0x20 << 1); 123 DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1);
122 DECLARE_BITMAP(sw_ctls, 0x20 << 1); 124 DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1);
123 125
124 /* capture setup for dynamic dual-adc switch */ 126 /* capture setup for dynamic dual-adc switch */
125 hda_nid_t cur_adc; 127 hda_nid_t cur_adc;
@@ -3149,7 +3151,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3149static inline unsigned int get_ctl_pos(unsigned int data) 3151static inline unsigned int get_ctl_pos(unsigned int data)
3150{ 3152{
3151 hda_nid_t nid = get_amp_nid_(data); 3153 hda_nid_t nid = get_amp_nid_(data);
3152 unsigned int dir = get_amp_direction_(data); 3154 unsigned int dir;
3155 if (snd_BUG_ON(nid >= MAX_VOL_NIDS))
3156 return 0;
3157 dir = get_amp_direction_(data);
3153 return (nid << 1) | dir; 3158 return (nid << 1) | dir;
3154} 3159}
3155 3160
@@ -4436,12 +4441,20 @@ static void alc889_fixup_dac_route(struct hda_codec *codec,
4436 const struct alc_fixup *fix, int action) 4441 const struct alc_fixup *fix, int action)
4437{ 4442{
4438 if (action == ALC_FIXUP_ACT_PRE_PROBE) { 4443 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
4444 /* fake the connections during parsing the tree */
4439 hda_nid_t conn1[2] = { 0x0c, 0x0d }; 4445 hda_nid_t conn1[2] = { 0x0c, 0x0d };
4440 hda_nid_t conn2[2] = { 0x0e, 0x0f }; 4446 hda_nid_t conn2[2] = { 0x0e, 0x0f };
4441 snd_hda_override_conn_list(codec, 0x14, 2, conn1); 4447 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
4442 snd_hda_override_conn_list(codec, 0x15, 2, conn1); 4448 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
4443 snd_hda_override_conn_list(codec, 0x18, 2, conn2); 4449 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
4444 snd_hda_override_conn_list(codec, 0x1a, 2, conn2); 4450 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
4451 } else if (action == ALC_FIXUP_ACT_PROBE) {
4452 /* restore the connections */
4453 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
4454 snd_hda_override_conn_list(codec, 0x14, 5, conn);
4455 snd_hda_override_conn_list(codec, 0x15, 5, conn);
4456 snd_hda_override_conn_list(codec, 0x18, 5, conn);
4457 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
4445 } 4458 }
4446} 4459}
4447 4460
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 5ef70b5d27e4..278c0a0575f5 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -146,13 +146,10 @@ static const struct snd_kcontrol_new ak4642_snd_controls[] = {
146 146
147 SOC_DOUBLE_R_TLV("Digital Playback Volume", L_DVC, R_DVC, 147 SOC_DOUBLE_R_TLV("Digital Playback Volume", L_DVC, R_DVC,
148 0, 0xFF, 1, out_tlv), 148 0, 0xFF, 1, out_tlv),
149
150 SOC_SINGLE("Headphone Switch", PW_MGMT2, 6, 1, 0),
151}; 149};
152 150
153static const struct snd_kcontrol_new ak4642_hpout_mixer_controls[] = { 151static const struct snd_kcontrol_new ak4642_headphone_control =
154 SOC_DAPM_SINGLE("DACH", MD_CTL4, 0, 1, 0), 152 SOC_DAPM_SINGLE("Switch", PW_MGMT2, 6, 1, 0);
155};
156 153
157static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { 154static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = {
158 SOC_DAPM_SINGLE("DACL", SG_SL1, 4, 1, 0), 155 SOC_DAPM_SINGLE("DACL", SG_SL1, 4, 1, 0),
@@ -165,13 +162,12 @@ static const struct snd_soc_dapm_widget ak4642_dapm_widgets[] = {
165 SND_SOC_DAPM_OUTPUT("HPOUTR"), 162 SND_SOC_DAPM_OUTPUT("HPOUTR"),
166 SND_SOC_DAPM_OUTPUT("LINEOUT"), 163 SND_SOC_DAPM_OUTPUT("LINEOUT"),
167 164
168 SND_SOC_DAPM_MIXER("HPOUTL Mixer", PW_MGMT2, 5, 0, 165 SND_SOC_DAPM_PGA("HPL Out", PW_MGMT2, 5, 0, NULL, 0),
169 &ak4642_hpout_mixer_controls[0], 166 SND_SOC_DAPM_PGA("HPR Out", PW_MGMT2, 4, 0, NULL, 0),
170 ARRAY_SIZE(ak4642_hpout_mixer_controls)), 167 SND_SOC_DAPM_SWITCH("Headphone Enable", SND_SOC_NOPM, 0, 0,
168 &ak4642_headphone_control),
171 169
172 SND_SOC_DAPM_MIXER("HPOUTR Mixer", PW_MGMT2, 4, 0, 170 SND_SOC_DAPM_PGA("DACH", MD_CTL4, 0, 0, NULL, 0),
173 &ak4642_hpout_mixer_controls[0],
174 ARRAY_SIZE(ak4642_hpout_mixer_controls)),
175 171
176 SND_SOC_DAPM_MIXER("LINEOUT Mixer", PW_MGMT1, 3, 0, 172 SND_SOC_DAPM_MIXER("LINEOUT Mixer", PW_MGMT1, 3, 0,
177 &ak4642_lout_mixer_controls[0], 173 &ak4642_lout_mixer_controls[0],
@@ -184,12 +180,17 @@ static const struct snd_soc_dapm_widget ak4642_dapm_widgets[] = {
184static const struct snd_soc_dapm_route ak4642_intercon[] = { 180static const struct snd_soc_dapm_route ak4642_intercon[] = {
185 181
186 /* Outputs */ 182 /* Outputs */
187 {"HPOUTL", NULL, "HPOUTL Mixer"}, 183 {"HPOUTL", NULL, "HPL Out"},
188 {"HPOUTR", NULL, "HPOUTR Mixer"}, 184 {"HPOUTR", NULL, "HPR Out"},
189 {"LINEOUT", NULL, "LINEOUT Mixer"}, 185 {"LINEOUT", NULL, "LINEOUT Mixer"},
190 186
191 {"HPOUTL Mixer", "DACH", "DAC"}, 187 {"HPL Out", NULL, "Headphone Enable"},
192 {"HPOUTR Mixer", "DACH", "DAC"}, 188 {"HPR Out", NULL, "Headphone Enable"},
189
190 {"Headphone Enable", "Switch", "DACH"},
191
192 {"DACH", NULL, "DAC"},
193
193 {"LINEOUT Mixer", "DACL", "DAC"}, 194 {"LINEOUT Mixer", "DACL", "DAC"},
194}; 195};
195 196
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 29c4b02c4790..0ac228b7dc04 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2564,7 +2564,7 @@ static int dsp2_event(struct snd_soc_dapm_widget *w,
2564 return 0; 2564 return 0;
2565} 2565}
2566 2566
2567static const char *st_text[] = { "None", "Right", "Left" }; 2567static const char *st_text[] = { "None", "Left", "Right" };
2568 2568
2569static const struct soc_enum str_enum = 2569static const struct soc_enum str_enum =
2570 SOC_ENUM_SINGLE(WM8962_DAC_DSP_MIXING_1, 2, 3, st_text); 2570 SOC_ENUM_SINGLE(WM8962_DAC_DSP_MIXING_1, 2, 3, st_text);
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index 2cf87f5afed4..fde9a7a29cb6 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -311,8 +311,10 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
311 311
312 spin_lock(&dev->spinlock); 312 spin_lock(&dev->spinlock);
313 313
314 if (dev->input_panic || dev->output_panic) 314 if (dev->input_panic || dev->output_panic) {
315 ptr = SNDRV_PCM_POS_XRUN; 315 ptr = SNDRV_PCM_POS_XRUN;
316 goto unlock;
317 }
316 318
317 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) 319 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
318 ptr = bytes_to_frames(sub->runtime, 320 ptr = bytes_to_frames(sub->runtime,
@@ -321,6 +323,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
321 ptr = bytes_to_frames(sub->runtime, 323 ptr = bytes_to_frames(sub->runtime,
322 dev->audio_in_buf_pos[index]); 324 dev->audio_in_buf_pos[index]);
323 325
326unlock:
324 spin_unlock(&dev->spinlock); 327 spin_unlock(&dev->spinlock);
325 return ptr; 328 return ptr;
326} 329}
diff --git a/sound/usb/card.h b/sound/usb/card.h
index a39edcc32a93..da5fa1ac4eda 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -1,6 +1,7 @@
1#ifndef __USBAUDIO_CARD_H 1#ifndef __USBAUDIO_CARD_H
2#define __USBAUDIO_CARD_H 2#define __USBAUDIO_CARD_H
3 3
4#define MAX_NR_RATES 1024
4#define MAX_PACKS 20 5#define MAX_PACKS 20
5#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ 6#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
6#define MAX_URBS 8 7#define MAX_URBS 8
diff --git a/sound/usb/format.c b/sound/usb/format.c
index e09aba19375c..ddfef57c4c9f 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -209,8 +209,6 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
209 return 0; 209 return 0;
210} 210}
211 211
212#define MAX_UAC2_NR_RATES 1024
213
214/* 212/*
215 * Helper function to walk the array of sample rate triplets reported by 213 * Helper function to walk the array of sample rate triplets reported by
216 * the device. The problem is that we need to parse whole array first to 214 * the device. The problem is that we need to parse whole array first to
@@ -255,7 +253,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
255 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 253 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
256 254
257 nr_rates++; 255 nr_rates++;
258 if (nr_rates >= MAX_UAC2_NR_RATES) { 256 if (nr_rates >= MAX_NR_RATES) {
259 snd_printk(KERN_ERR "invalid uac2 rates\n"); 257 snd_printk(KERN_ERR "invalid uac2 rates\n");
260 break; 258 break;
261 } 259 }
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index a3ddac0deffd..27817266867a 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -132,10 +132,14 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
132 unsigned *rate_table = NULL; 132 unsigned *rate_table = NULL;
133 133
134 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); 134 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
135 if (! fp) { 135 if (!fp) {
136 snd_printk(KERN_ERR "cannot memdup\n"); 136 snd_printk(KERN_ERR "cannot memdup\n");
137 return -ENOMEM; 137 return -ENOMEM;
138 } 138 }
139 if (fp->nr_rates > MAX_NR_RATES) {
140 kfree(fp);
141 return -EINVAL;
142 }
139 if (fp->nr_rates > 0) { 143 if (fp->nr_rates > 0) {
140 rate_table = kmemdup(fp->rate_table, 144 rate_table = kmemdup(fp->rate_table,
141 sizeof(int) * fp->nr_rates, GFP_KERNEL); 145 sizeof(int) * fp->nr_rates, GFP_KERNEL);