aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cgroups/memory.txt5
-rw-r--r--Documentation/filesystems/vfs.txt2
-rw-r--r--MAINTAINERS44
-rw-r--r--Makefile2
-rw-r--r--arch/c6x/include/asm/irq.h4
-rw-r--r--arch/c6x/kernel/irq.c13
-rw-r--r--arch/powerpc/include/asm/irq.h2
-rw-r--r--arch/powerpc/kernel/entry_32.S39
-rw-r--r--arch/powerpc/kernel/irq.c6
-rw-r--r--arch/powerpc/kernel/process.c4
-rw-r--r--arch/powerpc/kvm/book3s_hv_builtin.c9
-rw-r--r--arch/powerpc/kvm/book3s_hv_interrupts.S8
-rw-r--r--arch/powerpc/kvm/book3s_interrupts.S7
-rw-r--r--arch/powerpc/kvm/book3s_pr.c9
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S7
-rw-r--r--arch/powerpc/platforms/cell/axon_msi.c2
-rw-r--r--arch/powerpc/platforms/cell/beat_interrupt.c2
-rw-r--r--arch/powerpc/platforms/powermac/smp.c2
-rw-r--r--arch/powerpc/platforms/ps3/interrupt.c3
-rw-r--r--arch/sh/Kconfig.debug1
-rw-r--r--arch/sh/boards/board-sh7785lcr.c1
-rw-r--r--arch/sh/boards/mach-hp6xx/pm.c1
-rw-r--r--arch/sh/drivers/dma/dma-sysfs.c2
-rw-r--r--arch/sh/kernel/cpu/fpu.c1
-rw-r--r--arch/sh/kernel/cpu/sh2a/fpu.c1
-rw-r--r--arch/sh/kernel/cpu/sh4/fpu.c1
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7757.c2
-rw-r--r--arch/sh/kernel/cpu/shmobile/pm.c1
-rw-r--r--arch/sh/kernel/idle.c2
-rw-r--r--arch/sh/kernel/kgdb.c1
-rw-r--r--arch/sh/kernel/process_32.c1
-rw-r--r--arch/sh/kernel/smp.c1
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-sigreturn.S35
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-trapa.S23
-rw-r--r--arch/sh/mm/cache-sh4.c1
-rw-r--r--arch/sh/mm/flush-sh4.c1
-rw-r--r--arch/sh/mm/sram.c1
-rw-r--r--arch/sparc/kernel/leon_pci.c13
-rw-r--r--arch/sparc/mm/fault_32.c37
-rw-r--r--arch/sparc/mm/fault_64.c37
-rw-r--r--arch/tile/Kconfig8
-rw-r--r--arch/tile/Makefile5
-rw-r--r--arch/tile/include/arch/spr_def.h4
-rw-r--r--arch/tile/include/asm/atomic.h50
-rw-r--r--arch/tile/include/asm/atomic_32.h2
-rw-r--r--arch/tile/include/asm/bitops_64.h8
-rw-r--r--arch/tile/include/asm/cmpxchg.h73
-rw-r--r--arch/tile/include/asm/irq.h2
-rw-r--r--arch/tile/include/asm/spinlock_64.h2
-rw-r--r--arch/tile/include/asm/stack.h1
-rw-r--r--arch/tile/include/asm/traps.h6
-rw-r--r--arch/tile/kernel/entry.S2
-rw-r--r--arch/tile/kernel/intvec_32.S24
-rw-r--r--arch/tile/kernel/intvec_64.S52
-rw-r--r--arch/tile/kernel/module.c2
-rw-r--r--arch/tile/kernel/proc.c4
-rw-r--r--arch/tile/kernel/process.c3
-rw-r--r--arch/tile/kernel/setup.c28
-rw-r--r--arch/tile/kernel/single_step.c31
-rw-r--r--arch/tile/kernel/smp.c8
-rw-r--r--arch/tile/kernel/smpboot.c2
-rw-r--r--arch/tile/kernel/stack.c232
-rw-r--r--arch/tile/kernel/traps.c15
-rw-r--r--arch/tile/lib/Makefile1
-rw-r--r--arch/tile/lib/cacheflush.c30
-rw-r--r--arch/tile/lib/memcpy_user_64.c8
-rw-r--r--arch/tile/lib/spinlock_common.h2
-rw-r--r--arch/tile/mm/fault.c22
-rw-r--r--arch/tile/mm/homecache.c1
-rw-r--r--arch/tile/mm/init.c26
-rw-r--r--arch/tile/mm/pgtable.c38
-rw-r--r--arch/um/drivers/cow.h35
-rw-r--r--arch/um/drivers/cow_user.c43
-rw-r--r--arch/um/drivers/mconsole_kern.c1
-rw-r--r--arch/um/include/asm/Kbuild3
-rw-r--r--arch/um/kernel/Makefile7
-rw-r--r--arch/um/kernel/process.c6
-rw-r--r--arch/um/kernel/skas/mmu.c1
-rw-r--r--arch/x86/Makefile.um3
-rw-r--r--arch/x86/include/asm/uaccess.h2
-rw-r--r--arch/x86/include/asm/uaccess_32.h5
-rw-r--r--arch/x86/include/asm/uaccess_64.h4
-rw-r--r--arch/x86/kernel/kvm.c4
-rw-r--r--arch/x86/kvm/pmu.c2
-rw-r--r--arch/x86/kvm/vmx.c2
-rw-r--r--arch/x86/lib/usercopy.c103
-rw-r--r--arch/x86/lib/usercopy_32.c87
-rw-r--r--arch/x86/lib/usercopy_64.c49
-rw-r--r--arch/x86/um/asm/barrier.h75
-rw-r--r--arch/x86/um/asm/system.h135
-rw-r--r--arch/x86/xen/mmu.c4
-rw-r--r--arch/x86/xen/smp.c2
-rw-r--r--crypto/Kconfig6
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/base/regmap/regcache-rbtree.c8
-rw-r--r--drivers/base/regmap/regcache.c1
-rw-r--r--drivers/bcma/Kconfig2
-rw-r--r--drivers/bcma/driver_pci_host.c1
-rw-r--r--drivers/block/xen-blkfront.c2
-rw-r--r--drivers/bluetooth/ath3k.c4
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/bluetooth/hci_ldisc.c2
-rw-r--r--drivers/char/random.c11
-rw-r--r--drivers/char/tile-srom.c12
-rw-r--r--drivers/cpuidle/cpuidle.c5
-rw-r--r--drivers/dma/dmaengine.c14
-rw-r--r--drivers/dma/ioat/dma.c16
-rw-r--r--drivers/dma/ioat/dma.h6
-rw-r--r--drivers/dma/ioat/dma_v2.c12
-rw-r--r--drivers/dma/ioat/dma_v2.h4
-rw-r--r--drivers/dma/ioat/dma_v3.c49
-rw-r--r--drivers/dma/iop-adma.c4
-rw-r--r--drivers/edac/tile_edac.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_buf.c47
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_core.c14
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h10
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c20
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.c45
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.h2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.c107
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.h23
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c20
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c42
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c40
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c2
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h3
-rw-r--r--drivers/gpu/drm/i915/intel_display.c69
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c49
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c2
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c1
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c4
-rw-r--r--drivers/gpu/drm/radeon/r100.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c2
-rw-r--r--drivers/gpu/drm/radeon/r600_cp.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_clocks.c24
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c12
-rw-r--r--drivers/gpu/drm/savage/savage_state.c6
-rw-r--r--drivers/i2c/busses/i2c-designware-pcidrv.c1
-rw-r--r--drivers/infiniband/core/sysfs.c9
-rw-r--r--drivers/infiniband/hw/mlx4/main.c5
-rw-r--r--drivers/input/misc/da9052_onkey.c3
-rw-r--r--drivers/input/mouse/elantech.c10
-rw-r--r--drivers/input/mouse/gpio_mouse.c2
-rw-r--r--drivers/input/mouse/sentelic.c8
-rw-r--r--drivers/input/mouse/trackpoint.c14
-rw-r--r--drivers/input/touchscreen/tps6507x-ts.c4
-rw-r--r--drivers/md/bitmap.c5
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c12
-rw-r--r--drivers/media/dvb/dvb-usb/it913x.c54
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c4
-rw-r--r--drivers/media/video/uvc/uvc_video.c50
-rw-r--r--drivers/mmc/card/block.c27
-rw-r--r--drivers/mmc/core/bus.c17
-rw-r--r--drivers/mmc/core/core.c10
-rw-r--r--drivers/mmc/core/mmc.c30
-rw-r--r--drivers/mmc/core/sdio_bus.c12
-rw-r--r--drivers/mmc/host/atmel-mci-regs.h1
-rw-r--r--drivers/mmc/host/atmel-mci.c55
-rw-r--r--drivers/mmc/host/omap_hsmmc.c181
-rw-r--r--drivers/mmc/host/sdhci-dove.c1
-rw-r--r--drivers/mmc/host/sdhci-pci.c6
-rw-r--r--drivers/mmc/host/sdhci-s3c.c159
-rw-r--r--drivers/mmc/host/sdhci.c5
-rw-r--r--drivers/mmc/host/sh_mmcif.c13
-rw-r--r--drivers/mtd/mtdchar.c20
-rw-r--r--drivers/net/ethernet/tile/tilepro.c77
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c6
-rw-r--r--drivers/net/wireless/rtlwifi/base.c5
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c6
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c34
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h6
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/pci/xen-pcifront.c1
-rw-r--r--drivers/regulator/anatop-regulator.c6
-rw-r--r--drivers/rtc/rtc-efi.c1
-rw-r--r--drivers/rtc/rtc-pl031.c3
-rw-r--r--drivers/rtc/rtc-r9701.c22
-rw-r--r--drivers/rtc/rtc-s3c.c31
-rw-r--r--drivers/rtc/rtc-twl.c43
-rw-r--r--drivers/staging/android/lowmemorykiller.c48
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h1
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c10
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c13
-rw-r--r--drivers/target/tcm_fc/tfc_io.c2
-rw-r--r--drivers/tty/serial/sh-sci.c167
-rw-r--r--drivers/tty/serial/sh-sci.h8
-rw-r--r--drivers/xen/xen-pciback/pciback_ops.c2
-rw-r--r--fs/gfs2/Kconfig7
-rw-r--r--fs/gfs2/aops.c4
-rw-r--r--fs/gfs2/bmap.c6
-rw-r--r--fs/gfs2/dir.c4
-rw-r--r--fs/gfs2/inode.c13
-rw-r--r--fs/gfs2/rgrp.c8
-rw-r--r--fs/gfs2/xattr.c12
-rw-r--r--fs/libfs.c1
-rw-r--r--include/drm/exynos_drm.h5
-rw-r--r--include/linux/dmaengine.h1
-rw-r--r--include/linux/irq.h5
-rw-r--r--include/linux/irqdomain.h12
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h12
-rw-r--r--include/linux/skbuff.h13
-rw-r--r--include/linux/types.h6
-rw-r--r--include/linux/vgaarb.h2
-rw-r--r--include/net/bluetooth/hci.h3
-rw-r--r--include/net/bluetooth/hci_core.h12
-rw-r--r--include/net/bluetooth/mgmt.h2
-rw-r--r--include/net/mac80211.h2
-rw-r--r--include/sound/core.h10
-rw-r--r--kernel/cred.c2
-rw-r--r--kernel/irq/Kconfig2
-rw-r--r--kernel/irq/irqdomain.c46
-rw-r--r--kernel/panic.c2
-rw-r--r--kernel/sysctl.c8
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/memcontrol.c6
-rw-r--r--mm/vmscan.c7
-rw-r--r--net/bluetooth/hci_core.c7
-rw-r--r--net/bluetooth/l2cap_core.c3
-rw-r--r--net/bluetooth/l2cap_sock.c5
-rw-r--r--net/bluetooth/mgmt.c13
-rw-r--r--net/bridge/br_multicast.c81
-rw-r--r--net/bridge/br_private.h4
-rw-r--r--net/core/skbuff.c4
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c12
-rw-r--r--net/ipv4/tcp.c15
-rw-r--r--net/ipv4/tcp_input.c9
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/tcp_output.c2
-rw-r--r--net/ipv6/netfilter/ip6_tables.c14
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/mac80211/mlme.c3
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c4
-rw-r--r--net/nfc/llcp/commands.c4
-rw-r--r--net/wireless/nl80211.c31
-rw-r--r--net/wireless/wext-core.c6
-rw-r--r--scripts/mod/modpost.c7
-rw-r--r--scripts/mod/modpost.h1
-rw-r--r--security/smack/smack_lsm.c19
-rw-r--r--sound/isa/sscape.c6
-rw-r--r--sound/oss/msnd_pinnacle.c8
-rw-r--r--sound/pci/Kconfig4
-rw-r--r--sound/pci/asihpi/hpi_internal.h4
-rw-r--r--sound/pci/asihpi/hpios.c10
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/hda_eld.c6
-rw-r--r--sound/pci/hda/hda_proc.c13
-rw-r--r--sound/pci/hda/patch_conexant.c108
-rw-r--r--sound/pci/hda/patch_hdmi.c9
-rw-r--r--sound/soc/codecs/ak4642.c2
-rw-r--r--sound/soc/codecs/sgtl5000.c25
-rw-r--r--sound/soc/imx/imx-audmux.c5
-rw-r--r--sound/soc/pxa/pxa2xx-i2s.c1
-rw-r--r--sound/soc/soc-core.c2
-rw-r--r--sound/soc/tegra/tegra_i2s.c6
-rw-r--r--sound/soc/tegra/tegra_spdif.c4
265 files changed, 2379 insertions, 1877 deletions
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index 4c95c0034a4..9b1067afb22 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -34,8 +34,7 @@ Current Status: linux-2.6.34-mmotm(development version of 2010/April)
34 34
35Features: 35Features:
36 - accounting anonymous pages, file caches, swap caches usage and limiting them. 36 - accounting anonymous pages, file caches, swap caches usage and limiting them.
37 - private LRU and reclaim routine. (system's global LRU and private LRU 37 - pages are linked to per-memcg LRU exclusively, and there is no global LRU.
38 work independently from each other)
39 - optionally, memory+swap usage can be accounted and limited. 38 - optionally, memory+swap usage can be accounted and limited.
40 - hierarchical accounting 39 - hierarchical accounting
41 - soft limit 40 - soft limit
@@ -154,7 +153,7 @@ updated. page_cgroup has its own LRU on cgroup.
1542.2.1 Accounting details 1532.2.1 Accounting details
155 154
156All mapped anon pages (RSS) and cache pages (Page Cache) are accounted. 155All mapped anon pages (RSS) and cache pages (Page Cache) are accounted.
157Some pages which are never reclaimable and will not be on the global LRU 156Some pages which are never reclaimable and will not be on the LRU
158are not accounted. We just account pages under usual VM management. 157are not accounted. We just account pages under usual VM management.
159 158
160RSS pages are accounted at page_fault unless they've already been accounted 159RSS pages are accounted at page_fault unless they've already been accounted
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index e916e3d3648..0d049202808 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -114,7 +114,7 @@ members are defined:
114struct file_system_type { 114struct file_system_type {
115 const char *name; 115 const char *name;
116 int fs_flags; 116 int fs_flags;
117 struct dentry (*mount) (struct file_system_type *, int, 117 struct dentry *(*mount) (struct file_system_type *, int,
118 const char *, void *); 118 const char *, void *);
119 void (*kill_sb) (struct super_block *); 119 void (*kill_sb) (struct super_block *);
120 struct module *owner; 120 struct module *owner;
diff --git a/MAINTAINERS b/MAINTAINERS
index d710c000805..6750036223d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -228,7 +228,7 @@ M: Len Brown <lenb@kernel.org>
228L: linux-acpi@vger.kernel.org 228L: linux-acpi@vger.kernel.org
229W: http://www.lesswatts.org/projects/acpi/ 229W: http://www.lesswatts.org/projects/acpi/
230Q: http://patchwork.kernel.org/project/linux-acpi/list/ 230Q: http://patchwork.kernel.org/project/linux-acpi/list/
231T: git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git 231T: git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
232S: Supported 232S: Supported
233F: drivers/acpi/ 233F: drivers/acpi/
234F: drivers/pnp/pnpacpi/ 234F: drivers/pnp/pnpacpi/
@@ -1522,8 +1522,8 @@ M: Gustavo Padovan <gustavo@padovan.org>
1522M: Johan Hedberg <johan.hedberg@gmail.com> 1522M: Johan Hedberg <johan.hedberg@gmail.com>
1523L: linux-bluetooth@vger.kernel.org 1523L: linux-bluetooth@vger.kernel.org
1524W: http://www.bluez.org/ 1524W: http://www.bluez.org/
1525T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth.git 1525T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git
1526T: git git://git.kernel.org/pub/scm/linux/kernel/git/jh/bluetooth.git 1526T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
1527S: Maintained 1527S: Maintained
1528F: drivers/bluetooth/ 1528F: drivers/bluetooth/
1529 1529
@@ -1533,8 +1533,8 @@ M: Gustavo Padovan <gustavo@padovan.org>
1533M: Johan Hedberg <johan.hedberg@gmail.com> 1533M: Johan Hedberg <johan.hedberg@gmail.com>
1534L: linux-bluetooth@vger.kernel.org 1534L: linux-bluetooth@vger.kernel.org
1535W: http://www.bluez.org/ 1535W: http://www.bluez.org/
1536T: git git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth.git 1536T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git
1537T: git git://git.kernel.org/pub/scm/linux/kernel/git/jh/bluetooth.git 1537T: git git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
1538S: Maintained 1538S: Maintained
1539F: net/bluetooth/ 1539F: net/bluetooth/
1540F: include/net/bluetooth/ 1540F: include/net/bluetooth/
@@ -2451,17 +2451,17 @@ F: fs/ecryptfs/
2451 2451
2452EDAC-CORE 2452EDAC-CORE
2453M: Doug Thompson <dougthompson@xmission.com> 2453M: Doug Thompson <dougthompson@xmission.com>
2454L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2454L: linux-edac@vger.kernel.org
2455W: bluesmoke.sourceforge.net 2455W: bluesmoke.sourceforge.net
2456S: Supported 2456S: Supported
2457F: Documentation/edac.txt 2457F: Documentation/edac.txt
2458F: drivers/edac/edac_* 2458F: drivers/edac/
2459F: include/linux/edac.h 2459F: include/linux/edac.h
2460 2460
2461EDAC-AMD64 2461EDAC-AMD64
2462M: Doug Thompson <dougthompson@xmission.com> 2462M: Doug Thompson <dougthompson@xmission.com>
2463M: Borislav Petkov <borislav.petkov@amd.com> 2463M: Borislav Petkov <borislav.petkov@amd.com>
2464L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2464L: linux-edac@vger.kernel.org
2465W: bluesmoke.sourceforge.net 2465W: bluesmoke.sourceforge.net
2466S: Supported 2466S: Supported
2467F: drivers/edac/amd64_edac* 2467F: drivers/edac/amd64_edac*
@@ -2469,35 +2469,35 @@ F: drivers/edac/amd64_edac*
2469EDAC-E752X 2469EDAC-E752X
2470M: Mark Gross <mark.gross@intel.com> 2470M: Mark Gross <mark.gross@intel.com>
2471M: Doug Thompson <dougthompson@xmission.com> 2471M: Doug Thompson <dougthompson@xmission.com>
2472L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2472L: linux-edac@vger.kernel.org
2473W: bluesmoke.sourceforge.net 2473W: bluesmoke.sourceforge.net
2474S: Maintained 2474S: Maintained
2475F: drivers/edac/e752x_edac.c 2475F: drivers/edac/e752x_edac.c
2476 2476
2477EDAC-E7XXX 2477EDAC-E7XXX
2478M: Doug Thompson <dougthompson@xmission.com> 2478M: Doug Thompson <dougthompson@xmission.com>
2479L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2479L: linux-edac@vger.kernel.org
2480W: bluesmoke.sourceforge.net 2480W: bluesmoke.sourceforge.net
2481S: Maintained 2481S: Maintained
2482F: drivers/edac/e7xxx_edac.c 2482F: drivers/edac/e7xxx_edac.c
2483 2483
2484EDAC-I82443BXGX 2484EDAC-I82443BXGX
2485M: Tim Small <tim@buttersideup.com> 2485M: Tim Small <tim@buttersideup.com>
2486L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2486L: linux-edac@vger.kernel.org
2487W: bluesmoke.sourceforge.net 2487W: bluesmoke.sourceforge.net
2488S: Maintained 2488S: Maintained
2489F: drivers/edac/i82443bxgx_edac.c 2489F: drivers/edac/i82443bxgx_edac.c
2490 2490
2491EDAC-I3000 2491EDAC-I3000
2492M: Jason Uhlenkott <juhlenko@akamai.com> 2492M: Jason Uhlenkott <juhlenko@akamai.com>
2493L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2493L: linux-edac@vger.kernel.org
2494W: bluesmoke.sourceforge.net 2494W: bluesmoke.sourceforge.net
2495S: Maintained 2495S: Maintained
2496F: drivers/edac/i3000_edac.c 2496F: drivers/edac/i3000_edac.c
2497 2497
2498EDAC-I5000 2498EDAC-I5000
2499M: Doug Thompson <dougthompson@xmission.com> 2499M: Doug Thompson <dougthompson@xmission.com>
2500L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2500L: linux-edac@vger.kernel.org
2501W: bluesmoke.sourceforge.net 2501W: bluesmoke.sourceforge.net
2502S: Maintained 2502S: Maintained
2503F: drivers/edac/i5000_edac.c 2503F: drivers/edac/i5000_edac.c
@@ -2526,21 +2526,21 @@ F: drivers/edac/i7core_edac.c
2526EDAC-I82975X 2526EDAC-I82975X
2527M: Ranganathan Desikan <ravi@jetztechnologies.com> 2527M: Ranganathan Desikan <ravi@jetztechnologies.com>
2528M: "Arvind R." <arvino55@gmail.com> 2528M: "Arvind R." <arvino55@gmail.com>
2529L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2529L: linux-edac@vger.kernel.org
2530W: bluesmoke.sourceforge.net 2530W: bluesmoke.sourceforge.net
2531S: Maintained 2531S: Maintained
2532F: drivers/edac/i82975x_edac.c 2532F: drivers/edac/i82975x_edac.c
2533 2533
2534EDAC-PASEMI 2534EDAC-PASEMI
2535M: Egor Martovetsky <egor@pasemi.com> 2535M: Egor Martovetsky <egor@pasemi.com>
2536L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2536L: linux-edac@vger.kernel.org
2537W: bluesmoke.sourceforge.net 2537W: bluesmoke.sourceforge.net
2538S: Maintained 2538S: Maintained
2539F: drivers/edac/pasemi_edac.c 2539F: drivers/edac/pasemi_edac.c
2540 2540
2541EDAC-R82600 2541EDAC-R82600
2542M: Tim Small <tim@buttersideup.com> 2542M: Tim Small <tim@buttersideup.com>
2543L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2543L: linux-edac@vger.kernel.org
2544W: bluesmoke.sourceforge.net 2544W: bluesmoke.sourceforge.net
2545S: Maintained 2545S: Maintained
2546F: drivers/edac/r82600_edac.c 2546F: drivers/edac/r82600_edac.c
@@ -4528,8 +4528,7 @@ S: Supported
4528F: drivers/net/ethernet/myricom/myri10ge/ 4528F: drivers/net/ethernet/myricom/myri10ge/
4529 4529
4530NATSEMI ETHERNET DRIVER (DP8381x) 4530NATSEMI ETHERNET DRIVER (DP8381x)
4531M: Tim Hockin <thockin@hockin.org> 4531S: Orphan
4532S: Maintained
4533F: drivers/net/ethernet/natsemi/natsemi.c 4532F: drivers/net/ethernet/natsemi/natsemi.c
4534 4533
4535NATIVE INSTRUMENTS USB SOUND INTERFACE DRIVER 4534NATIVE INSTRUMENTS USB SOUND INTERFACE DRIVER
@@ -4798,6 +4797,7 @@ F: arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
4798F: arch/arm/mach-omap2/clockdomain44xx.c 4797F: arch/arm/mach-omap2/clockdomain44xx.c
4799 4798
4800OMAP AUDIO SUPPORT 4799OMAP AUDIO SUPPORT
4800M: Peter Ujfalusi <peter.ujfalusi@ti.com>
4801M: Jarkko Nikula <jarkko.nikula@bitmer.com> 4801M: Jarkko Nikula <jarkko.nikula@bitmer.com>
4802L: alsa-devel@alsa-project.org (subscribers-only) 4802L: alsa-devel@alsa-project.org (subscribers-only)
4803L: linux-omap@vger.kernel.org 4803L: linux-omap@vger.kernel.org
@@ -5112,6 +5112,11 @@ F: drivers/i2c/busses/i2c-pca-*
5112F: include/linux/i2c-algo-pca.h 5112F: include/linux/i2c-algo-pca.h
5113F: include/linux/i2c-pca-platform.h 5113F: include/linux/i2c-pca-platform.h
5114 5114
5115PCDP - PRIMARY CONSOLE AND DEBUG PORT
5116M: Khalid Aziz <khalid.aziz@hp.com>
5117S: Maintained
5118F: drivers/firmware/pcdp.*
5119
5115PCI ERROR RECOVERY 5120PCI ERROR RECOVERY
5116M: Linas Vepstas <linasvepstas@gmail.com> 5121M: Linas Vepstas <linasvepstas@gmail.com>
5117L: linux-pci@vger.kernel.org 5122L: linux-pci@vger.kernel.org
@@ -7456,8 +7461,7 @@ F: include/linux/wm97xx.h
7456 7461
7457WOLFSON MICROELECTRONICS DRIVERS 7462WOLFSON MICROELECTRONICS DRIVERS
7458M: Mark Brown <broonie@opensource.wolfsonmicro.com> 7463M: Mark Brown <broonie@opensource.wolfsonmicro.com>
7459M: Ian Lartey <ian@opensource.wolfsonmicro.com> 7464L: patches@opensource.wolfsonmicro.com
7460M: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
7461T: git git://opensource.wolfsonmicro.com/linux-2.6-asoc 7465T: git git://opensource.wolfsonmicro.com/linux-2.6-asoc
7462T: git git://opensource.wolfsonmicro.com/linux-2.6-audioplus 7466T: git git://opensource.wolfsonmicro.com/linux-2.6-audioplus
7463W: http://opensource.wolfsonmicro.com/content/linux-drivers-wolfson-devices 7467W: http://opensource.wolfsonmicro.com/content/linux-drivers-wolfson-devices
diff --git a/Makefile b/Makefile
index 5e637c23974..0df3d003a07 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 4 2PATCHLEVEL = 4
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Saber-toothed Squirrel 5NAME = Saber-toothed Squirrel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/c6x/include/asm/irq.h b/arch/c6x/include/asm/irq.h
index f13b78d5e1c..ab4577f93d9 100644
--- a/arch/c6x/include/asm/irq.h
+++ b/arch/c6x/include/asm/irq.h
@@ -42,10 +42,6 @@
42/* This number is used when no interrupt has been assigned */ 42/* This number is used when no interrupt has been assigned */
43#define NO_IRQ 0 43#define NO_IRQ 0
44 44
45struct irq_data;
46extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
47extern irq_hw_number_t virq_to_hw(unsigned int virq);
48
49extern void __init init_pic_c64xplus(void); 45extern void __init init_pic_c64xplus(void);
50 46
51extern void init_IRQ(void); 47extern void init_IRQ(void);
diff --git a/arch/c6x/kernel/irq.c b/arch/c6x/kernel/irq.c
index 65b8ddf54b4..c90fb5e82ad 100644
--- a/arch/c6x/kernel/irq.c
+++ b/arch/c6x/kernel/irq.c
@@ -130,16 +130,3 @@ int arch_show_interrupts(struct seq_file *p, int prec)
130 seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count); 130 seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
131 return 0; 131 return 0;
132} 132}
133
134irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
135{
136 return d->hwirq;
137}
138EXPORT_SYMBOL_GPL(irqd_to_hwirq);
139
140irq_hw_number_t virq_to_hw(unsigned int virq)
141{
142 struct irq_data *irq_data = irq_get_irq_data(virq);
143 return WARN_ON(!irq_data) ? 0 : irq_data->hwirq;
144}
145EXPORT_SYMBOL_GPL(virq_to_hw);
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index cf417e51073..e648af92ced 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -33,8 +33,6 @@ extern atomic_t ppc_n_lost_interrupts;
33/* Same thing, used by the generic IRQ code */ 33/* Same thing, used by the generic IRQ code */
34#define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS 34#define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS
35 35
36struct irq_data;
37extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
38extern irq_hw_number_t virq_to_hw(unsigned int virq); 36extern irq_hw_number_t virq_to_hw(unsigned int virq);
39 37
40/** 38/**
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 3e57a00b8cb..ba3aeb4bc06 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -206,40 +206,43 @@ reenable_mmu: /* re-enable mmu so we can */
206 andi. r10,r10,MSR_EE /* Did EE change? */ 206 andi. r10,r10,MSR_EE /* Did EE change? */
207 beq 1f 207 beq 1f
208 208
209 /* Save handler and return address into the 2 unused words
210 * of the STACK_FRAME_OVERHEAD (sneak sneak sneak). Everything
211 * else can be recovered from the pt_regs except r3 which for
212 * normal interrupts has been set to pt_regs and for syscalls
213 * is an argument, so we temporarily use ORIG_GPR3 to save it
214 */
215 stw r9,8(r1)
216 stw r11,12(r1)
217 stw r3,ORIG_GPR3(r1)
218 /* 209 /*
219 * The trace_hardirqs_off will use CALLER_ADDR0 and CALLER_ADDR1. 210 * The trace_hardirqs_off will use CALLER_ADDR0 and CALLER_ADDR1.
220 * If from user mode there is only one stack frame on the stack, and 211 * If from user mode there is only one stack frame on the stack, and
221 * accessing CALLER_ADDR1 will cause oops. So we need create a dummy 212 * accessing CALLER_ADDR1 will cause oops. So we need create a dummy
222 * stack frame to make trace_hardirqs_off happy. 213 * stack frame to make trace_hardirqs_off happy.
214 *
215 * This is handy because we also need to save a bunch of GPRs,
216 * r3 can be different from GPR3(r1) at this point, r9 and r11
217 * contains the old MSR and handler address respectively,
218 * r4 & r5 can contain page fault arguments that need to be passed
219 * along as well. r12, CCR, CTR, XER etc... are left clobbered as
220 * they aren't useful past this point (aren't syscall arguments),
221 * the rest is restored from the exception frame.
223 */ 222 */
223 stwu r1,-32(r1)
224 stw r9,8(r1)
225 stw r11,12(r1)
226 stw r3,16(r1)
227 stw r4,20(r1)
228 stw r5,24(r1)
224 andi. r12,r12,MSR_PR 229 andi. r12,r12,MSR_PR
225 beq 11f 230 b 11f
226 stwu r1,-16(r1)
227 bl trace_hardirqs_off 231 bl trace_hardirqs_off
228 addi r1,r1,16
229 b 12f 232 b 12f
230
23111: 23311:
232 bl trace_hardirqs_off 234 bl trace_hardirqs_off
23312: 23512:
236 lwz r5,24(r1)
237 lwz r4,20(r1)
238 lwz r3,16(r1)
239 lwz r11,12(r1)
240 lwz r9,8(r1)
241 addi r1,r1,32
234 lwz r0,GPR0(r1) 242 lwz r0,GPR0(r1)
235 lwz r3,ORIG_GPR3(r1)
236 lwz r4,GPR4(r1)
237 lwz r5,GPR5(r1)
238 lwz r6,GPR6(r1) 243 lwz r6,GPR6(r1)
239 lwz r7,GPR7(r1) 244 lwz r7,GPR7(r1)
240 lwz r8,GPR8(r1) 245 lwz r8,GPR8(r1)
241 lwz r9,8(r1)
242 lwz r11,12(r1)
2431: mtctr r11 2461: mtctr r11
244 mtlr r9 247 mtlr r9
245 bctr /* jump to handler */ 248 bctr /* jump to handler */
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 243dbabfe74..5ec1b2354ca 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -560,12 +560,6 @@ void do_softirq(void)
560 local_irq_restore(flags); 560 local_irq_restore(flags);
561} 561}
562 562
563irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
564{
565 return d->hwirq;
566}
567EXPORT_SYMBOL_GPL(irqd_to_hwirq);
568
569irq_hw_number_t virq_to_hw(unsigned int virq) 563irq_hw_number_t virq_to_hw(unsigned int virq)
570{ 564{
571 struct irq_data *irq_data = irq_get_irq_data(virq); 565 struct irq_data *irq_data = irq_get_irq_data(virq);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index f88698c0f33..4937c969009 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1235,7 +1235,7 @@ void __ppc64_runlatch_on(void)
1235 ctrl |= CTRL_RUNLATCH; 1235 ctrl |= CTRL_RUNLATCH;
1236 mtspr(SPRN_CTRLT, ctrl); 1236 mtspr(SPRN_CTRLT, ctrl);
1237 1237
1238 ti->local_flags |= TLF_RUNLATCH; 1238 ti->local_flags |= _TLF_RUNLATCH;
1239} 1239}
1240 1240
1241/* Called with hard IRQs off */ 1241/* Called with hard IRQs off */
@@ -1244,7 +1244,7 @@ void __ppc64_runlatch_off(void)
1244 struct thread_info *ti = current_thread_info(); 1244 struct thread_info *ti = current_thread_info();
1245 unsigned long ctrl; 1245 unsigned long ctrl;
1246 1246
1247 ti->local_flags &= ~TLF_RUNLATCH; 1247 ti->local_flags &= ~_TLF_RUNLATCH;
1248 1248
1249 ctrl = mfspr(SPRN_CTRLF); 1249 ctrl = mfspr(SPRN_CTRLF);
1250 ctrl &= ~CTRL_RUNLATCH; 1250 ctrl &= ~CTRL_RUNLATCH;
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index bed1279aa6a..e1b60f56f2a 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -173,9 +173,9 @@ static void __init kvm_linear_init_one(ulong size, int count, int type)
173 173
174static struct kvmppc_linear_info *kvm_alloc_linear(int type) 174static struct kvmppc_linear_info *kvm_alloc_linear(int type)
175{ 175{
176 struct kvmppc_linear_info *ri; 176 struct kvmppc_linear_info *ri, *ret;
177 177
178 ri = NULL; 178 ret = NULL;
179 spin_lock(&linear_lock); 179 spin_lock(&linear_lock);
180 list_for_each_entry(ri, &free_linears, list) { 180 list_for_each_entry(ri, &free_linears, list) {
181 if (ri->type != type) 181 if (ri->type != type)
@@ -183,11 +183,12 @@ static struct kvmppc_linear_info *kvm_alloc_linear(int type)
183 183
184 list_del(&ri->list); 184 list_del(&ri->list);
185 atomic_inc(&ri->use_count); 185 atomic_inc(&ri->use_count);
186 memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT);
187 ret = ri;
186 break; 188 break;
187 } 189 }
188 spin_unlock(&linear_lock); 190 spin_unlock(&linear_lock);
189 memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT); 191 return ret;
190 return ri;
191} 192}
192 193
193static void kvm_release_linear(struct kvmppc_linear_info *ri) 194static void kvm_release_linear(struct kvmppc_linear_info *ri)
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 3f7b674dd4b..d3fb4df02c4 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -46,8 +46,10 @@ _GLOBAL(__kvmppc_vcore_entry)
46 /* Save host state to the stack */ 46 /* Save host state to the stack */
47 stdu r1, -SWITCH_FRAME_SIZE(r1) 47 stdu r1, -SWITCH_FRAME_SIZE(r1)
48 48
49 /* Save non-volatile registers (r14 - r31) */ 49 /* Save non-volatile registers (r14 - r31) and CR */
50 SAVE_NVGPRS(r1) 50 SAVE_NVGPRS(r1)
51 mfcr r3
52 std r3, _CCR(r1)
51 53
52 /* Save host DSCR */ 54 /* Save host DSCR */
53BEGIN_FTR_SECTION 55BEGIN_FTR_SECTION
@@ -157,8 +159,10 @@ kvmppc_handler_highmem:
157 * R13 = PACA 159 * R13 = PACA
158 */ 160 */
159 161
160 /* Restore non-volatile host registers (r14 - r31) */ 162 /* Restore non-volatile host registers (r14 - r31) and CR */
161 REST_NVGPRS(r1) 163 REST_NVGPRS(r1)
164 ld r4, _CCR(r1)
165 mtcr r4
162 166
163 addi r1, r1, SWITCH_FRAME_SIZE 167 addi r1, r1, SWITCH_FRAME_SIZE
164 ld r0, PPC_LR_STKOFF(r1) 168 ld r0, PPC_LR_STKOFF(r1)
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S
index 0a8515a5c04..3e35383bdb2 100644
--- a/arch/powerpc/kvm/book3s_interrupts.S
+++ b/arch/powerpc/kvm/book3s_interrupts.S
@@ -84,6 +84,10 @@ kvm_start_entry:
84 /* Save non-volatile registers (r14 - r31) */ 84 /* Save non-volatile registers (r14 - r31) */
85 SAVE_NVGPRS(r1) 85 SAVE_NVGPRS(r1)
86 86
87 /* Save CR */
88 mfcr r14
89 stw r14, _CCR(r1)
90
87 /* Save LR */ 91 /* Save LR */
88 PPC_STL r0, _LINK(r1) 92 PPC_STL r0, _LINK(r1)
89 93
@@ -165,6 +169,9 @@ kvm_exit_loop:
165 PPC_LL r4, _LINK(r1) 169 PPC_LL r4, _LINK(r1)
166 mtlr r4 170 mtlr r4
167 171
172 lwz r14, _CCR(r1)
173 mtcr r14
174
168 /* Restore non-volatile host registers (r14 - r31) */ 175 /* Restore non-volatile host registers (r14 - r31) */
169 REST_NVGPRS(r1) 176 REST_NVGPRS(r1)
170 177
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 642d88574b0..7759053d391 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -777,6 +777,7 @@ program_interrupt:
777 } 777 }
778 } 778 }
779 779
780 preempt_disable();
780 if (!(r & RESUME_HOST)) { 781 if (!(r & RESUME_HOST)) {
781 /* To avoid clobbering exit_reason, only check for signals if 782 /* To avoid clobbering exit_reason, only check for signals if
782 * we aren't already exiting to userspace for some other 783 * we aren't already exiting to userspace for some other
@@ -798,8 +799,6 @@ program_interrupt:
798 run->exit_reason = KVM_EXIT_INTR; 799 run->exit_reason = KVM_EXIT_INTR;
799 r = -EINTR; 800 r = -EINTR;
800 } else { 801 } else {
801 preempt_disable();
802
803 /* In case an interrupt came in that was triggered 802 /* In case an interrupt came in that was triggered
804 * from userspace (like DEC), we need to check what 803 * from userspace (like DEC), we need to check what
805 * to inject now! */ 804 * to inject now! */
@@ -881,7 +880,8 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
881 880
882 switch (reg->id) { 881 switch (reg->id) {
883 case KVM_REG_PPC_HIOR: 882 case KVM_REG_PPC_HIOR:
884 r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr); 883 r = copy_to_user((u64 __user *)(long)reg->addr,
884 &to_book3s(vcpu)->hior, sizeof(u64));
885 break; 885 break;
886 default: 886 default:
887 break; 887 break;
@@ -896,7 +896,8 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
896 896
897 switch (reg->id) { 897 switch (reg->id) {
898 case KVM_REG_PPC_HIOR: 898 case KVM_REG_PPC_HIOR:
899 r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr); 899 r = copy_from_user(&to_book3s(vcpu)->hior,
900 (u64 __user *)(long)reg->addr, sizeof(u64));
900 if (!r) 901 if (!r)
901 to_book3s(vcpu)->hior_explicit = true; 902 to_book3s(vcpu)->hior_explicit = true;
902 break; 903 break;
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 10d8ef602e5..c8c4b878795 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -34,7 +34,8 @@
34/* r2 is special: it holds 'current', and it made nonvolatile in the 34/* r2 is special: it holds 'current', and it made nonvolatile in the
35 * kernel with the -ffixed-r2 gcc option. */ 35 * kernel with the -ffixed-r2 gcc option. */
36#define HOST_R2 12 36#define HOST_R2 12
37#define HOST_NV_GPRS 16 37#define HOST_CR 16
38#define HOST_NV_GPRS 20
38#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4)) 39#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4))
39#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4) 40#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4)
40#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */ 41#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
@@ -296,8 +297,10 @@ heavyweight_exit:
296 297
297 /* Return to kvm_vcpu_run(). */ 298 /* Return to kvm_vcpu_run(). */
298 lwz r4, HOST_STACK_LR(r1) 299 lwz r4, HOST_STACK_LR(r1)
300 lwz r5, HOST_CR(r1)
299 addi r1, r1, HOST_STACK_SIZE 301 addi r1, r1, HOST_STACK_SIZE
300 mtlr r4 302 mtlr r4
303 mtcr r5
301 /* r3 still contains the return code from kvmppc_handle_exit(). */ 304 /* r3 still contains the return code from kvmppc_handle_exit(). */
302 blr 305 blr
303 306
@@ -314,6 +317,8 @@ _GLOBAL(__kvmppc_vcpu_run)
314 stw r3, HOST_RUN(r1) 317 stw r3, HOST_RUN(r1)
315 mflr r3 318 mflr r3
316 stw r3, HOST_STACK_LR(r1) 319 stw r3, HOST_STACK_LR(r1)
320 mfcr r5
321 stw r5, HOST_CR(r1)
317 322
318 /* Save host non-volatile register state to stack. */ 323 /* Save host non-volatile register state to stack. */
319 stw r14, HOST_NV_GPR(r14)(r1) 324 stw r14, HOST_NV_GPR(r14)(r1)
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index db360fc4cf0..d09f3e8e686 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -392,7 +392,7 @@ static int axon_msi_probe(struct platform_device *device)
392 } 392 }
393 memset(msic->fifo_virt, 0xff, MSIC_FIFO_SIZE_BYTES); 393 memset(msic->fifo_virt, 0xff, MSIC_FIFO_SIZE_BYTES);
394 394
395 msic->irq_domain = irq_domain_add_nomap(dn, &msic_host_ops, msic); 395 msic->irq_domain = irq_domain_add_nomap(dn, 0, &msic_host_ops, msic);
396 if (!msic->irq_domain) { 396 if (!msic->irq_domain) {
397 printk(KERN_ERR "axon_msi: couldn't allocate irq_domain for %s\n", 397 printk(KERN_ERR "axon_msi: couldn't allocate irq_domain for %s\n",
398 dn->full_name); 398 dn->full_name);
diff --git a/arch/powerpc/platforms/cell/beat_interrupt.c b/arch/powerpc/platforms/cell/beat_interrupt.c
index e5c3a2c6090..f9a48af335c 100644
--- a/arch/powerpc/platforms/cell/beat_interrupt.c
+++ b/arch/powerpc/platforms/cell/beat_interrupt.c
@@ -239,7 +239,7 @@ void __init beatic_init_IRQ(void)
239 ppc_md.get_irq = beatic_get_irq; 239 ppc_md.get_irq = beatic_get_irq;
240 240
241 /* Allocate an irq host */ 241 /* Allocate an irq host */
242 beatic_host = irq_domain_add_nomap(NULL, &beatic_pic_host_ops, NULL); 242 beatic_host = irq_domain_add_nomap(NULL, 0, &beatic_pic_host_ops, NULL);
243 BUG_ON(beatic_host == NULL); 243 BUG_ON(beatic_host == NULL);
244 irq_set_default_host(beatic_host); 244 irq_set_default_host(beatic_host);
245} 245}
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index a81e5a88fbd..b4ddaa3fbb2 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -192,7 +192,7 @@ static int psurge_secondary_ipi_init(void)
192{ 192{
193 int rc = -ENOMEM; 193 int rc = -ENOMEM;
194 194
195 psurge_host = irq_domain_add_nomap(NULL, &psurge_host_ops, NULL); 195 psurge_host = irq_domain_add_nomap(NULL, 0, &psurge_host_ops, NULL);
196 196
197 if (psurge_host) 197 if (psurge_host)
198 psurge_secondary_virq = irq_create_direct_mapping(psurge_host); 198 psurge_secondary_virq = irq_create_direct_mapping(psurge_host);
diff --git a/arch/powerpc/platforms/ps3/interrupt.c b/arch/powerpc/platforms/ps3/interrupt.c
index 2a4ff86cc21..5f3b23220b8 100644
--- a/arch/powerpc/platforms/ps3/interrupt.c
+++ b/arch/powerpc/platforms/ps3/interrupt.c
@@ -753,9 +753,8 @@ void __init ps3_init_IRQ(void)
753 unsigned cpu; 753 unsigned cpu;
754 struct irq_domain *host; 754 struct irq_domain *host;
755 755
756 host = irq_domain_add_nomap(NULL, &ps3_host_ops, NULL); 756 host = irq_domain_add_nomap(NULL, PS3_PLUG_MAX + 1, &ps3_host_ops, NULL);
757 irq_set_default_host(host); 757 irq_set_default_host(host);
758 irq_set_virq_count(PS3_PLUG_MAX + 1);
759 758
760 for_each_possible_cpu(cpu) { 759 for_each_possible_cpu(cpu) {
761 struct ps3_private *pd = &per_cpu(ps3_private, cpu); 760 struct ps3_private *pd = &per_cpu(ps3_private, cpu);
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index c1d5a820b1a..5f2bb4242c0 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -61,6 +61,7 @@ config DUMP_CODE
61config DWARF_UNWINDER 61config DWARF_UNWINDER
62 bool "Enable the DWARF unwinder for stacktraces" 62 bool "Enable the DWARF unwinder for stacktraces"
63 select FRAME_POINTER 63 select FRAME_POINTER
64 depends on SUPERH32
64 default n 65 default n
65 help 66 help
66 Enabling this option will make stacktraces more accurate, at 67 Enabling this option will make stacktraces more accurate, at
diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index d879848f3cd..d0d6221d7c2 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -28,6 +28,7 @@
28#include <cpu/sh7785.h> 28#include <cpu/sh7785.h>
29#include <asm/heartbeat.h> 29#include <asm/heartbeat.h>
30#include <asm/clock.h> 30#include <asm/clock.h>
31#include <asm/bl_bit.h>
31 32
32/* 33/*
33 * NOTE: This board has 2 physical memory maps. 34 * NOTE: This board has 2 physical memory maps.
diff --git a/arch/sh/boards/mach-hp6xx/pm.c b/arch/sh/boards/mach-hp6xx/pm.c
index adc9b4bba82..8b50cf763c0 100644
--- a/arch/sh/boards/mach-hp6xx/pm.c
+++ b/arch/sh/boards/mach-hp6xx/pm.c
@@ -14,6 +14,7 @@
14#include <linux/gfp.h> 14#include <linux/gfp.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/hd64461.h> 16#include <asm/hd64461.h>
17#include <asm/bl_bit.h>
17#include <mach/hp6xx.h> 18#include <mach/hp6xx.h>
18#include <cpu/dac.h> 19#include <cpu/dac.h>
19#include <asm/freq.h> 20#include <asm/freq.h>
diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index b1cb2715ad6..67ee9560381 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -54,7 +54,7 @@ static int __init dma_subsys_init(void)
54 if (unlikely(ret)) 54 if (unlikely(ret))
55 return ret; 55 return ret;
56 56
57 return device_create_file(dma_subsys.dev_root, &dev_attr_devices.attr); 57 return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
58} 58}
59postcore_initcall(dma_subsys_init); 59postcore_initcall(dma_subsys_init);
60 60
diff --git a/arch/sh/kernel/cpu/fpu.c b/arch/sh/kernel/cpu/fpu.c
index 7f1b70cace3..f8f7af51c12 100644
--- a/arch/sh/kernel/cpu/fpu.c
+++ b/arch/sh/kernel/cpu/fpu.c
@@ -2,6 +2,7 @@
2#include <linux/slab.h> 2#include <linux/slab.h>
3#include <asm/processor.h> 3#include <asm/processor.h>
4#include <asm/fpu.h> 4#include <asm/fpu.h>
5#include <asm/traps.h>
5 6
6int init_fpu(struct task_struct *tsk) 7int init_fpu(struct task_struct *tsk)
7{ 8{
diff --git a/arch/sh/kernel/cpu/sh2a/fpu.c b/arch/sh/kernel/cpu/sh2a/fpu.c
index 488d24e0cdf..98bbaa447c9 100644
--- a/arch/sh/kernel/cpu/sh2a/fpu.c
+++ b/arch/sh/kernel/cpu/sh2a/fpu.c
@@ -14,6 +14,7 @@
14#include <asm/processor.h> 14#include <asm/processor.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/fpu.h> 16#include <asm/fpu.h>
17#include <asm/traps.h>
17 18
18/* The PR (precision) bit in the FP Status Register must be clear when 19/* The PR (precision) bit in the FP Status Register must be clear when
19 * an frchg instruction is executed, otherwise the instruction is undefined. 20 * an frchg instruction is executed, otherwise the instruction is undefined.
diff --git a/arch/sh/kernel/cpu/sh4/fpu.c b/arch/sh/kernel/cpu/sh4/fpu.c
index e74cd6c0f10..69ab4d3c8d4 100644
--- a/arch/sh/kernel/cpu/sh4/fpu.c
+++ b/arch/sh/kernel/cpu/sh4/fpu.c
@@ -16,6 +16,7 @@
16#include <cpu/fpu.h> 16#include <cpu/fpu.h>
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/fpu.h> 18#include <asm/fpu.h>
19#include <asm/traps.h>
19 20
20/* The PR (precision) bit in the FP Status Register must be clear when 21/* The PR (precision) bit in the FP Status Register must be clear when
21 * an frchg instruction is executed, otherwise the instruction is undefined. 22 * an frchg instruction is executed, otherwise the instruction is undefined.
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 5853989586e..04ab5aeaf92 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -113,7 +113,7 @@ static struct clk_lookup lookups[] = {
113 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]), 113 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
114 114
115 /* MSTP32 clocks */ 115 /* MSTP32 clocks */
116 CLKDEV_CON_ID("sdhi0", &mstp_clks[MSTP004]), 116 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP004]),
117 CLKDEV_CON_ID("riic0", &mstp_clks[MSTP000]), 117 CLKDEV_CON_ID("riic0", &mstp_clks[MSTP000]),
118 CLKDEV_CON_ID("riic1", &mstp_clks[MSTP000]), 118 CLKDEV_CON_ID("riic1", &mstp_clks[MSTP000]),
119 CLKDEV_CON_ID("riic2", &mstp_clks[MSTP000]), 119 CLKDEV_CON_ID("riic2", &mstp_clks[MSTP000]),
diff --git a/arch/sh/kernel/cpu/shmobile/pm.c b/arch/sh/kernel/cpu/shmobile/pm.c
index a6f95ae4aae..08d27fac8d0 100644
--- a/arch/sh/kernel/cpu/shmobile/pm.c
+++ b/arch/sh/kernel/cpu/shmobile/pm.c
@@ -16,6 +16,7 @@
16#include <asm/suspend.h> 16#include <asm/suspend.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/bl_bit.h>
19 20
20/* 21/*
21 * Notifier lists for pre/post sleep notification 22 * Notifier lists for pre/post sleep notification
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 64852ecc688..ee226e20c20 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -17,8 +17,8 @@
17#include <linux/irqflags.h> 17#include <linux/irqflags.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/cpuidle.h> 19#include <linux/cpuidle.h>
20#include <asm/pgalloc.h>
21#include <linux/atomic.h> 20#include <linux/atomic.h>
21#include <asm/pgalloc.h>
22#include <asm/smp.h> 22#include <asm/smp.h>
23#include <asm/bl_bit.h> 23#include <asm/bl_bit.h>
24 24
diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c
index efb6d398dec..b117781bfea 100644
--- a/arch/sh/kernel/kgdb.c
+++ b/arch/sh/kernel/kgdb.c
@@ -14,6 +14,7 @@
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/traps.h>
17 18
18/* Macros for single step instruction identification */ 19/* Macros for single step instruction identification */
19#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900) 20#define OPCODE_BT(op) (((op) & 0xff00) == 0x8900)
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index f72e3a95158..94273aaf78c 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -26,6 +26,7 @@
26#include <asm/mmu_context.h> 26#include <asm/mmu_context.h>
27#include <asm/fpu.h> 27#include <asm/fpu.h>
28#include <asm/syscalls.h> 28#include <asm/syscalls.h>
29#include <asm/switch_to.h>
29 30
30void show_regs(struct pt_regs * regs) 31void show_regs(struct pt_regs * regs)
31{ 32{
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index a17a14d3234..eaebdf6a5c7 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -27,6 +27,7 @@
27#include <asm/smp.h> 27#include <asm/smp.h>
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/sections.h> 29#include <asm/sections.h>
30#include <asm/setup.h>
30 31
31int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ 32int __cpu_number_map[NR_CPUS]; /* Map physical to logical */
32int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ 33int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */
diff --git a/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S b/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S
index 555a64f124c..23af1758405 100644
--- a/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S
+++ b/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S
@@ -34,6 +34,41 @@ __kernel_rt_sigreturn:
341: .short __NR_rt_sigreturn 341: .short __NR_rt_sigreturn
35.LEND_rt_sigreturn: 35.LEND_rt_sigreturn:
36 .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn 36 .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
37 .previous
37 38
38 .section .eh_frame,"a",@progbits 39 .section .eh_frame,"a",@progbits
40.LCIE1:
41 .ualong .LCIE1_end - .LCIE1_start
42.LCIE1_start:
43 .ualong 0 /* CIE ID */
44 .byte 0x1 /* Version number */
45 .string "zRS" /* NUL-terminated augmentation string */
46 .uleb128 0x1 /* Code alignment factor */
47 .sleb128 -4 /* Data alignment factor */
48 .byte 0x11 /* Return address register column */
49 .uleb128 0x1 /* Augmentation length and data */
50 .byte 0x1b /* DW_EH_PE_pcrel | DW_EH_PE_sdata4. */
51 .byte 0xc, 0xf, 0x0 /* DW_CFA_def_cfa: r15 ofs 0 */
52
53 .align 2
54.LCIE1_end:
55
56 .ualong .LFDE0_end-.LFDE0_start /* Length FDE0 */
57.LFDE0_start:
58 .ualong .LFDE0_start-.LCIE1 /* CIE pointer */
59 .ualong .LSTART_sigreturn-. /* PC-relative start address */
60 .ualong .LEND_sigreturn-.LSTART_sigreturn
61 .uleb128 0 /* Augmentation */
62 .align 2
63.LFDE0_end:
64
65 .ualong .LFDE1_end-.LFDE1_start /* Length FDE1 */
66.LFDE1_start:
67 .ualong .LFDE1_start-.LCIE1 /* CIE pointer */
68 .ualong .LSTART_rt_sigreturn-. /* PC-relative start address */
69 .ualong .LEND_rt_sigreturn-.LSTART_rt_sigreturn
70 .uleb128 0 /* Augmentation */
71 .align 2
72.LFDE1_end:
73
39 .previous 74 .previous
diff --git a/arch/sh/kernel/vsyscall/vsyscall-trapa.S b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
index 3e70f851cdc..0eb74d00690 100644
--- a/arch/sh/kernel/vsyscall/vsyscall-trapa.S
+++ b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
@@ -3,37 +3,34 @@
3 .type __kernel_vsyscall,@function 3 .type __kernel_vsyscall,@function
4__kernel_vsyscall: 4__kernel_vsyscall:
5.LSTART_vsyscall: 5.LSTART_vsyscall:
6 /* XXX: We'll have to do something here once we opt to use the vDSO 6 trapa #0x10
7 * page for something other than the signal trampoline.. as well as 7 nop
8 * fill out .eh_frame -- PFM. */
9.LEND_vsyscall: 8.LEND_vsyscall:
10 .size __kernel_vsyscall,.-.LSTART_vsyscall 9 .size __kernel_vsyscall,.-.LSTART_vsyscall
10 .previous
11 11
12 .section .eh_frame,"a",@progbits 12 .section .eh_frame,"a",@progbits
13 .previous
14.LCIE: 13.LCIE:
15 .ualong .LCIE_end - .LCIE_start 14 .ualong .LCIE_end - .LCIE_start
16.LCIE_start: 15.LCIE_start:
17 .ualong 0 /* CIE ID */ 16 .ualong 0 /* CIE ID */
18 .byte 0x1 /* Version number */ 17 .byte 0x1 /* Version number */
19 .string "zRS" /* NUL-terminated augmentation string */ 18 .string "zR" /* NUL-terminated augmentation string */
20 .uleb128 0x1 /* Code alignment factor */ 19 .uleb128 0x1 /* Code alignment factor */
21 .sleb128 -4 /* Data alignment factor */ 20 .sleb128 -4 /* Data alignment factor */
22 .byte 0x11 /* Return address register column */ 21 .byte 0x11 /* Return address register column */
23 /* Augmentation length and data (none) */ 22 .uleb128 0x1 /* Augmentation length and data */
24 .byte 0xc /* DW_CFA_def_cfa */ 23 .byte 0x1b /* DW_EH_PE_pcrel | DW_EH_PE_sdata4. */
25 .uleb128 0xf /* r15 */ 24 .byte 0xc,0xf,0x0 /* DW_CFA_def_cfa: r15 ofs 0 */
26 .uleb128 0x0 /* offset 0 */
27
28 .align 2 25 .align 2
29.LCIE_end: 26.LCIE_end:
30 27
31 .ualong .LFDE_end-.LFDE_start /* Length FDE */ 28 .ualong .LFDE_end-.LFDE_start /* Length FDE */
32.LFDE_start: 29.LFDE_start:
33 .ualong .LCIE /* CIE pointer */ 30 .ualong .LFDE_start-.LCIE /* CIE pointer */
34 .ualong .LSTART_vsyscall-. /* start address */ 31 .ualong .LSTART_vsyscall-. /* PC-relative start address */
35 .ualong .LEND_vsyscall-.LSTART_vsyscall 32 .ualong .LEND_vsyscall-.LSTART_vsyscall
36 .uleb128 0 33 .uleb128 0 /* Augmentation */
37 .align 2 34 .align 2
38.LFDE_end: 35.LFDE_end:
39 .previous 36 .previous
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 112fea12522..0e529285b28 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <asm/pgtable.h> 19#include <asm/pgtable.h>
20#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
21#include <asm/cache_insns.h>
21#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
22 23
23/* 24/*
diff --git a/arch/sh/mm/flush-sh4.c b/arch/sh/mm/flush-sh4.c
index 75a17f5bfa1..0b85dd9dd3a 100644
--- a/arch/sh/mm/flush-sh4.c
+++ b/arch/sh/mm/flush-sh4.c
@@ -1,5 +1,6 @@
1#include <linux/mm.h> 1#include <linux/mm.h>
2#include <asm/mmu_context.h> 2#include <asm/mmu_context.h>
3#include <asm/cache_insns.h>
3#include <asm/cacheflush.h> 4#include <asm/cacheflush.h>
4#include <asm/traps.h> 5#include <asm/traps.h>
5 6
diff --git a/arch/sh/mm/sram.c b/arch/sh/mm/sram.c
index bc156ec4545..2d8fa718d55 100644
--- a/arch/sh/mm/sram.c
+++ b/arch/sh/mm/sram.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h>
12#include <asm/sram.h> 13#include <asm/sram.h>
13 14
14/* 15/*
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index aba6b958b2a..19f56058742 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -45,7 +45,6 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
45 45
46void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 46void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
47{ 47{
48 struct leon_pci_info *info = pbus->sysdata;
49 struct pci_dev *dev; 48 struct pci_dev *dev;
50 int i, has_io, has_mem; 49 int i, has_io, has_mem;
51 u16 cmd; 50 u16 cmd;
@@ -111,18 +110,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
111 return pci_enable_resources(dev, mask); 110 return pci_enable_resources(dev, mask);
112} 111}
113 112
114struct device_node *pci_device_to_OF_node(struct pci_dev *pdev)
115{
116 /*
117 * Currently the OpenBoot nodes are not connected with the PCI device,
118 * this is because the LEON PROM does not create PCI nodes. Eventually
119 * this will change and the same approach as pcic.c can be used to
120 * match PROM nodes with pci devices.
121 */
122 return NULL;
123}
124EXPORT_SYMBOL(pci_device_to_OF_node);
125
126void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 113void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
127{ 114{
128#ifdef CONFIG_PCI_DEBUG 115#ifdef CONFIG_PCI_DEBUG
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index 7705c6731e2..df3155a1799 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -225,6 +225,8 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
225 unsigned long g2; 225 unsigned long g2;
226 int from_user = !(regs->psr & PSR_PS); 226 int from_user = !(regs->psr & PSR_PS);
227 int fault, code; 227 int fault, code;
228 unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
229 (write ? FAULT_FLAG_WRITE : 0));
228 230
229 if(text_fault) 231 if(text_fault)
230 address = regs->pc; 232 address = regs->pc;
@@ -251,6 +253,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
251 253
252 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); 254 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
253 255
256retry:
254 down_read(&mm->mmap_sem); 257 down_read(&mm->mmap_sem);
255 258
256 /* 259 /*
@@ -289,7 +292,11 @@ good_area:
289 * make sure we exit gracefully rather than endlessly redo 292 * make sure we exit gracefully rather than endlessly redo
290 * the fault. 293 * the fault.
291 */ 294 */
292 fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); 295 fault = handle_mm_fault(mm, vma, address, flags);
296
297 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
298 return;
299
293 if (unlikely(fault & VM_FAULT_ERROR)) { 300 if (unlikely(fault & VM_FAULT_ERROR)) {
294 if (fault & VM_FAULT_OOM) 301 if (fault & VM_FAULT_OOM)
295 goto out_of_memory; 302 goto out_of_memory;
@@ -297,13 +304,29 @@ good_area:
297 goto do_sigbus; 304 goto do_sigbus;
298 BUG(); 305 BUG();
299 } 306 }
300 if (fault & VM_FAULT_MAJOR) { 307
301 current->maj_flt++; 308 if (flags & FAULT_FLAG_ALLOW_RETRY) {
302 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); 309 if (fault & VM_FAULT_MAJOR) {
303 } else { 310 current->maj_flt++;
304 current->min_flt++; 311 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
305 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); 312 1, regs, address);
313 } else {
314 current->min_flt++;
315 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
316 1, regs, address);
317 }
318 if (fault & VM_FAULT_RETRY) {
319 flags &= ~FAULT_FLAG_ALLOW_RETRY;
320
321 /* No need to up_read(&mm->mmap_sem) as we would
322 * have already released it in __lock_page_or_retry
323 * in mm/filemap.c.
324 */
325
326 goto retry;
327 }
306 } 328 }
329
307 up_read(&mm->mmap_sem); 330 up_read(&mm->mmap_sem);
308 return; 331 return;
309 332
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index 504c0622f72..1fe0429b631 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -279,6 +279,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
279 unsigned int insn = 0; 279 unsigned int insn = 0;
280 int si_code, fault_code, fault; 280 int si_code, fault_code, fault;
281 unsigned long address, mm_rss; 281 unsigned long address, mm_rss;
282 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
282 283
283 fault_code = get_thread_fault_code(); 284 fault_code = get_thread_fault_code();
284 285
@@ -333,6 +334,8 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
333 insn = get_fault_insn(regs, insn); 334 insn = get_fault_insn(regs, insn);
334 goto handle_kernel_fault; 335 goto handle_kernel_fault;
335 } 336 }
337
338retry:
336 down_read(&mm->mmap_sem); 339 down_read(&mm->mmap_sem);
337 } 340 }
338 341
@@ -423,7 +426,12 @@ good_area:
423 goto bad_area; 426 goto bad_area;
424 } 427 }
425 428
426 fault = handle_mm_fault(mm, vma, address, (fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0); 429 flags |= ((fault_code & FAULT_CODE_WRITE) ? FAULT_FLAG_WRITE : 0);
430 fault = handle_mm_fault(mm, vma, address, flags);
431
432 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
433 return;
434
427 if (unlikely(fault & VM_FAULT_ERROR)) { 435 if (unlikely(fault & VM_FAULT_ERROR)) {
428 if (fault & VM_FAULT_OOM) 436 if (fault & VM_FAULT_OOM)
429 goto out_of_memory; 437 goto out_of_memory;
@@ -431,12 +439,27 @@ good_area:
431 goto do_sigbus; 439 goto do_sigbus;
432 BUG(); 440 BUG();
433 } 441 }
434 if (fault & VM_FAULT_MAJOR) { 442
435 current->maj_flt++; 443 if (flags & FAULT_FLAG_ALLOW_RETRY) {
436 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); 444 if (fault & VM_FAULT_MAJOR) {
437 } else { 445 current->maj_flt++;
438 current->min_flt++; 446 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
439 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); 447 1, regs, address);
448 } else {
449 current->min_flt++;
450 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
451 1, regs, address);
452 }
453 if (fault & VM_FAULT_RETRY) {
454 flags &= ~FAULT_FLAG_ALLOW_RETRY;
455
456 /* No need to up_read(&mm->mmap_sem) as we would
457 * have already released it in __lock_page_or_retry
458 * in mm/filemap.c.
459 */
460
461 goto retry;
462 }
440 } 463 }
441 up_read(&mm->mmap_sem); 464 up_read(&mm->mmap_sem);
442 465
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 11270ca22c0..96033e2d684 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -12,7 +12,7 @@ config TILE
12 select GENERIC_PENDING_IRQ if SMP 12 select GENERIC_PENDING_IRQ if SMP
13 select GENERIC_IRQ_SHOW 13 select GENERIC_IRQ_SHOW
14 select SYS_HYPERVISOR 14 select SYS_HYPERVISOR
15 select ARCH_HAVE_NMI_SAFE_CMPXCHG if !M386 15 select ARCH_HAVE_NMI_SAFE_CMPXCHG
16 16
17# FIXME: investigate whether we need/want these options. 17# FIXME: investigate whether we need/want these options.
18# select HAVE_IOREMAP_PROT 18# select HAVE_IOREMAP_PROT
@@ -69,6 +69,9 @@ config ARCH_PHYS_ADDR_T_64BIT
69config ARCH_DMA_ADDR_T_64BIT 69config ARCH_DMA_ADDR_T_64BIT
70 def_bool y 70 def_bool y
71 71
72config NEED_DMA_MAP_STATE
73 def_bool y
74
72config LOCKDEP_SUPPORT 75config LOCKDEP_SUPPORT
73 def_bool y 76 def_bool y
74 77
@@ -118,7 +121,7 @@ config 64BIT
118 121
119config ARCH_DEFCONFIG 122config ARCH_DEFCONFIG
120 string 123 string
121 default "arch/tile/configs/tile_defconfig" if !TILEGX 124 default "arch/tile/configs/tilepro_defconfig" if !TILEGX
122 default "arch/tile/configs/tilegx_defconfig" if TILEGX 125 default "arch/tile/configs/tilegx_defconfig" if TILEGX
123 126
124source "init/Kconfig" 127source "init/Kconfig"
@@ -240,6 +243,7 @@ endchoice
240 243
241config PAGE_OFFSET 244config PAGE_OFFSET
242 hex 245 hex
246 depends on !64BIT
243 default 0xF0000000 if VMSPLIT_3_75G 247 default 0xF0000000 if VMSPLIT_3_75G
244 default 0xE0000000 if VMSPLIT_3_5G 248 default 0xE0000000 if VMSPLIT_3_5G
245 default 0xB0000000 if VMSPLIT_2_75G 249 default 0xB0000000 if VMSPLIT_2_75G
diff --git a/arch/tile/Makefile b/arch/tile/Makefile
index 17acce70569..9520bc5a4b7 100644
--- a/arch/tile/Makefile
+++ b/arch/tile/Makefile
@@ -30,7 +30,8 @@ ifneq ($(CONFIG_DEBUG_EXTRA_FLAGS),"")
30KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS) 30KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS)
31endif 31endif
32 32
33LIBGCC_PATH := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 33LIBGCC_PATH := \
34 $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name)
34 35
35# Provide the path to use for "make defconfig". 36# Provide the path to use for "make defconfig".
36KBUILD_DEFCONFIG := $(ARCH)_defconfig 37KBUILD_DEFCONFIG := $(ARCH)_defconfig
@@ -53,8 +54,6 @@ libs-y += $(LIBGCC_PATH)
53# See arch/tile/Kbuild for content of core part of the kernel 54# See arch/tile/Kbuild for content of core part of the kernel
54core-y += arch/tile/ 55core-y += arch/tile/
55 56
56core-$(CONFIG_KVM) += arch/tile/kvm/
57
58ifdef TILERA_ROOT 57ifdef TILERA_ROOT
59INSTALL_PATH ?= $(TILERA_ROOT)/tile/boot 58INSTALL_PATH ?= $(TILERA_ROOT)/tile/boot
60endif 59endif
diff --git a/arch/tile/include/arch/spr_def.h b/arch/tile/include/arch/spr_def.h
index f548efeb2de..d6ba449b536 100644
--- a/arch/tile/include/arch/spr_def.h
+++ b/arch/tile/include/arch/spr_def.h
@@ -60,8 +60,8 @@
60 _concat4(SPR_IPI_EVENT_, CONFIG_KERNEL_PL,,) 60 _concat4(SPR_IPI_EVENT_, CONFIG_KERNEL_PL,,)
61#define SPR_IPI_EVENT_RESET_K \ 61#define SPR_IPI_EVENT_RESET_K \
62 _concat4(SPR_IPI_EVENT_RESET_, CONFIG_KERNEL_PL,,) 62 _concat4(SPR_IPI_EVENT_RESET_, CONFIG_KERNEL_PL,,)
63#define SPR_IPI_MASK_SET_K \ 63#define SPR_IPI_EVENT_SET_K \
64 _concat4(SPR_IPI_MASK_SET_, CONFIG_KERNEL_PL,,) 64 _concat4(SPR_IPI_EVENT_SET_, CONFIG_KERNEL_PL,,)
65#define INT_IPI_K \ 65#define INT_IPI_K \
66 _concat4(INT_IPI_, CONFIG_KERNEL_PL,,) 66 _concat4(INT_IPI_, CONFIG_KERNEL_PL,,)
67 67
diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h
index bb696da5d7c..f2461429a4a 100644
--- a/arch/tile/include/asm/atomic.h
+++ b/arch/tile/include/asm/atomic.h
@@ -17,6 +17,8 @@
17#ifndef _ASM_TILE_ATOMIC_H 17#ifndef _ASM_TILE_ATOMIC_H
18#define _ASM_TILE_ATOMIC_H 18#define _ASM_TILE_ATOMIC_H
19 19
20#include <asm/cmpxchg.h>
21
20#ifndef __ASSEMBLY__ 22#ifndef __ASSEMBLY__
21 23
22#include <linux/compiler.h> 24#include <linux/compiler.h>
@@ -121,54 +123,6 @@ static inline int atomic_read(const atomic_t *v)
121 */ 123 */
122#define atomic_add_negative(i, v) (atomic_add_return((i), (v)) < 0) 124#define atomic_add_negative(i, v) (atomic_add_return((i), (v)) < 0)
123 125
124/* Nonexistent functions intended to cause link errors. */
125extern unsigned long __xchg_called_with_bad_pointer(void);
126extern unsigned long __cmpxchg_called_with_bad_pointer(void);
127
128#define xchg(ptr, x) \
129 ({ \
130 typeof(*(ptr)) __x; \
131 switch (sizeof(*(ptr))) { \
132 case 4: \
133 __x = (typeof(__x))(typeof(__x-__x))atomic_xchg( \
134 (atomic_t *)(ptr), \
135 (u32)(typeof((x)-(x)))(x)); \
136 break; \
137 case 8: \
138 __x = (typeof(__x))(typeof(__x-__x))atomic64_xchg( \
139 (atomic64_t *)(ptr), \
140 (u64)(typeof((x)-(x)))(x)); \
141 break; \
142 default: \
143 __xchg_called_with_bad_pointer(); \
144 } \
145 __x; \
146 })
147
148#define cmpxchg(ptr, o, n) \
149 ({ \
150 typeof(*(ptr)) __x; \
151 switch (sizeof(*(ptr))) { \
152 case 4: \
153 __x = (typeof(__x))(typeof(__x-__x))atomic_cmpxchg( \
154 (atomic_t *)(ptr), \
155 (u32)(typeof((o)-(o)))(o), \
156 (u32)(typeof((n)-(n)))(n)); \
157 break; \
158 case 8: \
159 __x = (typeof(__x))(typeof(__x-__x))atomic64_cmpxchg( \
160 (atomic64_t *)(ptr), \
161 (u64)(typeof((o)-(o)))(o), \
162 (u64)(typeof((n)-(n)))(n)); \
163 break; \
164 default: \
165 __cmpxchg_called_with_bad_pointer(); \
166 } \
167 __x; \
168 })
169
170#define tas(ptr) (xchg((ptr), 1))
171
172#endif /* __ASSEMBLY__ */ 126#endif /* __ASSEMBLY__ */
173 127
174#ifndef __tilegx__ 128#ifndef __tilegx__
diff --git a/arch/tile/include/asm/atomic_32.h b/arch/tile/include/asm/atomic_32.h
index 466dc4a39a4..54d1da826f9 100644
--- a/arch/tile/include/asm/atomic_32.h
+++ b/arch/tile/include/asm/atomic_32.h
@@ -200,7 +200,7 @@ static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
200 * @u: ...unless v is equal to u. 200 * @u: ...unless v is equal to u.
201 * 201 *
202 * Atomically adds @a to @v, so long as @v was not already @u. 202 * Atomically adds @a to @v, so long as @v was not already @u.
203 * Returns the old value of @v. 203 * Returns non-zero if @v was not @u, and zero otherwise.
204 */ 204 */
205static inline u64 atomic64_add_unless(atomic64_t *v, u64 a, u64 u) 205static inline u64 atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
206{ 206{
diff --git a/arch/tile/include/asm/bitops_64.h b/arch/tile/include/asm/bitops_64.h
index 58d021a9834..60b87ee54fb 100644
--- a/arch/tile/include/asm/bitops_64.h
+++ b/arch/tile/include/asm/bitops_64.h
@@ -38,10 +38,10 @@ static inline void clear_bit(unsigned nr, volatile unsigned long *addr)
38 38
39static inline void change_bit(unsigned nr, volatile unsigned long *addr) 39static inline void change_bit(unsigned nr, volatile unsigned long *addr)
40{ 40{
41 unsigned long old, mask = (1UL << (nr % BITS_PER_LONG)); 41 unsigned long mask = (1UL << (nr % BITS_PER_LONG));
42 long guess, oldval; 42 unsigned long guess, oldval;
43 addr += nr / BITS_PER_LONG; 43 addr += nr / BITS_PER_LONG;
44 old = *addr; 44 oldval = *addr;
45 do { 45 do {
46 guess = oldval; 46 guess = oldval;
47 oldval = atomic64_cmpxchg((atomic64_t *)addr, 47 oldval = atomic64_cmpxchg((atomic64_t *)addr,
@@ -85,7 +85,7 @@ static inline int test_and_change_bit(unsigned nr,
85 volatile unsigned long *addr) 85 volatile unsigned long *addr)
86{ 86{
87 unsigned long mask = (1UL << (nr % BITS_PER_LONG)); 87 unsigned long mask = (1UL << (nr % BITS_PER_LONG));
88 long guess, oldval = *addr; 88 unsigned long guess, oldval;
89 addr += nr / BITS_PER_LONG; 89 addr += nr / BITS_PER_LONG;
90 oldval = *addr; 90 oldval = *addr;
91 do { 91 do {
diff --git a/arch/tile/include/asm/cmpxchg.h b/arch/tile/include/asm/cmpxchg.h
new file mode 100644
index 00000000000..276f067e364
--- /dev/null
+++ b/arch/tile/include/asm/cmpxchg.h
@@ -0,0 +1,73 @@
1/*
2 * cmpxchg.h -- forked from asm/atomic.h with this copyright:
3 *
4 * Copyright 2010 Tilera Corporation. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation, version 2.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
13 * NON INFRINGEMENT. See the GNU General Public License for
14 * more details.
15 *
16 */
17
18#ifndef _ASM_TILE_CMPXCHG_H
19#define _ASM_TILE_CMPXCHG_H
20
21#ifndef __ASSEMBLY__
22
23/* Nonexistent functions intended to cause link errors. */
24extern unsigned long __xchg_called_with_bad_pointer(void);
25extern unsigned long __cmpxchg_called_with_bad_pointer(void);
26
27#define xchg(ptr, x) \
28 ({ \
29 typeof(*(ptr)) __x; \
30 switch (sizeof(*(ptr))) { \
31 case 4: \
32 __x = (typeof(__x))(typeof(__x-__x))atomic_xchg( \
33 (atomic_t *)(ptr), \
34 (u32)(typeof((x)-(x)))(x)); \
35 break; \
36 case 8: \
37 __x = (typeof(__x))(typeof(__x-__x))atomic64_xchg( \
38 (atomic64_t *)(ptr), \
39 (u64)(typeof((x)-(x)))(x)); \
40 break; \
41 default: \
42 __xchg_called_with_bad_pointer(); \
43 } \
44 __x; \
45 })
46
47#define cmpxchg(ptr, o, n) \
48 ({ \
49 typeof(*(ptr)) __x; \
50 switch (sizeof(*(ptr))) { \
51 case 4: \
52 __x = (typeof(__x))(typeof(__x-__x))atomic_cmpxchg( \
53 (atomic_t *)(ptr), \
54 (u32)(typeof((o)-(o)))(o), \
55 (u32)(typeof((n)-(n)))(n)); \
56 break; \
57 case 8: \
58 __x = (typeof(__x))(typeof(__x-__x))atomic64_cmpxchg( \
59 (atomic64_t *)(ptr), \
60 (u64)(typeof((o)-(o)))(o), \
61 (u64)(typeof((n)-(n)))(n)); \
62 break; \
63 default: \
64 __cmpxchg_called_with_bad_pointer(); \
65 } \
66 __x; \
67 })
68
69#define tas(ptr) (xchg((ptr), 1))
70
71#endif /* __ASSEMBLY__ */
72
73#endif /* _ASM_TILE_CMPXCHG_H */
diff --git a/arch/tile/include/asm/irq.h b/arch/tile/include/asm/irq.h
index f80f8ceabc6..33cff9a3058 100644
--- a/arch/tile/include/asm/irq.h
+++ b/arch/tile/include/asm/irq.h
@@ -21,7 +21,7 @@
21#define NR_IRQS 32 21#define NR_IRQS 32
22 22
23/* IRQ numbers used for linux IPIs. */ 23/* IRQ numbers used for linux IPIs. */
24#define IRQ_RESCHEDULE 1 24#define IRQ_RESCHEDULE 0
25 25
26#define irq_canonicalize(irq) (irq) 26#define irq_canonicalize(irq) (irq)
27 27
diff --git a/arch/tile/include/asm/spinlock_64.h b/arch/tile/include/asm/spinlock_64.h
index 72be5904e02..5f8b6a095fd 100644
--- a/arch/tile/include/asm/spinlock_64.h
+++ b/arch/tile/include/asm/spinlock_64.h
@@ -137,7 +137,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
137static inline void arch_write_unlock(arch_rwlock_t *rw) 137static inline void arch_write_unlock(arch_rwlock_t *rw)
138{ 138{
139 __insn_mf(); 139 __insn_mf();
140 rw->lock = 0; 140 __insn_exch4(&rw->lock, 0); /* Avoid waiting in the write buffer. */
141} 141}
142 142
143static inline int arch_read_trylock(arch_rwlock_t *rw) 143static inline int arch_read_trylock(arch_rwlock_t *rw)
diff --git a/arch/tile/include/asm/stack.h b/arch/tile/include/asm/stack.h
index 4d97a2db932..0e9d382a2d4 100644
--- a/arch/tile/include/asm/stack.h
+++ b/arch/tile/include/asm/stack.h
@@ -25,7 +25,6 @@
25struct KBacktraceIterator { 25struct KBacktraceIterator {
26 BacktraceIterator it; 26 BacktraceIterator it;
27 struct task_struct *task; /* task we are backtracing */ 27 struct task_struct *task; /* task we are backtracing */
28 pte_t *pgtable; /* page table for user space access */
29 int end; /* iteration complete. */ 28 int end; /* iteration complete. */
30 int new_context; /* new context is starting */ 29 int new_context; /* new context is starting */
31 int profile; /* profiling, so stop on async intrpt */ 30 int profile; /* profiling, so stop on async intrpt */
diff --git a/arch/tile/include/asm/traps.h b/arch/tile/include/asm/traps.h
index 5f20f920f93..e28c3df4176 100644
--- a/arch/tile/include/asm/traps.h
+++ b/arch/tile/include/asm/traps.h
@@ -64,7 +64,11 @@ void do_breakpoint(struct pt_regs *, int fault_num);
64 64
65 65
66#ifdef __tilegx__ 66#ifdef __tilegx__
67/* kernel/single_step.c */
67void gx_singlestep_handle(struct pt_regs *, int fault_num); 68void gx_singlestep_handle(struct pt_regs *, int fault_num);
69
70/* kernel/intvec_64.S */
71void fill_ra_stack(void);
68#endif 72#endif
69 73
70#endif /* _ASM_TILE_SYSCALLS_H */ 74#endif /* _ASM_TILE_TRAPS_H */
diff --git a/arch/tile/kernel/entry.S b/arch/tile/kernel/entry.S
index 431e9ae6048..ec91568df88 100644
--- a/arch/tile/kernel/entry.S
+++ b/arch/tile/kernel/entry.S
@@ -85,6 +85,7 @@ STD_ENTRY(cpu_idle_on_new_stack)
85/* Loop forever on a nap during SMP boot. */ 85/* Loop forever on a nap during SMP boot. */
86STD_ENTRY(smp_nap) 86STD_ENTRY(smp_nap)
87 nap 87 nap
88 nop /* avoid provoking the icache prefetch with a jump */
88 j smp_nap /* we are not architecturally guaranteed not to exit nap */ 89 j smp_nap /* we are not architecturally guaranteed not to exit nap */
89 jrp lr /* clue in the backtracer */ 90 jrp lr /* clue in the backtracer */
90 STD_ENDPROC(smp_nap) 91 STD_ENDPROC(smp_nap)
@@ -105,5 +106,6 @@ STD_ENTRY(_cpu_idle)
105 .global _cpu_idle_nap 106 .global _cpu_idle_nap
106_cpu_idle_nap: 107_cpu_idle_nap:
107 nap 108 nap
109 nop /* avoid provoking the icache prefetch with a jump */
108 jrp lr 110 jrp lr
109 STD_ENDPROC(_cpu_idle) 111 STD_ENDPROC(_cpu_idle)
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index aecc8ed5f39..5d56a1ef5ba 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -799,6 +799,10 @@ handle_interrupt:
799 * This routine takes a boolean in r30 indicating if this is an NMI. 799 * This routine takes a boolean in r30 indicating if this is an NMI.
800 * If so, we also expect a boolean in r31 indicating whether to 800 * If so, we also expect a boolean in r31 indicating whether to
801 * re-enable the oprofile interrupts. 801 * re-enable the oprofile interrupts.
802 *
803 * Note that .Lresume_userspace is jumped to directly in several
804 * places, and we need to make sure r30 is set correctly in those
805 * callers as well.
802 */ 806 */
803STD_ENTRY(interrupt_return) 807STD_ENTRY(interrupt_return)
804 /* If we're resuming to kernel space, don't check thread flags. */ 808 /* If we're resuming to kernel space, don't check thread flags. */
@@ -1237,7 +1241,10 @@ handle_syscall:
1237 bzt r30, 1f 1241 bzt r30, 1f
1238 jal do_syscall_trace 1242 jal do_syscall_trace
1239 FEEDBACK_REENTER(handle_syscall) 1243 FEEDBACK_REENTER(handle_syscall)
12401: j .Lresume_userspace /* jump into middle of interrupt_return */ 12441: {
1245 movei r30, 0 /* not an NMI */
1246 j .Lresume_userspace /* jump into middle of interrupt_return */
1247 }
1241 1248
1242.Linvalid_syscall: 1249.Linvalid_syscall:
1243 /* Report an invalid syscall back to the user program */ 1250 /* Report an invalid syscall back to the user program */
@@ -1246,7 +1253,10 @@ handle_syscall:
1246 movei r28, -ENOSYS 1253 movei r28, -ENOSYS
1247 } 1254 }
1248 sw r29, r28 1255 sw r29, r28
1249 j .Lresume_userspace /* jump into middle of interrupt_return */ 1256 {
1257 movei r30, 0 /* not an NMI */
1258 j .Lresume_userspace /* jump into middle of interrupt_return */
1259 }
1250 STD_ENDPROC(handle_syscall) 1260 STD_ENDPROC(handle_syscall)
1251 1261
1252 /* Return the address for oprofile to suppress in backtraces. */ 1262 /* Return the address for oprofile to suppress in backtraces. */
@@ -1262,7 +1272,10 @@ STD_ENTRY(ret_from_fork)
1262 jal sim_notify_fork 1272 jal sim_notify_fork
1263 jal schedule_tail 1273 jal schedule_tail
1264 FEEDBACK_REENTER(ret_from_fork) 1274 FEEDBACK_REENTER(ret_from_fork)
1265 j .Lresume_userspace /* jump into middle of interrupt_return */ 1275 {
1276 movei r30, 0 /* not an NMI */
1277 j .Lresume_userspace /* jump into middle of interrupt_return */
1278 }
1266 STD_ENDPROC(ret_from_fork) 1279 STD_ENDPROC(ret_from_fork)
1267 1280
1268 /* 1281 /*
@@ -1376,7 +1389,10 @@ handle_ill:
1376 1389
1377 jal send_sigtrap /* issue a SIGTRAP */ 1390 jal send_sigtrap /* issue a SIGTRAP */
1378 FEEDBACK_REENTER(handle_ill) 1391 FEEDBACK_REENTER(handle_ill)
1379 j .Lresume_userspace /* jump into middle of interrupt_return */ 1392 {
1393 movei r30, 0 /* not an NMI */
1394 j .Lresume_userspace /* jump into middle of interrupt_return */
1395 }
1380 1396
1381.Ldispatch_normal_ill: 1397.Ldispatch_normal_ill:
1382 { 1398 {
diff --git a/arch/tile/kernel/intvec_64.S b/arch/tile/kernel/intvec_64.S
index 79c93e10ba2..49d9d662168 100644
--- a/arch/tile/kernel/intvec_64.S
+++ b/arch/tile/kernel/intvec_64.S
@@ -22,6 +22,7 @@
22#include <asm/irqflags.h> 22#include <asm/irqflags.h>
23#include <asm/asm-offsets.h> 23#include <asm/asm-offsets.h>
24#include <asm/types.h> 24#include <asm/types.h>
25#include <asm/signal.h>
25#include <hv/hypervisor.h> 26#include <hv/hypervisor.h>
26#include <arch/abi.h> 27#include <arch/abi.h>
27#include <arch/interrupts.h> 28#include <arch/interrupts.h>
@@ -605,6 +606,10 @@ handle_interrupt:
605 * This routine takes a boolean in r30 indicating if this is an NMI. 606 * This routine takes a boolean in r30 indicating if this is an NMI.
606 * If so, we also expect a boolean in r31 indicating whether to 607 * If so, we also expect a boolean in r31 indicating whether to
607 * re-enable the oprofile interrupts. 608 * re-enable the oprofile interrupts.
609 *
610 * Note that .Lresume_userspace is jumped to directly in several
611 * places, and we need to make sure r30 is set correctly in those
612 * callers as well.
608 */ 613 */
609STD_ENTRY(interrupt_return) 614STD_ENTRY(interrupt_return)
610 /* If we're resuming to kernel space, don't check thread flags. */ 615 /* If we're resuming to kernel space, don't check thread flags. */
@@ -1039,11 +1044,28 @@ handle_syscall:
1039 1044
1040 /* Do syscall trace again, if requested. */ 1045 /* Do syscall trace again, if requested. */
1041 ld r30, r31 1046 ld r30, r31
1042 andi r30, r30, _TIF_SYSCALL_TRACE 1047 andi r0, r30, _TIF_SYSCALL_TRACE
1043 beqzt r30, 1f 1048 {
1049 andi r0, r30, _TIF_SINGLESTEP
1050 beqzt r0, 1f
1051 }
1044 jal do_syscall_trace 1052 jal do_syscall_trace
1045 FEEDBACK_REENTER(handle_syscall) 1053 FEEDBACK_REENTER(handle_syscall)
10461: j .Lresume_userspace /* jump into middle of interrupt_return */ 1054 andi r0, r30, _TIF_SINGLESTEP
1055
10561: beqzt r0, 2f
1057
1058 /* Single stepping -- notify ptrace. */
1059 {
1060 movei r0, SIGTRAP
1061 jal ptrace_notify
1062 }
1063 FEEDBACK_REENTER(handle_syscall)
1064
10652: {
1066 movei r30, 0 /* not an NMI */
1067 j .Lresume_userspace /* jump into middle of interrupt_return */
1068 }
1047 1069
1048.Lcompat_syscall: 1070.Lcompat_syscall:
1049 /* 1071 /*
@@ -1077,7 +1099,10 @@ handle_syscall:
1077 movei r28, -ENOSYS 1099 movei r28, -ENOSYS
1078 } 1100 }
1079 st r29, r28 1101 st r29, r28
1080 j .Lresume_userspace /* jump into middle of interrupt_return */ 1102 {
1103 movei r30, 0 /* not an NMI */
1104 j .Lresume_userspace /* jump into middle of interrupt_return */
1105 }
1081 STD_ENDPROC(handle_syscall) 1106 STD_ENDPROC(handle_syscall)
1082 1107
1083 /* Return the address for oprofile to suppress in backtraces. */ 1108 /* Return the address for oprofile to suppress in backtraces. */
@@ -1093,7 +1118,10 @@ STD_ENTRY(ret_from_fork)
1093 jal sim_notify_fork 1118 jal sim_notify_fork
1094 jal schedule_tail 1119 jal schedule_tail
1095 FEEDBACK_REENTER(ret_from_fork) 1120 FEEDBACK_REENTER(ret_from_fork)
1096 j .Lresume_userspace 1121 {
1122 movei r30, 0 /* not an NMI */
1123 j .Lresume_userspace /* jump into middle of interrupt_return */
1124 }
1097 STD_ENDPROC(ret_from_fork) 1125 STD_ENDPROC(ret_from_fork)
1098 1126
1099/* Various stub interrupt handlers and syscall handlers */ 1127/* Various stub interrupt handlers and syscall handlers */
@@ -1156,6 +1184,18 @@ int_unalign:
1156 push_extra_callee_saves r0 1184 push_extra_callee_saves r0
1157 j do_trap 1185 j do_trap
1158 1186
1187/* Fill the return address stack with nonzero entries. */
1188STD_ENTRY(fill_ra_stack)
1189 {
1190 move r0, lr
1191 jal 1f
1192 }
11931: jal 2f
11942: jal 3f
11953: jal 4f
11964: jrp r0
1197 STD_ENDPROC(fill_ra_stack)
1198
1159/* Include .intrpt1 array of interrupt vectors */ 1199/* Include .intrpt1 array of interrupt vectors */
1160 .section ".intrpt1", "ax" 1200 .section ".intrpt1", "ax"
1161 1201
@@ -1166,7 +1206,7 @@ int_unalign:
1166#define do_hardwall_trap bad_intr 1206#define do_hardwall_trap bad_intr
1167#endif 1207#endif
1168 1208
1169 int_hand INT_MEM_ERROR, MEM_ERROR, bad_intr 1209 int_hand INT_MEM_ERROR, MEM_ERROR, do_trap
1170 int_hand INT_SINGLE_STEP_3, SINGLE_STEP_3, bad_intr 1210 int_hand INT_SINGLE_STEP_3, SINGLE_STEP_3, bad_intr
1171#if CONFIG_KERNEL_PL == 2 1211#if CONFIG_KERNEL_PL == 2
1172 int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, gx_singlestep_handle 1212 int_hand INT_SINGLE_STEP_2, SINGLE_STEP_2, gx_singlestep_handle
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index b90ab992567..98d47692010 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -67,6 +67,8 @@ void *module_alloc(unsigned long size)
67 area = __get_vm_area(size, VM_ALLOC, MEM_MODULE_START, MEM_MODULE_END); 67 area = __get_vm_area(size, VM_ALLOC, MEM_MODULE_START, MEM_MODULE_END);
68 if (!area) 68 if (!area)
69 goto error; 69 goto error;
70 area->nr_pages = npages;
71 area->pages = pages;
70 72
71 if (map_vm_area(area, prot_rwx, &pages)) { 73 if (map_vm_area(area, prot_rwx, &pages)) {
72 vunmap(area->addr); 74 vunmap(area->addr);
diff --git a/arch/tile/kernel/proc.c b/arch/tile/kernel/proc.c
index 7a932704640..446a7f52cc1 100644
--- a/arch/tile/kernel/proc.c
+++ b/arch/tile/kernel/proc.c
@@ -146,7 +146,6 @@ static ctl_table unaligned_table[] = {
146 }, 146 },
147 {} 147 {}
148}; 148};
149#endif
150 149
151static struct ctl_path tile_path[] = { 150static struct ctl_path tile_path[] = {
152 { .procname = "tile" }, 151 { .procname = "tile" },
@@ -155,10 +154,9 @@ static struct ctl_path tile_path[] = {
155 154
156static int __init proc_sys_tile_init(void) 155static int __init proc_sys_tile_init(void)
157{ 156{
158#ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */
159 register_sysctl_paths(tile_path, unaligned_table); 157 register_sysctl_paths(tile_path, unaligned_table);
160#endif
161 return 0; 158 return 0;
162} 159}
163 160
164arch_initcall(proc_sys_tile_init); 161arch_initcall(proc_sys_tile_init);
162#endif
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 30caecac94d..2d5ef617bb3 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -28,6 +28,7 @@
28#include <linux/tracehook.h> 28#include <linux/tracehook.h>
29#include <linux/signal.h> 29#include <linux/signal.h>
30#include <asm/stack.h> 30#include <asm/stack.h>
31#include <asm/switch_to.h>
31#include <asm/homecache.h> 32#include <asm/homecache.h>
32#include <asm/syscalls.h> 33#include <asm/syscalls.h>
33#include <asm/traps.h> 34#include <asm/traps.h>
@@ -285,7 +286,7 @@ struct task_struct *validate_current(void)
285 static struct task_struct corrupt = { .comm = "<corrupt>" }; 286 static struct task_struct corrupt = { .comm = "<corrupt>" };
286 struct task_struct *tsk = current; 287 struct task_struct *tsk = current;
287 if (unlikely((unsigned long)tsk < PAGE_OFFSET || 288 if (unlikely((unsigned long)tsk < PAGE_OFFSET ||
288 (void *)tsk > high_memory || 289 (high_memory && (void *)tsk > high_memory) ||
289 ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) { 290 ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) {
290 pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer); 291 pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer);
291 tsk = &corrupt; 292 tsk = &corrupt;
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index 92a94f4920a..bff23f47611 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -103,13 +103,11 @@ unsigned long __initdata pci_reserve_end_pfn = -1U;
103 103
104static int __init setup_maxmem(char *str) 104static int __init setup_maxmem(char *str)
105{ 105{
106 long maxmem_mb; 106 unsigned long long maxmem;
107 if (str == NULL || strict_strtol(str, 0, &maxmem_mb) != 0 || 107 if (str == NULL || (maxmem = memparse(str, NULL)) == 0)
108 maxmem_mb == 0)
109 return -EINVAL; 108 return -EINVAL;
110 109
111 maxmem_pfn = (maxmem_mb >> (HPAGE_SHIFT - 20)) << 110 maxmem_pfn = (maxmem >> HPAGE_SHIFT) << (HPAGE_SHIFT - PAGE_SHIFT);
112 (HPAGE_SHIFT - PAGE_SHIFT);
113 pr_info("Forcing RAM used to no more than %dMB\n", 111 pr_info("Forcing RAM used to no more than %dMB\n",
114 maxmem_pfn >> (20 - PAGE_SHIFT)); 112 maxmem_pfn >> (20 - PAGE_SHIFT));
115 return 0; 113 return 0;
@@ -119,14 +117,15 @@ early_param("maxmem", setup_maxmem);
119static int __init setup_maxnodemem(char *str) 117static int __init setup_maxnodemem(char *str)
120{ 118{
121 char *endp; 119 char *endp;
122 long maxnodemem_mb, node; 120 unsigned long long maxnodemem;
121 long node;
123 122
124 node = str ? simple_strtoul(str, &endp, 0) : INT_MAX; 123 node = str ? simple_strtoul(str, &endp, 0) : INT_MAX;
125 if (node >= MAX_NUMNODES || *endp != ':' || 124 if (node >= MAX_NUMNODES || *endp != ':')
126 strict_strtol(endp+1, 0, &maxnodemem_mb) != 0)
127 return -EINVAL; 125 return -EINVAL;
128 126
129 maxnodemem_pfn[node] = (maxnodemem_mb >> (HPAGE_SHIFT - 20)) << 127 maxnodemem = memparse(endp+1, NULL);
128 maxnodemem_pfn[node] = (maxnodemem >> HPAGE_SHIFT) <<
130 (HPAGE_SHIFT - PAGE_SHIFT); 129 (HPAGE_SHIFT - PAGE_SHIFT);
131 pr_info("Forcing RAM used on node %ld to no more than %dMB\n", 130 pr_info("Forcing RAM used on node %ld to no more than %dMB\n",
132 node, maxnodemem_pfn[node] >> (20 - PAGE_SHIFT)); 131 node, maxnodemem_pfn[node] >> (20 - PAGE_SHIFT));
@@ -913,6 +912,13 @@ void __cpuinit setup_cpu(int boot)
913 912
914#ifdef CONFIG_BLK_DEV_INITRD 913#ifdef CONFIG_BLK_DEV_INITRD
915 914
915/*
916 * Note that the kernel can potentially support other compression
917 * techniques than gz, though we don't do so by default. If we ever
918 * decide to do so we can either look for other filename extensions,
919 * or just allow a file with this name to be compressed with an
920 * arbitrary compressor (somewhat counterintuitively).
921 */
916static int __initdata set_initramfs_file; 922static int __initdata set_initramfs_file;
917static char __initdata initramfs_file[128] = "initramfs.cpio.gz"; 923static char __initdata initramfs_file[128] = "initramfs.cpio.gz";
918 924
@@ -928,9 +934,9 @@ static int __init setup_initramfs_file(char *str)
928early_param("initramfs_file", setup_initramfs_file); 934early_param("initramfs_file", setup_initramfs_file);
929 935
930/* 936/*
931 * We look for an additional "initramfs.cpio.gz" file in the hvfs. 937 * We look for an "initramfs.cpio.gz" file in the hvfs.
932 * If there is one, we allocate some memory for it and it will be 938 * If there is one, we allocate some memory for it and it will be
933 * unpacked to the initramfs after any built-in initramfs_data. 939 * unpacked to the initramfs.
934 */ 940 */
935static void __init load_hv_initrd(void) 941static void __init load_hv_initrd(void)
936{ 942{
diff --git a/arch/tile/kernel/single_step.c b/arch/tile/kernel/single_step.c
index bc1eb586e24..9efbc1391b3 100644
--- a/arch/tile/kernel/single_step.c
+++ b/arch/tile/kernel/single_step.c
@@ -153,6 +153,25 @@ static tile_bundle_bits rewrite_load_store_unaligned(
153 if (((unsigned long)addr % size) == 0) 153 if (((unsigned long)addr % size) == 0)
154 return bundle; 154 return bundle;
155 155
156 /*
157 * Return SIGBUS with the unaligned address, if requested.
158 * Note that we return SIGBUS even for completely invalid addresses
159 * as long as they are in fact unaligned; this matches what the
160 * tilepro hardware would be doing, if it could provide us with the
161 * actual bad address in an SPR, which it doesn't.
162 */
163 if (unaligned_fixup == 0) {
164 siginfo_t info = {
165 .si_signo = SIGBUS,
166 .si_code = BUS_ADRALN,
167 .si_addr = addr
168 };
169 trace_unhandled_signal("unaligned trap", regs,
170 (unsigned long)addr, SIGBUS);
171 force_sig_info(info.si_signo, &info, current);
172 return (tilepro_bundle_bits) 0;
173 }
174
156#ifndef __LITTLE_ENDIAN 175#ifndef __LITTLE_ENDIAN
157# error We assume little-endian representation with copy_xx_user size 2 here 176# error We assume little-endian representation with copy_xx_user size 2 here
158#endif 177#endif
@@ -192,18 +211,6 @@ static tile_bundle_bits rewrite_load_store_unaligned(
192 return (tile_bundle_bits) 0; 211 return (tile_bundle_bits) 0;
193 } 212 }
194 213
195 if (unaligned_fixup == 0) {
196 siginfo_t info = {
197 .si_signo = SIGBUS,
198 .si_code = BUS_ADRALN,
199 .si_addr = addr
200 };
201 trace_unhandled_signal("unaligned trap", regs,
202 (unsigned long)addr, SIGBUS);
203 force_sig_info(info.si_signo, &info, current);
204 return (tile_bundle_bits) 0;
205 }
206
207 if (unaligned_printk || unaligned_fixup_count == 0) { 214 if (unaligned_printk || unaligned_fixup_count == 0) {
208 pr_info("Process %d/%s: PC %#lx: Fixup of" 215 pr_info("Process %d/%s: PC %#lx: Fixup of"
209 " unaligned %s at %#lx.\n", 216 " unaligned %s at %#lx.\n",
diff --git a/arch/tile/kernel/smp.c b/arch/tile/kernel/smp.c
index a44e103c5a6..91da0f72195 100644
--- a/arch/tile/kernel/smp.c
+++ b/arch/tile/kernel/smp.c
@@ -103,7 +103,7 @@ static void smp_stop_cpu_interrupt(void)
103 set_cpu_online(smp_processor_id(), 0); 103 set_cpu_online(smp_processor_id(), 0);
104 arch_local_irq_disable_all(); 104 arch_local_irq_disable_all();
105 for (;;) 105 for (;;)
106 asm("nap"); 106 asm("nap; nop");
107} 107}
108 108
109/* This function calls the 'stop' function on all other CPUs in the system. */ 109/* This function calls the 'stop' function on all other CPUs in the system. */
@@ -113,6 +113,12 @@ void smp_send_stop(void)
113 send_IPI_allbutself(MSG_TAG_STOP_CPU); 113 send_IPI_allbutself(MSG_TAG_STOP_CPU);
114} 114}
115 115
116/* On panic, just wait; we may get an smp_send_stop() later on. */
117void panic_smp_self_stop(void)
118{
119 while (1)
120 asm("nap; nop");
121}
116 122
117/* 123/*
118 * Dispatch code called from hv_message_intr() for HV_MSG_TILE hv messages. 124 * Dispatch code called from hv_message_intr() for HV_MSG_TILE hv messages.
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index b949edcec20..172aef7d315 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -196,6 +196,8 @@ void __cpuinit online_secondary(void)
196 /* This must be done before setting cpu_online_mask */ 196 /* This must be done before setting cpu_online_mask */
197 wmb(); 197 wmb();
198 198
199 notify_cpu_starting(smp_processor_id());
200
199 /* 201 /*
200 * We need to hold call_lock, so there is no inconsistency 202 * We need to hold call_lock, so there is no inconsistency
201 * between the time smp_call_function() determines number of 203 * between the time smp_call_function() determines number of
diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index 37ee4d037e0..b2f44c28dda 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -21,10 +21,12 @@
21#include <linux/stacktrace.h> 21#include <linux/stacktrace.h>
22#include <linux/uaccess.h> 22#include <linux/uaccess.h>
23#include <linux/mmzone.h> 23#include <linux/mmzone.h>
24#include <linux/dcache.h>
25#include <linux/fs.h>
24#include <asm/backtrace.h> 26#include <asm/backtrace.h>
25#include <asm/page.h> 27#include <asm/page.h>
26#include <asm/tlbflush.h>
27#include <asm/ucontext.h> 28#include <asm/ucontext.h>
29#include <asm/switch_to.h>
28#include <asm/sigframe.h> 30#include <asm/sigframe.h>
29#include <asm/stack.h> 31#include <asm/stack.h>
30#include <arch/abi.h> 32#include <arch/abi.h>
@@ -44,72 +46,23 @@ static int in_kernel_stack(struct KBacktraceIterator *kbt, unsigned long sp)
44 return sp >= kstack_base && sp < kstack_base + THREAD_SIZE; 46 return sp >= kstack_base && sp < kstack_base + THREAD_SIZE;
45} 47}
46 48
47/* Is address valid for reading? */
48static int valid_address(struct KBacktraceIterator *kbt, unsigned long address)
49{
50 HV_PTE *l1_pgtable = kbt->pgtable;
51 HV_PTE *l2_pgtable;
52 unsigned long pfn;
53 HV_PTE pte;
54 struct page *page;
55
56 if (l1_pgtable == NULL)
57 return 0; /* can't read user space in other tasks */
58
59#ifdef CONFIG_64BIT
60 /* Find the real l1_pgtable by looking in the l0_pgtable. */
61 pte = l1_pgtable[HV_L0_INDEX(address)];
62 if (!hv_pte_get_present(pte))
63 return 0;
64 pfn = hv_pte_get_pfn(pte);
65 if (pte_huge(pte)) {
66 if (!pfn_valid(pfn)) {
67 pr_err("L0 huge page has bad pfn %#lx\n", pfn);
68 return 0;
69 }
70 return hv_pte_get_present(pte) && hv_pte_get_readable(pte);
71 }
72 page = pfn_to_page(pfn);
73 BUG_ON(PageHighMem(page)); /* No HIGHMEM on 64-bit. */
74 l1_pgtable = (HV_PTE *)pfn_to_kaddr(pfn);
75#endif
76 pte = l1_pgtable[HV_L1_INDEX(address)];
77 if (!hv_pte_get_present(pte))
78 return 0;
79 pfn = hv_pte_get_pfn(pte);
80 if (pte_huge(pte)) {
81 if (!pfn_valid(pfn)) {
82 pr_err("huge page has bad pfn %#lx\n", pfn);
83 return 0;
84 }
85 return hv_pte_get_present(pte) && hv_pte_get_readable(pte);
86 }
87
88 page = pfn_to_page(pfn);
89 if (PageHighMem(page)) {
90 pr_err("L2 page table not in LOWMEM (%#llx)\n",
91 HV_PFN_TO_CPA(pfn));
92 return 0;
93 }
94 l2_pgtable = (HV_PTE *)pfn_to_kaddr(pfn);
95 pte = l2_pgtable[HV_L2_INDEX(address)];
96 return hv_pte_get_present(pte) && hv_pte_get_readable(pte);
97}
98
99/* Callback for backtracer; basically a glorified memcpy */ 49/* Callback for backtracer; basically a glorified memcpy */
100static bool read_memory_func(void *result, unsigned long address, 50static bool read_memory_func(void *result, unsigned long address,
101 unsigned int size, void *vkbt) 51 unsigned int size, void *vkbt)
102{ 52{
103 int retval; 53 int retval;
104 struct KBacktraceIterator *kbt = (struct KBacktraceIterator *)vkbt; 54 struct KBacktraceIterator *kbt = (struct KBacktraceIterator *)vkbt;
55
56 if (address == 0)
57 return 0;
105 if (__kernel_text_address(address)) { 58 if (__kernel_text_address(address)) {
106 /* OK to read kernel code. */ 59 /* OK to read kernel code. */
107 } else if (address >= PAGE_OFFSET) { 60 } else if (address >= PAGE_OFFSET) {
108 /* We only tolerate kernel-space reads of this task's stack */ 61 /* We only tolerate kernel-space reads of this task's stack */
109 if (!in_kernel_stack(kbt, address)) 62 if (!in_kernel_stack(kbt, address))
110 return 0; 63 return 0;
111 } else if (!valid_address(kbt, address)) { 64 } else if (!kbt->is_current) {
112 return 0; /* invalid user-space address */ 65 return 0; /* can't read from other user address spaces */
113 } 66 }
114 pagefault_disable(); 67 pagefault_disable();
115 retval = __copy_from_user_inatomic(result, 68 retval = __copy_from_user_inatomic(result,
@@ -127,6 +80,8 @@ static struct pt_regs *valid_fault_handler(struct KBacktraceIterator* kbt)
127 unsigned long sp = kbt->it.sp; 80 unsigned long sp = kbt->it.sp;
128 struct pt_regs *p; 81 struct pt_regs *p;
129 82
83 if (sp % sizeof(long) != 0)
84 return NULL;
130 if (!in_kernel_stack(kbt, sp)) 85 if (!in_kernel_stack(kbt, sp))
131 return NULL; 86 return NULL;
132 if (!in_kernel_stack(kbt, sp + C_ABI_SAVE_AREA_SIZE + PTREGS_SIZE-1)) 87 if (!in_kernel_stack(kbt, sp + C_ABI_SAVE_AREA_SIZE + PTREGS_SIZE-1))
@@ -169,27 +124,27 @@ static int is_sigreturn(unsigned long pc)
169} 124}
170 125
171/* Return a pt_regs pointer for a valid signal handler frame */ 126/* Return a pt_regs pointer for a valid signal handler frame */
172static struct pt_regs *valid_sigframe(struct KBacktraceIterator* kbt) 127static struct pt_regs *valid_sigframe(struct KBacktraceIterator* kbt,
128 struct rt_sigframe* kframe)
173{ 129{
174 BacktraceIterator *b = &kbt->it; 130 BacktraceIterator *b = &kbt->it;
175 131
176 if (b->pc == VDSO_BASE) { 132 if (b->pc == VDSO_BASE && b->sp < PAGE_OFFSET &&
177 struct rt_sigframe *frame; 133 b->sp % sizeof(long) == 0) {
178 unsigned long sigframe_top = 134 int retval;
179 b->sp + sizeof(struct rt_sigframe) - 1; 135 pagefault_disable();
180 if (!valid_address(kbt, b->sp) || 136 retval = __copy_from_user_inatomic(
181 !valid_address(kbt, sigframe_top)) { 137 kframe, (void __user __force *)b->sp,
182 if (kbt->verbose) 138 sizeof(*kframe));
183 pr_err(" (odd signal: sp %#lx?)\n", 139 pagefault_enable();
184 (unsigned long)(b->sp)); 140 if (retval != 0 ||
141 (unsigned int)(kframe->info.si_signo) >= _NSIG)
185 return NULL; 142 return NULL;
186 }
187 frame = (struct rt_sigframe *)b->sp;
188 if (kbt->verbose) { 143 if (kbt->verbose) {
189 pr_err(" <received signal %d>\n", 144 pr_err(" <received signal %d>\n",
190 frame->info.si_signo); 145 kframe->info.si_signo);
191 } 146 }
192 return (struct pt_regs *)&frame->uc.uc_mcontext; 147 return (struct pt_regs *)&kframe->uc.uc_mcontext;
193 } 148 }
194 return NULL; 149 return NULL;
195} 150}
@@ -202,10 +157,11 @@ static int KBacktraceIterator_is_sigreturn(struct KBacktraceIterator *kbt)
202static int KBacktraceIterator_restart(struct KBacktraceIterator *kbt) 157static int KBacktraceIterator_restart(struct KBacktraceIterator *kbt)
203{ 158{
204 struct pt_regs *p; 159 struct pt_regs *p;
160 struct rt_sigframe kframe;
205 161
206 p = valid_fault_handler(kbt); 162 p = valid_fault_handler(kbt);
207 if (p == NULL) 163 if (p == NULL)
208 p = valid_sigframe(kbt); 164 p = valid_sigframe(kbt, &kframe);
209 if (p == NULL) 165 if (p == NULL)
210 return 0; 166 return 0;
211 backtrace_init(&kbt->it, read_memory_func, kbt, 167 backtrace_init(&kbt->it, read_memory_func, kbt,
@@ -265,41 +221,19 @@ void KBacktraceIterator_init(struct KBacktraceIterator *kbt,
265 221
266 /* 222 /*
267 * Set up callback information. We grab the kernel stack base 223 * Set up callback information. We grab the kernel stack base
268 * so we will allow reads of that address range, and if we're 224 * so we will allow reads of that address range.
269 * asking about the current process we grab the page table
270 * so we can check user accesses before trying to read them.
271 * We flush the TLB to avoid any weird skew issues.
272 */ 225 */
273 is_current = (t == NULL); 226 is_current = (t == NULL || t == current);
274 kbt->is_current = is_current; 227 kbt->is_current = is_current;
275 if (is_current) 228 if (is_current)
276 t = validate_current(); 229 t = validate_current();
277 kbt->task = t; 230 kbt->task = t;
278 kbt->pgtable = NULL;
279 kbt->verbose = 0; /* override in caller if desired */ 231 kbt->verbose = 0; /* override in caller if desired */
280 kbt->profile = 0; /* override in caller if desired */ 232 kbt->profile = 0; /* override in caller if desired */
281 kbt->end = KBT_ONGOING; 233 kbt->end = KBT_ONGOING;
282 kbt->new_context = 0; 234 kbt->new_context = 1;
283 if (is_current) { 235 if (is_current)
284 HV_PhysAddr pgdir_pa = hv_inquire_context().page_table;
285 if (pgdir_pa == (unsigned long)swapper_pg_dir - PAGE_OFFSET) {
286 /*
287 * Not just an optimization: this also allows
288 * this to work at all before va/pa mappings
289 * are set up.
290 */
291 kbt->pgtable = swapper_pg_dir;
292 } else {
293 struct page *page = pfn_to_page(PFN_DOWN(pgdir_pa));
294 if (!PageHighMem(page))
295 kbt->pgtable = __va(pgdir_pa);
296 else
297 pr_err("page table not in LOWMEM"
298 " (%#llx)\n", pgdir_pa);
299 }
300 local_flush_tlb_all();
301 validate_stack(regs); 236 validate_stack(regs);
302 }
303 237
304 if (regs == NULL) { 238 if (regs == NULL) {
305 if (is_current || t->state == TASK_RUNNING) { 239 if (is_current || t->state == TASK_RUNNING) {
@@ -345,6 +279,78 @@ void KBacktraceIterator_next(struct KBacktraceIterator *kbt)
345} 279}
346EXPORT_SYMBOL(KBacktraceIterator_next); 280EXPORT_SYMBOL(KBacktraceIterator_next);
347 281
282static void describe_addr(struct KBacktraceIterator *kbt,
283 unsigned long address,
284 int have_mmap_sem, char *buf, size_t bufsize)
285{
286 struct vm_area_struct *vma;
287 size_t namelen, remaining;
288 unsigned long size, offset, adjust;
289 char *p, *modname;
290 const char *name;
291 int rc;
292
293 /*
294 * Look one byte back for every caller frame (i.e. those that
295 * aren't a new context) so we look up symbol data for the
296 * call itself, not the following instruction, which may be on
297 * a different line (or in a different function).
298 */
299 adjust = !kbt->new_context;
300 address -= adjust;
301
302 if (address >= PAGE_OFFSET) {
303 /* Handle kernel symbols. */
304 BUG_ON(bufsize < KSYM_NAME_LEN);
305 name = kallsyms_lookup(address, &size, &offset,
306 &modname, buf);
307 if (name == NULL) {
308 buf[0] = '\0';
309 return;
310 }
311 namelen = strlen(buf);
312 remaining = (bufsize - 1) - namelen;
313 p = buf + namelen;
314 rc = snprintf(p, remaining, "+%#lx/%#lx ",
315 offset + adjust, size);
316 if (modname && rc < remaining)
317 snprintf(p + rc, remaining - rc, "[%s] ", modname);
318 buf[bufsize-1] = '\0';
319 return;
320 }
321
322 /* If we don't have the mmap_sem, we can't show any more info. */
323 buf[0] = '\0';
324 if (!have_mmap_sem)
325 return;
326
327 /* Find vma info. */
328 vma = find_vma(kbt->task->mm, address);
329 if (vma == NULL || address < vma->vm_start) {
330 snprintf(buf, bufsize, "[unmapped address] ");
331 return;
332 }
333
334 if (vma->vm_file) {
335 char *s;
336 p = d_path(&vma->vm_file->f_path, buf, bufsize);
337 if (IS_ERR(p))
338 p = "?";
339 s = strrchr(p, '/');
340 if (s)
341 p = s+1;
342 } else {
343 p = "anon";
344 }
345
346 /* Generate a string description of the vma info. */
347 namelen = strlen(p);
348 remaining = (bufsize - 1) - namelen;
349 memmove(buf, p, namelen);
350 snprintf(buf + namelen, remaining, "[%lx+%lx] ",
351 vma->vm_start, vma->vm_end - vma->vm_start);
352}
353
348/* 354/*
349 * This method wraps the backtracer's more generic support. 355 * This method wraps the backtracer's more generic support.
350 * It is only invoked from the architecture-specific code; show_stack() 356 * It is only invoked from the architecture-specific code; show_stack()
@@ -353,6 +359,7 @@ EXPORT_SYMBOL(KBacktraceIterator_next);
353void tile_show_stack(struct KBacktraceIterator *kbt, int headers) 359void tile_show_stack(struct KBacktraceIterator *kbt, int headers)
354{ 360{
355 int i; 361 int i;
362 int have_mmap_sem = 0;
356 363
357 if (headers) { 364 if (headers) {
358 /* 365 /*
@@ -369,31 +376,16 @@ void tile_show_stack(struct KBacktraceIterator *kbt, int headers)
369 kbt->verbose = 1; 376 kbt->verbose = 1;
370 i = 0; 377 i = 0;
371 for (; !KBacktraceIterator_end(kbt); KBacktraceIterator_next(kbt)) { 378 for (; !KBacktraceIterator_end(kbt); KBacktraceIterator_next(kbt)) {
372 char *modname;
373 const char *name;
374 unsigned long address = kbt->it.pc;
375 unsigned long offset, size;
376 char namebuf[KSYM_NAME_LEN+100]; 379 char namebuf[KSYM_NAME_LEN+100];
380 unsigned long address = kbt->it.pc;
377 381
378 if (address >= PAGE_OFFSET) 382 /* Try to acquire the mmap_sem as we pass into userspace. */
379 name = kallsyms_lookup(address, &size, &offset, 383 if (address < PAGE_OFFSET && !have_mmap_sem && kbt->task->mm)
380 &modname, namebuf); 384 have_mmap_sem =
381 else 385 down_read_trylock(&kbt->task->mm->mmap_sem);
382 name = NULL; 386
383 387 describe_addr(kbt, address, have_mmap_sem,
384 if (!name) 388 namebuf, sizeof(namebuf));
385 namebuf[0] = '\0';
386 else {
387 size_t namelen = strlen(namebuf);
388 size_t remaining = (sizeof(namebuf) - 1) - namelen;
389 char *p = namebuf + namelen;
390 int rc = snprintf(p, remaining, "+%#lx/%#lx ",
391 offset, size);
392 if (modname && rc < remaining)
393 snprintf(p + rc, remaining - rc,
394 "[%s] ", modname);
395 namebuf[sizeof(namebuf)-1] = '\0';
396 }
397 389
398 pr_err(" frame %d: 0x%lx %s(sp 0x%lx)\n", 390 pr_err(" frame %d: 0x%lx %s(sp 0x%lx)\n",
399 i++, address, namebuf, (unsigned long)(kbt->it.sp)); 391 i++, address, namebuf, (unsigned long)(kbt->it.sp));
@@ -408,6 +400,8 @@ void tile_show_stack(struct KBacktraceIterator *kbt, int headers)
408 pr_err("Stack dump stopped; next frame identical to this one\n"); 400 pr_err("Stack dump stopped; next frame identical to this one\n");
409 if (headers) 401 if (headers)
410 pr_err("Stack dump complete\n"); 402 pr_err("Stack dump complete\n");
403 if (have_mmap_sem)
404 up_read(&kbt->task->mm->mmap_sem);
411} 405}
412EXPORT_SYMBOL(tile_show_stack); 406EXPORT_SYMBOL(tile_show_stack);
413 407
diff --git a/arch/tile/kernel/traps.c b/arch/tile/kernel/traps.c
index 2bb6602a1ee..73cff814ac5 100644
--- a/arch/tile/kernel/traps.c
+++ b/arch/tile/kernel/traps.c
@@ -200,7 +200,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
200{ 200{
201 siginfo_t info = { 0 }; 201 siginfo_t info = { 0 };
202 int signo, code; 202 int signo, code;
203 unsigned long address; 203 unsigned long address = 0;
204 bundle_bits instr; 204 bundle_bits instr;
205 205
206 /* Re-enable interrupts. */ 206 /* Re-enable interrupts. */
@@ -223,6 +223,10 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
223 } 223 }
224 224
225 switch (fault_num) { 225 switch (fault_num) {
226 case INT_MEM_ERROR:
227 signo = SIGBUS;
228 code = BUS_OBJERR;
229 break;
226 case INT_ILL: 230 case INT_ILL:
227 if (copy_from_user(&instr, (void __user *)regs->pc, 231 if (copy_from_user(&instr, (void __user *)regs->pc,
228 sizeof(instr))) { 232 sizeof(instr))) {
@@ -289,7 +293,10 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
289 address = regs->pc; 293 address = regs->pc;
290 break; 294 break;
291#ifdef __tilegx__ 295#ifdef __tilegx__
292 case INT_ILL_TRANS: 296 case INT_ILL_TRANS: {
297 /* Avoid a hardware erratum with the return address stack. */
298 fill_ra_stack();
299
293 signo = SIGSEGV; 300 signo = SIGSEGV;
294 code = SEGV_MAPERR; 301 code = SEGV_MAPERR;
295 if (reason & SPR_ILL_TRANS_REASON__I_STREAM_VA_RMASK) 302 if (reason & SPR_ILL_TRANS_REASON__I_STREAM_VA_RMASK)
@@ -297,6 +304,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
297 else 304 else
298 address = 0; /* FIXME: GX: single-step for address */ 305 address = 0; /* FIXME: GX: single-step for address */
299 break; 306 break;
307 }
300#endif 308#endif
301 default: 309 default:
302 panic("Unexpected do_trap interrupt number %d", fault_num); 310 panic("Unexpected do_trap interrupt number %d", fault_num);
@@ -308,7 +316,8 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
308 info.si_addr = (void __user *)address; 316 info.si_addr = (void __user *)address;
309 if (signo == SIGILL) 317 if (signo == SIGILL)
310 info.si_trapno = fault_num; 318 info.si_trapno = fault_num;
311 trace_unhandled_signal("trap", regs, address, signo); 319 if (signo != SIGTRAP)
320 trace_unhandled_signal("trap", regs, address, signo);
312 force_sig_info(signo, &info, current); 321 force_sig_info(signo, &info, current);
313} 322}
314 323
diff --git a/arch/tile/lib/Makefile b/arch/tile/lib/Makefile
index 0c26086ecbe..985f5985823 100644
--- a/arch/tile/lib/Makefile
+++ b/arch/tile/lib/Makefile
@@ -7,6 +7,7 @@ lib-y = cacheflush.o checksum.o cpumask.o delay.o uaccess.o \
7 strchr_$(BITS).o strlen_$(BITS).o 7 strchr_$(BITS).o strlen_$(BITS).o
8 8
9ifeq ($(CONFIG_TILEGX),y) 9ifeq ($(CONFIG_TILEGX),y)
10CFLAGS_REMOVE_memcpy_user_64.o = -fno-omit-frame-pointer
10lib-y += memcpy_user_64.o 11lib-y += memcpy_user_64.o
11else 12else
12lib-y += atomic_32.o atomic_asm_32.o memcpy_tile64.o 13lib-y += atomic_32.o atomic_asm_32.o memcpy_tile64.o
diff --git a/arch/tile/lib/cacheflush.c b/arch/tile/lib/cacheflush.c
index 8928aace7a6..db4fb89e12d 100644
--- a/arch/tile/lib/cacheflush.c
+++ b/arch/tile/lib/cacheflush.c
@@ -39,7 +39,21 @@ void finv_buffer_remote(void *buffer, size_t size, int hfh)
39{ 39{
40 char *p, *base; 40 char *p, *base;
41 size_t step_size, load_count; 41 size_t step_size, load_count;
42
43 /*
44 * On TILEPro the striping granularity is a fixed 8KB; on
45 * TILE-Gx it is configurable, and we rely on the fact that
46 * the hypervisor always configures maximum striping, so that
47 * bits 9 and 10 of the PA are part of the stripe function, so
48 * every 512 bytes we hit a striping boundary.
49 *
50 */
51#ifdef __tilegx__
52 const unsigned long STRIPE_WIDTH = 512;
53#else
42 const unsigned long STRIPE_WIDTH = 8192; 54 const unsigned long STRIPE_WIDTH = 8192;
55#endif
56
43#ifdef __tilegx__ 57#ifdef __tilegx__
44 /* 58 /*
45 * On TILE-Gx, we must disable the dstream prefetcher before doing 59 * On TILE-Gx, we must disable the dstream prefetcher before doing
@@ -74,7 +88,7 @@ void finv_buffer_remote(void *buffer, size_t size, int hfh)
74 * memory, that one load would be sufficient, but since we may 88 * memory, that one load would be sufficient, but since we may
75 * be, we also need to back up to the last load issued to 89 * be, we also need to back up to the last load issued to
76 * another memory controller, which would be the point where 90 * another memory controller, which would be the point where
77 * we crossed an 8KB boundary (the granularity of striping 91 * we crossed a "striping" boundary (the granularity of striping
78 * across memory controllers). Keep backing up and doing this 92 * across memory controllers). Keep backing up and doing this
79 * until we are before the beginning of the buffer, or have 93 * until we are before the beginning of the buffer, or have
80 * hit all the controllers. 94 * hit all the controllers.
@@ -88,12 +102,22 @@ void finv_buffer_remote(void *buffer, size_t size, int hfh)
88 * every cache line on a full memory stripe on each 102 * every cache line on a full memory stripe on each
89 * controller" that we simply do that, to simplify the logic. 103 * controller" that we simply do that, to simplify the logic.
90 * 104 *
91 * FIXME: See bug 9535 for some issues with this code. 105 * On TILE-Gx the hash-for-home function is much more complex,
106 * with the upshot being we can't readily guarantee we have
107 * hit both entries in the 128-entry AMT that were hit by any
108 * load in the entire range, so we just re-load them all.
109 * With larger buffers, we may want to consider using a hypervisor
110 * trap to issue loads directly to each hash-for-home tile for
111 * each controller (doing it from Linux would trash the TLB).
92 */ 112 */
93 if (hfh) { 113 if (hfh) {
94 step_size = L2_CACHE_BYTES; 114 step_size = L2_CACHE_BYTES;
115#ifdef __tilegx__
116 load_count = (size + L2_CACHE_BYTES - 1) / L2_CACHE_BYTES;
117#else
95 load_count = (STRIPE_WIDTH / L2_CACHE_BYTES) * 118 load_count = (STRIPE_WIDTH / L2_CACHE_BYTES) *
96 (1 << CHIP_LOG_NUM_MSHIMS()); 119 (1 << CHIP_LOG_NUM_MSHIMS());
120#endif
97 } else { 121 } else {
98 step_size = STRIPE_WIDTH; 122 step_size = STRIPE_WIDTH;
99 load_count = (1 << CHIP_LOG_NUM_MSHIMS()); 123 load_count = (1 << CHIP_LOG_NUM_MSHIMS());
@@ -109,7 +133,7 @@ void finv_buffer_remote(void *buffer, size_t size, int hfh)
109 133
110 /* Figure out how far back we need to go. */ 134 /* Figure out how far back we need to go. */
111 base = p - (step_size * (load_count - 2)); 135 base = p - (step_size * (load_count - 2));
112 if ((long)base < (long)buffer) 136 if ((unsigned long)base < (unsigned long)buffer)
113 base = buffer; 137 base = buffer;
114 138
115 /* 139 /*
diff --git a/arch/tile/lib/memcpy_user_64.c b/arch/tile/lib/memcpy_user_64.c
index 4763b3aff1c..37440caa737 100644
--- a/arch/tile/lib/memcpy_user_64.c
+++ b/arch/tile/lib/memcpy_user_64.c
@@ -14,7 +14,13 @@
14 * Do memcpy(), but trap and return "n" when a load or store faults. 14 * Do memcpy(), but trap and return "n" when a load or store faults.
15 * 15 *
16 * Note: this idiom only works when memcpy() compiles to a leaf function. 16 * Note: this idiom only works when memcpy() compiles to a leaf function.
17 * If "sp" is updated during memcpy, the "jrp lr" will be incorrect. 17 * Here leaf function not only means it does not have calls, but also
18 * requires no stack operations (sp, stack frame pointer) and no
19 * use of callee-saved registers, else "jrp lr" will be incorrect since
20 * unwinding stack frame is bypassed. Since memcpy() is not complex so
21 * these conditions are satisfied here, but we need to be careful when
22 * modifying this file. This is not a clean solution but is the best
23 * one so far.
18 * 24 *
19 * Also note that we are capturing "n" from the containing scope here. 25 * Also note that we are capturing "n" from the containing scope here.
20 */ 26 */
diff --git a/arch/tile/lib/spinlock_common.h b/arch/tile/lib/spinlock_common.h
index c1010980913..6ac37509fac 100644
--- a/arch/tile/lib/spinlock_common.h
+++ b/arch/tile/lib/spinlock_common.h
@@ -60,5 +60,5 @@ static void delay_backoff(int iterations)
60 loops += __insn_crc32_32(stack_pointer, get_cycles_low()) & 60 loops += __insn_crc32_32(stack_pointer, get_cycles_low()) &
61 (loops - 1); 61 (loops - 1);
62 62
63 relax(1 << exponent); 63 relax(loops);
64} 64}
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index cba30e9547b..22e58f51ed2 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -130,7 +130,7 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
130} 130}
131 131
132/* 132/*
133 * Handle a fault on the vmalloc or module mapping area 133 * Handle a fault on the vmalloc area.
134 */ 134 */
135static inline int vmalloc_fault(pgd_t *pgd, unsigned long address) 135static inline int vmalloc_fault(pgd_t *pgd, unsigned long address)
136{ 136{
@@ -203,9 +203,14 @@ static pgd_t *get_current_pgd(void)
203 * interrupt or a critical region, and must do as little as possible. 203 * interrupt or a critical region, and must do as little as possible.
204 * Similarly, we can't use atomic ops here, since we may be handling a 204 * Similarly, we can't use atomic ops here, since we may be handling a
205 * fault caused by an atomic op access. 205 * fault caused by an atomic op access.
206 *
207 * If we find a migrating PTE while we're in an NMI context, and we're
208 * at a PC that has a registered exception handler, we don't wait,
209 * since this thread may (e.g.) have been interrupted while migrating
210 * its own stack, which would then cause us to self-deadlock.
206 */ 211 */
207static int handle_migrating_pte(pgd_t *pgd, int fault_num, 212static int handle_migrating_pte(pgd_t *pgd, int fault_num,
208 unsigned long address, 213 unsigned long address, unsigned long pc,
209 int is_kernel_mode, int write) 214 int is_kernel_mode, int write)
210{ 215{
211 pud_t *pud; 216 pud_t *pud;
@@ -227,6 +232,8 @@ static int handle_migrating_pte(pgd_t *pgd, int fault_num,
227 pte_offset_kernel(pmd, address); 232 pte_offset_kernel(pmd, address);
228 pteval = *pte; 233 pteval = *pte;
229 if (pte_migrating(pteval)) { 234 if (pte_migrating(pteval)) {
235 if (in_nmi() && search_exception_tables(pc))
236 return 0;
230 wait_for_migration(pte); 237 wait_for_migration(pte);
231 return 1; 238 return 1;
232 } 239 }
@@ -300,7 +307,7 @@ static int handle_page_fault(struct pt_regs *regs,
300 * rather than trying to patch up the existing PTE. 307 * rather than trying to patch up the existing PTE.
301 */ 308 */
302 pgd = get_current_pgd(); 309 pgd = get_current_pgd();
303 if (handle_migrating_pte(pgd, fault_num, address, 310 if (handle_migrating_pte(pgd, fault_num, address, regs->pc,
304 is_kernel_mode, write)) 311 is_kernel_mode, write))
305 return 1; 312 return 1;
306 313
@@ -335,9 +342,12 @@ static int handle_page_fault(struct pt_regs *regs,
335 /* 342 /*
336 * If we're trying to touch user-space addresses, we must 343 * If we're trying to touch user-space addresses, we must
337 * be either at PL0, or else with interrupts enabled in the 344 * be either at PL0, or else with interrupts enabled in the
338 * kernel, so either way we can re-enable interrupts here. 345 * kernel, so either way we can re-enable interrupts here
346 * unless we are doing atomic access to user space with
347 * interrupts disabled.
339 */ 348 */
340 local_irq_enable(); 349 if (!(regs->flags & PT_FLAGS_DISABLE_IRQ))
350 local_irq_enable();
341 351
342 mm = tsk->mm; 352 mm = tsk->mm;
343 353
@@ -665,7 +675,7 @@ struct intvec_state do_page_fault_ics(struct pt_regs *regs, int fault_num,
665 */ 675 */
666 if (fault_num == INT_DTLB_ACCESS) 676 if (fault_num == INT_DTLB_ACCESS)
667 write = 1; 677 write = 1;
668 if (handle_migrating_pte(pgd, fault_num, address, 1, write)) 678 if (handle_migrating_pte(pgd, fault_num, address, pc, 1, write))
669 return state; 679 return state;
670 680
671 /* Return zero so that we continue on with normal fault handling. */ 681 /* Return zero so that we continue on with normal fault handling. */
diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c
index 1cc6ae477c9..499f73770b0 100644
--- a/arch/tile/mm/homecache.c
+++ b/arch/tile/mm/homecache.c
@@ -394,6 +394,7 @@ int page_home(struct page *page)
394 return pte_to_home(*virt_to_pte(NULL, kva)); 394 return pte_to_home(*virt_to_pte(NULL, kva));
395 } 395 }
396} 396}
397EXPORT_SYMBOL(page_home);
397 398
398void homecache_change_page_home(struct page *page, int order, int home) 399void homecache_change_page_home(struct page *page, int order, int home)
399{ 400{
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 830c4908ea7..6a9d20ddc34 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -254,11 +254,6 @@ static pgprot_t __init init_pgprot(ulong address)
254 return construct_pgprot(PAGE_KERNEL_RO, PAGE_HOME_IMMUTABLE); 254 return construct_pgprot(PAGE_KERNEL_RO, PAGE_HOME_IMMUTABLE);
255 } 255 }
256 256
257 /* As a performance optimization, keep the boot init stack here. */
258 if (address >= (ulong)&init_thread_union &&
259 address < (ulong)&init_thread_union + THREAD_SIZE)
260 return construct_pgprot(PAGE_KERNEL, smp_processor_id());
261
262#ifndef __tilegx__ 257#ifndef __tilegx__
263#if !ATOMIC_LOCKS_FOUND_VIA_TABLE() 258#if !ATOMIC_LOCKS_FOUND_VIA_TABLE()
264 /* Force the atomic_locks[] array page to be hash-for-home. */ 259 /* Force the atomic_locks[] array page to be hash-for-home. */
@@ -557,6 +552,7 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
557 552
558 address = MEM_SV_INTRPT; 553 address = MEM_SV_INTRPT;
559 pmd = get_pmd(pgtables, address); 554 pmd = get_pmd(pgtables, address);
555 pfn = 0; /* code starts at PA 0 */
560 if (ktext_small) { 556 if (ktext_small) {
561 /* Allocate an L2 PTE for the kernel text */ 557 /* Allocate an L2 PTE for the kernel text */
562 int cpu = 0; 558 int cpu = 0;
@@ -579,10 +575,15 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
579 } 575 }
580 576
581 BUG_ON(address != (unsigned long)_stext); 577 BUG_ON(address != (unsigned long)_stext);
582 pfn = 0; /* code starts at PA 0 */ 578 pte = NULL;
583 pte = alloc_pte(); 579 for (; address < (unsigned long)_einittext;
584 for (pte_ofs = 0; address < (unsigned long)_einittext; 580 pfn++, address += PAGE_SIZE) {
585 pfn++, pte_ofs++, address += PAGE_SIZE) { 581 pte_ofs = pte_index(address);
582 if (pte_ofs == 0) {
583 if (pte)
584 assign_pte(pmd++, pte);
585 pte = alloc_pte();
586 }
586 if (!ktext_local) { 587 if (!ktext_local) {
587 prot = set_remote_cache_cpu(prot, cpu); 588 prot = set_remote_cache_cpu(prot, cpu);
588 cpu = cpumask_next(cpu, &ktext_mask); 589 cpu = cpumask_next(cpu, &ktext_mask);
@@ -591,7 +592,8 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
591 } 592 }
592 pte[pte_ofs] = pfn_pte(pfn, prot); 593 pte[pte_ofs] = pfn_pte(pfn, prot);
593 } 594 }
594 assign_pte(pmd, pte); 595 if (pte)
596 assign_pte(pmd, pte);
595 } else { 597 } else {
596 pte_t pteval = pfn_pte(0, PAGE_KERNEL_EXEC); 598 pte_t pteval = pfn_pte(0, PAGE_KERNEL_EXEC);
597 pteval = pte_mkhuge(pteval); 599 pteval = pte_mkhuge(pteval);
@@ -614,7 +616,9 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
614 else 616 else
615 pteval = hv_pte_set_mode(pteval, 617 pteval = hv_pte_set_mode(pteval,
616 HV_PTE_MODE_CACHE_NO_L3); 618 HV_PTE_MODE_CACHE_NO_L3);
617 *(pte_t *)pmd = pteval; 619 for (; address < (unsigned long)_einittext;
620 pfn += PFN_DOWN(HPAGE_SIZE), address += HPAGE_SIZE)
621 *(pte_t *)(pmd++) = pfn_pte(pfn, pteval);
618 } 622 }
619 623
620 /* Set swapper_pgprot here so it is flushed to memory right away. */ 624 /* Set swapper_pgprot here so it is flushed to memory right away. */
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index 87303693a07..2410aa899b3 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -177,14 +177,10 @@ void shatter_huge_page(unsigned long addr)
177 if (!pmd_huge_page(*pmd)) 177 if (!pmd_huge_page(*pmd))
178 return; 178 return;
179 179
180 /* 180 spin_lock_irqsave(&init_mm.page_table_lock, flags);
181 * Grab the pgd_lock, since we may need it to walk the pgd_list,
182 * and since we need some kind of lock here to avoid races.
183 */
184 spin_lock_irqsave(&pgd_lock, flags);
185 if (!pmd_huge_page(*pmd)) { 181 if (!pmd_huge_page(*pmd)) {
186 /* Lost the race to convert the huge page. */ 182 /* Lost the race to convert the huge page. */
187 spin_unlock_irqrestore(&pgd_lock, flags); 183 spin_unlock_irqrestore(&init_mm.page_table_lock, flags);
188 return; 184 return;
189 } 185 }
190 186
@@ -194,6 +190,7 @@ void shatter_huge_page(unsigned long addr)
194 190
195#ifdef __PAGETABLE_PMD_FOLDED 191#ifdef __PAGETABLE_PMD_FOLDED
196 /* Walk every pgd on the system and update the pmd there. */ 192 /* Walk every pgd on the system and update the pmd there. */
193 spin_lock(&pgd_lock);
197 list_for_each(pos, &pgd_list) { 194 list_for_each(pos, &pgd_list) {
198 pmd_t *copy_pmd; 195 pmd_t *copy_pmd;
199 pgd = list_to_pgd(pos) + pgd_index(addr); 196 pgd = list_to_pgd(pos) + pgd_index(addr);
@@ -201,6 +198,7 @@ void shatter_huge_page(unsigned long addr)
201 copy_pmd = pmd_offset(pud, addr); 198 copy_pmd = pmd_offset(pud, addr);
202 __set_pmd(copy_pmd, *pmd); 199 __set_pmd(copy_pmd, *pmd);
203 } 200 }
201 spin_unlock(&pgd_lock);
204#endif 202#endif
205 203
206 /* Tell every cpu to notice the change. */ 204 /* Tell every cpu to notice the change. */
@@ -208,7 +206,7 @@ void shatter_huge_page(unsigned long addr)
208 cpu_possible_mask, NULL, 0); 206 cpu_possible_mask, NULL, 0);
209 207
210 /* Hold the lock until the TLB flush is finished to avoid races. */ 208 /* Hold the lock until the TLB flush is finished to avoid races. */
211 spin_unlock_irqrestore(&pgd_lock, flags); 209 spin_unlock_irqrestore(&init_mm.page_table_lock, flags);
212} 210}
213 211
214/* 212/*
@@ -217,9 +215,13 @@ void shatter_huge_page(unsigned long addr)
217 * against pageattr.c; it is the unique case in which a valid change 215 * against pageattr.c; it is the unique case in which a valid change
218 * of kernel pagetables can't be lazily synchronized by vmalloc faults. 216 * of kernel pagetables can't be lazily synchronized by vmalloc faults.
219 * vmalloc faults work because attached pagetables are never freed. 217 * vmalloc faults work because attached pagetables are never freed.
220 * The locking scheme was chosen on the basis of manfred's 218 *
221 * recommendations and having no core impact whatsoever. 219 * The lock is always taken with interrupts disabled, unlike on x86
222 * -- wli 220 * and other platforms, because we need to take the lock in
221 * shatter_huge_page(), which may be called from an interrupt context.
222 * We are not at risk from the tlbflush IPI deadlock that was seen on
223 * x86, since we use the flush_remote() API to have the hypervisor do
224 * the TLB flushes regardless of irq disabling.
223 */ 225 */
224DEFINE_SPINLOCK(pgd_lock); 226DEFINE_SPINLOCK(pgd_lock);
225LIST_HEAD(pgd_list); 227LIST_HEAD(pgd_list);
@@ -469,10 +471,18 @@ void __set_pte(pte_t *ptep, pte_t pte)
469 471
470void set_pte(pte_t *ptep, pte_t pte) 472void set_pte(pte_t *ptep, pte_t pte)
471{ 473{
472 struct page *page = pfn_to_page(pte_pfn(pte)); 474 if (pte_present(pte) &&
473 475 (!CHIP_HAS_MMIO() || hv_pte_get_mode(pte) != HV_PTE_MODE_MMIO)) {
474 /* Update the home of a PTE if necessary */ 476 /* The PTE actually references physical memory. */
475 pte = pte_set_home(pte, page_home(page)); 477 unsigned long pfn = pte_pfn(pte);
478 if (pfn_valid(pfn)) {
479 /* Update the home of the PTE from the struct page. */
480 pte = pte_set_home(pte, page_home(pfn_to_page(pfn)));
481 } else if (hv_pte_get_mode(pte) == 0) {
482 /* remap_pfn_range(), etc, must supply PTE mode. */
483 panic("set_pte(): out-of-range PFN and mode 0\n");
484 }
485 }
476 486
477 __set_pte(ptep, pte); 487 __set_pte(ptep, pte);
478} 488}
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
index dc36b222100..6673508f342 100644
--- a/arch/um/drivers/cow.h
+++ b/arch/um/drivers/cow.h
@@ -3,41 +3,6 @@
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5 5
6#if defined(__KERNEL__)
7
8# include <asm/byteorder.h>
9
10# if defined(__BIG_ENDIAN)
11# define ntohll(x) (x)
12# define htonll(x) (x)
13# elif defined(__LITTLE_ENDIAN)
14# define ntohll(x) be64_to_cpu(x)
15# define htonll(x) cpu_to_be64(x)
16# else
17# error "Could not determine byte order"
18# endif
19
20#else
21/* For the definition of ntohl, htonl and __BYTE_ORDER */
22#include <endian.h>
23#include <netinet/in.h>
24#if defined(__BYTE_ORDER)
25
26# if __BYTE_ORDER == __BIG_ENDIAN
27# define ntohll(x) (x)
28# define htonll(x) (x)
29# elif __BYTE_ORDER == __LITTLE_ENDIAN
30# define ntohll(x) bswap_64(x)
31# define htonll(x) bswap_64(x)
32# else
33# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined"
34# endif
35
36#else /* ! defined(__BYTE_ORDER) */
37# error "Could not determine byte order: __BYTE_ORDER not defined"
38#endif
39#endif /* ! defined(__KERNEL__) */
40
41extern int init_cow_file(int fd, char *cow_file, char *backing_file, 6extern int init_cow_file(int fd, char *cow_file, char *backing_file,
42 int sectorsize, int alignment, int *bitmap_offset_out, 7 int sectorsize, int alignment, int *bitmap_offset_out,
43 unsigned long *bitmap_len_out, int *data_offset_out); 8 unsigned long *bitmap_len_out, int *data_offset_out);
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index 9cbb426c0b9..0ee9cc6cc4c 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -8,11 +8,10 @@
8 * that. 8 * that.
9 */ 9 */
10#include <unistd.h> 10#include <unistd.h>
11#include <byteswap.h>
12#include <errno.h> 11#include <errno.h>
13#include <string.h> 12#include <string.h>
14#include <arpa/inet.h> 13#include <arpa/inet.h>
15#include <asm/types.h> 14#include <endian.h>
16#include "cow.h" 15#include "cow.h"
17#include "cow_sys.h" 16#include "cow_sys.h"
18 17
@@ -214,8 +213,8 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
214 "header\n"); 213 "header\n");
215 goto out; 214 goto out;
216 } 215 }
217 header->magic = htonl(COW_MAGIC); 216 header->magic = htobe32(COW_MAGIC);
218 header->version = htonl(COW_VERSION); 217 header->version = htobe32(COW_VERSION);
219 218
220 err = -EINVAL; 219 err = -EINVAL;
221 if (strlen(backing_file) > sizeof(header->backing_file) - 1) { 220 if (strlen(backing_file) > sizeof(header->backing_file) - 1) {
@@ -246,10 +245,10 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
246 goto out_free; 245 goto out_free;
247 } 246 }
248 247
249 header->mtime = htonl(modtime); 248 header->mtime = htobe32(modtime);
250 header->size = htonll(*size); 249 header->size = htobe64(*size);
251 header->sectorsize = htonl(sectorsize); 250 header->sectorsize = htobe32(sectorsize);
252 header->alignment = htonl(alignment); 251 header->alignment = htobe32(alignment);
253 header->cow_format = COW_BITMAP; 252 header->cow_format = COW_BITMAP;
254 253
255 err = cow_write_file(fd, header, sizeof(*header)); 254 err = cow_write_file(fd, header, sizeof(*header));
@@ -301,8 +300,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
301 magic = header->v1.magic; 300 magic = header->v1.magic;
302 if (magic == COW_MAGIC) 301 if (magic == COW_MAGIC)
303 version = header->v1.version; 302 version = header->v1.version;
304 else if (magic == ntohl(COW_MAGIC)) 303 else if (magic == be32toh(COW_MAGIC))
305 version = ntohl(header->v1.version); 304 version = be32toh(header->v1.version);
306 /* No error printed because the non-COW case comes through here */ 305 /* No error printed because the non-COW case comes through here */
307 else goto out; 306 else goto out;
308 307
@@ -327,9 +326,9 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
327 "header\n"); 326 "header\n");
328 goto out; 327 goto out;
329 } 328 }
330 *mtime_out = ntohl(header->v2.mtime); 329 *mtime_out = be32toh(header->v2.mtime);
331 *size_out = ntohll(header->v2.size); 330 *size_out = be64toh(header->v2.size);
332 *sectorsize_out = ntohl(header->v2.sectorsize); 331 *sectorsize_out = be32toh(header->v2.sectorsize);
333 *bitmap_offset_out = sizeof(header->v2); 332 *bitmap_offset_out = sizeof(header->v2);
334 *align_out = *sectorsize_out; 333 *align_out = *sectorsize_out;
335 file = header->v2.backing_file; 334 file = header->v2.backing_file;
@@ -341,10 +340,10 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
341 "header\n"); 340 "header\n");
342 goto out; 341 goto out;
343 } 342 }
344 *mtime_out = ntohl(header->v3.mtime); 343 *mtime_out = be32toh(header->v3.mtime);
345 *size_out = ntohll(header->v3.size); 344 *size_out = be64toh(header->v3.size);
346 *sectorsize_out = ntohl(header->v3.sectorsize); 345 *sectorsize_out = be32toh(header->v3.sectorsize);
347 *align_out = ntohl(header->v3.alignment); 346 *align_out = be32toh(header->v3.alignment);
348 if (*align_out == 0) { 347 if (*align_out == 0) {
349 cow_printf("read_cow_header - invalid COW header, " 348 cow_printf("read_cow_header - invalid COW header, "
350 "align == 0\n"); 349 "align == 0\n");
@@ -366,16 +365,16 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
366 * this was used until Dec2005 - 64bits are needed to represent 365 * this was used until Dec2005 - 64bits are needed to represent
367 * 2038+. I.e. we can safely do this truncating cast. 366 * 2038+. I.e. we can safely do this truncating cast.
368 * 367 *
369 * Additionally, we must use ntohl() instead of ntohll(), since 368 * Additionally, we must use be32toh() instead of be64toh(), since
370 * the program used to use the former (tested - I got mtime 369 * the program used to use the former (tested - I got mtime
371 * mismatch "0 vs whatever"). 370 * mismatch "0 vs whatever").
372 * 371 *
373 * Ever heard about bug-to-bug-compatibility ? ;-) */ 372 * Ever heard about bug-to-bug-compatibility ? ;-) */
374 *mtime_out = (time32_t) ntohl(header->v3_b.mtime); 373 *mtime_out = (time32_t) be32toh(header->v3_b.mtime);
375 374
376 *size_out = ntohll(header->v3_b.size); 375 *size_out = be64toh(header->v3_b.size);
377 *sectorsize_out = ntohl(header->v3_b.sectorsize); 376 *sectorsize_out = be32toh(header->v3_b.sectorsize);
378 *align_out = ntohl(header->v3_b.alignment); 377 *align_out = be32toh(header->v3_b.alignment);
379 if (*align_out == 0) { 378 if (*align_out == 0) {
380 cow_printf("read_cow_header - invalid COW header, " 379 cow_printf("read_cow_header - invalid COW header, "
381 "align == 0\n"); 380 "align == 0\n");
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index e672bd6d43e..43b39d61b53 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -22,6 +22,7 @@
22#include <linux/workqueue.h> 22#include <linux/workqueue.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/switch_to.h>
25 26
26#include "init.h" 27#include "init.h"
27#include "irq_kern.h" 28#include "irq_kern.h"
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index 8419f5cf2ac..fff24352255 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -1,3 +1,4 @@
1generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h 1generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h
2generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h 2generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h
3generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h 3generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h exec.h
4generic-y += switch_to.h
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 492bc4c1b62..65a1c3d690e 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -3,9 +3,10 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \ 6CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \
7 -DELF_ARCH=$(LDS_ELF_ARCH) \ 7 -DELF_ARCH=$(LDS_ELF_ARCH) \
8 -DELF_FORMAT=$(LDS_ELF_FORMAT) 8 -DELF_FORMAT=$(LDS_ELF_FORMAT) \
9 $(LDS_EXTRA)
9extra-y := vmlinux.lds 10extra-y := vmlinux.lds
10clean-files := 11clean-files :=
11 12
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index f386d04a84a..2b73dedb44c 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -88,11 +88,8 @@ static inline void set_current(struct task_struct *task)
88 88
89extern void arch_switch_to(struct task_struct *to); 89extern void arch_switch_to(struct task_struct *to);
90 90
91void *_switch_to(void *prev, void *next, void *last) 91void *__switch_to(struct task_struct *from, struct task_struct *to)
92{ 92{
93 struct task_struct *from = prev;
94 struct task_struct *to = next;
95
96 to->thread.prev_sched = from; 93 to->thread.prev_sched = from;
97 set_current(to); 94 set_current(to);
98 95
@@ -111,7 +108,6 @@ void *_switch_to(void *prev, void *next, void *last)
111 } while (current->thread.saved_task); 108 } while (current->thread.saved_task);
112 109
113 return current->thread.prev_sched; 110 return current->thread.prev_sched;
114
115} 111}
116 112
117void interrupt_end(void) 113void interrupt_end(void)
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 4947b319f53..0a49ef0c2bf 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -103,7 +103,6 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
103 103
104void uml_setup_stubs(struct mm_struct *mm) 104void uml_setup_stubs(struct mm_struct *mm)
105{ 105{
106 struct page **pages;
107 int err, ret; 106 int err, ret;
108 107
109 if (!skas_needs_stub) 108 if (!skas_needs_stub)
diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
index 4be406abeef..36b62bc5263 100644
--- a/arch/x86/Makefile.um
+++ b/arch/x86/Makefile.um
@@ -14,6 +14,9 @@ LINK-y += $(call cc-option,-m32)
14 14
15export LDFLAGS 15export LDFLAGS
16 16
17LDS_EXTRA := -Ui386
18export LDS_EXTRA
19
17# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. 20# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
18include $(srctree)/arch/x86/Makefile_32.cpu 21include $(srctree)/arch/x86/Makefile_32.cpu
19 22
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 8be5f54d936..e0544597cfe 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -557,6 +557,8 @@ struct __large_struct { unsigned long buf[100]; };
557 557
558extern unsigned long 558extern unsigned long
559copy_from_user_nmi(void *to, const void __user *from, unsigned long n); 559copy_from_user_nmi(void *to, const void __user *from, unsigned long n);
560extern __must_check long
561strncpy_from_user(char *dst, const char __user *src, long count);
560 562
561/* 563/*
562 * movsl can be slow when source and dest are not both 8-byte aligned 564 * movsl can be slow when source and dest are not both 8-byte aligned
diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
index 566e803cc60..8084bc73b18 100644
--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -213,11 +213,6 @@ static inline unsigned long __must_check copy_from_user(void *to,
213 return n; 213 return n;
214} 214}
215 215
216long __must_check strncpy_from_user(char *dst, const char __user *src,
217 long count);
218long __must_check __strncpy_from_user(char *dst,
219 const char __user *src, long count);
220
221/** 216/**
222 * strlen_user: - Get the size of a string in user space. 217 * strlen_user: - Get the size of a string in user space.
223 * @str: The string to measure. 218 * @str: The string to measure.
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 1c66d30971a..fcd4b6f3ef0 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -208,10 +208,6 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
208 } 208 }
209} 209}
210 210
211__must_check long
212strncpy_from_user(char *dst, const char __user *src, long count);
213__must_check long
214__strncpy_from_user(char *dst, const char __user *src, long count);
215__must_check long strnlen_user(const char __user *str, long n); 211__must_check long strnlen_user(const char __user *str, long n);
216__must_check long __strnlen_user(const char __user *str, long n); 212__must_check long __strnlen_user(const char __user *str, long n);
217__must_check long strlen_user(const char __user *str); 213__must_check long strlen_user(const char __user *str);
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 694d801bf60..b8ba6e4a27e 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -38,6 +38,7 @@
38#include <asm/traps.h> 38#include <asm/traps.h>
39#include <asm/desc.h> 39#include <asm/desc.h>
40#include <asm/tlbflush.h> 40#include <asm/tlbflush.h>
41#include <asm/idle.h>
41 42
42static int kvmapf = 1; 43static int kvmapf = 1;
43 44
@@ -253,7 +254,10 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
253 kvm_async_pf_task_wait((u32)read_cr2()); 254 kvm_async_pf_task_wait((u32)read_cr2());
254 break; 255 break;
255 case KVM_PV_REASON_PAGE_READY: 256 case KVM_PV_REASON_PAGE_READY:
257 rcu_irq_enter();
258 exit_idle();
256 kvm_async_pf_task_wake((u32)read_cr2()); 259 kvm_async_pf_task_wake((u32)read_cr2());
260 rcu_irq_exit();
257 break; 261 break;
258 } 262 }
259} 263}
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index a73f0c10481..173df38dbda 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -369,7 +369,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data)
369 case MSR_CORE_PERF_FIXED_CTR_CTRL: 369 case MSR_CORE_PERF_FIXED_CTR_CTRL:
370 if (pmu->fixed_ctr_ctrl == data) 370 if (pmu->fixed_ctr_ctrl == data)
371 return 0; 371 return 0;
372 if (!(data & 0xfffffffffffff444)) { 372 if (!(data & 0xfffffffffffff444ull)) {
373 reprogram_fixed_counters(pmu, data); 373 reprogram_fixed_counters(pmu, data);
374 return 0; 374 return 0;
375 } 375 }
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 280751c8472..ad85adfef84 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3906,7 +3906,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
3906 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); 3906 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
3907 3907
3908 vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; 3908 vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
3909 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
3909 vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ 3910 vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */
3911 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
3910 vmx_set_cr4(&vmx->vcpu, 0); 3912 vmx_set_cr4(&vmx->vcpu, 0);
3911 vmx_set_efer(&vmx->vcpu, 0); 3913 vmx_set_efer(&vmx->vcpu, 0);
3912 vmx_fpu_activate(&vmx->vcpu); 3914 vmx_fpu_activate(&vmx->vcpu);
diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index 97be9cb5448..57252c928f5 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -7,6 +7,8 @@
7#include <linux/highmem.h> 7#include <linux/highmem.h>
8#include <linux/module.h> 8#include <linux/module.h>
9 9
10#include <asm/word-at-a-time.h>
11
10/* 12/*
11 * best effort, GUP based copy_from_user() that is NMI-safe 13 * best effort, GUP based copy_from_user() that is NMI-safe
12 */ 14 */
@@ -41,3 +43,104 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
41 return len; 43 return len;
42} 44}
43EXPORT_SYMBOL_GPL(copy_from_user_nmi); 45EXPORT_SYMBOL_GPL(copy_from_user_nmi);
46
47static inline unsigned long count_bytes(unsigned long mask)
48{
49 mask = (mask - 1) & ~mask;
50 mask >>= 7;
51 return count_masked_bytes(mask);
52}
53
54/*
55 * Do a strncpy, return length of string without final '\0'.
56 * 'count' is the user-supplied count (return 'count' if we
57 * hit it), 'max' is the address space maximum (and we return
58 * -EFAULT if we hit it).
59 */
60static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, long max)
61{
62 long res = 0;
63
64 /*
65 * Truncate 'max' to the user-specified limit, so that
66 * we only have one limit we need to check in the loop
67 */
68 if (max > count)
69 max = count;
70
71 while (max >= sizeof(unsigned long)) {
72 unsigned long c;
73
74 /* Fall back to byte-at-a-time if we get a page fault */
75 if (unlikely(__get_user(c,(unsigned long __user *)(src+res))))
76 break;
77 /* This can write a few bytes past the NUL character, but that's ok */
78 *(unsigned long *)(dst+res) = c;
79 c = has_zero(c);
80 if (c)
81 return res + count_bytes(c);
82 res += sizeof(unsigned long);
83 max -= sizeof(unsigned long);
84 }
85
86 while (max) {
87 char c;
88
89 if (unlikely(__get_user(c,src+res)))
90 return -EFAULT;
91 dst[res] = c;
92 if (!c)
93 return res;
94 res++;
95 max--;
96 }
97
98 /*
99 * Uhhuh. We hit 'max'. But was that the user-specified maximum
100 * too? If so, that's ok - we got as much as the user asked for.
101 */
102 if (res >= count)
103 return count;
104
105 /*
106 * Nope: we hit the address space limit, and we still had more
107 * characters the caller would have wanted. That's an EFAULT.
108 */
109 return -EFAULT;
110}
111
112/**
113 * strncpy_from_user: - Copy a NUL terminated string from userspace.
114 * @dst: Destination address, in kernel space. This buffer must be at
115 * least @count bytes long.
116 * @src: Source address, in user space.
117 * @count: Maximum number of bytes to copy, including the trailing NUL.
118 *
119 * Copies a NUL-terminated string from userspace to kernel space.
120 *
121 * On success, returns the length of the string (not including the trailing
122 * NUL).
123 *
124 * If access to userspace fails, returns -EFAULT (some data may have been
125 * copied).
126 *
127 * If @count is smaller than the length of the string, copies @count bytes
128 * and returns @count.
129 */
130long
131strncpy_from_user(char *dst, const char __user *src, long count)
132{
133 unsigned long max_addr, src_addr;
134
135 if (unlikely(count <= 0))
136 return 0;
137
138 max_addr = current_thread_info()->addr_limit.seg;
139 src_addr = (unsigned long)src;
140 if (likely(src_addr < max_addr)) {
141 unsigned long max = max_addr - src_addr;
142 return do_strncpy_from_user(dst, src, count, max);
143 }
144 return -EFAULT;
145}
146EXPORT_SYMBOL(strncpy_from_user);
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index d9b094ca7aa..ef2a6a5d78e 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -33,93 +33,6 @@ static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned lon
33 __movsl_is_ok((unsigned long)(a1), (unsigned long)(a2), (n)) 33 __movsl_is_ok((unsigned long)(a1), (unsigned long)(a2), (n))
34 34
35/* 35/*
36 * Copy a null terminated string from userspace.
37 */
38
39#define __do_strncpy_from_user(dst, src, count, res) \
40do { \
41 int __d0, __d1, __d2; \
42 might_fault(); \
43 __asm__ __volatile__( \
44 " testl %1,%1\n" \
45 " jz 2f\n" \
46 "0: lodsb\n" \
47 " stosb\n" \
48 " testb %%al,%%al\n" \
49 " jz 1f\n" \
50 " decl %1\n" \
51 " jnz 0b\n" \
52 "1: subl %1,%0\n" \
53 "2:\n" \
54 ".section .fixup,\"ax\"\n" \
55 "3: movl %5,%0\n" \
56 " jmp 2b\n" \
57 ".previous\n" \
58 _ASM_EXTABLE(0b,3b) \
59 : "=&d"(res), "=&c"(count), "=&a" (__d0), "=&S" (__d1), \
60 "=&D" (__d2) \
61 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
62 : "memory"); \
63} while (0)
64
65/**
66 * __strncpy_from_user: - Copy a NUL terminated string from userspace, with less checking.
67 * @dst: Destination address, in kernel space. This buffer must be at
68 * least @count bytes long.
69 * @src: Source address, in user space.
70 * @count: Maximum number of bytes to copy, including the trailing NUL.
71 *
72 * Copies a NUL-terminated string from userspace to kernel space.
73 * Caller must check the specified block with access_ok() before calling
74 * this function.
75 *
76 * On success, returns the length of the string (not including the trailing
77 * NUL).
78 *
79 * If access to userspace fails, returns -EFAULT (some data may have been
80 * copied).
81 *
82 * If @count is smaller than the length of the string, copies @count bytes
83 * and returns @count.
84 */
85long
86__strncpy_from_user(char *dst, const char __user *src, long count)
87{
88 long res;
89 __do_strncpy_from_user(dst, src, count, res);
90 return res;
91}
92EXPORT_SYMBOL(__strncpy_from_user);
93
94/**
95 * strncpy_from_user: - Copy a NUL terminated string from userspace.
96 * @dst: Destination address, in kernel space. This buffer must be at
97 * least @count bytes long.
98 * @src: Source address, in user space.
99 * @count: Maximum number of bytes to copy, including the trailing NUL.
100 *
101 * Copies a NUL-terminated string from userspace to kernel space.
102 *
103 * On success, returns the length of the string (not including the trailing
104 * NUL).
105 *
106 * If access to userspace fails, returns -EFAULT (some data may have been
107 * copied).
108 *
109 * If @count is smaller than the length of the string, copies @count bytes
110 * and returns @count.
111 */
112long
113strncpy_from_user(char *dst, const char __user *src, long count)
114{
115 long res = -EFAULT;
116 if (access_ok(VERIFY_READ, src, 1))
117 __do_strncpy_from_user(dst, src, count, res);
118 return res;
119}
120EXPORT_SYMBOL(strncpy_from_user);
121
122/*
123 * Zero Userspace 36 * Zero Userspace
124 */ 37 */
125 38
diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
index b7c2849ffb6..0d0326f388c 100644
--- a/arch/x86/lib/usercopy_64.c
+++ b/arch/x86/lib/usercopy_64.c
@@ -9,55 +9,6 @@
9#include <asm/uaccess.h> 9#include <asm/uaccess.h>
10 10
11/* 11/*
12 * Copy a null terminated string from userspace.
13 */
14
15#define __do_strncpy_from_user(dst,src,count,res) \
16do { \
17 long __d0, __d1, __d2; \
18 might_fault(); \
19 __asm__ __volatile__( \
20 " testq %1,%1\n" \
21 " jz 2f\n" \
22 "0: lodsb\n" \
23 " stosb\n" \
24 " testb %%al,%%al\n" \
25 " jz 1f\n" \
26 " decq %1\n" \
27 " jnz 0b\n" \
28 "1: subq %1,%0\n" \
29 "2:\n" \
30 ".section .fixup,\"ax\"\n" \
31 "3: movq %5,%0\n" \
32 " jmp 2b\n" \
33 ".previous\n" \
34 _ASM_EXTABLE(0b,3b) \
35 : "=&r"(res), "=&c"(count), "=&a" (__d0), "=&S" (__d1), \
36 "=&D" (__d2) \
37 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
38 : "memory"); \
39} while (0)
40
41long
42__strncpy_from_user(char *dst, const char __user *src, long count)
43{
44 long res;
45 __do_strncpy_from_user(dst, src, count, res);
46 return res;
47}
48EXPORT_SYMBOL(__strncpy_from_user);
49
50long
51strncpy_from_user(char *dst, const char __user *src, long count)
52{
53 long res = -EFAULT;
54 if (access_ok(VERIFY_READ, src, 1))
55 return __strncpy_from_user(dst, src, count);
56 return res;
57}
58EXPORT_SYMBOL(strncpy_from_user);
59
60/*
61 * Zero Userspace 12 * Zero Userspace
62 */ 13 */
63 14
diff --git a/arch/x86/um/asm/barrier.h b/arch/x86/um/asm/barrier.h
new file mode 100644
index 00000000000..7d01b8c56c0
--- /dev/null
+++ b/arch/x86/um/asm/barrier.h
@@ -0,0 +1,75 @@
1#ifndef _ASM_UM_BARRIER_H_
2#define _ASM_UM_BARRIER_H_
3
4#include <asm/asm.h>
5#include <asm/segment.h>
6#include <asm/cpufeature.h>
7#include <asm/cmpxchg.h>
8#include <asm/nops.h>
9
10#include <linux/kernel.h>
11#include <linux/irqflags.h>
12
13/*
14 * Force strict CPU ordering.
15 * And yes, this is required on UP too when we're talking
16 * to devices.
17 */
18#ifdef CONFIG_X86_32
19
20#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
21#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
22#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
23
24#else /* CONFIG_X86_32 */
25
26#define mb() asm volatile("mfence" : : : "memory")
27#define rmb() asm volatile("lfence" : : : "memory")
28#define wmb() asm volatile("sfence" : : : "memory")
29
30#endif /* CONFIG_X86_32 */
31
32#define read_barrier_depends() do { } while (0)
33
34#ifdef CONFIG_SMP
35
36#define smp_mb() mb()
37#ifdef CONFIG_X86_PPRO_FENCE
38#define smp_rmb() rmb()
39#else /* CONFIG_X86_PPRO_FENCE */
40#define smp_rmb() barrier()
41#endif /* CONFIG_X86_PPRO_FENCE */
42
43#ifdef CONFIG_X86_OOSTORE
44#define smp_wmb() wmb()
45#else /* CONFIG_X86_OOSTORE */
46#define smp_wmb() barrier()
47#endif /* CONFIG_X86_OOSTORE */
48
49#define smp_read_barrier_depends() read_barrier_depends()
50#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
51
52#else /* CONFIG_SMP */
53
54#define smp_mb() barrier()
55#define smp_rmb() barrier()
56#define smp_wmb() barrier()
57#define smp_read_barrier_depends() do { } while (0)
58#define set_mb(var, value) do { var = value; barrier(); } while (0)
59
60#endif /* CONFIG_SMP */
61
62/*
63 * Stop RDTSC speculation. This is needed when you need to use RDTSC
64 * (or get_cycles or vread that possibly accesses the TSC) in a defined
65 * code region.
66 *
67 * (Could use an alternative three way for this if there was one.)
68 */
69static inline void rdtsc_barrier(void)
70{
71 alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC);
72 alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC);
73}
74
75#endif
diff --git a/arch/x86/um/asm/system.h b/arch/x86/um/asm/system.h
deleted file mode 100644
index a459fd9b759..00000000000
--- a/arch/x86/um/asm/system.h
+++ /dev/null
@@ -1,135 +0,0 @@
1#ifndef _ASM_X86_SYSTEM_H_
2#define _ASM_X86_SYSTEM_H_
3
4#include <asm/asm.h>
5#include <asm/segment.h>
6#include <asm/cpufeature.h>
7#include <asm/cmpxchg.h>
8#include <asm/nops.h>
9
10#include <linux/kernel.h>
11#include <linux/irqflags.h>
12
13/* entries in ARCH_DLINFO: */
14#ifdef CONFIG_IA32_EMULATION
15# define AT_VECTOR_SIZE_ARCH 2
16#else
17# define AT_VECTOR_SIZE_ARCH 1
18#endif
19
20extern unsigned long arch_align_stack(unsigned long sp);
21
22void default_idle(void);
23
24/*
25 * Force strict CPU ordering.
26 * And yes, this is required on UP too when we're talking
27 * to devices.
28 */
29#ifdef CONFIG_X86_32
30/*
31 * Some non-Intel clones support out of order store. wmb() ceases to be a
32 * nop for these.
33 */
34#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
35#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
36#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
37#else
38#define mb() asm volatile("mfence":::"memory")
39#define rmb() asm volatile("lfence":::"memory")
40#define wmb() asm volatile("sfence" ::: "memory")
41#endif
42
43/**
44 * read_barrier_depends - Flush all pending reads that subsequents reads
45 * depend on.
46 *
47 * No data-dependent reads from memory-like regions are ever reordered
48 * over this barrier. All reads preceding this primitive are guaranteed
49 * to access memory (but not necessarily other CPUs' caches) before any
50 * reads following this primitive that depend on the data return by
51 * any of the preceding reads. This primitive is much lighter weight than
52 * rmb() on most CPUs, and is never heavier weight than is
53 * rmb().
54 *
55 * These ordering constraints are respected by both the local CPU
56 * and the compiler.
57 *
58 * Ordering is not guaranteed by anything other than these primitives,
59 * not even by data dependencies. See the documentation for
60 * memory_barrier() for examples and URLs to more information.
61 *
62 * For example, the following code would force ordering (the initial
63 * value of "a" is zero, "b" is one, and "p" is "&a"):
64 *
65 * <programlisting>
66 * CPU 0 CPU 1
67 *
68 * b = 2;
69 * memory_barrier();
70 * p = &b; q = p;
71 * read_barrier_depends();
72 * d = *q;
73 * </programlisting>
74 *
75 * because the read of "*q" depends on the read of "p" and these
76 * two reads are separated by a read_barrier_depends(). However,
77 * the following code, with the same initial values for "a" and "b":
78 *
79 * <programlisting>
80 * CPU 0 CPU 1
81 *
82 * a = 2;
83 * memory_barrier();
84 * b = 3; y = b;
85 * read_barrier_depends();
86 * x = a;
87 * </programlisting>
88 *
89 * does not enforce ordering, since there is no data dependency between
90 * the read of "a" and the read of "b". Therefore, on some CPUs, such
91 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
92 * in cases like this where there are no data dependencies.
93 **/
94
95#define read_barrier_depends() do { } while (0)
96
97#ifdef CONFIG_SMP
98#define smp_mb() mb()
99#ifdef CONFIG_X86_PPRO_FENCE
100# define smp_rmb() rmb()
101#else
102# define smp_rmb() barrier()
103#endif
104#ifdef CONFIG_X86_OOSTORE
105# define smp_wmb() wmb()
106#else
107# define smp_wmb() barrier()
108#endif
109#define smp_read_barrier_depends() read_barrier_depends()
110#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
111#else
112#define smp_mb() barrier()
113#define smp_rmb() barrier()
114#define smp_wmb() barrier()
115#define smp_read_barrier_depends() do { } while (0)
116#define set_mb(var, value) do { var = value; barrier(); } while (0)
117#endif
118
119/*
120 * Stop RDTSC speculation. This is needed when you need to use RDTSC
121 * (or get_cycles or vread that possibly accesses the TSC) in a defined
122 * code region.
123 *
124 * (Could use an alternative three way for this if there was one.)
125 */
126static inline void rdtsc_barrier(void)
127{
128 alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC);
129 alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC);
130}
131
132extern void *_switch_to(void *prev, void *next, void *last);
133#define switch_to(prev, next, last) prev = _switch_to(prev, next, last)
134
135#endif
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 988828b479e..b8e279479a6 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1859,6 +1859,7 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
1859#endif /* CONFIG_X86_64 */ 1859#endif /* CONFIG_X86_64 */
1860 1860
1861static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss; 1861static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
1862static unsigned char fake_ioapic_mapping[PAGE_SIZE] __page_aligned_bss;
1862 1863
1863static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) 1864static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
1864{ 1865{
@@ -1899,7 +1900,7 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
1899 * We just don't map the IO APIC - all access is via 1900 * We just don't map the IO APIC - all access is via
1900 * hypercalls. Keep the address in the pte for reference. 1901 * hypercalls. Keep the address in the pte for reference.
1901 */ 1902 */
1902 pte = pfn_pte(PFN_DOWN(__pa(dummy_mapping)), PAGE_KERNEL); 1903 pte = pfn_pte(PFN_DOWN(__pa(fake_ioapic_mapping)), PAGE_KERNEL);
1903 break; 1904 break;
1904#endif 1905#endif
1905 1906
@@ -2064,6 +2065,7 @@ void __init xen_init_mmu_ops(void)
2064 pv_mmu_ops = xen_mmu_ops; 2065 pv_mmu_ops = xen_mmu_ops;
2065 2066
2066 memset(dummy_mapping, 0xff, PAGE_SIZE); 2067 memset(dummy_mapping, 0xff, PAGE_SIZE);
2068 memset(fake_ioapic_mapping, 0xfd, PAGE_SIZE);
2067} 2069}
2068 2070
2069/* Protected by xen_reservation_lock. */ 2071/* Protected by xen_reservation_lock. */
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 02900e8ce26..5fac6919b95 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -59,7 +59,7 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
59 59
60static void __cpuinit cpu_bringup(void) 60static void __cpuinit cpu_bringup(void)
61{ 61{
62 int cpu = smp_processor_id(); 62 int cpu;
63 63
64 cpu_init(); 64 cpu_init();
65 touch_softlockup_watchdog(); 65 touch_softlockup_watchdog();
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 21ff9d01543..8e84225c096 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -627,7 +627,7 @@ config CRYPTO_BLOWFISH_COMMON
627 627
628config CRYPTO_BLOWFISH_X86_64 628config CRYPTO_BLOWFISH_X86_64
629 tristate "Blowfish cipher algorithm (x86_64)" 629 tristate "Blowfish cipher algorithm (x86_64)"
630 depends on (X86 || UML_X86) && 64BIT 630 depends on X86 && 64BIT
631 select CRYPTO_ALGAPI 631 select CRYPTO_ALGAPI
632 select CRYPTO_BLOWFISH_COMMON 632 select CRYPTO_BLOWFISH_COMMON
633 help 633 help
@@ -657,7 +657,7 @@ config CRYPTO_CAMELLIA
657 657
658config CRYPTO_CAMELLIA_X86_64 658config CRYPTO_CAMELLIA_X86_64
659 tristate "Camellia cipher algorithm (x86_64)" 659 tristate "Camellia cipher algorithm (x86_64)"
660 depends on (X86 || UML_X86) && 64BIT 660 depends on X86 && 64BIT
661 depends on CRYPTO 661 depends on CRYPTO
662 select CRYPTO_ALGAPI 662 select CRYPTO_ALGAPI
663 select CRYPTO_LRW 663 select CRYPTO_LRW
@@ -893,7 +893,7 @@ config CRYPTO_TWOFISH_X86_64
893 893
894config CRYPTO_TWOFISH_X86_64_3WAY 894config CRYPTO_TWOFISH_X86_64_3WAY
895 tristate "Twofish cipher algorithm (x86_64, 3-way parallel)" 895 tristate "Twofish cipher algorithm (x86_64, 3-way parallel)"
896 depends on (X86 || UML_X86) && 64BIT 896 depends on X86 && 64BIT
897 select CRYPTO_ALGAPI 897 select CRYPTO_ALGAPI
898 select CRYPTO_TWOFISH_COMMON 898 select CRYPTO_TWOFISH_COMMON
899 select CRYPTO_TWOFISH_X86_64 899 select CRYPTO_TWOFISH_X86_64
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index b3447f63e46..f3decb30223 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -786,7 +786,7 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
786 while (1) { 786 while (1) {
787 787
788 if (cx->entry_method == ACPI_CSTATE_HALT) 788 if (cx->entry_method == ACPI_CSTATE_HALT)
789 halt(); 789 safe_halt();
790 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { 790 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
791 inb(cx->address); 791 inb(cx->address);
792 /* See comment in acpi_idle_do_entry() */ 792 /* See comment in acpi_idle_do_entry() */
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index fb14a6343d4..92b779ee002 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -138,6 +138,7 @@ static int rbtree_show(struct seq_file *s, void *ignored)
138 unsigned int base, top; 138 unsigned int base, top;
139 int nodes = 0; 139 int nodes = 0;
140 int registers = 0; 140 int registers = 0;
141 int average;
141 142
142 mutex_lock(&map->lock); 143 mutex_lock(&map->lock);
143 144
@@ -152,8 +153,13 @@ static int rbtree_show(struct seq_file *s, void *ignored)
152 registers += top - base + 1; 153 registers += top - base + 1;
153 } 154 }
154 155
156 if (nodes)
157 average = registers / nodes;
158 else
159 average = 0;
160
155 seq_printf(s, "%d nodes, %d registers, average %d registers\n", 161 seq_printf(s, "%d nodes, %d registers, average %d registers\n",
156 nodes, registers, registers / nodes); 162 nodes, registers, average);
157 163
158 mutex_unlock(&map->lock); 164 mutex_unlock(&map->lock);
159 165
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 87f54dbf601..74b69095def 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -346,6 +346,7 @@ out:
346 346
347 return ret; 347 return ret;
348} 348}
349EXPORT_SYMBOL_GPL(regcache_sync_region);
349 350
350/** 351/**
351 * regcache_cache_only: Put a register map into cache only mode 352 * regcache_cache_only: Put a register map into cache only mode
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig
index c1172dafdff..fb7c80fb721 100644
--- a/drivers/bcma/Kconfig
+++ b/drivers/bcma/Kconfig
@@ -29,7 +29,7 @@ config BCMA_HOST_PCI
29 29
30config BCMA_DRIVER_PCI_HOSTMODE 30config BCMA_DRIVER_PCI_HOSTMODE
31 bool "Driver for PCI core working in hostmode" 31 bool "Driver for PCI core working in hostmode"
32 depends on BCMA && MIPS 32 depends on BCMA && MIPS && BCMA_HOST_PCI
33 help 33 help
34 PCI core hostmode operation (external PCI bus). 34 PCI core hostmode operation (external PCI bus).
35 35
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 4e20bcfa7ec..d2097a11c3c 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include "bcma_private.h" 12#include "bcma_private.h"
13#include <linux/pci.h>
13#include <linux/export.h> 14#include <linux/export.h>
14#include <linux/bcma/bcma.h> 15#include <linux/bcma/bcma.h>
15#include <asm/paccess.h> 16#include <asm/paccess.h>
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index d5e1ab95674..98cbeba8cd5 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1475,7 +1475,7 @@ static int __init xlblk_init(void)
1475 if (!xen_domain()) 1475 if (!xen_domain())
1476 return -ENODEV; 1476 return -ENODEV;
1477 1477
1478 if (!xen_platform_pci_unplug) 1478 if (xen_hvm_domain() && !xen_platform_pci_unplug)
1479 return -ENODEV; 1479 return -ENODEV;
1480 1480
1481 if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) { 1481 if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 48442476ec0..ae9edca7b56 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -72,7 +72,9 @@ static struct usb_device_id ath3k_table[] = {
72 72
73 /* Atheros AR3012 with sflash firmware*/ 73 /* Atheros AR3012 with sflash firmware*/
74 { USB_DEVICE(0x0CF3, 0x3004) }, 74 { USB_DEVICE(0x0CF3, 0x3004) },
75 { USB_DEVICE(0x0CF3, 0x311D) },
75 { USB_DEVICE(0x13d3, 0x3375) }, 76 { USB_DEVICE(0x13d3, 0x3375) },
77 { USB_DEVICE(0x04CA, 0x3005) },
76 78
77 /* Atheros AR5BBU12 with sflash firmware */ 79 /* Atheros AR5BBU12 with sflash firmware */
78 { USB_DEVICE(0x0489, 0xE02C) }, 80 { USB_DEVICE(0x0489, 0xE02C) },
@@ -89,7 +91,9 @@ static struct usb_device_id ath3k_blist_tbl[] = {
89 91
90 /* Atheros AR3012 with sflash firmware*/ 92 /* Atheros AR3012 with sflash firmware*/
91 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, 93 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
94 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
92 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 95 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
96 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
93 97
94 { } /* Terminating entry */ 98 { } /* Terminating entry */
95}; 99};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 480cad92004..3311b812a0c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -61,7 +61,7 @@ static struct usb_device_id btusb_table[] = {
61 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, 61 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
62 62
63 /* Broadcom SoftSailing reporting vendor specific */ 63 /* Broadcom SoftSailing reporting vendor specific */
64 { USB_DEVICE(0x05ac, 0x21e1) }, 64 { USB_DEVICE(0x0a5c, 0x21e1) },
65 65
66 /* Apple MacBookPro 7,1 */ 66 /* Apple MacBookPro 7,1 */
67 { USB_DEVICE(0x05ac, 0x8213) }, 67 { USB_DEVICE(0x05ac, 0x8213) },
@@ -103,6 +103,7 @@ static struct usb_device_id btusb_table[] = {
103 /* Broadcom BCM20702A0 */ 103 /* Broadcom BCM20702A0 */
104 { USB_DEVICE(0x0a5c, 0x21e3) }, 104 { USB_DEVICE(0x0a5c, 0x21e3) },
105 { USB_DEVICE(0x0a5c, 0x21e6) }, 105 { USB_DEVICE(0x0a5c, 0x21e6) },
106 { USB_DEVICE(0x0a5c, 0x21e8) },
106 { USB_DEVICE(0x0a5c, 0x21f3) }, 107 { USB_DEVICE(0x0a5c, 0x21f3) },
107 { USB_DEVICE(0x413c, 0x8197) }, 108 { USB_DEVICE(0x413c, 0x8197) },
108 109
@@ -129,7 +130,9 @@ static struct usb_device_id blacklist_table[] = {
129 130
130 /* Atheros 3012 with sflash firmware */ 131 /* Atheros 3012 with sflash firmware */
131 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, 132 { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
133 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
132 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 134 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
135 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
133 136
134 /* Atheros AR5BBU12 with sflash firmware */ 137 /* Atheros AR5BBU12 with sflash firmware */
135 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 138 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index fd5adb408f4..98a8c05d4f2 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -299,11 +299,11 @@ static void hci_uart_tty_close(struct tty_struct *tty)
299 hci_uart_close(hdev); 299 hci_uart_close(hdev);
300 300
301 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { 301 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
302 hu->proto->close(hu);
303 if (hdev) { 302 if (hdev) {
304 hci_unregister_dev(hdev); 303 hci_unregister_dev(hdev);
305 hci_free_dev(hdev); 304 hci_free_dev(hdev);
306 } 305 }
306 hu->proto->close(hu);
307 } 307 }
308 308
309 kfree(hu); 309 kfree(hu);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 54ca8b23cde..4ec04a75473 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1260,10 +1260,15 @@ static int proc_do_uuid(ctl_table *table, int write,
1260 uuid = table->data; 1260 uuid = table->data;
1261 if (!uuid) { 1261 if (!uuid) {
1262 uuid = tmp_uuid; 1262 uuid = tmp_uuid;
1263 uuid[8] = 0;
1264 }
1265 if (uuid[8] == 0)
1266 generate_random_uuid(uuid); 1263 generate_random_uuid(uuid);
1264 } else {
1265 static DEFINE_SPINLOCK(bootid_spinlock);
1266
1267 spin_lock(&bootid_spinlock);
1268 if (!uuid[8])
1269 generate_random_uuid(uuid);
1270 spin_unlock(&bootid_spinlock);
1271 }
1267 1272
1268 sprintf(buf, "%pU", uuid); 1273 sprintf(buf, "%pU", uuid);
1269 1274
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 4dc019408fa..3b22a606f79 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -194,17 +194,17 @@ static ssize_t srom_read(struct file *filp, char __user *buf,
194 194
195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf, 195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf,
196 *f_pos, bytes_this_pass); 196 *f_pos, bytes_this_pass);
197 if (hv_retval > 0) { 197 if (hv_retval <= 0) {
198 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
199 retval = -EFAULT;
200 break;
201 }
202 } else if (hv_retval <= 0) {
203 if (retval == 0) 198 if (retval == 0)
204 retval = hv_retval; 199 retval = hv_retval;
205 break; 200 break;
206 } 201 }
207 202
203 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
204 retval = -EFAULT;
205 break;
206 }
207
208 retval += hv_retval; 208 retval += hv_retval;
209 *f_pos += hv_retval; 209 *f_pos += hv_retval;
210 buf += hv_retval; 210 buf += hv_retval;
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 87411cebc57..2f0083a51a9 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -74,7 +74,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
74/** 74/**
75 * cpuidle_play_dead - cpu off-lining 75 * cpuidle_play_dead - cpu off-lining
76 * 76 *
77 * Only returns in case of an error 77 * Returns in case of an error or no driver
78 */ 78 */
79int cpuidle_play_dead(void) 79int cpuidle_play_dead(void)
80{ 80{
@@ -83,6 +83,9 @@ int cpuidle_play_dead(void)
83 int i, dead_state = -1; 83 int i, dead_state = -1;
84 int power_usage = -1; 84 int power_usage = -1;
85 85
86 if (!drv)
87 return -ENODEV;
88
86 /* Find lowest-power state that supports long-term idle */ 89 /* Find lowest-power state that supports long-term idle */
87 for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { 90 for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
88 struct cpuidle_state *s = &drv->states[i]; 91 struct cpuidle_state *s = &drv->states[i];
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 767bcc31b36..2397f6f451b 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -332,6 +332,20 @@ struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
332} 332}
333EXPORT_SYMBOL(dma_find_channel); 333EXPORT_SYMBOL(dma_find_channel);
334 334
335/*
336 * net_dma_find_channel - find a channel for net_dma
337 * net_dma has alignment requirements
338 */
339struct dma_chan *net_dma_find_channel(void)
340{
341 struct dma_chan *chan = dma_find_channel(DMA_MEMCPY);
342 if (chan && !is_dma_copy_aligned(chan->device, 1, 1, 1))
343 return NULL;
344
345 return chan;
346}
347EXPORT_SYMBOL(net_dma_find_channel);
348
335/** 349/**
336 * dma_issue_pending_all - flush all pending operations across all channels 350 * dma_issue_pending_all - flush all pending operations across all channels
337 */ 351 */
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 31493d80e0e..73b2b65cb1d 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -546,9 +546,9 @@ void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
546 PCI_DMA_TODEVICE, flags, 0); 546 PCI_DMA_TODEVICE, flags, 0);
547} 547}
548 548
549unsigned long ioat_get_current_completion(struct ioat_chan_common *chan) 549dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan)
550{ 550{
551 unsigned long phys_complete; 551 dma_addr_t phys_complete;
552 u64 completion; 552 u64 completion;
553 553
554 completion = *chan->completion; 554 completion = *chan->completion;
@@ -569,7 +569,7 @@ unsigned long ioat_get_current_completion(struct ioat_chan_common *chan)
569} 569}
570 570
571bool ioat_cleanup_preamble(struct ioat_chan_common *chan, 571bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
572 unsigned long *phys_complete) 572 dma_addr_t *phys_complete)
573{ 573{
574 *phys_complete = ioat_get_current_completion(chan); 574 *phys_complete = ioat_get_current_completion(chan);
575 if (*phys_complete == chan->last_completion) 575 if (*phys_complete == chan->last_completion)
@@ -580,14 +580,14 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
580 return true; 580 return true;
581} 581}
582 582
583static void __cleanup(struct ioat_dma_chan *ioat, unsigned long phys_complete) 583static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)
584{ 584{
585 struct ioat_chan_common *chan = &ioat->base; 585 struct ioat_chan_common *chan = &ioat->base;
586 struct list_head *_desc, *n; 586 struct list_head *_desc, *n;
587 struct dma_async_tx_descriptor *tx; 587 struct dma_async_tx_descriptor *tx;
588 588
589 dev_dbg(to_dev(chan), "%s: phys_complete: %lx\n", 589 dev_dbg(to_dev(chan), "%s: phys_complete: %llx\n",
590 __func__, phys_complete); 590 __func__, (unsigned long long) phys_complete);
591 list_for_each_safe(_desc, n, &ioat->used_desc) { 591 list_for_each_safe(_desc, n, &ioat->used_desc) {
592 struct ioat_desc_sw *desc; 592 struct ioat_desc_sw *desc;
593 593
@@ -652,7 +652,7 @@ static void __cleanup(struct ioat_dma_chan *ioat, unsigned long phys_complete)
652static void ioat1_cleanup(struct ioat_dma_chan *ioat) 652static void ioat1_cleanup(struct ioat_dma_chan *ioat)
653{ 653{
654 struct ioat_chan_common *chan = &ioat->base; 654 struct ioat_chan_common *chan = &ioat->base;
655 unsigned long phys_complete; 655 dma_addr_t phys_complete;
656 656
657 prefetch(chan->completion); 657 prefetch(chan->completion);
658 658
@@ -698,7 +698,7 @@ static void ioat1_timer_event(unsigned long data)
698 mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); 698 mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT);
699 spin_unlock_bh(&ioat->desc_lock); 699 spin_unlock_bh(&ioat->desc_lock);
700 } else if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 700 } else if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
701 unsigned long phys_complete; 701 dma_addr_t phys_complete;
702 702
703 spin_lock_bh(&ioat->desc_lock); 703 spin_lock_bh(&ioat->desc_lock);
704 /* if we haven't made progress and we have already 704 /* if we haven't made progress and we have already
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index c7888bccd97..5e8fe01ba69 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -88,7 +88,7 @@ struct ioatdma_device {
88struct ioat_chan_common { 88struct ioat_chan_common {
89 struct dma_chan common; 89 struct dma_chan common;
90 void __iomem *reg_base; 90 void __iomem *reg_base;
91 unsigned long last_completion; 91 dma_addr_t last_completion;
92 spinlock_t cleanup_lock; 92 spinlock_t cleanup_lock;
93 unsigned long state; 93 unsigned long state;
94 #define IOAT_COMPLETION_PENDING 0 94 #define IOAT_COMPLETION_PENDING 0
@@ -310,7 +310,7 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device);
310void __devexit ioat_dma_remove(struct ioatdma_device *device); 310void __devexit ioat_dma_remove(struct ioatdma_device *device);
311struct dca_provider * __devinit ioat_dca_init(struct pci_dev *pdev, 311struct dca_provider * __devinit ioat_dca_init(struct pci_dev *pdev,
312 void __iomem *iobase); 312 void __iomem *iobase);
313unsigned long ioat_get_current_completion(struct ioat_chan_common *chan); 313dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan);
314void ioat_init_channel(struct ioatdma_device *device, 314void ioat_init_channel(struct ioatdma_device *device,
315 struct ioat_chan_common *chan, int idx); 315 struct ioat_chan_common *chan, int idx);
316enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie, 316enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie,
@@ -318,7 +318,7 @@ enum dma_status ioat_dma_tx_status(struct dma_chan *c, dma_cookie_t cookie,
318void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags, 318void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
319 size_t len, struct ioat_dma_descriptor *hw); 319 size_t len, struct ioat_dma_descriptor *hw);
320bool ioat_cleanup_preamble(struct ioat_chan_common *chan, 320bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
321 unsigned long *phys_complete); 321 dma_addr_t *phys_complete);
322void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); 322void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
323void ioat_kobject_del(struct ioatdma_device *device); 323void ioat_kobject_del(struct ioatdma_device *device);
324extern const struct sysfs_ops ioat_sysfs_ops; 324extern const struct sysfs_ops ioat_sysfs_ops;
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index e8e110ff3d9..86895760b59 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -128,7 +128,7 @@ static void ioat2_start_null_desc(struct ioat2_dma_chan *ioat)
128 spin_unlock_bh(&ioat->prep_lock); 128 spin_unlock_bh(&ioat->prep_lock);
129} 129}
130 130
131static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) 131static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)
132{ 132{
133 struct ioat_chan_common *chan = &ioat->base; 133 struct ioat_chan_common *chan = &ioat->base;
134 struct dma_async_tx_descriptor *tx; 134 struct dma_async_tx_descriptor *tx;
@@ -179,7 +179,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete)
179static void ioat2_cleanup(struct ioat2_dma_chan *ioat) 179static void ioat2_cleanup(struct ioat2_dma_chan *ioat)
180{ 180{
181 struct ioat_chan_common *chan = &ioat->base; 181 struct ioat_chan_common *chan = &ioat->base;
182 unsigned long phys_complete; 182 dma_addr_t phys_complete;
183 183
184 spin_lock_bh(&chan->cleanup_lock); 184 spin_lock_bh(&chan->cleanup_lock);
185 if (ioat_cleanup_preamble(chan, &phys_complete)) 185 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -260,7 +260,7 @@ int ioat2_reset_sync(struct ioat_chan_common *chan, unsigned long tmo)
260static void ioat2_restart_channel(struct ioat2_dma_chan *ioat) 260static void ioat2_restart_channel(struct ioat2_dma_chan *ioat)
261{ 261{
262 struct ioat_chan_common *chan = &ioat->base; 262 struct ioat_chan_common *chan = &ioat->base;
263 unsigned long phys_complete; 263 dma_addr_t phys_complete;
264 264
265 ioat2_quiesce(chan, 0); 265 ioat2_quiesce(chan, 0);
266 if (ioat_cleanup_preamble(chan, &phys_complete)) 266 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -275,7 +275,7 @@ void ioat2_timer_event(unsigned long data)
275 struct ioat_chan_common *chan = &ioat->base; 275 struct ioat_chan_common *chan = &ioat->base;
276 276
277 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 277 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
278 unsigned long phys_complete; 278 dma_addr_t phys_complete;
279 u64 status; 279 u64 status;
280 280
281 status = ioat_chansts(chan); 281 status = ioat_chansts(chan);
@@ -572,9 +572,9 @@ bool reshape_ring(struct ioat2_dma_chan *ioat, int order)
572 */ 572 */
573 struct ioat_chan_common *chan = &ioat->base; 573 struct ioat_chan_common *chan = &ioat->base;
574 struct dma_chan *c = &chan->common; 574 struct dma_chan *c = &chan->common;
575 const u16 curr_size = ioat2_ring_size(ioat); 575 const u32 curr_size = ioat2_ring_size(ioat);
576 const u16 active = ioat2_ring_active(ioat); 576 const u16 active = ioat2_ring_active(ioat);
577 const u16 new_size = 1 << order; 577 const u32 new_size = 1 << order;
578 struct ioat_ring_ent **ring; 578 struct ioat_ring_ent **ring;
579 u16 i; 579 u16 i;
580 580
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h
index a2c413b2b8d..be2a55b95c2 100644
--- a/drivers/dma/ioat/dma_v2.h
+++ b/drivers/dma/ioat/dma_v2.h
@@ -74,7 +74,7 @@ static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c)
74 return container_of(chan, struct ioat2_dma_chan, base); 74 return container_of(chan, struct ioat2_dma_chan, base);
75} 75}
76 76
77static inline u16 ioat2_ring_size(struct ioat2_dma_chan *ioat) 77static inline u32 ioat2_ring_size(struct ioat2_dma_chan *ioat)
78{ 78{
79 return 1 << ioat->alloc_order; 79 return 1 << ioat->alloc_order;
80} 80}
@@ -91,7 +91,7 @@ static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat)
91 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat)); 91 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat));
92} 92}
93 93
94static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) 94static inline u32 ioat2_ring_space(struct ioat2_dma_chan *ioat)
95{ 95{
96 return ioat2_ring_size(ioat) - ioat2_ring_active(ioat); 96 return ioat2_ring_size(ioat) - ioat2_ring_active(ioat);
97} 97}
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 2c4476c0e40..f7f1dc62c15 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -257,7 +257,7 @@ static bool desc_has_ext(struct ioat_ring_ent *desc)
257 * The difference from the dma_v2.c __cleanup() is that this routine 257 * The difference from the dma_v2.c __cleanup() is that this routine
258 * handles extended descriptors and dma-unmapping raid operations. 258 * handles extended descriptors and dma-unmapping raid operations.
259 */ 259 */
260static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) 260static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)
261{ 261{
262 struct ioat_chan_common *chan = &ioat->base; 262 struct ioat_chan_common *chan = &ioat->base;
263 struct ioat_ring_ent *desc; 263 struct ioat_ring_ent *desc;
@@ -314,7 +314,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete)
314static void ioat3_cleanup(struct ioat2_dma_chan *ioat) 314static void ioat3_cleanup(struct ioat2_dma_chan *ioat)
315{ 315{
316 struct ioat_chan_common *chan = &ioat->base; 316 struct ioat_chan_common *chan = &ioat->base;
317 unsigned long phys_complete; 317 dma_addr_t phys_complete;
318 318
319 spin_lock_bh(&chan->cleanup_lock); 319 spin_lock_bh(&chan->cleanup_lock);
320 if (ioat_cleanup_preamble(chan, &phys_complete)) 320 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -333,7 +333,7 @@ static void ioat3_cleanup_event(unsigned long data)
333static void ioat3_restart_channel(struct ioat2_dma_chan *ioat) 333static void ioat3_restart_channel(struct ioat2_dma_chan *ioat)
334{ 334{
335 struct ioat_chan_common *chan = &ioat->base; 335 struct ioat_chan_common *chan = &ioat->base;
336 unsigned long phys_complete; 336 dma_addr_t phys_complete;
337 337
338 ioat2_quiesce(chan, 0); 338 ioat2_quiesce(chan, 0);
339 if (ioat_cleanup_preamble(chan, &phys_complete)) 339 if (ioat_cleanup_preamble(chan, &phys_complete))
@@ -348,7 +348,7 @@ static void ioat3_timer_event(unsigned long data)
348 struct ioat_chan_common *chan = &ioat->base; 348 struct ioat_chan_common *chan = &ioat->base;
349 349
350 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { 350 if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) {
351 unsigned long phys_complete; 351 dma_addr_t phys_complete;
352 u64 status; 352 u64 status;
353 353
354 status = ioat_chansts(chan); 354 status = ioat_chansts(chan);
@@ -1149,6 +1149,44 @@ static int ioat3_reset_hw(struct ioat_chan_common *chan)
1149 return ioat2_reset_sync(chan, msecs_to_jiffies(200)); 1149 return ioat2_reset_sync(chan, msecs_to_jiffies(200));
1150} 1150}
1151 1151
1152static bool is_jf_ioat(struct pci_dev *pdev)
1153{
1154 switch (pdev->device) {
1155 case PCI_DEVICE_ID_INTEL_IOAT_JSF0:
1156 case PCI_DEVICE_ID_INTEL_IOAT_JSF1:
1157 case PCI_DEVICE_ID_INTEL_IOAT_JSF2:
1158 case PCI_DEVICE_ID_INTEL_IOAT_JSF3:
1159 case PCI_DEVICE_ID_INTEL_IOAT_JSF4:
1160 case PCI_DEVICE_ID_INTEL_IOAT_JSF5:
1161 case PCI_DEVICE_ID_INTEL_IOAT_JSF6:
1162 case PCI_DEVICE_ID_INTEL_IOAT_JSF7:
1163 case PCI_DEVICE_ID_INTEL_IOAT_JSF8:
1164 case PCI_DEVICE_ID_INTEL_IOAT_JSF9:
1165 return true;
1166 default:
1167 return false;
1168 }
1169}
1170
1171static bool is_snb_ioat(struct pci_dev *pdev)
1172{
1173 switch (pdev->device) {
1174 case PCI_DEVICE_ID_INTEL_IOAT_SNB0:
1175 case PCI_DEVICE_ID_INTEL_IOAT_SNB1:
1176 case PCI_DEVICE_ID_INTEL_IOAT_SNB2:
1177 case PCI_DEVICE_ID_INTEL_IOAT_SNB3:
1178 case PCI_DEVICE_ID_INTEL_IOAT_SNB4:
1179 case PCI_DEVICE_ID_INTEL_IOAT_SNB5:
1180 case PCI_DEVICE_ID_INTEL_IOAT_SNB6:
1181 case PCI_DEVICE_ID_INTEL_IOAT_SNB7:
1182 case PCI_DEVICE_ID_INTEL_IOAT_SNB8:
1183 case PCI_DEVICE_ID_INTEL_IOAT_SNB9:
1184 return true;
1185 default:
1186 return false;
1187 }
1188}
1189
1152int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca) 1190int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
1153{ 1191{
1154 struct pci_dev *pdev = device->pdev; 1192 struct pci_dev *pdev = device->pdev;
@@ -1169,6 +1207,9 @@ int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
1169 dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; 1207 dma->device_alloc_chan_resources = ioat2_alloc_chan_resources;
1170 dma->device_free_chan_resources = ioat2_free_chan_resources; 1208 dma->device_free_chan_resources = ioat2_free_chan_resources;
1171 1209
1210 if (is_jf_ioat(pdev) || is_snb_ioat(pdev))
1211 dma->copy_align = 6;
1212
1172 dma_cap_set(DMA_INTERRUPT, dma->cap_mask); 1213 dma_cap_set(DMA_INTERRUPT, dma->cap_mask);
1173 dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock; 1214 dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock;
1174 1215
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index da6c4c2c066..79e3eba2970 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -1252,8 +1252,8 @@ iop_adma_pq_zero_sum_self_test(struct iop_adma_device *device)
1252 struct page **pq_hw = &pq[IOP_ADMA_NUM_SRC_TEST+2]; 1252 struct page **pq_hw = &pq[IOP_ADMA_NUM_SRC_TEST+2];
1253 /* address conversion buffers (dma_map / page_address) */ 1253 /* address conversion buffers (dma_map / page_address) */
1254 void *pq_sw[IOP_ADMA_NUM_SRC_TEST+2]; 1254 void *pq_sw[IOP_ADMA_NUM_SRC_TEST+2];
1255 dma_addr_t pq_src[IOP_ADMA_NUM_SRC_TEST]; 1255 dma_addr_t pq_src[IOP_ADMA_NUM_SRC_TEST+2];
1256 dma_addr_t pq_dest[2]; 1256 dma_addr_t *pq_dest = &pq_src[IOP_ADMA_NUM_SRC_TEST];
1257 1257
1258 int i; 1258 int i;
1259 struct dma_async_tx_descriptor *tx; 1259 struct dma_async_tx_descriptor *tx;
diff --git a/drivers/edac/tile_edac.c b/drivers/edac/tile_edac.c
index 1d5cf06f6c6..e99d0097618 100644
--- a/drivers/edac/tile_edac.c
+++ b/drivers/edac/tile_edac.c
@@ -145,7 +145,11 @@ static int __devinit tile_edac_mc_probe(struct platform_device *pdev)
145 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 145 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
146 146
147 mci->mod_name = DRV_NAME; 147 mci->mod_name = DRV_NAME;
148#ifdef __tilegx__
149 mci->ctl_name = "TILEGx_Memory_Controller";
150#else
148 mci->ctl_name = "TILEPro_Memory_Controller"; 151 mci->ctl_name = "TILEPro_Memory_Controller";
152#endif
149 mci->dev_name = dev_name(&pdev->dev); 153 mci->dev_name = dev_name(&pdev->dev);
150 mci->edac_check = tile_edac_check; 154 mci->edac_check = tile_edac_check;
151 155
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 4a3a5f72ed4..de8d2090bce 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -34,14 +34,14 @@
34static int lowlevel_buffer_allocate(struct drm_device *dev, 34static int lowlevel_buffer_allocate(struct drm_device *dev,
35 unsigned int flags, struct exynos_drm_gem_buf *buf) 35 unsigned int flags, struct exynos_drm_gem_buf *buf)
36{ 36{
37 dma_addr_t start_addr, end_addr; 37 dma_addr_t start_addr;
38 unsigned int npages, page_size, i = 0; 38 unsigned int npages, page_size, i = 0;
39 struct scatterlist *sgl; 39 struct scatterlist *sgl;
40 int ret = 0; 40 int ret = 0;
41 41
42 DRM_DEBUG_KMS("%s\n", __FILE__); 42 DRM_DEBUG_KMS("%s\n", __FILE__);
43 43
44 if (flags & EXYNOS_BO_NONCONTIG) { 44 if (IS_NONCONTIG_BUFFER(flags)) {
45 DRM_DEBUG_KMS("not support allocation type.\n"); 45 DRM_DEBUG_KMS("not support allocation type.\n");
46 return -EINVAL; 46 return -EINVAL;
47 } 47 }
@@ -52,13 +52,13 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
52 } 52 }
53 53
54 if (buf->size >= SZ_1M) { 54 if (buf->size >= SZ_1M) {
55 npages = (buf->size >> SECTION_SHIFT) + 1; 55 npages = buf->size >> SECTION_SHIFT;
56 page_size = SECTION_SIZE; 56 page_size = SECTION_SIZE;
57 } else if (buf->size >= SZ_64K) { 57 } else if (buf->size >= SZ_64K) {
58 npages = (buf->size >> 16) + 1; 58 npages = buf->size >> 16;
59 page_size = SZ_64K; 59 page_size = SZ_64K;
60 } else { 60 } else {
61 npages = (buf->size >> PAGE_SHIFT) + 1; 61 npages = buf->size >> PAGE_SHIFT;
62 page_size = PAGE_SIZE; 62 page_size = PAGE_SIZE;
63 } 63 }
64 64
@@ -76,26 +76,13 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
76 return -ENOMEM; 76 return -ENOMEM;
77 } 77 }
78 78
79 buf->kvaddr = dma_alloc_writecombine(dev->dev, buf->size, 79 buf->kvaddr = dma_alloc_writecombine(dev->dev, buf->size,
80 &buf->dma_addr, GFP_KERNEL); 80 &buf->dma_addr, GFP_KERNEL);
81 if (!buf->kvaddr) { 81 if (!buf->kvaddr) {
82 DRM_ERROR("failed to allocate buffer.\n"); 82 DRM_ERROR("failed to allocate buffer.\n");
83 ret = -ENOMEM; 83 ret = -ENOMEM;
84 goto err1; 84 goto err1;
85 } 85 }
86
87 start_addr = buf->dma_addr;
88 end_addr = buf->dma_addr + buf->size;
89
90 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL);
91 if (!buf->pages) {
92 DRM_ERROR("failed to allocate pages.\n");
93 ret = -ENOMEM;
94 goto err2;
95 }
96
97 start_addr = buf->dma_addr;
98 end_addr = buf->dma_addr + buf->size;
99 86
100 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL); 87 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL);
101 if (!buf->pages) { 88 if (!buf->pages) {
@@ -105,23 +92,17 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
105 } 92 }
106 93
107 sgl = buf->sgt->sgl; 94 sgl = buf->sgt->sgl;
95 start_addr = buf->dma_addr;
108 96
109 while (i < npages) { 97 while (i < npages) {
110 buf->pages[i] = phys_to_page(start_addr); 98 buf->pages[i] = phys_to_page(start_addr);
111 sg_set_page(sgl, buf->pages[i], page_size, 0); 99 sg_set_page(sgl, buf->pages[i], page_size, 0);
112 sg_dma_address(sgl) = start_addr; 100 sg_dma_address(sgl) = start_addr;
113 start_addr += page_size; 101 start_addr += page_size;
114 if (end_addr - start_addr < page_size)
115 break;
116 sgl = sg_next(sgl); 102 sgl = sg_next(sgl);
117 i++; 103 i++;
118 } 104 }
119 105
120 buf->pages[i] = phys_to_page(start_addr);
121
122 sgl = sg_next(sgl);
123 sg_set_page(sgl, buf->pages[i+1], end_addr - start_addr, 0);
124
125 DRM_DEBUG_KMS("vaddr(0x%lx), dma_addr(0x%lx), size(0x%lx)\n", 106 DRM_DEBUG_KMS("vaddr(0x%lx), dma_addr(0x%lx), size(0x%lx)\n",
126 (unsigned long)buf->kvaddr, 107 (unsigned long)buf->kvaddr,
127 (unsigned long)buf->dma_addr, 108 (unsigned long)buf->dma_addr,
@@ -150,7 +131,7 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev,
150 * non-continuous memory would be released by exynos 131 * non-continuous memory would be released by exynos
151 * gem framework. 132 * gem framework.
152 */ 133 */
153 if (flags & EXYNOS_BO_NONCONTIG) { 134 if (IS_NONCONTIG_BUFFER(flags)) {
154 DRM_DEBUG_KMS("not support allocation type.\n"); 135 DRM_DEBUG_KMS("not support allocation type.\n");
155 return; 136 return;
156 } 137 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c
index 411832e8e17..eaf630dc5db 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_core.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_core.c
@@ -54,16 +54,18 @@ static int exynos_drm_subdrv_probe(struct drm_device *dev,
54 * 54 *
55 * P.S. note that this driver is considered for modularization. 55 * P.S. note that this driver is considered for modularization.
56 */ 56 */
57 ret = subdrv->probe(dev, subdrv->manager.dev); 57 ret = subdrv->probe(dev, subdrv->dev);
58 if (ret) 58 if (ret)
59 return ret; 59 return ret;
60 } 60 }
61 61
62 if (subdrv->is_local) 62 if (!subdrv->manager)
63 return 0; 63 return 0;
64 64
65 subdrv->manager->dev = subdrv->dev;
66
65 /* create and initialize a encoder for this sub driver. */ 67 /* create and initialize a encoder for this sub driver. */
66 encoder = exynos_drm_encoder_create(dev, &subdrv->manager, 68 encoder = exynos_drm_encoder_create(dev, subdrv->manager,
67 (1 << MAX_CRTC) - 1); 69 (1 << MAX_CRTC) - 1);
68 if (!encoder) { 70 if (!encoder) {
69 DRM_ERROR("failed to create encoder\n"); 71 DRM_ERROR("failed to create encoder\n");
@@ -186,7 +188,7 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
186 188
187 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { 189 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
188 if (subdrv->open) { 190 if (subdrv->open) {
189 ret = subdrv->open(dev, subdrv->manager.dev, file); 191 ret = subdrv->open(dev, subdrv->dev, file);
190 if (ret) 192 if (ret)
191 goto err; 193 goto err;
192 } 194 }
@@ -197,7 +199,7 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
197err: 199err:
198 list_for_each_entry_reverse(subdrv, &subdrv->list, list) { 200 list_for_each_entry_reverse(subdrv, &subdrv->list, list) {
199 if (subdrv->close) 201 if (subdrv->close)
200 subdrv->close(dev, subdrv->manager.dev, file); 202 subdrv->close(dev, subdrv->dev, file);
201 } 203 }
202 return ret; 204 return ret;
203} 205}
@@ -209,7 +211,7 @@ void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file)
209 211
210 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { 212 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
211 if (subdrv->close) 213 if (subdrv->close)
212 subdrv->close(dev, subdrv->manager.dev, file); 214 subdrv->close(dev, subdrv->dev, file);
213 } 215 }
214} 216}
215EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close); 217EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index fbd0a232c93..1d814175cd4 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -225,24 +225,25 @@ struct exynos_drm_private {
225 * Exynos drm sub driver structure. 225 * Exynos drm sub driver structure.
226 * 226 *
227 * @list: sub driver has its own list object to register to exynos drm driver. 227 * @list: sub driver has its own list object to register to exynos drm driver.
228 * @dev: pointer to device object for subdrv device driver.
228 * @drm_dev: pointer to drm_device and this pointer would be set 229 * @drm_dev: pointer to drm_device and this pointer would be set
229 * when sub driver calls exynos_drm_subdrv_register(). 230 * when sub driver calls exynos_drm_subdrv_register().
230 * @is_local: appear encoder and connector disrelated device. 231 * @manager: subdrv has its own manager to control a hardware appropriately
232 * and we can access a hardware drawing on this manager.
231 * @probe: this callback would be called by exynos drm driver after 233 * @probe: this callback would be called by exynos drm driver after
232 * subdrv is registered to it. 234 * subdrv is registered to it.
233 * @remove: this callback is used to release resources created 235 * @remove: this callback is used to release resources created
234 * by probe callback. 236 * by probe callback.
235 * @open: this would be called with drm device file open. 237 * @open: this would be called with drm device file open.
236 * @close: this would be called with drm device file close. 238 * @close: this would be called with drm device file close.
237 * @manager: subdrv has its own manager to control a hardware appropriately
238 * and we can access a hardware drawing on this manager.
239 * @encoder: encoder object owned by this sub driver. 239 * @encoder: encoder object owned by this sub driver.
240 * @connector: connector object owned by this sub driver. 240 * @connector: connector object owned by this sub driver.
241 */ 241 */
242struct exynos_drm_subdrv { 242struct exynos_drm_subdrv {
243 struct list_head list; 243 struct list_head list;
244 struct device *dev;
244 struct drm_device *drm_dev; 245 struct drm_device *drm_dev;
245 bool is_local; 246 struct exynos_drm_manager *manager;
246 247
247 int (*probe)(struct drm_device *drm_dev, struct device *dev); 248 int (*probe)(struct drm_device *drm_dev, struct device *dev);
248 void (*remove)(struct drm_device *dev); 249 void (*remove)(struct drm_device *dev);
@@ -251,7 +252,6 @@ struct exynos_drm_subdrv {
251 void (*close)(struct drm_device *drm_dev, struct device *dev, 252 void (*close)(struct drm_device *drm_dev, struct device *dev,
252 struct drm_file *file); 253 struct drm_file *file);
253 254
254 struct exynos_drm_manager manager;
255 struct drm_encoder *encoder; 255 struct drm_encoder *encoder;
256 struct drm_connector *connector; 256 struct drm_connector *connector;
257}; 257};
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ecb6db22970..29fdbfeb43c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -172,7 +172,7 @@ static void fimd_dpms(struct device *subdrv_dev, int mode)
172static void fimd_apply(struct device *subdrv_dev) 172static void fimd_apply(struct device *subdrv_dev)
173{ 173{
174 struct fimd_context *ctx = get_fimd_context(subdrv_dev); 174 struct fimd_context *ctx = get_fimd_context(subdrv_dev);
175 struct exynos_drm_manager *mgr = &ctx->subdrv.manager; 175 struct exynos_drm_manager *mgr = ctx->subdrv.manager;
176 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 176 struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
177 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops; 177 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
178 struct fimd_win_data *win_data; 178 struct fimd_win_data *win_data;
@@ -577,6 +577,13 @@ static struct exynos_drm_overlay_ops fimd_overlay_ops = {
577 .disable = fimd_win_disable, 577 .disable = fimd_win_disable,
578}; 578};
579 579
580static struct exynos_drm_manager fimd_manager = {
581 .pipe = -1,
582 .ops = &fimd_manager_ops,
583 .overlay_ops = &fimd_overlay_ops,
584 .display_ops = &fimd_display_ops,
585};
586
580static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc) 587static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc)
581{ 588{
582 struct exynos_drm_private *dev_priv = drm_dev->dev_private; 589 struct exynos_drm_private *dev_priv = drm_dev->dev_private;
@@ -628,7 +635,7 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
628 struct fimd_context *ctx = (struct fimd_context *)dev_id; 635 struct fimd_context *ctx = (struct fimd_context *)dev_id;
629 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 636 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
630 struct drm_device *drm_dev = subdrv->drm_dev; 637 struct drm_device *drm_dev = subdrv->drm_dev;
631 struct exynos_drm_manager *manager = &subdrv->manager; 638 struct exynos_drm_manager *manager = subdrv->manager;
632 u32 val; 639 u32 val;
633 640
634 val = readl(ctx->regs + VIDINTCON1); 641 val = readl(ctx->regs + VIDINTCON1);
@@ -744,7 +751,7 @@ static void fimd_clear_win(struct fimd_context *ctx, int win)
744static int fimd_power_on(struct fimd_context *ctx, bool enable) 751static int fimd_power_on(struct fimd_context *ctx, bool enable)
745{ 752{
746 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 753 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
747 struct device *dev = subdrv->manager.dev; 754 struct device *dev = subdrv->dev;
748 755
749 DRM_DEBUG_KMS("%s\n", __FILE__); 756 DRM_DEBUG_KMS("%s\n", __FILE__);
750 757
@@ -867,13 +874,10 @@ static int __devinit fimd_probe(struct platform_device *pdev)
867 874
868 subdrv = &ctx->subdrv; 875 subdrv = &ctx->subdrv;
869 876
877 subdrv->dev = dev;
878 subdrv->manager = &fimd_manager;
870 subdrv->probe = fimd_subdrv_probe; 879 subdrv->probe = fimd_subdrv_probe;
871 subdrv->remove = fimd_subdrv_remove; 880 subdrv->remove = fimd_subdrv_remove;
872 subdrv->manager.pipe = -1;
873 subdrv->manager.ops = &fimd_manager_ops;
874 subdrv->manager.overlay_ops = &fimd_overlay_ops;
875 subdrv->manager.display_ops = &fimd_display_ops;
876 subdrv->manager.dev = dev;
877 881
878 mutex_init(&ctx->lock); 882 mutex_init(&ctx->lock);
879 883
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index fa1aa94a3d8..26d51979116 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -56,9 +56,28 @@ static unsigned int convert_to_vm_err_msg(int msg)
56 return out_msg; 56 return out_msg;
57} 57}
58 58
59static unsigned int mask_gem_flags(unsigned int flags) 59static int check_gem_flags(unsigned int flags)
60{ 60{
61 return flags &= EXYNOS_BO_NONCONTIG; 61 if (flags & ~(EXYNOS_BO_MASK)) {
62 DRM_ERROR("invalid flags.\n");
63 return -EINVAL;
64 }
65
66 return 0;
67}
68
69static unsigned long roundup_gem_size(unsigned long size, unsigned int flags)
70{
71 if (!IS_NONCONTIG_BUFFER(flags)) {
72 if (size >= SZ_1M)
73 return roundup(size, SECTION_SIZE);
74 else if (size >= SZ_64K)
75 return roundup(size, SZ_64K);
76 else
77 goto out;
78 }
79out:
80 return roundup(size, PAGE_SIZE);
62} 81}
63 82
64static struct page **exynos_gem_get_pages(struct drm_gem_object *obj, 83static struct page **exynos_gem_get_pages(struct drm_gem_object *obj,
@@ -319,10 +338,17 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
319 struct exynos_drm_gem_buf *buf; 338 struct exynos_drm_gem_buf *buf;
320 int ret; 339 int ret;
321 340
322 size = roundup(size, PAGE_SIZE); 341 if (!size) {
323 DRM_DEBUG_KMS("%s: size = 0x%lx\n", __FILE__, size); 342 DRM_ERROR("invalid size.\n");
343 return ERR_PTR(-EINVAL);
344 }
324 345
325 flags = mask_gem_flags(flags); 346 size = roundup_gem_size(size, flags);
347 DRM_DEBUG_KMS("%s\n", __FILE__);
348
349 ret = check_gem_flags(flags);
350 if (ret)
351 return ERR_PTR(ret);
326 352
327 buf = exynos_drm_init_buf(dev, size); 353 buf = exynos_drm_init_buf(dev, size);
328 if (!buf) 354 if (!buf)
@@ -331,7 +357,7 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
331 exynos_gem_obj = exynos_drm_gem_init(dev, size); 357 exynos_gem_obj = exynos_drm_gem_init(dev, size);
332 if (!exynos_gem_obj) { 358 if (!exynos_gem_obj) {
333 ret = -ENOMEM; 359 ret = -ENOMEM;
334 goto err; 360 goto err_fini_buf;
335 } 361 }
336 362
337 exynos_gem_obj->buffer = buf; 363 exynos_gem_obj->buffer = buf;
@@ -347,18 +373,19 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
347 ret = exynos_drm_gem_get_pages(&exynos_gem_obj->base); 373 ret = exynos_drm_gem_get_pages(&exynos_gem_obj->base);
348 if (ret < 0) { 374 if (ret < 0) {
349 drm_gem_object_release(&exynos_gem_obj->base); 375 drm_gem_object_release(&exynos_gem_obj->base);
350 goto err; 376 goto err_fini_buf;
351 } 377 }
352 } else { 378 } else {
353 ret = exynos_drm_alloc_buf(dev, buf, flags); 379 ret = exynos_drm_alloc_buf(dev, buf, flags);
354 if (ret < 0) { 380 if (ret < 0) {
355 drm_gem_object_release(&exynos_gem_obj->base); 381 drm_gem_object_release(&exynos_gem_obj->base);
356 goto err; 382 goto err_fini_buf;
357 } 383 }
358 } 384 }
359 385
360 return exynos_gem_obj; 386 return exynos_gem_obj;
361err: 387
388err_fini_buf:
362 exynos_drm_fini_buf(dev, buf); 389 exynos_drm_fini_buf(dev, buf);
363 return ERR_PTR(ret); 390 return ERR_PTR(ret);
364} 391}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index e40fbad8b70..4ed84203950 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -29,6 +29,8 @@
29#define to_exynos_gem_obj(x) container_of(x,\ 29#define to_exynos_gem_obj(x) container_of(x,\
30 struct exynos_drm_gem_obj, base) 30 struct exynos_drm_gem_obj, base)
31 31
32#define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG)
33
32/* 34/*
33 * exynos drm gem buffer structure. 35 * exynos drm gem buffer structure.
34 * 36 *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
index 14eb26b0ba1..3424463676e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
@@ -30,9 +30,8 @@
30 struct drm_hdmi_context, subdrv); 30 struct drm_hdmi_context, subdrv);
31 31
32/* these callback points shoud be set by specific drivers. */ 32/* these callback points shoud be set by specific drivers. */
33static struct exynos_hdmi_display_ops *hdmi_display_ops; 33static struct exynos_hdmi_ops *hdmi_ops;
34static struct exynos_hdmi_manager_ops *hdmi_manager_ops; 34static struct exynos_mixer_ops *mixer_ops;
35static struct exynos_hdmi_overlay_ops *hdmi_overlay_ops;
36 35
37struct drm_hdmi_context { 36struct drm_hdmi_context {
38 struct exynos_drm_subdrv subdrv; 37 struct exynos_drm_subdrv subdrv;
@@ -40,31 +39,20 @@ struct drm_hdmi_context {
40 struct exynos_drm_hdmi_context *mixer_ctx; 39 struct exynos_drm_hdmi_context *mixer_ctx;
41}; 40};
42 41
43void exynos_drm_display_ops_register(struct exynos_hdmi_display_ops 42void exynos_hdmi_ops_register(struct exynos_hdmi_ops *ops)
44 *display_ops)
45{ 43{
46 DRM_DEBUG_KMS("%s\n", __FILE__); 44 DRM_DEBUG_KMS("%s\n", __FILE__);
47 45
48 if (display_ops) 46 if (ops)
49 hdmi_display_ops = display_ops; 47 hdmi_ops = ops;
50} 48}
51 49
52void exynos_drm_manager_ops_register(struct exynos_hdmi_manager_ops 50void exynos_mixer_ops_register(struct exynos_mixer_ops *ops)
53 *manager_ops)
54{ 51{
55 DRM_DEBUG_KMS("%s\n", __FILE__); 52 DRM_DEBUG_KMS("%s\n", __FILE__);
56 53
57 if (manager_ops) 54 if (ops)
58 hdmi_manager_ops = manager_ops; 55 mixer_ops = ops;
59}
60
61void exynos_drm_overlay_ops_register(struct exynos_hdmi_overlay_ops
62 *overlay_ops)
63{
64 DRM_DEBUG_KMS("%s\n", __FILE__);
65
66 if (overlay_ops)
67 hdmi_overlay_ops = overlay_ops;
68} 56}
69 57
70static bool drm_hdmi_is_connected(struct device *dev) 58static bool drm_hdmi_is_connected(struct device *dev)
@@ -73,8 +61,8 @@ static bool drm_hdmi_is_connected(struct device *dev)
73 61
74 DRM_DEBUG_KMS("%s\n", __FILE__); 62 DRM_DEBUG_KMS("%s\n", __FILE__);
75 63
76 if (hdmi_display_ops && hdmi_display_ops->is_connected) 64 if (hdmi_ops && hdmi_ops->is_connected)
77 return hdmi_display_ops->is_connected(ctx->hdmi_ctx->ctx); 65 return hdmi_ops->is_connected(ctx->hdmi_ctx->ctx);
78 66
79 return false; 67 return false;
80} 68}
@@ -86,9 +74,9 @@ static int drm_hdmi_get_edid(struct device *dev,
86 74
87 DRM_DEBUG_KMS("%s\n", __FILE__); 75 DRM_DEBUG_KMS("%s\n", __FILE__);
88 76
89 if (hdmi_display_ops && hdmi_display_ops->get_edid) 77 if (hdmi_ops && hdmi_ops->get_edid)
90 return hdmi_display_ops->get_edid(ctx->hdmi_ctx->ctx, 78 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector, edid,
91 connector, edid, len); 79 len);
92 80
93 return 0; 81 return 0;
94} 82}
@@ -99,9 +87,8 @@ static int drm_hdmi_check_timing(struct device *dev, void *timing)
99 87
100 DRM_DEBUG_KMS("%s\n", __FILE__); 88 DRM_DEBUG_KMS("%s\n", __FILE__);
101 89
102 if (hdmi_display_ops && hdmi_display_ops->check_timing) 90 if (hdmi_ops && hdmi_ops->check_timing)
103 return hdmi_display_ops->check_timing(ctx->hdmi_ctx->ctx, 91 return hdmi_ops->check_timing(ctx->hdmi_ctx->ctx, timing);
104 timing);
105 92
106 return 0; 93 return 0;
107} 94}
@@ -112,8 +99,8 @@ static int drm_hdmi_power_on(struct device *dev, int mode)
112 99
113 DRM_DEBUG_KMS("%s\n", __FILE__); 100 DRM_DEBUG_KMS("%s\n", __FILE__);
114 101
115 if (hdmi_display_ops && hdmi_display_ops->power_on) 102 if (hdmi_ops && hdmi_ops->power_on)
116 return hdmi_display_ops->power_on(ctx->hdmi_ctx->ctx, mode); 103 return hdmi_ops->power_on(ctx->hdmi_ctx->ctx, mode);
117 104
118 return 0; 105 return 0;
119} 106}
@@ -130,13 +117,13 @@ static int drm_hdmi_enable_vblank(struct device *subdrv_dev)
130{ 117{
131 struct drm_hdmi_context *ctx = to_context(subdrv_dev); 118 struct drm_hdmi_context *ctx = to_context(subdrv_dev);
132 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 119 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
133 struct exynos_drm_manager *manager = &subdrv->manager; 120 struct exynos_drm_manager *manager = subdrv->manager;
134 121
135 DRM_DEBUG_KMS("%s\n", __FILE__); 122 DRM_DEBUG_KMS("%s\n", __FILE__);
136 123
137 if (hdmi_overlay_ops && hdmi_overlay_ops->enable_vblank) 124 if (mixer_ops && mixer_ops->enable_vblank)
138 return hdmi_overlay_ops->enable_vblank(ctx->mixer_ctx->ctx, 125 return mixer_ops->enable_vblank(ctx->mixer_ctx->ctx,
139 manager->pipe); 126 manager->pipe);
140 127
141 return 0; 128 return 0;
142} 129}
@@ -147,8 +134,8 @@ static void drm_hdmi_disable_vblank(struct device *subdrv_dev)
147 134
148 DRM_DEBUG_KMS("%s\n", __FILE__); 135 DRM_DEBUG_KMS("%s\n", __FILE__);
149 136
150 if (hdmi_overlay_ops && hdmi_overlay_ops->disable_vblank) 137 if (mixer_ops && mixer_ops->disable_vblank)
151 return hdmi_overlay_ops->disable_vblank(ctx->mixer_ctx->ctx); 138 return mixer_ops->disable_vblank(ctx->mixer_ctx->ctx);
152} 139}
153 140
154static void drm_hdmi_mode_fixup(struct device *subdrv_dev, 141static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
@@ -160,9 +147,9 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
160 147
161 DRM_DEBUG_KMS("%s\n", __FILE__); 148 DRM_DEBUG_KMS("%s\n", __FILE__);
162 149
163 if (hdmi_manager_ops && hdmi_manager_ops->mode_fixup) 150 if (hdmi_ops && hdmi_ops->mode_fixup)
164 hdmi_manager_ops->mode_fixup(ctx->hdmi_ctx->ctx, connector, 151 hdmi_ops->mode_fixup(ctx->hdmi_ctx->ctx, connector, mode,
165 mode, adjusted_mode); 152 adjusted_mode);
166} 153}
167 154
168static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode) 155static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode)
@@ -171,8 +158,8 @@ static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode)
171 158
172 DRM_DEBUG_KMS("%s\n", __FILE__); 159 DRM_DEBUG_KMS("%s\n", __FILE__);
173 160
174 if (hdmi_manager_ops && hdmi_manager_ops->mode_set) 161 if (hdmi_ops && hdmi_ops->mode_set)
175 hdmi_manager_ops->mode_set(ctx->hdmi_ctx->ctx, mode); 162 hdmi_ops->mode_set(ctx->hdmi_ctx->ctx, mode);
176} 163}
177 164
178static void drm_hdmi_get_max_resol(struct device *subdrv_dev, 165static void drm_hdmi_get_max_resol(struct device *subdrv_dev,
@@ -182,9 +169,8 @@ static void drm_hdmi_get_max_resol(struct device *subdrv_dev,
182 169
183 DRM_DEBUG_KMS("%s\n", __FILE__); 170 DRM_DEBUG_KMS("%s\n", __FILE__);
184 171
185 if (hdmi_manager_ops && hdmi_manager_ops->get_max_resol) 172 if (hdmi_ops && hdmi_ops->get_max_resol)
186 hdmi_manager_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, 173 hdmi_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, height);
187 height);
188} 174}
189 175
190static void drm_hdmi_commit(struct device *subdrv_dev) 176static void drm_hdmi_commit(struct device *subdrv_dev)
@@ -193,8 +179,8 @@ static void drm_hdmi_commit(struct device *subdrv_dev)
193 179
194 DRM_DEBUG_KMS("%s\n", __FILE__); 180 DRM_DEBUG_KMS("%s\n", __FILE__);
195 181
196 if (hdmi_manager_ops && hdmi_manager_ops->commit) 182 if (hdmi_ops && hdmi_ops->commit)
197 hdmi_manager_ops->commit(ctx->hdmi_ctx->ctx); 183 hdmi_ops->commit(ctx->hdmi_ctx->ctx);
198} 184}
199 185
200static void drm_hdmi_dpms(struct device *subdrv_dev, int mode) 186static void drm_hdmi_dpms(struct device *subdrv_dev, int mode)
@@ -209,8 +195,8 @@ static void drm_hdmi_dpms(struct device *subdrv_dev, int mode)
209 case DRM_MODE_DPMS_STANDBY: 195 case DRM_MODE_DPMS_STANDBY:
210 case DRM_MODE_DPMS_SUSPEND: 196 case DRM_MODE_DPMS_SUSPEND:
211 case DRM_MODE_DPMS_OFF: 197 case DRM_MODE_DPMS_OFF:
212 if (hdmi_manager_ops && hdmi_manager_ops->disable) 198 if (hdmi_ops && hdmi_ops->disable)
213 hdmi_manager_ops->disable(ctx->hdmi_ctx->ctx); 199 hdmi_ops->disable(ctx->hdmi_ctx->ctx);
214 break; 200 break;
215 default: 201 default:
216 DRM_DEBUG_KMS("unkown dps mode: %d\n", mode); 202 DRM_DEBUG_KMS("unkown dps mode: %d\n", mode);
@@ -235,8 +221,8 @@ static void drm_mixer_mode_set(struct device *subdrv_dev,
235 221
236 DRM_DEBUG_KMS("%s\n", __FILE__); 222 DRM_DEBUG_KMS("%s\n", __FILE__);
237 223
238 if (hdmi_overlay_ops && hdmi_overlay_ops->win_mode_set) 224 if (mixer_ops && mixer_ops->win_mode_set)
239 hdmi_overlay_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay); 225 mixer_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay);
240} 226}
241 227
242static void drm_mixer_commit(struct device *subdrv_dev, int zpos) 228static void drm_mixer_commit(struct device *subdrv_dev, int zpos)
@@ -245,8 +231,8 @@ static void drm_mixer_commit(struct device *subdrv_dev, int zpos)
245 231
246 DRM_DEBUG_KMS("%s\n", __FILE__); 232 DRM_DEBUG_KMS("%s\n", __FILE__);
247 233
248 if (hdmi_overlay_ops && hdmi_overlay_ops->win_commit) 234 if (mixer_ops && mixer_ops->win_commit)
249 hdmi_overlay_ops->win_commit(ctx->mixer_ctx->ctx, zpos); 235 mixer_ops->win_commit(ctx->mixer_ctx->ctx, zpos);
250} 236}
251 237
252static void drm_mixer_disable(struct device *subdrv_dev, int zpos) 238static void drm_mixer_disable(struct device *subdrv_dev, int zpos)
@@ -255,8 +241,8 @@ static void drm_mixer_disable(struct device *subdrv_dev, int zpos)
255 241
256 DRM_DEBUG_KMS("%s\n", __FILE__); 242 DRM_DEBUG_KMS("%s\n", __FILE__);
257 243
258 if (hdmi_overlay_ops && hdmi_overlay_ops->win_disable) 244 if (mixer_ops && mixer_ops->win_disable)
259 hdmi_overlay_ops->win_disable(ctx->mixer_ctx->ctx, zpos); 245 mixer_ops->win_disable(ctx->mixer_ctx->ctx, zpos);
260} 246}
261 247
262static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = { 248static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = {
@@ -265,6 +251,12 @@ static struct exynos_drm_overlay_ops drm_hdmi_overlay_ops = {
265 .disable = drm_mixer_disable, 251 .disable = drm_mixer_disable,
266}; 252};
267 253
254static struct exynos_drm_manager hdmi_manager = {
255 .pipe = -1,
256 .ops = &drm_hdmi_manager_ops,
257 .overlay_ops = &drm_hdmi_overlay_ops,
258 .display_ops = &drm_hdmi_display_ops,
259};
268 260
269static int hdmi_subdrv_probe(struct drm_device *drm_dev, 261static int hdmi_subdrv_probe(struct drm_device *drm_dev,
270 struct device *dev) 262 struct device *dev)
@@ -332,12 +324,9 @@ static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev)
332 324
333 subdrv = &ctx->subdrv; 325 subdrv = &ctx->subdrv;
334 326
327 subdrv->dev = dev;
328 subdrv->manager = &hdmi_manager;
335 subdrv->probe = hdmi_subdrv_probe; 329 subdrv->probe = hdmi_subdrv_probe;
336 subdrv->manager.pipe = -1;
337 subdrv->manager.ops = &drm_hdmi_manager_ops;
338 subdrv->manager.overlay_ops = &drm_hdmi_overlay_ops;
339 subdrv->manager.display_ops = &drm_hdmi_display_ops;
340 subdrv->manager.dev = dev;
341 330
342 platform_set_drvdata(pdev, subdrv); 331 platform_set_drvdata(pdev, subdrv);
343 332
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
index 44497cfb6c7..f3ae192c8dc 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
@@ -38,15 +38,15 @@ struct exynos_drm_hdmi_context {
38 void *ctx; 38 void *ctx;
39}; 39};
40 40
41struct exynos_hdmi_display_ops { 41struct exynos_hdmi_ops {
42 /* display */
42 bool (*is_connected)(void *ctx); 43 bool (*is_connected)(void *ctx);
43 int (*get_edid)(void *ctx, struct drm_connector *connector, 44 int (*get_edid)(void *ctx, struct drm_connector *connector,
44 u8 *edid, int len); 45 u8 *edid, int len);
45 int (*check_timing)(void *ctx, void *timing); 46 int (*check_timing)(void *ctx, void *timing);
46 int (*power_on)(void *ctx, int mode); 47 int (*power_on)(void *ctx, int mode);
47};
48 48
49struct exynos_hdmi_manager_ops { 49 /* manager */
50 void (*mode_fixup)(void *ctx, struct drm_connector *connector, 50 void (*mode_fixup)(void *ctx, struct drm_connector *connector,
51 struct drm_display_mode *mode, 51 struct drm_display_mode *mode,
52 struct drm_display_mode *adjusted_mode); 52 struct drm_display_mode *adjusted_mode);
@@ -57,22 +57,17 @@ struct exynos_hdmi_manager_ops {
57 void (*disable)(void *ctx); 57 void (*disable)(void *ctx);
58}; 58};
59 59
60struct exynos_hdmi_overlay_ops { 60struct exynos_mixer_ops {
61 /* manager */
61 int (*enable_vblank)(void *ctx, int pipe); 62 int (*enable_vblank)(void *ctx, int pipe);
62 void (*disable_vblank)(void *ctx); 63 void (*disable_vblank)(void *ctx);
64
65 /* overlay */
63 void (*win_mode_set)(void *ctx, struct exynos_drm_overlay *overlay); 66 void (*win_mode_set)(void *ctx, struct exynos_drm_overlay *overlay);
64 void (*win_commit)(void *ctx, int zpos); 67 void (*win_commit)(void *ctx, int zpos);
65 void (*win_disable)(void *ctx, int zpos); 68 void (*win_disable)(void *ctx, int zpos);
66}; 69};
67 70
68extern struct platform_driver hdmi_driver; 71void exynos_hdmi_ops_register(struct exynos_hdmi_ops *ops);
69extern struct platform_driver mixer_driver; 72void exynos_mixer_ops_register(struct exynos_mixer_ops *ops);
70
71void exynos_drm_display_ops_register(struct exynos_hdmi_display_ops
72 *display_ops);
73void exynos_drm_manager_ops_register(struct exynos_hdmi_manager_ops
74 *manager_ops);
75void exynos_drm_overlay_ops_register(struct exynos_hdmi_overlay_ops
76 *overlay_ops);
77
78#endif 73#endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index c277a3a445f..f92fe4c6174 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -24,6 +24,10 @@ struct exynos_plane {
24 24
25static const uint32_t formats[] = { 25static const uint32_t formats[] = {
26 DRM_FORMAT_XRGB8888, 26 DRM_FORMAT_XRGB8888,
27 DRM_FORMAT_ARGB8888,
28 DRM_FORMAT_NV12,
29 DRM_FORMAT_NV12M,
30 DRM_FORMAT_NV12MT,
27}; 31};
28 32
29static int 33static int
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 8e1339f9fe1..7b9c153dceb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -199,7 +199,7 @@ static void vidi_dpms(struct device *subdrv_dev, int mode)
199static void vidi_apply(struct device *subdrv_dev) 199static void vidi_apply(struct device *subdrv_dev)
200{ 200{
201 struct vidi_context *ctx = get_vidi_context(subdrv_dev); 201 struct vidi_context *ctx = get_vidi_context(subdrv_dev);
202 struct exynos_drm_manager *mgr = &ctx->subdrv.manager; 202 struct exynos_drm_manager *mgr = ctx->subdrv.manager;
203 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 203 struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
204 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops; 204 struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
205 struct vidi_win_data *win_data; 205 struct vidi_win_data *win_data;
@@ -374,6 +374,13 @@ static struct exynos_drm_overlay_ops vidi_overlay_ops = {
374 .disable = vidi_win_disable, 374 .disable = vidi_win_disable,
375}; 375};
376 376
377static struct exynos_drm_manager vidi_manager = {
378 .pipe = -1,
379 .ops = &vidi_manager_ops,
380 .overlay_ops = &vidi_overlay_ops,
381 .display_ops = &vidi_display_ops,
382};
383
377static void vidi_finish_pageflip(struct drm_device *drm_dev, int crtc) 384static void vidi_finish_pageflip(struct drm_device *drm_dev, int crtc)
378{ 385{
379 struct exynos_drm_private *dev_priv = drm_dev->dev_private; 386 struct exynos_drm_private *dev_priv = drm_dev->dev_private;
@@ -425,7 +432,7 @@ static void vidi_fake_vblank_handler(struct work_struct *work)
425 struct vidi_context *ctx = container_of(work, struct vidi_context, 432 struct vidi_context *ctx = container_of(work, struct vidi_context,
426 work); 433 work);
427 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 434 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
428 struct exynos_drm_manager *manager = &subdrv->manager; 435 struct exynos_drm_manager *manager = subdrv->manager;
429 436
430 if (manager->pipe < 0) 437 if (manager->pipe < 0)
431 return; 438 return;
@@ -471,7 +478,7 @@ static void vidi_subdrv_remove(struct drm_device *drm_dev)
471static int vidi_power_on(struct vidi_context *ctx, bool enable) 478static int vidi_power_on(struct vidi_context *ctx, bool enable)
472{ 479{
473 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 480 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
474 struct device *dev = subdrv->manager.dev; 481 struct device *dev = subdrv->dev;
475 482
476 DRM_DEBUG_KMS("%s\n", __FILE__); 483 DRM_DEBUG_KMS("%s\n", __FILE__);
477 484
@@ -611,13 +618,10 @@ static int __devinit vidi_probe(struct platform_device *pdev)
611 ctx->raw_edid = (struct edid *)fake_edid_info; 618 ctx->raw_edid = (struct edid *)fake_edid_info;
612 619
613 subdrv = &ctx->subdrv; 620 subdrv = &ctx->subdrv;
621 subdrv->dev = dev;
622 subdrv->manager = &vidi_manager;
614 subdrv->probe = vidi_subdrv_probe; 623 subdrv->probe = vidi_subdrv_probe;
615 subdrv->remove = vidi_subdrv_remove; 624 subdrv->remove = vidi_subdrv_remove;
616 subdrv->manager.pipe = -1;
617 subdrv->manager.ops = &vidi_manager_ops;
618 subdrv->manager.overlay_ops = &vidi_overlay_ops;
619 subdrv->manager.display_ops = &vidi_display_ops;
620 subdrv->manager.dev = dev;
621 625
622 mutex_init(&ctx->lock); 626 mutex_init(&ctx->lock);
623 627
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 575a8cbd353..b0035387645 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -40,7 +40,6 @@
40 40
41#include "exynos_hdmi.h" 41#include "exynos_hdmi.h"
42 42
43#define HDMI_OVERLAY_NUMBER 3
44#define MAX_WIDTH 1920 43#define MAX_WIDTH 1920
45#define MAX_HEIGHT 1080 44#define MAX_HEIGHT 1080
46#define get_hdmi_context(dev) platform_get_drvdata(to_platform_device(dev)) 45#define get_hdmi_context(dev) platform_get_drvdata(to_platform_device(dev))
@@ -1194,7 +1193,7 @@ static int hdmi_conf_index(struct hdmi_context *hdata,
1194 1193
1195static bool hdmi_is_connected(void *ctx) 1194static bool hdmi_is_connected(void *ctx)
1196{ 1195{
1197 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1196 struct hdmi_context *hdata = ctx;
1198 u32 val = hdmi_reg_read(hdata, HDMI_HPD_STATUS); 1197 u32 val = hdmi_reg_read(hdata, HDMI_HPD_STATUS);
1199 1198
1200 if (val) 1199 if (val)
@@ -1207,7 +1206,7 @@ static int hdmi_get_edid(void *ctx, struct drm_connector *connector,
1207 u8 *edid, int len) 1206 u8 *edid, int len)
1208{ 1207{
1209 struct edid *raw_edid; 1208 struct edid *raw_edid;
1210 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1209 struct hdmi_context *hdata = ctx;
1211 1210
1212 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1211 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1213 1212
@@ -1275,7 +1274,7 @@ static int hdmi_v14_check_timing(struct fb_videomode *check_timing)
1275 1274
1276static int hdmi_check_timing(void *ctx, void *timing) 1275static int hdmi_check_timing(void *ctx, void *timing)
1277{ 1276{
1278 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1277 struct hdmi_context *hdata = ctx;
1279 struct fb_videomode *check_timing = timing; 1278 struct fb_videomode *check_timing = timing;
1280 1279
1281 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1280 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1312,13 +1311,6 @@ static int hdmi_display_power_on(void *ctx, int mode)
1312 return 0; 1311 return 0;
1313} 1312}
1314 1313
1315static struct exynos_hdmi_display_ops display_ops = {
1316 .is_connected = hdmi_is_connected,
1317 .get_edid = hdmi_get_edid,
1318 .check_timing = hdmi_check_timing,
1319 .power_on = hdmi_display_power_on,
1320};
1321
1322static void hdmi_set_acr(u32 freq, u8 *acr) 1314static void hdmi_set_acr(u32 freq, u8 *acr)
1323{ 1315{
1324 u32 n, cts; 1316 u32 n, cts;
@@ -1914,7 +1906,7 @@ static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector,
1914 struct drm_display_mode *adjusted_mode) 1906 struct drm_display_mode *adjusted_mode)
1915{ 1907{
1916 struct drm_display_mode *m; 1908 struct drm_display_mode *m;
1917 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1909 struct hdmi_context *hdata = ctx;
1918 int index; 1910 int index;
1919 1911
1920 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1912 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1951,7 +1943,7 @@ static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector,
1951 1943
1952static void hdmi_mode_set(void *ctx, void *mode) 1944static void hdmi_mode_set(void *ctx, void *mode)
1953{ 1945{
1954 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1946 struct hdmi_context *hdata = ctx;
1955 int conf_idx; 1947 int conf_idx;
1956 1948
1957 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1949 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
@@ -1974,7 +1966,7 @@ static void hdmi_get_max_resol(void *ctx, unsigned int *width,
1974 1966
1975static void hdmi_commit(void *ctx) 1967static void hdmi_commit(void *ctx)
1976{ 1968{
1977 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1969 struct hdmi_context *hdata = ctx;
1978 1970
1979 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1971 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1980 1972
@@ -1985,7 +1977,7 @@ static void hdmi_commit(void *ctx)
1985 1977
1986static void hdmi_disable(void *ctx) 1978static void hdmi_disable(void *ctx)
1987{ 1979{
1988 struct hdmi_context *hdata = (struct hdmi_context *)ctx; 1980 struct hdmi_context *hdata = ctx;
1989 1981
1990 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1982 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1991 1983
@@ -1996,7 +1988,14 @@ static void hdmi_disable(void *ctx)
1996 } 1988 }
1997} 1989}
1998 1990
1999static struct exynos_hdmi_manager_ops manager_ops = { 1991static struct exynos_hdmi_ops hdmi_ops = {
1992 /* display */
1993 .is_connected = hdmi_is_connected,
1994 .get_edid = hdmi_get_edid,
1995 .check_timing = hdmi_check_timing,
1996 .power_on = hdmi_display_power_on,
1997
1998 /* manager */
2000 .mode_fixup = hdmi_mode_fixup, 1999 .mode_fixup = hdmi_mode_fixup,
2001 .mode_set = hdmi_mode_set, 2000 .mode_set = hdmi_mode_set,
2002 .get_max_resol = hdmi_get_max_resol, 2001 .get_max_resol = hdmi_get_max_resol,
@@ -2020,7 +2019,7 @@ static void hdmi_hotplug_func(struct work_struct *work)
2020static irqreturn_t hdmi_irq_handler(int irq, void *arg) 2019static irqreturn_t hdmi_irq_handler(int irq, void *arg)
2021{ 2020{
2022 struct exynos_drm_hdmi_context *ctx = arg; 2021 struct exynos_drm_hdmi_context *ctx = arg;
2023 struct hdmi_context *hdata = (struct hdmi_context *)ctx->ctx; 2022 struct hdmi_context *hdata = ctx->ctx;
2024 u32 intc_flag; 2023 u32 intc_flag;
2025 2024
2026 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG); 2025 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
@@ -2173,7 +2172,7 @@ static int hdmi_runtime_suspend(struct device *dev)
2173 2172
2174 DRM_DEBUG_KMS("%s\n", __func__); 2173 DRM_DEBUG_KMS("%s\n", __func__);
2175 2174
2176 hdmi_resource_poweroff((struct hdmi_context *)ctx->ctx); 2175 hdmi_resource_poweroff(ctx->ctx);
2177 2176
2178 return 0; 2177 return 0;
2179} 2178}
@@ -2184,7 +2183,7 @@ static int hdmi_runtime_resume(struct device *dev)
2184 2183
2185 DRM_DEBUG_KMS("%s\n", __func__); 2184 DRM_DEBUG_KMS("%s\n", __func__);
2186 2185
2187 hdmi_resource_poweron((struct hdmi_context *)ctx->ctx); 2186 hdmi_resource_poweron(ctx->ctx);
2188 2187
2189 return 0; 2188 return 0;
2190} 2189}
@@ -2322,8 +2321,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2322 hdata->irq = res->start; 2321 hdata->irq = res->start;
2323 2322
2324 /* register specific callbacks to common hdmi. */ 2323 /* register specific callbacks to common hdmi. */
2325 exynos_drm_display_ops_register(&display_ops); 2324 exynos_hdmi_ops_register(&hdmi_ops);
2326 exynos_drm_manager_ops_register(&manager_ops);
2327 2325
2328 hdmi_resource_poweron(hdata); 2326 hdmi_resource_poweron(hdata);
2329 2327
@@ -2351,7 +2349,7 @@ err_data:
2351static int __devexit hdmi_remove(struct platform_device *pdev) 2349static int __devexit hdmi_remove(struct platform_device *pdev)
2352{ 2350{
2353 struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev); 2351 struct exynos_drm_hdmi_context *ctx = platform_get_drvdata(pdev);
2354 struct hdmi_context *hdata = (struct hdmi_context *)ctx->ctx; 2352 struct hdmi_context *hdata = ctx->ctx;
2355 2353
2356 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2354 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2357 2355
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 4d5f41e1952..e15438c0112 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -37,7 +37,8 @@
37#include "exynos_drm_drv.h" 37#include "exynos_drm_drv.h"
38#include "exynos_drm_hdmi.h" 38#include "exynos_drm_hdmi.h"
39 39
40#define HDMI_OVERLAY_NUMBER 3 40#define MIXER_WIN_NR 3
41#define MIXER_DEFAULT_WIN 0
41 42
42#define get_mixer_context(dev) platform_get_drvdata(to_platform_device(dev)) 43#define get_mixer_context(dev) platform_get_drvdata(to_platform_device(dev))
43 44
@@ -75,16 +76,12 @@ struct mixer_resources {
75}; 76};
76 77
77struct mixer_context { 78struct mixer_context {
78 struct fb_videomode *default_timing;
79 unsigned int default_win;
80 unsigned int default_bpp;
81 unsigned int irq; 79 unsigned int irq;
82 int pipe; 80 int pipe;
83 bool interlace; 81 bool interlace;
84 bool vp_enabled;
85 82
86 struct mixer_resources mixer_res; 83 struct mixer_resources mixer_res;
87 struct hdmi_win_data win_data[HDMI_OVERLAY_NUMBER]; 84 struct hdmi_win_data win_data[MIXER_WIN_NR];
88}; 85};
89 86
90static const u8 filter_y_horiz_tap8[] = { 87static const u8 filter_y_horiz_tap8[] = {
@@ -643,9 +640,9 @@ static void mixer_win_mode_set(void *ctx,
643 640
644 win = overlay->zpos; 641 win = overlay->zpos;
645 if (win == DEFAULT_ZPOS) 642 if (win == DEFAULT_ZPOS)
646 win = mixer_ctx->default_win; 643 win = MIXER_DEFAULT_WIN;
647 644
648 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 645 if (win < 0 || win > MIXER_WIN_NR) {
649 DRM_ERROR("overlay plane[%d] is wrong\n", win); 646 DRM_ERROR("overlay plane[%d] is wrong\n", win);
650 return; 647 return;
651 } 648 }
@@ -683,9 +680,9 @@ static void mixer_win_commit(void *ctx, int zpos)
683 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 680 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
684 681
685 if (win == DEFAULT_ZPOS) 682 if (win == DEFAULT_ZPOS)
686 win = mixer_ctx->default_win; 683 win = MIXER_DEFAULT_WIN;
687 684
688 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 685 if (win < 0 || win > MIXER_WIN_NR) {
689 DRM_ERROR("overlay plane[%d] is wrong\n", win); 686 DRM_ERROR("overlay plane[%d] is wrong\n", win);
690 return; 687 return;
691 } 688 }
@@ -706,9 +703,9 @@ static void mixer_win_disable(void *ctx, int zpos)
706 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 703 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
707 704
708 if (win == DEFAULT_ZPOS) 705 if (win == DEFAULT_ZPOS)
709 win = mixer_ctx->default_win; 706 win = MIXER_DEFAULT_WIN;
710 707
711 if (win < 0 || win > HDMI_OVERLAY_NUMBER) { 708 if (win < 0 || win > MIXER_WIN_NR) {
712 DRM_ERROR("overlay plane[%d] is wrong\n", win); 709 DRM_ERROR("overlay plane[%d] is wrong\n", win);
713 return; 710 return;
714 } 711 }
@@ -722,9 +719,12 @@ static void mixer_win_disable(void *ctx, int zpos)
722 spin_unlock_irqrestore(&res->reg_slock, flags); 719 spin_unlock_irqrestore(&res->reg_slock, flags);
723} 720}
724 721
725static struct exynos_hdmi_overlay_ops overlay_ops = { 722static struct exynos_mixer_ops mixer_ops = {
723 /* manager */
726 .enable_vblank = mixer_enable_vblank, 724 .enable_vblank = mixer_enable_vblank,
727 .disable_vblank = mixer_disable_vblank, 725 .disable_vblank = mixer_disable_vblank,
726
727 /* overlay */
728 .win_mode_set = mixer_win_mode_set, 728 .win_mode_set = mixer_win_mode_set,
729 .win_commit = mixer_win_commit, 729 .win_commit = mixer_win_commit,
730 .win_disable = mixer_win_disable, 730 .win_disable = mixer_win_disable,
@@ -771,8 +771,7 @@ static void mixer_finish_pageflip(struct drm_device *drm_dev, int crtc)
771static irqreturn_t mixer_irq_handler(int irq, void *arg) 771static irqreturn_t mixer_irq_handler(int irq, void *arg)
772{ 772{
773 struct exynos_drm_hdmi_context *drm_hdmi_ctx = arg; 773 struct exynos_drm_hdmi_context *drm_hdmi_ctx = arg;
774 struct mixer_context *ctx = 774 struct mixer_context *ctx = drm_hdmi_ctx->ctx;
775 (struct mixer_context *)drm_hdmi_ctx->ctx;
776 struct mixer_resources *res = &ctx->mixer_res; 775 struct mixer_resources *res = &ctx->mixer_res;
777 u32 val, val_base; 776 u32 val, val_base;
778 777
@@ -902,7 +901,7 @@ static int mixer_runtime_resume(struct device *dev)
902 901
903 DRM_DEBUG_KMS("resume - start\n"); 902 DRM_DEBUG_KMS("resume - start\n");
904 903
905 mixer_resource_poweron((struct mixer_context *)ctx->ctx); 904 mixer_resource_poweron(ctx->ctx);
906 905
907 return 0; 906 return 0;
908} 907}
@@ -913,7 +912,7 @@ static int mixer_runtime_suspend(struct device *dev)
913 912
914 DRM_DEBUG_KMS("suspend - start\n"); 913 DRM_DEBUG_KMS("suspend - start\n");
915 914
916 mixer_resource_poweroff((struct mixer_context *)ctx->ctx); 915 mixer_resource_poweroff(ctx->ctx);
917 916
918 return 0; 917 return 0;
919} 918}
@@ -926,8 +925,7 @@ static const struct dev_pm_ops mixer_pm_ops = {
926static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx, 925static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
927 struct platform_device *pdev) 926 struct platform_device *pdev)
928{ 927{
929 struct mixer_context *mixer_ctx = 928 struct mixer_context *mixer_ctx = ctx->ctx;
930 (struct mixer_context *)ctx->ctx;
931 struct device *dev = &pdev->dev; 929 struct device *dev = &pdev->dev;
932 struct mixer_resources *mixer_res = &mixer_ctx->mixer_res; 930 struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
933 struct resource *res; 931 struct resource *res;
@@ -1076,7 +1074,7 @@ static int __devinit mixer_probe(struct platform_device *pdev)
1076 goto fail; 1074 goto fail;
1077 1075
1078 /* register specific callback point to common hdmi. */ 1076 /* register specific callback point to common hdmi. */
1079 exynos_drm_overlay_ops_register(&overlay_ops); 1077 exynos_mixer_ops_register(&mixer_ops);
1080 1078
1081 mixer_resource_poweron(ctx); 1079 mixer_resource_poweron(ctx);
1082 1080
@@ -1093,7 +1091,7 @@ static int mixer_remove(struct platform_device *pdev)
1093 struct device *dev = &pdev->dev; 1091 struct device *dev = &pdev->dev;
1094 struct exynos_drm_hdmi_context *drm_hdmi_ctx = 1092 struct exynos_drm_hdmi_context *drm_hdmi_ctx =
1095 platform_get_drvdata(pdev); 1093 platform_get_drvdata(pdev);
1096 struct mixer_context *ctx = (struct mixer_context *)drm_hdmi_ctx->ctx; 1094 struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1097 1095
1098 dev_info(dev, "remove successful\n"); 1096 dev_info(dev, "remove successful\n");
1099 1097
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index dfa55e7478f..ae8a64f9f84 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(semaphores,
64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))"); 64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
65 65
66int i915_enable_rc6 __read_mostly = -1; 66int i915_enable_rc6 __read_mostly = -1;
67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600); 67module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
68MODULE_PARM_DESC(i915_enable_rc6, 68MODULE_PARM_DESC(i915_enable_rc6,
69 "Enable power-saving render C-state 6. " 69 "Enable power-saving render C-state 6. "
70 "Different stages can be selected via bitmask values " 70 "Different stages can be selected via bitmask values "
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4c65c639f77..0e3c6acde95 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1493,6 +1493,7 @@ i915_gem_object_move_off_active(struct drm_i915_gem_object *obj)
1493{ 1493{
1494 list_del_init(&obj->ring_list); 1494 list_del_init(&obj->ring_list);
1495 obj->last_rendering_seqno = 0; 1495 obj->last_rendering_seqno = 0;
1496 obj->last_fenced_seqno = 0;
1496} 1497}
1497 1498
1498static void 1499static void
@@ -1521,6 +1522,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)
1521 BUG_ON(!list_empty(&obj->gpu_write_list)); 1522 BUG_ON(!list_empty(&obj->gpu_write_list));
1522 BUG_ON(!obj->active); 1523 BUG_ON(!obj->active);
1523 obj->ring = NULL; 1524 obj->ring = NULL;
1525 obj->last_fenced_ring = NULL;
1524 1526
1525 i915_gem_object_move_off_active(obj); 1527 i915_gem_object_move_off_active(obj);
1526 obj->fenced_gpu_access = false; 1528 obj->fenced_gpu_access = false;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 2abf4eb9403..b4bb1ef77dd 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3728,6 +3728,9 @@
3728#define GT_FIFO_FREE_ENTRIES 0x120008 3728#define GT_FIFO_FREE_ENTRIES 0x120008
3729#define GT_FIFO_NUM_RESERVED_ENTRIES 20 3729#define GT_FIFO_NUM_RESERVED_ENTRIES 20
3730 3730
3731#define GEN6_UCGCTL1 0x9400
3732# define GEN6_BLBUNIT_CLOCK_GATE_DISABLE (1 << 5)
3733
3731#define GEN6_UCGCTL2 0x9404 3734#define GEN6_UCGCTL2 0x9404
3732# define GEN6_RCZUNIT_CLOCK_GATE_DISABLE (1 << 13) 3735# define GEN6_RCZUNIT_CLOCK_GATE_DISABLE (1 << 13)
3733# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12) 3736# define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE (1 << 12)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 91b35fd1db8..bae38acf44d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2245,6 +2245,33 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
2245} 2245}
2246 2246
2247static int 2247static int
2248intel_finish_fb(struct drm_framebuffer *old_fb)
2249{
2250 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2251 struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
2252 bool was_interruptible = dev_priv->mm.interruptible;
2253 int ret;
2254
2255 wait_event(dev_priv->pending_flip_queue,
2256 atomic_read(&dev_priv->mm.wedged) ||
2257 atomic_read(&obj->pending_flip) == 0);
2258
2259 /* Big Hammer, we also need to ensure that any pending
2260 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2261 * current scanout is retired before unpinning the old
2262 * framebuffer.
2263 *
2264 * This should only fail upon a hung GPU, in which case we
2265 * can safely continue.
2266 */
2267 dev_priv->mm.interruptible = false;
2268 ret = i915_gem_object_finish_gpu(obj);
2269 dev_priv->mm.interruptible = was_interruptible;
2270
2271 return ret;
2272}
2273
2274static int
2248intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, 2275intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2249 struct drm_framebuffer *old_fb) 2276 struct drm_framebuffer *old_fb)
2250{ 2277{
@@ -2282,25 +2309,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2282 return ret; 2309 return ret;
2283 } 2310 }
2284 2311
2285 if (old_fb) { 2312 if (old_fb)
2286 struct drm_i915_private *dev_priv = dev->dev_private; 2313 intel_finish_fb(old_fb);
2287 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2288
2289 wait_event(dev_priv->pending_flip_queue,
2290 atomic_read(&dev_priv->mm.wedged) ||
2291 atomic_read(&obj->pending_flip) == 0);
2292
2293 /* Big Hammer, we also need to ensure that any pending
2294 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2295 * current scanout is retired before unpinning the old
2296 * framebuffer.
2297 *
2298 * This should only fail upon a hung GPU, in which case we
2299 * can safely continue.
2300 */
2301 ret = i915_gem_object_finish_gpu(obj);
2302 (void) ret;
2303 }
2304 2314
2305 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y, 2315 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y,
2306 LEAVE_ATOMIC_MODE_SET); 2316 LEAVE_ATOMIC_MODE_SET);
@@ -3371,6 +3381,23 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
3371 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 3381 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
3372 struct drm_device *dev = crtc->dev; 3382 struct drm_device *dev = crtc->dev;
3373 3383
3384 /* Flush any pending WAITs before we disable the pipe. Note that
3385 * we need to drop the struct_mutex in order to acquire it again
3386 * during the lowlevel dpms routines around a couple of the
3387 * operations. It does not look trivial nor desirable to move
3388 * that locking higher. So instead we leave a window for the
3389 * submission of further commands on the fb before we can actually
3390 * disable it. This race with userspace exists anyway, and we can
3391 * only rely on the pipe being disabled by userspace after it
3392 * receives the hotplug notification and has flushed any pending
3393 * batches.
3394 */
3395 if (crtc->fb) {
3396 mutex_lock(&dev->struct_mutex);
3397 intel_finish_fb(crtc->fb);
3398 mutex_unlock(&dev->struct_mutex);
3399 }
3400
3374 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 3401 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
3375 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); 3402 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
3376 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); 3403 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);
@@ -8529,6 +8556,10 @@ static void gen6_init_clock_gating(struct drm_device *dev)
8529 I915_WRITE(WM2_LP_ILK, 0); 8556 I915_WRITE(WM2_LP_ILK, 0);
8530 I915_WRITE(WM1_LP_ILK, 0); 8557 I915_WRITE(WM1_LP_ILK, 0);
8531 8558
8559 I915_WRITE(GEN6_UCGCTL1,
8560 I915_READ(GEN6_UCGCTL1) |
8561 GEN6_BLBUNIT_CLOCK_GATE_DISABLE);
8562
8532 /* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock 8563 /* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock
8533 * gating disable must be set. Failure to set it results in 8564 * gating disable must be set. Failure to set it results in
8534 * flickering pixels due to Z write ordering failures after 8565 * flickering pixels due to Z write ordering failures after
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 110552ff302..4b637919f74 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -219,14 +219,38 @@ intel_dp_max_data_rate(int max_link_clock, int max_lanes)
219 return (max_link_clock * max_lanes * 8) / 10; 219 return (max_link_clock * max_lanes * 8) / 10;
220} 220}
221 221
222static bool
223intel_dp_adjust_dithering(struct intel_dp *intel_dp,
224 struct drm_display_mode *mode,
225 struct drm_display_mode *adjusted_mode)
226{
227 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp));
228 int max_lanes = intel_dp_max_lane_count(intel_dp);
229 int max_rate, mode_rate;
230
231 mode_rate = intel_dp_link_required(mode->clock, 24);
232 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
233
234 if (mode_rate > max_rate) {
235 mode_rate = intel_dp_link_required(mode->clock, 18);
236 if (mode_rate > max_rate)
237 return false;
238
239 if (adjusted_mode)
240 adjusted_mode->private_flags
241 |= INTEL_MODE_DP_FORCE_6BPC;
242
243 return true;
244 }
245
246 return true;
247}
248
222static int 249static int
223intel_dp_mode_valid(struct drm_connector *connector, 250intel_dp_mode_valid(struct drm_connector *connector,
224 struct drm_display_mode *mode) 251 struct drm_display_mode *mode)
225{ 252{
226 struct intel_dp *intel_dp = intel_attached_dp(connector); 253 struct intel_dp *intel_dp = intel_attached_dp(connector);
227 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp));
228 int max_lanes = intel_dp_max_lane_count(intel_dp);
229 int max_rate, mode_rate;
230 254
231 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { 255 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
232 if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay) 256 if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay)
@@ -236,16 +260,8 @@ intel_dp_mode_valid(struct drm_connector *connector,
236 return MODE_PANEL; 260 return MODE_PANEL;
237 } 261 }
238 262
239 mode_rate = intel_dp_link_required(mode->clock, 24); 263 if (!intel_dp_adjust_dithering(intel_dp, mode, NULL))
240 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); 264 return MODE_CLOCK_HIGH;
241
242 if (mode_rate > max_rate) {
243 mode_rate = intel_dp_link_required(mode->clock, 18);
244 if (mode_rate > max_rate)
245 return MODE_CLOCK_HIGH;
246 else
247 mode->private_flags |= INTEL_MODE_DP_FORCE_6BPC;
248 }
249 265
250 if (mode->clock < 10000) 266 if (mode->clock < 10000)
251 return MODE_CLOCK_LOW; 267 return MODE_CLOCK_LOW;
@@ -672,7 +688,7 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
672 int lane_count, clock; 688 int lane_count, clock;
673 int max_lane_count = intel_dp_max_lane_count(intel_dp); 689 int max_lane_count = intel_dp_max_lane_count(intel_dp);
674 int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0; 690 int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
675 int bpp = mode->private_flags & INTEL_MODE_DP_FORCE_6BPC ? 18 : 24; 691 int bpp;
676 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; 692 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
677 693
678 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) { 694 if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
@@ -686,6 +702,11 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
686 mode->clock = intel_dp->panel_fixed_mode->clock; 702 mode->clock = intel_dp->panel_fixed_mode->clock;
687 } 703 }
688 704
705 if (!intel_dp_adjust_dithering(intel_dp, mode, adjusted_mode))
706 return false;
707
708 bpp = adjusted_mode->private_flags & INTEL_MODE_DP_FORCE_6BPC ? 18 : 24;
709
689 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 710 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
690 for (clock = 0; clock <= max_clock; clock++) { 711 for (clock = 0; clock <= max_clock; clock++) {
691 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count); 712 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count);
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 601c86e664a..8fdc9570021 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -390,7 +390,7 @@ int intel_setup_gmbus(struct drm_device *dev)
390 bus->has_gpio = intel_gpio_setup(bus, i); 390 bus->has_gpio = intel_gpio_setup(bus, i);
391 391
392 /* XXX force bit banging until GMBUS is fully debugged */ 392 /* XXX force bit banging until GMBUS is fully debugged */
393 if (bus->has_gpio && IS_GEN2(dev)) 393 if (bus->has_gpio)
394 bus->force_bit = true; 394 bus->force_bit = true;
395 } 395 }
396 396
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index e25581a9f60..f75806e5bff 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1038,7 +1038,7 @@ int intel_init_ring_buffer(struct drm_device *dev,
1038 * of the buffer. 1038 * of the buffer.
1039 */ 1039 */
1040 ring->effective_size = ring->size; 1040 ring->effective_size = ring->size;
1041 if (IS_I830(ring->dev)) 1041 if (IS_I830(ring->dev) || IS_845G(ring->dev))
1042 ring->effective_size -= 128; 1042 ring->effective_size -= 128;
1043 1043
1044 return 0; 1044 return 0;
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index a464771a724..e90dfb625c4 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -95,7 +95,6 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
95 /* must disable */ 95 /* must disable */
96 sprctl |= SPRITE_TRICKLE_FEED_DISABLE; 96 sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
97 sprctl |= SPRITE_ENABLE; 97 sprctl |= SPRITE_ENABLE;
98 sprctl |= SPRITE_DEST_KEY;
99 98
100 /* Sizes are 0 based */ 99 /* Sizes are 0 based */
101 src_w--; 100 src_w--;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index e607c4d7dd9..2d39f9977e0 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -230,6 +230,10 @@ atombios_dvo_setup(struct drm_encoder *encoder, int action)
230 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) 230 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
231 return; 231 return;
232 232
233 /* some R4xx chips have the wrong frev */
234 if (rdev->family <= CHIP_RV410)
235 frev = 1;
236
233 switch (frev) { 237 switch (frev) {
234 case 1: 238 case 1:
235 switch (crev) { 239 switch (crev) {
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 81801c176aa..fe33d35dae8 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2553,7 +2553,7 @@ static void r100_pll_errata_after_data(struct radeon_device *rdev)
2553 * or the chip could hang on a subsequent access 2553 * or the chip could hang on a subsequent access
2554 */ 2554 */
2555 if (rdev->pll_errata & CHIP_ERRATA_PLL_DELAY) { 2555 if (rdev->pll_errata & CHIP_ERRATA_PLL_DELAY) {
2556 udelay(5000); 2556 mdelay(5);
2557 } 2557 }
2558 2558
2559 /* This function is required to workaround a hardware bug in some (all?) 2559 /* This function is required to workaround a hardware bug in some (all?)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 391bd2636a8..de71243b591 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2839,7 +2839,7 @@ void r600_rlc_stop(struct radeon_device *rdev)
2839 /* r7xx asics need to soft reset RLC before halting */ 2839 /* r7xx asics need to soft reset RLC before halting */
2840 WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC); 2840 WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC);
2841 RREG32(SRBM_SOFT_RESET); 2841 RREG32(SRBM_SOFT_RESET);
2842 udelay(15000); 2842 mdelay(15);
2843 WREG32(SRBM_SOFT_RESET, 0); 2843 WREG32(SRBM_SOFT_RESET, 0);
2844 RREG32(SRBM_SOFT_RESET); 2844 RREG32(SRBM_SOFT_RESET);
2845 } 2845 }
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 84c54625095..75ed17c9611 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -407,7 +407,7 @@ static void r600_cp_load_microcode(drm_radeon_private_t *dev_priv)
407 407
408 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 408 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
409 RADEON_READ(R600_GRBM_SOFT_RESET); 409 RADEON_READ(R600_GRBM_SOFT_RESET);
410 DRM_UDELAY(15000); 410 mdelay(15);
411 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 411 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
412 412
413 fw_data = (const __be32 *)dev_priv->me_fw->data; 413 fw_data = (const __be32 *)dev_priv->me_fw->data;
@@ -500,7 +500,7 @@ static void r700_cp_load_microcode(drm_radeon_private_t *dev_priv)
500 500
501 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 501 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
502 RADEON_READ(R600_GRBM_SOFT_RESET); 502 RADEON_READ(R600_GRBM_SOFT_RESET);
503 DRM_UDELAY(15000); 503 mdelay(15);
504 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 504 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
505 505
506 fw_data = (const __be32 *)dev_priv->pfp_fw->data; 506 fw_data = (const __be32 *)dev_priv->pfp_fw->data;
@@ -1797,7 +1797,7 @@ static void r600_cp_init_ring_buffer(struct drm_device *dev,
1797 1797
1798 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP); 1798 RADEON_WRITE(R600_GRBM_SOFT_RESET, R600_SOFT_RESET_CP);
1799 RADEON_READ(R600_GRBM_SOFT_RESET); 1799 RADEON_READ(R600_GRBM_SOFT_RESET);
1800 DRM_UDELAY(15000); 1800 mdelay(15);
1801 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0); 1801 RADEON_WRITE(R600_GRBM_SOFT_RESET, 0);
1802 1802
1803 1803
diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c
index 6ae0c75f016..9c6b29a4192 100644
--- a/drivers/gpu/drm/radeon/radeon_clocks.c
+++ b/drivers/gpu/drm/radeon/radeon_clocks.c
@@ -633,7 +633,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
633 tmp &= ~(R300_SCLK_FORCE_VAP); 633 tmp &= ~(R300_SCLK_FORCE_VAP);
634 tmp |= RADEON_SCLK_FORCE_CP; 634 tmp |= RADEON_SCLK_FORCE_CP;
635 WREG32_PLL(RADEON_SCLK_CNTL, tmp); 635 WREG32_PLL(RADEON_SCLK_CNTL, tmp);
636 udelay(15000); 636 mdelay(15);
637 637
638 tmp = RREG32_PLL(R300_SCLK_CNTL2); 638 tmp = RREG32_PLL(R300_SCLK_CNTL2);
639 tmp &= ~(R300_SCLK_FORCE_TCL | 639 tmp &= ~(R300_SCLK_FORCE_TCL |
@@ -651,12 +651,12 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
651 tmp |= (RADEON_ENGIN_DYNCLK_MODE | 651 tmp |= (RADEON_ENGIN_DYNCLK_MODE |
652 (0x01 << RADEON_ACTIVE_HILO_LAT_SHIFT)); 652 (0x01 << RADEON_ACTIVE_HILO_LAT_SHIFT));
653 WREG32_PLL(RADEON_CLK_PWRMGT_CNTL, tmp); 653 WREG32_PLL(RADEON_CLK_PWRMGT_CNTL, tmp);
654 udelay(15000); 654 mdelay(15);
655 655
656 tmp = RREG32_PLL(RADEON_CLK_PIN_CNTL); 656 tmp = RREG32_PLL(RADEON_CLK_PIN_CNTL);
657 tmp |= RADEON_SCLK_DYN_START_CNTL; 657 tmp |= RADEON_SCLK_DYN_START_CNTL;
658 WREG32_PLL(RADEON_CLK_PIN_CNTL, tmp); 658 WREG32_PLL(RADEON_CLK_PIN_CNTL, tmp);
659 udelay(15000); 659 mdelay(15);
660 660
661 /* When DRI is enabled, setting DYN_STOP_LAT to zero can cause some R200 661 /* When DRI is enabled, setting DYN_STOP_LAT to zero can cause some R200
662 to lockup randomly, leave them as set by BIOS. 662 to lockup randomly, leave them as set by BIOS.
@@ -696,7 +696,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
696 tmp |= RADEON_SCLK_MORE_FORCEON; 696 tmp |= RADEON_SCLK_MORE_FORCEON;
697 } 697 }
698 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp); 698 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp);
699 udelay(15000); 699 mdelay(15);
700 } 700 }
701 701
702 /* RV200::A11 A12, RV250::A11 A12 */ 702 /* RV200::A11 A12, RV250::A11 A12 */
@@ -709,7 +709,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
709 tmp |= RADEON_TCL_BYPASS_DISABLE; 709 tmp |= RADEON_TCL_BYPASS_DISABLE;
710 WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp); 710 WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp);
711 } 711 }
712 udelay(15000); 712 mdelay(15);
713 713
714 /*enable dynamic mode for display clocks (PIXCLK and PIX2CLK) */ 714 /*enable dynamic mode for display clocks (PIXCLK and PIX2CLK) */
715 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL); 715 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL);
@@ -722,14 +722,14 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
722 RADEON_PIXCLK_TMDS_ALWAYS_ONb); 722 RADEON_PIXCLK_TMDS_ALWAYS_ONb);
723 723
724 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp); 724 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
725 udelay(15000); 725 mdelay(15);
726 726
727 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL); 727 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
728 tmp |= (RADEON_PIXCLK_ALWAYS_ONb | 728 tmp |= (RADEON_PIXCLK_ALWAYS_ONb |
729 RADEON_PIXCLK_DAC_ALWAYS_ONb); 729 RADEON_PIXCLK_DAC_ALWAYS_ONb);
730 730
731 WREG32_PLL(RADEON_VCLK_ECP_CNTL, tmp); 731 WREG32_PLL(RADEON_VCLK_ECP_CNTL, tmp);
732 udelay(15000); 732 mdelay(15);
733 } 733 }
734 } else { 734 } else {
735 /* Turn everything OFF (ForceON to everything) */ 735 /* Turn everything OFF (ForceON to everything) */
@@ -861,7 +861,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
861 } 861 }
862 WREG32_PLL(RADEON_SCLK_CNTL, tmp); 862 WREG32_PLL(RADEON_SCLK_CNTL, tmp);
863 863
864 udelay(16000); 864 mdelay(16);
865 865
866 if ((rdev->family == CHIP_R300) || 866 if ((rdev->family == CHIP_R300) ||
867 (rdev->family == CHIP_R350)) { 867 (rdev->family == CHIP_R350)) {
@@ -870,7 +870,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
870 R300_SCLK_FORCE_GA | 870 R300_SCLK_FORCE_GA |
871 R300_SCLK_FORCE_CBA); 871 R300_SCLK_FORCE_CBA);
872 WREG32_PLL(R300_SCLK_CNTL2, tmp); 872 WREG32_PLL(R300_SCLK_CNTL2, tmp);
873 udelay(16000); 873 mdelay(16);
874 } 874 }
875 875
876 if (rdev->flags & RADEON_IS_IGP) { 876 if (rdev->flags & RADEON_IS_IGP) {
@@ -878,7 +878,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
878 tmp &= ~(RADEON_FORCEON_MCLKA | 878 tmp &= ~(RADEON_FORCEON_MCLKA |
879 RADEON_FORCEON_YCLKA); 879 RADEON_FORCEON_YCLKA);
880 WREG32_PLL(RADEON_MCLK_CNTL, tmp); 880 WREG32_PLL(RADEON_MCLK_CNTL, tmp);
881 udelay(16000); 881 mdelay(16);
882 } 882 }
883 883
884 if ((rdev->family == CHIP_RV200) || 884 if ((rdev->family == CHIP_RV200) ||
@@ -887,7 +887,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
887 tmp = RREG32_PLL(RADEON_SCLK_MORE_CNTL); 887 tmp = RREG32_PLL(RADEON_SCLK_MORE_CNTL);
888 tmp |= RADEON_SCLK_MORE_FORCEON; 888 tmp |= RADEON_SCLK_MORE_FORCEON;
889 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp); 889 WREG32_PLL(RADEON_SCLK_MORE_CNTL, tmp);
890 udelay(16000); 890 mdelay(16);
891 } 891 }
892 892
893 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL); 893 tmp = RREG32_PLL(RADEON_PIXCLKS_CNTL);
@@ -900,7 +900,7 @@ void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable)
900 RADEON_PIXCLK_TMDS_ALWAYS_ONb); 900 RADEON_PIXCLK_TMDS_ALWAYS_ONb);
901 901
902 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp); 902 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
903 udelay(16000); 903 mdelay(16);
904 904
905 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL); 905 tmp = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
906 tmp &= ~(RADEON_PIXCLK_ALWAYS_ONb | 906 tmp &= ~(RADEON_PIXCLK_ALWAYS_ONb |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 81fc100be7e..2cad9fde92f 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -2845,7 +2845,7 @@ bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2845 case 4: 2845 case 4:
2846 val = RBIOS16(index); 2846 val = RBIOS16(index);
2847 index += 2; 2847 index += 2;
2848 udelay(val * 1000); 2848 mdelay(val);
2849 break; 2849 break;
2850 case 6: 2850 case 6:
2851 slave_addr = id & 0xff; 2851 slave_addr = id & 0xff;
@@ -3044,7 +3044,7 @@ static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
3044 udelay(150); 3044 udelay(150);
3045 break; 3045 break;
3046 case 2: 3046 case 2:
3047 udelay(1000); 3047 mdelay(1);
3048 break; 3048 break;
3049 case 3: 3049 case 3:
3050 while (tmp--) { 3050 while (tmp--) {
@@ -3075,13 +3075,13 @@ static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
3075 /*mclk_cntl |= 0x00001111;*//* ??? */ 3075 /*mclk_cntl |= 0x00001111;*//* ??? */
3076 WREG32_PLL(RADEON_MCLK_CNTL, 3076 WREG32_PLL(RADEON_MCLK_CNTL,
3077 mclk_cntl); 3077 mclk_cntl);
3078 udelay(10000); 3078 mdelay(10);
3079#endif 3079#endif
3080 WREG32_PLL 3080 WREG32_PLL
3081 (RADEON_CLK_PWRMGT_CNTL, 3081 (RADEON_CLK_PWRMGT_CNTL,
3082 tmp & 3082 tmp &
3083 ~RADEON_CG_NO1_DEBUG_0); 3083 ~RADEON_CG_NO1_DEBUG_0);
3084 udelay(10000); 3084 mdelay(10);
3085 } 3085 }
3086 break; 3086 break;
3087 default: 3087 default:
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 85bcfc8923a..3edec1c198e 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -900,6 +900,10 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
900 struct radeon_i2c_chan *i2c; 900 struct radeon_i2c_chan *i2c;
901 int ret; 901 int ret;
902 902
903 /* don't add the mm_i2c bus unless hw_i2c is enabled */
904 if (rec->mm_i2c && (radeon_hw_i2c == 0))
905 return NULL;
906
903 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); 907 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL);
904 if (i2c == NULL) 908 if (i2c == NULL)
905 return NULL; 909 return NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 2f46e0c8df5..42db254f6bb 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -88,7 +88,7 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
88 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL); 88 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
89 lvds_pll_cntl |= RADEON_LVDS_PLL_EN; 89 lvds_pll_cntl |= RADEON_LVDS_PLL_EN;
90 WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl); 90 WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl);
91 udelay(1000); 91 mdelay(1);
92 92
93 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL); 93 lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
94 lvds_pll_cntl &= ~RADEON_LVDS_PLL_RESET; 94 lvds_pll_cntl &= ~RADEON_LVDS_PLL_RESET;
@@ -101,7 +101,7 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
101 (backlight_level << RADEON_LVDS_BL_MOD_LEVEL_SHIFT)); 101 (backlight_level << RADEON_LVDS_BL_MOD_LEVEL_SHIFT));
102 if (is_mac) 102 if (is_mac)
103 lvds_gen_cntl |= RADEON_LVDS_BL_MOD_EN; 103 lvds_gen_cntl |= RADEON_LVDS_BL_MOD_EN;
104 udelay(panel_pwr_delay * 1000); 104 mdelay(panel_pwr_delay);
105 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 105 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
106 break; 106 break;
107 case DRM_MODE_DPMS_STANDBY: 107 case DRM_MODE_DPMS_STANDBY:
@@ -118,10 +118,10 @@ static void radeon_legacy_lvds_update(struct drm_encoder *encoder, int mode)
118 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 118 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
119 lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON); 119 lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON);
120 } 120 }
121 udelay(panel_pwr_delay * 1000); 121 mdelay(panel_pwr_delay);
122 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl); 122 WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
123 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl); 123 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
124 udelay(panel_pwr_delay * 1000); 124 mdelay(panel_pwr_delay);
125 break; 125 break;
126 } 126 }
127 127
@@ -656,7 +656,7 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
656 656
657 WREG32(RADEON_DAC_MACRO_CNTL, tmp); 657 WREG32(RADEON_DAC_MACRO_CNTL, tmp);
658 658
659 udelay(2000); 659 mdelay(2);
660 660
661 if (RREG32(RADEON_DAC_CNTL) & RADEON_DAC_CMP_OUTPUT) 661 if (RREG32(RADEON_DAC_CNTL) & RADEON_DAC_CMP_OUTPUT)
662 found = connector_status_connected; 662 found = connector_status_connected;
@@ -1499,7 +1499,7 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
1499 tmp = dac_cntl2 | RADEON_DAC2_DAC2_CLK_SEL | RADEON_DAC2_CMP_EN; 1499 tmp = dac_cntl2 | RADEON_DAC2_DAC2_CLK_SEL | RADEON_DAC2_CMP_EN;
1500 WREG32(RADEON_DAC_CNTL2, tmp); 1500 WREG32(RADEON_DAC_CNTL2, tmp);
1501 1501
1502 udelay(10000); 1502 mdelay(10);
1503 1503
1504 if (ASIC_IS_R300(rdev)) { 1504 if (ASIC_IS_R300(rdev)) {
1505 if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUT_B) 1505 if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUT_B)
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index 031aaaf79ac..b6d8608375c 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -988,7 +988,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
988 * for locking on FreeBSD. 988 * for locking on FreeBSD.
989 */ 989 */
990 if (cmdbuf->size) { 990 if (cmdbuf->size) {
991 kcmd_addr = kmalloc(cmdbuf->size * 8, GFP_KERNEL); 991 kcmd_addr = kmalloc_array(cmdbuf->size, 8, GFP_KERNEL);
992 if (kcmd_addr == NULL) 992 if (kcmd_addr == NULL)
993 return -ENOMEM; 993 return -ENOMEM;
994 994
@@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1015 cmdbuf->vb_addr = kvb_addr; 1015 cmdbuf->vb_addr = kvb_addr;
1016 } 1016 }
1017 if (cmdbuf->nbox) { 1017 if (cmdbuf->nbox) {
1018 kbox_addr = kmalloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), 1018 kbox_addr = kmalloc_array(cmdbuf->nbox, sizeof(struct drm_clip_rect),
1019 GFP_KERNEL); 1019 GFP_KERNEL);
1020 if (kbox_addr == NULL) { 1020 if (kbox_addr == NULL) {
1021 ret = -ENOMEM; 1021 ret = -ENOMEM;
1022 goto done; 1022 goto done;
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 37f42113af3..00e8f213f56 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -182,7 +182,6 @@ static int i2c_dw_pci_resume(struct device *dev)
182 pci_restore_state(pdev); 182 pci_restore_state(pdev);
183 183
184 i2c_dw_init(i2c); 184 i2c_dw_init(i2c);
185 i2c_dw_enable(i2c);
186 return 0; 185 return 0;
187} 186}
188 187
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 83b720ef6c3..246fdc15165 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
179{ 179{
180 struct ib_port_attr attr; 180 struct ib_port_attr attr;
181 char *speed = ""; 181 char *speed = "";
182 int rate = -1; /* in deci-Gb/sec */ 182 int rate; /* in deci-Gb/sec */
183 ssize_t ret; 183 ssize_t ret;
184 184
185 ret = ib_query_port(p->ibdev, p->port_num, &attr); 185 ret = ib_query_port(p->ibdev, p->port_num, &attr);
@@ -187,9 +187,6 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
187 return ret; 187 return ret;
188 188
189 switch (attr.active_speed) { 189 switch (attr.active_speed) {
190 case IB_SPEED_SDR:
191 rate = 25;
192 break;
193 case IB_SPEED_DDR: 190 case IB_SPEED_DDR:
194 speed = " DDR"; 191 speed = " DDR";
195 rate = 50; 192 rate = 50;
@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
210 speed = " EDR"; 207 speed = " EDR";
211 rate = 250; 208 rate = 250;
212 break; 209 break;
210 case IB_SPEED_SDR:
211 default: /* default to SDR for invalid rates */
212 rate = 25;
213 break;
213 } 214 }
214 215
215 rate *= ib_width_enum_to_int(attr.active_width); 216 rate *= ib_width_enum_to_int(attr.active_width);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 75d30562930..669673e8143 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -253,6 +253,11 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
253 if (out_mad->data[15] & 0x1) 253 if (out_mad->data[15] & 0x1)
254 props->active_speed = IB_SPEED_FDR10; 254 props->active_speed = IB_SPEED_FDR10;
255 } 255 }
256
257 /* Avoid wrong speed value returned by FW if the IB link is down. */
258 if (props->state == IB_PORT_DOWN)
259 props->active_speed = IB_SPEED_SDR;
260
256out: 261out:
257 kfree(in_mad); 262 kfree(in_mad);
258 kfree(out_mad); 263 kfree(out_mad);
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 34aebb8cd08..3c843cd725f 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -95,7 +95,8 @@ static int __devinit da9052_onkey_probe(struct platform_device *pdev)
95 input_dev = input_allocate_device(); 95 input_dev = input_allocate_device();
96 if (!onkey || !input_dev) { 96 if (!onkey || !input_dev) {
97 dev_err(&pdev->dev, "Failed to allocate memory\n"); 97 dev_err(&pdev->dev, "Failed to allocate memory\n");
98 return -ENOMEM; 98 error = -ENOMEM;
99 goto err_free_mem;
99 } 100 }
100 101
101 onkey->input = input_dev; 102 onkey->input = input_dev;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index d2c0db159b1..479011004a1 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -486,7 +486,6 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
486 unsigned char *packet = psmouse->packet; 486 unsigned char *packet = psmouse->packet;
487 487
488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
489 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
490 input_mt_report_pointer_emulation(dev, true); 489 input_mt_report_pointer_emulation(dev, true);
491 input_sync(dev); 490 input_sync(dev);
492} 491}
@@ -967,6 +966,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
967 if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) 966 if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width))
968 return -1; 967 return -1;
969 968
969 __set_bit(INPUT_PROP_POINTER, dev->propbit);
970 __set_bit(EV_KEY, dev->evbit); 970 __set_bit(EV_KEY, dev->evbit);
971 __set_bit(EV_ABS, dev->evbit); 971 __set_bit(EV_ABS, dev->evbit);
972 __clear_bit(EV_REL, dev->evbit); 972 __clear_bit(EV_REL, dev->evbit);
@@ -1017,7 +1017,9 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1017 */ 1017 */
1018 psmouse_warn(psmouse, "couldn't query resolution data.\n"); 1018 psmouse_warn(psmouse, "couldn't query resolution data.\n");
1019 } 1019 }
1020 1020 /* v4 is clickpad, with only one button. */
1021 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1022 __clear_bit(BTN_RIGHT, dev->keybit);
1021 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1023 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
1022 /* For X to recognize me as touchpad. */ 1024 /* For X to recognize me as touchpad. */
1023 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1025 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1245,6 +1247,8 @@ static void elantech_disconnect(struct psmouse *psmouse)
1245 */ 1247 */
1246static int elantech_reconnect(struct psmouse *psmouse) 1248static int elantech_reconnect(struct psmouse *psmouse)
1247{ 1249{
1250 psmouse_reset(psmouse);
1251
1248 if (elantech_detect(psmouse, 0)) 1252 if (elantech_detect(psmouse, 0))
1249 return -1; 1253 return -1;
1250 1254
@@ -1324,6 +1328,8 @@ int elantech_init(struct psmouse *psmouse)
1324 if (!etd) 1328 if (!etd)
1325 return -ENOMEM; 1329 return -ENOMEM;
1326 1330
1331 psmouse_reset(psmouse);
1332
1327 etd->parity[0] = 1; 1333 etd->parity[0] = 1;
1328 for (i = 1; i < 256; i++) 1334 for (i = 1; i < 256; i++)
1329 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1; 1335 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1;
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index a9ad8e1402b..39fe9b737ca 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -12,9 +12,9 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/input-polldev.h> 14#include <linux/input-polldev.h>
15#include <linux/gpio.h>
15#include <linux/gpio_mouse.h> 16#include <linux/gpio_mouse.h>
16 17
17#include <asm/gpio.h>
18 18
19/* 19/*
20 * Timer function which is run every scan_ms ms when the device is opened. 20 * Timer function which is run every scan_ms ms when the device is opened.
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index a977bfaa682..661a0ca3b3d 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -741,6 +741,14 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
741 } 741 }
742 } else { 742 } else {
743 /* SFAC packet */ 743 /* SFAC packet */
744 if ((packet[0] & (FSP_PB0_LBTN|FSP_PB0_PHY_BTN)) ==
745 FSP_PB0_LBTN) {
746 /* On-pad click in SFAC mode should be handled
747 * by userspace. On-pad clicks in MFMC mode
748 * are real clickpad clicks, and not ignored.
749 */
750 packet[0] &= ~FSP_PB0_LBTN;
751 }
744 752
745 /* no multi-finger information */ 753 /* no multi-finger information */
746 ad->last_mt_fgr = 0; 754 ad->last_mt_fgr = 0;
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 22b21801813..f3102494237 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -304,7 +304,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
304 return 0; 304 return 0;
305 305
306 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { 306 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
307 printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); 307 psmouse_warn(psmouse, "failed to get extended button data\n");
308 button_info = 0; 308 button_info = 0;
309 } 309 }
310 310
@@ -326,16 +326,18 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
326 326
327 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); 327 error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
328 if (error) { 328 if (error) {
329 printk(KERN_ERR 329 psmouse_err(psmouse,
330 "trackpoint.c: failed to create sysfs attributes, error: %d\n", 330 "failed to create sysfs attributes, error: %d\n",
331 error); 331 error);
332 kfree(psmouse->private); 332 kfree(psmouse->private);
333 psmouse->private = NULL; 333 psmouse->private = NULL;
334 return -1; 334 return -1;
335 } 335 }
336 336
337 printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", 337 psmouse_info(psmouse,
338 firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); 338 "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
339 firmware_id,
340 (button_info & 0xf0) >> 4, button_info & 0x0f);
339 341
340 return 0; 342 return 0;
341} 343}
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index 6c6f6d8ea9b..f7eda3d00fa 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/input/touchscreen/tps6507x_ts.c
3 *
4 * Touchscreen driver for the tps6507x chip. 2 * Touchscreen driver for the tps6507x chip.
5 * 3 *
6 * Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com) 4 * Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com)
@@ -376,4 +374,4 @@ module_platform_driver(tps6507x_ts_driver);
376MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>"); 374MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>");
377MODULE_DESCRIPTION("TPS6507x - TouchScreen driver"); 375MODULE_DESCRIPTION("TPS6507x - TouchScreen driver");
378MODULE_LICENSE("GPL v2"); 376MODULE_LICENSE("GPL v2");
379MODULE_ALIAS("platform:tps6507x-tsc"); 377MODULE_ALIAS("platform:tps6507x-ts");
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 3d0dfa7a89a..97e73e555d1 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -539,9 +539,6 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap)
539 bitmap->events_cleared = bitmap->mddev->events; 539 bitmap->events_cleared = bitmap->mddev->events;
540 sb->events_cleared = cpu_to_le64(bitmap->mddev->events); 540 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
541 541
542 bitmap->flags |= BITMAP_HOSTENDIAN;
543 sb->version = cpu_to_le32(BITMAP_MAJOR_HOSTENDIAN);
544
545 kunmap_atomic(sb); 542 kunmap_atomic(sb);
546 543
547 return 0; 544 return 0;
@@ -1788,7 +1785,9 @@ int bitmap_load(struct mddev *mddev)
1788 * re-add of a missing device */ 1785 * re-add of a missing device */
1789 start = mddev->recovery_cp; 1786 start = mddev->recovery_cp;
1790 1787
1788 mutex_lock(&mddev->bitmap_info.mutex);
1791 err = bitmap_init_from_disk(bitmap, start); 1789 err = bitmap_init_from_disk(bitmap, start);
1790 mutex_unlock(&mddev->bitmap_info.mutex);
1792 1791
1793 if (err) 1792 if (err)
1794 goto out; 1793 goto out;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d35e4c991e3..15dd59b84e9 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1712,6 +1712,7 @@ static int process_checks(struct r1bio *r1_bio)
1712 struct r1conf *conf = mddev->private; 1712 struct r1conf *conf = mddev->private;
1713 int primary; 1713 int primary;
1714 int i; 1714 int i;
1715 int vcnt;
1715 1716
1716 for (primary = 0; primary < conf->raid_disks * 2; primary++) 1717 for (primary = 0; primary < conf->raid_disks * 2; primary++)
1717 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1718 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
@@ -1721,9 +1722,9 @@ static int process_checks(struct r1bio *r1_bio)
1721 break; 1722 break;
1722 } 1723 }
1723 r1_bio->read_disk = primary; 1724 r1_bio->read_disk = primary;
1725 vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1724 for (i = 0; i < conf->raid_disks * 2; i++) { 1726 for (i = 0; i < conf->raid_disks * 2; i++) {
1725 int j; 1727 int j;
1726 int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9);
1727 struct bio *pbio = r1_bio->bios[primary]; 1728 struct bio *pbio = r1_bio->bios[primary];
1728 struct bio *sbio = r1_bio->bios[i]; 1729 struct bio *sbio = r1_bio->bios[i];
1729 int size; 1730 int size;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index fff782189e4..c8dbb84d535 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1788,6 +1788,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1788 struct r10conf *conf = mddev->private; 1788 struct r10conf *conf = mddev->private;
1789 int i, first; 1789 int i, first;
1790 struct bio *tbio, *fbio; 1790 struct bio *tbio, *fbio;
1791 int vcnt;
1791 1792
1792 atomic_set(&r10_bio->remaining, 1); 1793 atomic_set(&r10_bio->remaining, 1);
1793 1794
@@ -1802,10 +1803,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1802 first = i; 1803 first = i;
1803 fbio = r10_bio->devs[i].bio; 1804 fbio = r10_bio->devs[i].bio;
1804 1805
1806 vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
1805 /* now find blocks with errors */ 1807 /* now find blocks with errors */
1806 for (i=0 ; i < conf->copies ; i++) { 1808 for (i=0 ; i < conf->copies ; i++) {
1807 int j, d; 1809 int j, d;
1808 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1809 1810
1810 tbio = r10_bio->devs[i].bio; 1811 tbio = r10_bio->devs[i].bio;
1811 1812
@@ -1871,7 +1872,6 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1871 */ 1872 */
1872 for (i = 0; i < conf->copies; i++) { 1873 for (i = 0; i < conf->copies; i++) {
1873 int j, d; 1874 int j, d;
1874 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1875 1875
1876 tbio = r10_bio->devs[i].repl_bio; 1876 tbio = r10_bio->devs[i].repl_bio;
1877 if (!tbio || !tbio->bi_end_io) 1877 if (!tbio || !tbio->bi_end_io)
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 4555baa383b..39696c6a4ed 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -143,10 +143,12 @@ struct dvb_frontend_private {
143static void dvb_frontend_wakeup(struct dvb_frontend *fe); 143static void dvb_frontend_wakeup(struct dvb_frontend *fe);
144static int dtv_get_frontend(struct dvb_frontend *fe, 144static int dtv_get_frontend(struct dvb_frontend *fe,
145 struct dvb_frontend_parameters *p_out); 145 struct dvb_frontend_parameters *p_out);
146static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
147 struct dvb_frontend_parameters *p);
146 148
147static bool has_get_frontend(struct dvb_frontend *fe) 149static bool has_get_frontend(struct dvb_frontend *fe)
148{ 150{
149 return fe->ops.get_frontend; 151 return fe->ops.get_frontend != NULL;
150} 152}
151 153
152/* 154/*
@@ -697,6 +699,7 @@ restart:
697 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; 699 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
698 fepriv->delay = HZ / 2; 700 fepriv->delay = HZ / 2;
699 } 701 }
702 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
700 fe->ops.read_status(fe, &s); 703 fe->ops.read_status(fe, &s);
701 if (s != fepriv->status) { 704 if (s != fepriv->status) {
702 dvb_frontend_add_event(fe, s); /* update event list */ 705 dvb_frontend_add_event(fe, s); /* update event list */
@@ -1833,6 +1836,13 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
1833 return -EINVAL; 1836 return -EINVAL;
1834 1837
1835 /* 1838 /*
1839 * Initialize output parameters to match the values given by
1840 * the user. FE_SET_FRONTEND triggers an initial frontend event
1841 * with status = 0, which copies output parameters to userspace.
1842 */
1843 dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
1844
1845 /*
1836 * Be sure that the bandwidth will be filled for all 1846 * Be sure that the bandwidth will be filled for all
1837 * non-satellite systems, as tuners need to know what 1847 * non-satellite systems, as tuners need to know what
1838 * low pass/Nyquist half filter should be applied, in 1848 * low pass/Nyquist half filter should be applied, in
diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c
index 3b7b102f20a..482d249ca7f 100644
--- a/drivers/media/dvb/dvb-usb/it913x.c
+++ b/drivers/media/dvb/dvb-usb/it913x.c
@@ -238,12 +238,27 @@ static int it913x_read_reg(struct usb_device *udev, u32 reg)
238 238
239static u32 it913x_query(struct usb_device *udev, u8 pro) 239static u32 it913x_query(struct usb_device *udev, u8 pro)
240{ 240{
241 int ret; 241 int ret, i;
242 u8 data[4]; 242 u8 data[4];
243 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ, 243 u8 ver;
244 0x1222, 0, &data[0], 3); 244
245 for (i = 0; i < 5; i++) {
246 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ,
247 0x1222, 0, &data[0], 3);
248 ver = data[0];
249 if (ver > 0 && ver < 3)
250 break;
251 msleep(100);
252 }
245 253
246 it913x_config.chip_ver = data[0]; 254 if (ver < 1 || ver > 2) {
255 info("Failed to identify chip version applying 1");
256 it913x_config.chip_ver = 0x1;
257 it913x_config.chip_type = 0x9135;
258 return 0;
259 }
260
261 it913x_config.chip_ver = ver;
247 it913x_config.chip_type = (u16)(data[2] << 8) + data[1]; 262 it913x_config.chip_type = (u16)(data[2] << 8) + data[1];
248 263
249 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver, 264 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver,
@@ -660,30 +675,41 @@ static int it913x_download_firmware(struct usb_device *udev,
660 if ((packet_size > min_pkt) || (i == fw->size)) { 675 if ((packet_size > min_pkt) || (i == fw->size)) {
661 fw_data = (u8 *)(fw->data + pos); 676 fw_data = (u8 *)(fw->data + pos);
662 pos += packet_size; 677 pos += packet_size;
663 if (packet_size > 0) 678 if (packet_size > 0) {
664 ret |= it913x_io(udev, WRITE_DATA, 679 ret = it913x_io(udev, WRITE_DATA,
665 DEV_0, CMD_SCATTER_WRITE, 0, 680 DEV_0, CMD_SCATTER_WRITE, 0,
666 0, fw_data, packet_size); 681 0, fw_data, packet_size);
682 if (ret < 0)
683 break;
684 }
667 udelay(1000); 685 udelay(1000);
668 } 686 }
669 } 687 }
670 i++; 688 i++;
671 } 689 }
672 690
673 ret |= it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
674
675 msleep(100);
676
677 if (ret < 0) 691 if (ret < 0)
678 info("FRM Firmware Download Failed (%04x)" , ret); 692 info("FRM Firmware Download Failed (%d)" , ret);
679 else 693 else
680 info("FRM Firmware Download Completed - Resetting Device"); 694 info("FRM Firmware Download Completed - Resetting Device");
681 695
682 ret |= it913x_return_status(udev); 696 msleep(30);
697
698 ret = it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
699 if (ret < 0)
700 info("FRM Device not responding to reboot");
701
702 ret = it913x_return_status(udev);
703 if (ret == 0) {
704 info("FRM Failed to reboot device");
705 return -ENODEV;
706 }
683 707
684 msleep(30); 708 msleep(30);
685 709
686 ret |= it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400); 710 ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400);
711
712 msleep(30);
687 713
688 /* Tuner function */ 714 /* Tuner function */
689 if (it913x_config.dual_mode) 715 if (it913x_config.dual_mode)
@@ -901,5 +927,5 @@ module_usb_driver(it913x_driver);
901 927
902MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 928MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
903MODULE_DESCRIPTION("it913x USB 2 Driver"); 929MODULE_DESCRIPTION("it913x USB 2 Driver");
904MODULE_VERSION("1.27"); 930MODULE_VERSION("1.28");
905MODULE_LICENSE("GPL"); 931MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 5452beef8e1..989e556913e 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1763,13 +1763,13 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1763 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n"); 1763 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n");
1764 if (iarg > AUDIO_STEREO_SWAPPED) 1764 if (iarg > AUDIO_STEREO_SWAPPED)
1765 return -EINVAL; 1765 return -EINVAL;
1766 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg); 1766 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg + 1);
1767 1767
1768 case AUDIO_BILINGUAL_CHANNEL_SELECT: 1768 case AUDIO_BILINGUAL_CHANNEL_SELECT:
1769 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n"); 1769 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n");
1770 if (iarg > AUDIO_STEREO_SWAPPED) 1770 if (iarg > AUDIO_STEREO_SWAPPED)
1771 return -EINVAL; 1771 return -EINVAL;
1772 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg); 1772 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg + 1);
1773 1773
1774 default: 1774 default:
1775 return -EINVAL; 1775 return -EINVAL;
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 4a44f9a1bae..b76b0ac0958 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -468,22 +468,30 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
468 spin_unlock_irqrestore(&stream->clock.lock, flags); 468 spin_unlock_irqrestore(&stream->clock.lock, flags);
469} 469}
470 470
471static int uvc_video_clock_init(struct uvc_streaming *stream) 471static void uvc_video_clock_reset(struct uvc_streaming *stream)
472{ 472{
473 struct uvc_clock *clock = &stream->clock; 473 struct uvc_clock *clock = &stream->clock;
474 474
475 spin_lock_init(&clock->lock);
476 clock->head = 0; 475 clock->head = 0;
477 clock->count = 0; 476 clock->count = 0;
478 clock->size = 32;
479 clock->last_sof = -1; 477 clock->last_sof = -1;
480 clock->sof_offset = -1; 478 clock->sof_offset = -1;
479}
480
481static int uvc_video_clock_init(struct uvc_streaming *stream)
482{
483 struct uvc_clock *clock = &stream->clock;
484
485 spin_lock_init(&clock->lock);
486 clock->size = 32;
481 487
482 clock->samples = kmalloc(clock->size * sizeof(*clock->samples), 488 clock->samples = kmalloc(clock->size * sizeof(*clock->samples),
483 GFP_KERNEL); 489 GFP_KERNEL);
484 if (clock->samples == NULL) 490 if (clock->samples == NULL)
485 return -ENOMEM; 491 return -ENOMEM;
486 492
493 uvc_video_clock_reset(stream);
494
487 return 0; 495 return 0;
488} 496}
489 497
@@ -1424,8 +1432,6 @@ static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers)
1424 1432
1425 if (free_buffers) 1433 if (free_buffers)
1426 uvc_free_urb_buffers(stream); 1434 uvc_free_urb_buffers(stream);
1427
1428 uvc_video_clock_cleanup(stream);
1429} 1435}
1430 1436
1431/* 1437/*
@@ -1555,10 +1561,6 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
1555 1561
1556 uvc_video_stats_start(stream); 1562 uvc_video_stats_start(stream);
1557 1563
1558 ret = uvc_video_clock_init(stream);
1559 if (ret < 0)
1560 return ret;
1561
1562 if (intf->num_altsetting > 1) { 1564 if (intf->num_altsetting > 1) {
1563 struct usb_host_endpoint *best_ep = NULL; 1565 struct usb_host_endpoint *best_ep = NULL;
1564 unsigned int best_psize = 3 * 1024; 1566 unsigned int best_psize = 3 * 1024;
@@ -1683,6 +1685,8 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
1683 1685
1684 stream->frozen = 0; 1686 stream->frozen = 0;
1685 1687
1688 uvc_video_clock_reset(stream);
1689
1686 ret = uvc_commit_video(stream, &stream->ctrl); 1690 ret = uvc_commit_video(stream, &stream->ctrl);
1687 if (ret < 0) { 1691 if (ret < 0) {
1688 uvc_queue_enable(&stream->queue, 0); 1692 uvc_queue_enable(&stream->queue, 0);
@@ -1819,25 +1823,35 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1819 uvc_uninit_video(stream, 1); 1823 uvc_uninit_video(stream, 1);
1820 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1824 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1821 uvc_queue_enable(&stream->queue, 0); 1825 uvc_queue_enable(&stream->queue, 0);
1826 uvc_video_clock_cleanup(stream);
1822 return 0; 1827 return 0;
1823 } 1828 }
1824 1829
1825 ret = uvc_queue_enable(&stream->queue, 1); 1830 ret = uvc_video_clock_init(stream);
1826 if (ret < 0) 1831 if (ret < 0)
1827 return ret; 1832 return ret;
1828 1833
1834 ret = uvc_queue_enable(&stream->queue, 1);
1835 if (ret < 0)
1836 goto error_queue;
1837
1829 /* Commit the streaming parameters. */ 1838 /* Commit the streaming parameters. */
1830 ret = uvc_commit_video(stream, &stream->ctrl); 1839 ret = uvc_commit_video(stream, &stream->ctrl);
1831 if (ret < 0) { 1840 if (ret < 0)
1832 uvc_queue_enable(&stream->queue, 0); 1841 goto error_commit;
1833 return ret;
1834 }
1835 1842
1836 ret = uvc_init_video(stream, GFP_KERNEL); 1843 ret = uvc_init_video(stream, GFP_KERNEL);
1837 if (ret < 0) { 1844 if (ret < 0)
1838 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1845 goto error_video;
1839 uvc_queue_enable(&stream->queue, 0); 1846
1840 } 1847 return 0;
1848
1849error_video:
1850 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1851error_commit:
1852 uvc_queue_enable(&stream->queue, 0);
1853error_queue:
1854 uvc_video_clock_cleanup(stream);
1841 1855
1842 return ret; 1856 return ret;
1843} 1857}
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index eed213a5c8c..b1809650b7a 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1623,24 +1623,6 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
1623 return ret; 1623 return ret;
1624} 1624}
1625 1625
1626static int
1627mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
1628{
1629 int err;
1630
1631 mmc_claim_host(card->host);
1632 err = mmc_set_blocklen(card, 512);
1633 mmc_release_host(card->host);
1634
1635 if (err) {
1636 pr_err("%s: unable to set block size to 512: %d\n",
1637 md->disk->disk_name, err);
1638 return -EINVAL;
1639 }
1640
1641 return 0;
1642}
1643
1644static void mmc_blk_remove_req(struct mmc_blk_data *md) 1626static void mmc_blk_remove_req(struct mmc_blk_data *md)
1645{ 1627{
1646 struct mmc_card *card; 1628 struct mmc_card *card;
@@ -1768,7 +1750,6 @@ static const struct mmc_fixup blk_fixups[] =
1768static int mmc_blk_probe(struct mmc_card *card) 1750static int mmc_blk_probe(struct mmc_card *card)
1769{ 1751{
1770 struct mmc_blk_data *md, *part_md; 1752 struct mmc_blk_data *md, *part_md;
1771 int err;
1772 char cap_str[10]; 1753 char cap_str[10];
1773 1754
1774 /* 1755 /*
@@ -1781,10 +1762,6 @@ static int mmc_blk_probe(struct mmc_card *card)
1781 if (IS_ERR(md)) 1762 if (IS_ERR(md))
1782 return PTR_ERR(md); 1763 return PTR_ERR(md);
1783 1764
1784 err = mmc_blk_set_blksize(md, card);
1785 if (err)
1786 goto out;
1787
1788 string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2, 1765 string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
1789 cap_str, sizeof(cap_str)); 1766 cap_str, sizeof(cap_str));
1790 pr_info("%s: %s %s %s %s\n", 1767 pr_info("%s: %s %s %s %s\n",
@@ -1809,7 +1786,7 @@ static int mmc_blk_probe(struct mmc_card *card)
1809 out: 1786 out:
1810 mmc_blk_remove_parts(card, md); 1787 mmc_blk_remove_parts(card, md);
1811 mmc_blk_remove_req(md); 1788 mmc_blk_remove_req(md);
1812 return err; 1789 return 0;
1813} 1790}
1814 1791
1815static void mmc_blk_remove(struct mmc_card *card) 1792static void mmc_blk_remove(struct mmc_card *card)
@@ -1845,8 +1822,6 @@ static int mmc_blk_resume(struct mmc_card *card)
1845 struct mmc_blk_data *md = mmc_get_drvdata(card); 1822 struct mmc_blk_data *md = mmc_get_drvdata(card);
1846 1823
1847 if (md) { 1824 if (md) {
1848 mmc_blk_set_blksize(md, card);
1849
1850 /* 1825 /*
1851 * Resume involves the card going into idle state, 1826 * Resume involves the card going into idle state,
1852 * so current partition is always the main one. 1827 * so current partition is always the main one.
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 5d011a39dff..3f606068d55 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -267,6 +267,15 @@ int mmc_add_card(struct mmc_card *card)
267{ 267{
268 int ret; 268 int ret;
269 const char *type; 269 const char *type;
270 const char *uhs_bus_speed_mode = "";
271 static const char *const uhs_speeds[] = {
272 [UHS_SDR12_BUS_SPEED] = "SDR12 ",
273 [UHS_SDR25_BUS_SPEED] = "SDR25 ",
274 [UHS_SDR50_BUS_SPEED] = "SDR50 ",
275 [UHS_SDR104_BUS_SPEED] = "SDR104 ",
276 [UHS_DDR50_BUS_SPEED] = "DDR50 ",
277 };
278
270 279
271 dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); 280 dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca);
272 281
@@ -296,6 +305,10 @@ int mmc_add_card(struct mmc_card *card)
296 break; 305 break;
297 } 306 }
298 307
308 if (mmc_sd_card_uhs(card) &&
309 (card->sd_bus_speed < ARRAY_SIZE(uhs_speeds)))
310 uhs_bus_speed_mode = uhs_speeds[card->sd_bus_speed];
311
299 if (mmc_host_is_spi(card->host)) { 312 if (mmc_host_is_spi(card->host)) {
300 pr_info("%s: new %s%s%s card on SPI\n", 313 pr_info("%s: new %s%s%s card on SPI\n",
301 mmc_hostname(card->host), 314 mmc_hostname(card->host),
@@ -303,13 +316,13 @@ int mmc_add_card(struct mmc_card *card)
303 mmc_card_ddr_mode(card) ? "DDR " : "", 316 mmc_card_ddr_mode(card) ? "DDR " : "",
304 type); 317 type);
305 } else { 318 } else {
306 pr_info("%s: new %s%s%s%s card at address %04x\n", 319 pr_info("%s: new %s%s%s%s%s card at address %04x\n",
307 mmc_hostname(card->host), 320 mmc_hostname(card->host),
308 mmc_card_uhs(card) ? "ultra high speed " : 321 mmc_card_uhs(card) ? "ultra high speed " :
309 (mmc_card_highspeed(card) ? "high speed " : ""), 322 (mmc_card_highspeed(card) ? "high speed " : ""),
310 (mmc_card_hs200(card) ? "HS200 " : ""), 323 (mmc_card_hs200(card) ? "HS200 " : ""),
311 mmc_card_ddr_mode(card) ? "DDR " : "", 324 mmc_card_ddr_mode(card) ? "DDR " : "",
312 type, card->rca); 325 uhs_bus_speed_mode, type, card->rca);
313 } 326 }
314 327
315#ifdef CONFIG_DEBUG_FS 328#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 14f262e9246..7474c47b9c0 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -527,10 +527,14 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
527 527
528 if (data->flags & MMC_DATA_WRITE) 528 if (data->flags & MMC_DATA_WRITE)
529 /* 529 /*
530 * The limit is really 250 ms, but that is 530 * The MMC spec "It is strongly recommended
531 * insufficient for some crappy cards. 531 * for hosts to implement more than 500ms
532 * timeout value even if the card indicates
533 * the 250ms maximum busy length." Even the
534 * previous value of 300ms is known to be
535 * insufficient for some cards.
532 */ 536 */
533 limit_us = 300000; 537 limit_us = 3000000;
534 else 538 else
535 limit_us = 100000; 539 limit_us = 100000;
536 540
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 02914d609a9..54df5adc041 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card,
695 else if (host->ios.clock <= 200000000) 695 else if (host->ios.clock <= 200000000)
696 index = EXT_CSD_PWR_CL_200_195; 696 index = EXT_CSD_PWR_CL_200_195;
697 break; 697 break;
698 case MMC_VDD_27_28:
699 case MMC_VDD_28_29:
700 case MMC_VDD_29_30:
701 case MMC_VDD_30_31:
702 case MMC_VDD_31_32:
698 case MMC_VDD_32_33: 703 case MMC_VDD_32_33:
699 case MMC_VDD_33_34: 704 case MMC_VDD_33_34:
700 case MMC_VDD_34_35: 705 case MMC_VDD_34_35:
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1111 ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? 1116 ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?
1112 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; 1117 EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
1113 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); 1118 err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
1114 if (err) { 1119 if (err)
1115 pr_err("%s: power class selection to bus width %d failed\n", 1120 pr_warning("%s: power class selection to bus width %d"
1116 mmc_hostname(card->host), 1 << bus_width); 1121 " failed\n", mmc_hostname(card->host),
1117 goto err; 1122 1 << bus_width);
1118 }
1119 } 1123 }
1120 1124
1121 /* 1125 /*
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1147 err = mmc_select_powerclass(card, ext_csd_bits[idx][0], 1151 err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
1148 ext_csd); 1152 ext_csd);
1149 if (err) 1153 if (err)
1150 pr_err("%s: power class selection to " 1154 pr_warning("%s: power class selection to "
1151 "bus width %d failed\n", 1155 "bus width %d failed\n",
1152 mmc_hostname(card->host), 1156 mmc_hostname(card->host),
1153 1 << bus_width); 1157 1 << bus_width);
1154 1158
1155 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1159 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1156 EXT_CSD_BUS_WIDTH, 1160 EXT_CSD_BUS_WIDTH,
@@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1178 err = mmc_select_powerclass(card, ext_csd_bits[idx][1], 1182 err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
1179 ext_csd); 1183 ext_csd);
1180 if (err) 1184 if (err)
1181 pr_err("%s: power class selection to " 1185 pr_warning("%s: power class selection to "
1182 "bus width %d ddr %d failed\n", 1186 "bus width %d ddr %d failed\n",
1183 mmc_hostname(card->host), 1187 mmc_hostname(card->host),
1184 1 << bus_width, ddr); 1188 1 << bus_width, ddr);
1185 1189
1186 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1190 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1187 EXT_CSD_BUS_WIDTH, 1191 EXT_CSD_BUS_WIDTH,
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 40989e6bb53..236842ec955 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -192,9 +192,15 @@ static int sdio_bus_remove(struct device *dev)
192 return ret; 192 return ret;
193} 193}
194 194
195#ifdef CONFIG_PM_RUNTIME 195#ifdef CONFIG_PM
196
197static int pm_no_operation(struct device *dev)
198{
199 return 0;
200}
196 201
197static const struct dev_pm_ops sdio_bus_pm_ops = { 202static const struct dev_pm_ops sdio_bus_pm_ops = {
203 SET_SYSTEM_SLEEP_PM_OPS(pm_no_operation, pm_no_operation)
198 SET_RUNTIME_PM_OPS( 204 SET_RUNTIME_PM_OPS(
199 pm_generic_runtime_suspend, 205 pm_generic_runtime_suspend,
200 pm_generic_runtime_resume, 206 pm_generic_runtime_resume,
@@ -204,11 +210,11 @@ static const struct dev_pm_ops sdio_bus_pm_ops = {
204 210
205#define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops) 211#define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops)
206 212
207#else /* !CONFIG_PM_RUNTIME */ 213#else /* !CONFIG_PM */
208 214
209#define SDIO_PM_OPS_PTR NULL 215#define SDIO_PM_OPS_PTR NULL
210 216
211#endif /* !CONFIG_PM_RUNTIME */ 217#endif /* !CONFIG_PM */
212 218
213static struct bus_type sdio_bus_type = { 219static struct bus_type sdio_bus_type = {
214 .name = "sdio", 220 .name = "sdio",
diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h
index 000b3ad0f5c..787aba1682b 100644
--- a/drivers/mmc/host/atmel-mci-regs.h
+++ b/drivers/mmc/host/atmel-mci-regs.h
@@ -31,6 +31,7 @@
31# define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ 31# define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */
32# define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ 32# define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */
33# define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ 33# define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */
34# define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */
34#define ATMCI_DTOR 0x0008 /* Data Timeout */ 35#define ATMCI_DTOR 0x0008 /* Data Timeout */
35# define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ 36# define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */
36# define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ 37# define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 9819dc09ce0..e94476beca1 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -77,6 +77,7 @@ struct atmel_mci_caps {
77 bool has_cstor_reg; 77 bool has_cstor_reg;
78 bool has_highspeed; 78 bool has_highspeed;
79 bool has_rwproof; 79 bool has_rwproof;
80 bool has_odd_clk_div;
80}; 81};
81 82
82struct atmel_mci_dma { 83struct atmel_mci_dma {
@@ -482,7 +483,14 @@ err:
482static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, 483static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host,
483 unsigned int ns) 484 unsigned int ns)
484{ 485{
485 return (ns * (host->bus_hz / 1000000) + 999) / 1000; 486 /*
487 * It is easier here to use us instead of ns for the timeout,
488 * it prevents from overflows during calculation.
489 */
490 unsigned int us = DIV_ROUND_UP(ns, 1000);
491
492 /* Maximum clock frequency is host->bus_hz/2 */
493 return us * (DIV_ROUND_UP(host->bus_hz, 2000000));
486} 494}
487 495
488static void atmci_set_timeout(struct atmel_mci *host, 496static void atmci_set_timeout(struct atmel_mci *host,
@@ -1127,16 +1135,27 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1127 } 1135 }
1128 1136
1129 /* Calculate clock divider */ 1137 /* Calculate clock divider */
1130 clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; 1138 if (host->caps.has_odd_clk_div) {
1131 if (clkdiv > 255) { 1139 clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
1132 dev_warn(&mmc->class_dev, 1140 if (clkdiv > 511) {
1133 "clock %u too slow; using %lu\n", 1141 dev_warn(&mmc->class_dev,
1134 clock_min, host->bus_hz / (2 * 256)); 1142 "clock %u too slow; using %lu\n",
1135 clkdiv = 255; 1143 clock_min, host->bus_hz / (511 + 2));
1144 clkdiv = 511;
1145 }
1146 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv >> 1)
1147 | ATMCI_MR_CLKODD(clkdiv & 1);
1148 } else {
1149 clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1;
1150 if (clkdiv > 255) {
1151 dev_warn(&mmc->class_dev,
1152 "clock %u too slow; using %lu\n",
1153 clock_min, host->bus_hz / (2 * 256));
1154 clkdiv = 255;
1155 }
1156 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv);
1136 } 1157 }
1137 1158
1138 host->mode_reg = ATMCI_MR_CLKDIV(clkdiv);
1139
1140 /* 1159 /*
1141 * WRPROOF and RDPROOF prevent overruns/underruns by 1160 * WRPROOF and RDPROOF prevent overruns/underruns by
1142 * stopping the clock when the FIFO is full/empty. 1161 * stopping the clock when the FIFO is full/empty.
@@ -2007,35 +2026,35 @@ static void __init atmci_get_cap(struct atmel_mci *host)
2007 "version: 0x%x\n", version); 2026 "version: 0x%x\n", version);
2008 2027
2009 host->caps.has_dma = 0; 2028 host->caps.has_dma = 0;
2010 host->caps.has_pdc = 0; 2029 host->caps.has_pdc = 1;
2011 host->caps.has_cfg_reg = 0; 2030 host->caps.has_cfg_reg = 0;
2012 host->caps.has_cstor_reg = 0; 2031 host->caps.has_cstor_reg = 0;
2013 host->caps.has_highspeed = 0; 2032 host->caps.has_highspeed = 0;
2014 host->caps.has_rwproof = 0; 2033 host->caps.has_rwproof = 0;
2034 host->caps.has_odd_clk_div = 0;
2015 2035
2016 /* keep only major version number */ 2036 /* keep only major version number */
2017 switch (version & 0xf00) { 2037 switch (version & 0xf00) {
2018 case 0x100:
2019 case 0x200:
2020 host->caps.has_pdc = 1;
2021 host->caps.has_rwproof = 1;
2022 break;
2023 case 0x300:
2024 case 0x400:
2025 case 0x500: 2038 case 0x500:
2039 host->caps.has_odd_clk_div = 1;
2040 case 0x400:
2041 case 0x300:
2026#ifdef CONFIG_AT_HDMAC 2042#ifdef CONFIG_AT_HDMAC
2027 host->caps.has_dma = 1; 2043 host->caps.has_dma = 1;
2028#else 2044#else
2029 host->caps.has_dma = 0;
2030 dev_info(&host->pdev->dev, 2045 dev_info(&host->pdev->dev,
2031 "has dma capability but dma engine is not selected, then use pio\n"); 2046 "has dma capability but dma engine is not selected, then use pio\n");
2032#endif 2047#endif
2048 host->caps.has_pdc = 0;
2033 host->caps.has_cfg_reg = 1; 2049 host->caps.has_cfg_reg = 1;
2034 host->caps.has_cstor_reg = 1; 2050 host->caps.has_cstor_reg = 1;
2035 host->caps.has_highspeed = 1; 2051 host->caps.has_highspeed = 1;
2052 case 0x200:
2036 host->caps.has_rwproof = 1; 2053 host->caps.has_rwproof = 1;
2054 case 0x100:
2037 break; 2055 break;
2038 default: 2056 default:
2057 host->caps.has_pdc = 0;
2039 dev_warn(&host->pdev->dev, 2058 dev_warn(&host->pdev->dev,
2040 "Unmanaged mci version, set minimum capabilities\n"); 2059 "Unmanaged mci version, set minimum capabilities\n");
2041 break; 2060 break;
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 47adb161d3a..5c2b1c10af9 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1785,7 +1785,7 @@ static inline struct omap_mmc_platform_data
1785} 1785}
1786#endif 1786#endif
1787 1787
1788static int __init omap_hsmmc_probe(struct platform_device *pdev) 1788static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
1789{ 1789{
1790 struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; 1790 struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
1791 struct mmc_host *mmc; 1791 struct mmc_host *mmc;
@@ -1818,8 +1818,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1818 if (res == NULL || irq < 0) 1818 if (res == NULL || irq < 0)
1819 return -ENXIO; 1819 return -ENXIO;
1820 1820
1821 res->start += pdata->reg_offset;
1822 res->end += pdata->reg_offset;
1823 res = request_mem_region(res->start, resource_size(res), pdev->name); 1821 res = request_mem_region(res->start, resource_size(res), pdev->name);
1824 if (res == NULL) 1822 if (res == NULL)
1825 return -EBUSY; 1823 return -EBUSY;
@@ -1843,7 +1841,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1843 host->dma_ch = -1; 1841 host->dma_ch = -1;
1844 host->irq = irq; 1842 host->irq = irq;
1845 host->slot_id = 0; 1843 host->slot_id = 0;
1846 host->mapbase = res->start; 1844 host->mapbase = res->start + pdata->reg_offset;
1847 host->base = ioremap(host->mapbase, SZ_4K); 1845 host->base = ioremap(host->mapbase, SZ_4K);
1848 host->power_mode = MMC_POWER_OFF; 1846 host->power_mode = MMC_POWER_OFF;
1849 host->next_data.cookie = 1; 1847 host->next_data.cookie = 1;
@@ -1875,8 +1873,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1875 goto err1; 1873 goto err1;
1876 } 1874 }
1877 1875
1878 omap_hsmmc_context_save(host);
1879
1880 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { 1876 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
1881 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); 1877 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
1882 mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; 1878 mmc->caps2 |= MMC_CAP2_NO_MULTI_READ;
@@ -1887,6 +1883,8 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
1887 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); 1883 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY);
1888 pm_runtime_use_autosuspend(host->dev); 1884 pm_runtime_use_autosuspend(host->dev);
1889 1885
1886 omap_hsmmc_context_save(host);
1887
1890 if (cpu_is_omap2430()) { 1888 if (cpu_is_omap2430()) {
1891 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); 1889 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
1892 /* 1890 /*
@@ -2018,8 +2016,7 @@ err_reg:
2018err_irq_cd_init: 2016err_irq_cd_init:
2019 free_irq(host->irq, host); 2017 free_irq(host->irq, host);
2020err_irq: 2018err_irq:
2021 pm_runtime_mark_last_busy(host->dev); 2019 pm_runtime_put_sync(host->dev);
2022 pm_runtime_put_autosuspend(host->dev);
2023 pm_runtime_disable(host->dev); 2020 pm_runtime_disable(host->dev);
2024 clk_put(host->fclk); 2021 clk_put(host->fclk);
2025 if (host->got_dbclk) { 2022 if (host->got_dbclk) {
@@ -2037,35 +2034,33 @@ err:
2037 return ret; 2034 return ret;
2038} 2035}
2039 2036
2040static int omap_hsmmc_remove(struct platform_device *pdev) 2037static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
2041{ 2038{
2042 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); 2039 struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
2043 struct resource *res; 2040 struct resource *res;
2044 2041
2045 if (host) { 2042 pm_runtime_get_sync(host->dev);
2046 pm_runtime_get_sync(host->dev); 2043 mmc_remove_host(host->mmc);
2047 mmc_remove_host(host->mmc); 2044 if (host->use_reg)
2048 if (host->use_reg) 2045 omap_hsmmc_reg_put(host);
2049 omap_hsmmc_reg_put(host); 2046 if (host->pdata->cleanup)
2050 if (host->pdata->cleanup) 2047 host->pdata->cleanup(&pdev->dev);
2051 host->pdata->cleanup(&pdev->dev); 2048 free_irq(host->irq, host);
2052 free_irq(host->irq, host); 2049 if (mmc_slot(host).card_detect_irq)
2053 if (mmc_slot(host).card_detect_irq) 2050 free_irq(mmc_slot(host).card_detect_irq, host);
2054 free_irq(mmc_slot(host).card_detect_irq, host);
2055
2056 pm_runtime_put_sync(host->dev);
2057 pm_runtime_disable(host->dev);
2058 clk_put(host->fclk);
2059 if (host->got_dbclk) {
2060 clk_disable(host->dbclk);
2061 clk_put(host->dbclk);
2062 }
2063 2051
2064 mmc_free_host(host->mmc); 2052 pm_runtime_put_sync(host->dev);
2065 iounmap(host->base); 2053 pm_runtime_disable(host->dev);
2066 omap_hsmmc_gpio_free(pdev->dev.platform_data); 2054 clk_put(host->fclk);
2055 if (host->got_dbclk) {
2056 clk_disable(host->dbclk);
2057 clk_put(host->dbclk);
2067 } 2058 }
2068 2059
2060 mmc_free_host(host->mmc);
2061 iounmap(host->base);
2062 omap_hsmmc_gpio_free(pdev->dev.platform_data);
2063
2069 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2064 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2070 if (res) 2065 if (res)
2071 release_mem_region(res->start, resource_size(res)); 2066 release_mem_region(res->start, resource_size(res));
@@ -2078,49 +2073,45 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
2078static int omap_hsmmc_suspend(struct device *dev) 2073static int omap_hsmmc_suspend(struct device *dev)
2079{ 2074{
2080 int ret = 0; 2075 int ret = 0;
2081 struct platform_device *pdev = to_platform_device(dev); 2076 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2082 struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
2083 2077
2084 if (host && host->suspended) 2078 if (!host)
2085 return 0; 2079 return 0;
2086 2080
2087 if (host) { 2081 if (host && host->suspended)
2088 pm_runtime_get_sync(host->dev); 2082 return 0;
2089 host->suspended = 1;
2090 if (host->pdata->suspend) {
2091 ret = host->pdata->suspend(&pdev->dev,
2092 host->slot_id);
2093 if (ret) {
2094 dev_dbg(mmc_dev(host->mmc),
2095 "Unable to handle MMC board"
2096 " level suspend\n");
2097 host->suspended = 0;
2098 return ret;
2099 }
2100 }
2101 ret = mmc_suspend_host(host->mmc);
2102 2083
2084 pm_runtime_get_sync(host->dev);
2085 host->suspended = 1;
2086 if (host->pdata->suspend) {
2087 ret = host->pdata->suspend(dev, host->slot_id);
2103 if (ret) { 2088 if (ret) {
2089 dev_dbg(dev, "Unable to handle MMC board"
2090 " level suspend\n");
2104 host->suspended = 0; 2091 host->suspended = 0;
2105 if (host->pdata->resume) { 2092 return ret;
2106 ret = host->pdata->resume(&pdev->dev,
2107 host->slot_id);
2108 if (ret)
2109 dev_dbg(mmc_dev(host->mmc),
2110 "Unmask interrupt failed\n");
2111 }
2112 goto err;
2113 } 2093 }
2094 }
2095 ret = mmc_suspend_host(host->mmc);
2114 2096
2115 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { 2097 if (ret) {
2116 omap_hsmmc_disable_irq(host); 2098 host->suspended = 0;
2117 OMAP_HSMMC_WRITE(host->base, HCTL, 2099 if (host->pdata->resume) {
2118 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); 2100 ret = host->pdata->resume(dev, host->slot_id);
2101 if (ret)
2102 dev_dbg(dev, "Unmask interrupt failed\n");
2119 } 2103 }
2120 if (host->got_dbclk) 2104 goto err;
2121 clk_disable(host->dbclk); 2105 }
2122 2106
2107 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
2108 omap_hsmmc_disable_irq(host);
2109 OMAP_HSMMC_WRITE(host->base, HCTL,
2110 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
2123 } 2111 }
2112
2113 if (host->got_dbclk)
2114 clk_disable(host->dbclk);
2124err: 2115err:
2125 pm_runtime_put_sync(host->dev); 2116 pm_runtime_put_sync(host->dev);
2126 return ret; 2117 return ret;
@@ -2130,38 +2121,37 @@ err:
2130static int omap_hsmmc_resume(struct device *dev) 2121static int omap_hsmmc_resume(struct device *dev)
2131{ 2122{
2132 int ret = 0; 2123 int ret = 0;
2133 struct platform_device *pdev = to_platform_device(dev); 2124 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2134 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); 2125
2126 if (!host)
2127 return 0;
2135 2128
2136 if (host && !host->suspended) 2129 if (host && !host->suspended)
2137 return 0; 2130 return 0;
2138 2131
2139 if (host) { 2132 pm_runtime_get_sync(host->dev);
2140 pm_runtime_get_sync(host->dev);
2141 2133
2142 if (host->got_dbclk) 2134 if (host->got_dbclk)
2143 clk_enable(host->dbclk); 2135 clk_enable(host->dbclk);
2144 2136
2145 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) 2137 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
2146 omap_hsmmc_conf_bus_power(host); 2138 omap_hsmmc_conf_bus_power(host);
2147 2139
2148 if (host->pdata->resume) { 2140 if (host->pdata->resume) {
2149 ret = host->pdata->resume(&pdev->dev, host->slot_id); 2141 ret = host->pdata->resume(dev, host->slot_id);
2150 if (ret) 2142 if (ret)
2151 dev_dbg(mmc_dev(host->mmc), 2143 dev_dbg(dev, "Unmask interrupt failed\n");
2152 "Unmask interrupt failed\n"); 2144 }
2153 }
2154 2145
2155 omap_hsmmc_protect_card(host); 2146 omap_hsmmc_protect_card(host);
2156 2147
2157 /* Notify the core to resume the host */ 2148 /* Notify the core to resume the host */
2158 ret = mmc_resume_host(host->mmc); 2149 ret = mmc_resume_host(host->mmc);
2159 if (ret == 0) 2150 if (ret == 0)
2160 host->suspended = 0; 2151 host->suspended = 0;
2161 2152
2162 pm_runtime_mark_last_busy(host->dev); 2153 pm_runtime_mark_last_busy(host->dev);
2163 pm_runtime_put_autosuspend(host->dev); 2154 pm_runtime_put_autosuspend(host->dev);
2164 }
2165 2155
2166 return ret; 2156 return ret;
2167 2157
@@ -2178,7 +2168,7 @@ static int omap_hsmmc_runtime_suspend(struct device *dev)
2178 2168
2179 host = platform_get_drvdata(to_platform_device(dev)); 2169 host = platform_get_drvdata(to_platform_device(dev));
2180 omap_hsmmc_context_save(host); 2170 omap_hsmmc_context_save(host);
2181 dev_dbg(mmc_dev(host->mmc), "disabled\n"); 2171 dev_dbg(dev, "disabled\n");
2182 2172
2183 return 0; 2173 return 0;
2184} 2174}
@@ -2189,7 +2179,7 @@ static int omap_hsmmc_runtime_resume(struct device *dev)
2189 2179
2190 host = platform_get_drvdata(to_platform_device(dev)); 2180 host = platform_get_drvdata(to_platform_device(dev));
2191 omap_hsmmc_context_restore(host); 2181 omap_hsmmc_context_restore(host);
2192 dev_dbg(mmc_dev(host->mmc), "enabled\n"); 2182 dev_dbg(dev, "enabled\n");
2193 2183
2194 return 0; 2184 return 0;
2195} 2185}
@@ -2202,7 +2192,8 @@ static struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
2202}; 2192};
2203 2193
2204static struct platform_driver omap_hsmmc_driver = { 2194static struct platform_driver omap_hsmmc_driver = {
2205 .remove = omap_hsmmc_remove, 2195 .probe = omap_hsmmc_probe,
2196 .remove = __devexit_p(omap_hsmmc_remove),
2206 .driver = { 2197 .driver = {
2207 .name = DRIVER_NAME, 2198 .name = DRIVER_NAME,
2208 .owner = THIS_MODULE, 2199 .owner = THIS_MODULE,
@@ -2211,21 +2202,7 @@ static struct platform_driver omap_hsmmc_driver = {
2211 }, 2202 },
2212}; 2203};
2213 2204
2214static int __init omap_hsmmc_init(void) 2205module_platform_driver(omap_hsmmc_driver);
2215{
2216 /* Register the MMC driver */
2217 return platform_driver_probe(&omap_hsmmc_driver, omap_hsmmc_probe);
2218}
2219
2220static void __exit omap_hsmmc_cleanup(void)
2221{
2222 /* Unregister MMC driver */
2223 platform_driver_unregister(&omap_hsmmc_driver);
2224}
2225
2226module_init(omap_hsmmc_init);
2227module_exit(omap_hsmmc_cleanup);
2228
2229MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver"); 2206MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
2230MODULE_LICENSE("GPL"); 2207MODULE_LICENSE("GPL");
2231MODULE_ALIAS("platform:" DRIVER_NAME); 2208MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 46fd1fd1b60..177f697b583 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/module.h>
23#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
24 25
25#include "sdhci-pltfm.h" 26#include "sdhci-pltfm.h"
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index fbbebe251e0..69ef0beae10 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -1418,8 +1418,6 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
1418 1418
1419 slots = chip->num_slots; /* Quirk may have changed this */ 1419 slots = chip->num_slots; /* Quirk may have changed this */
1420 1420
1421 pci_enable_msi(pdev);
1422
1423 for (i = 0; i < slots; i++) { 1421 for (i = 0; i < slots; i++) {
1424 slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i); 1422 slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i);
1425 if (IS_ERR(slot)) { 1423 if (IS_ERR(slot)) {
@@ -1438,8 +1436,6 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
1438 return 0; 1436 return 0;
1439 1437
1440free: 1438free:
1441 pci_disable_msi(pdev);
1442
1443 pci_set_drvdata(pdev, NULL); 1439 pci_set_drvdata(pdev, NULL);
1444 kfree(chip); 1440 kfree(chip);
1445 1441
@@ -1462,8 +1458,6 @@ static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
1462 for (i = 0; i < chip->num_slots; i++) 1458 for (i = 0; i < chip->num_slots; i++)
1463 sdhci_pci_remove_slot(chip->slots[i]); 1459 sdhci_pci_remove_slot(chip->slots[i]);
1464 1460
1465 pci_disable_msi(pdev);
1466
1467 pci_set_drvdata(pdev, NULL); 1461 pci_set_drvdata(pdev, NULL);
1468 kfree(chip); 1462 kfree(chip);
1469 } 1463 }
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index b19e7d435f8..55a164fcaa1 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -20,6 +20,10 @@
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h>
24#include <linux/of_gpio.h>
25#include <linux/pm.h>
26#include <linux/pm_runtime.h>
23 27
24#include <linux/mmc/host.h> 28#include <linux/mmc/host.h>
25 29
@@ -53,6 +57,18 @@ struct sdhci_s3c {
53 struct clk *clk_bus[MAX_BUS_CLK]; 57 struct clk *clk_bus[MAX_BUS_CLK];
54}; 58};
55 59
60/**
61 * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
62 * @sdhci_quirks: sdhci host specific quirks.
63 *
64 * Specifies platform specific configuration of sdhci controller.
65 * Note: A structure for driver specific platform data is used for future
66 * expansion of its usage.
67 */
68struct sdhci_s3c_drv_data {
69 unsigned int sdhci_quirks;
70};
71
56static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host) 72static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
57{ 73{
58 return sdhci_priv(host); 74 return sdhci_priv(host);
@@ -132,10 +148,10 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
132 return UINT_MAX; 148 return UINT_MAX;
133 149
134 /* 150 /*
135 * Clock divider's step is different as 1 from that of host controller 151 * If controller uses a non-standard clock division, find the best clock
136 * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL. 152 * speed possible with selected clock source and skip the division.
137 */ 153 */
138 if (ourhost->pdata->clk_type) { 154 if (ourhost->host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
139 rate = clk_round_rate(clksrc, wanted); 155 rate = clk_round_rate(clksrc, wanted);
140 return wanted - rate; 156 return wanted - rate;
141 } 157 }
@@ -272,6 +288,8 @@ static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
272static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock) 288static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
273{ 289{
274 struct sdhci_s3c *ourhost = to_s3c(host); 290 struct sdhci_s3c *ourhost = to_s3c(host);
291 unsigned long timeout;
292 u16 clk = 0;
275 293
276 /* don't bother if the clock is going off */ 294 /* don't bother if the clock is going off */
277 if (clock == 0) 295 if (clock == 0)
@@ -282,6 +300,25 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
282 clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock); 300 clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
283 301
284 host->clock = clock; 302 host->clock = clock;
303
304 clk = SDHCI_CLOCK_INT_EN;
305 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
306
307 /* Wait max 20 ms */
308 timeout = 20;
309 while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
310 & SDHCI_CLOCK_INT_STABLE)) {
311 if (timeout == 0) {
312 printk(KERN_ERR "%s: Internal clock never "
313 "stabilised.\n", mmc_hostname(host->mmc));
314 return;
315 }
316 timeout--;
317 mdelay(1);
318 }
319
320 clk |= SDHCI_CLOCK_CARD_EN;
321 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
285} 322}
286 323
287/** 324/**
@@ -382,16 +419,24 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
382 } 419 }
383} 420}
384 421
422static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
423 struct platform_device *pdev)
424{
425 return (struct sdhci_s3c_drv_data *)
426 platform_get_device_id(pdev)->driver_data;
427}
428
385static int __devinit sdhci_s3c_probe(struct platform_device *pdev) 429static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
386{ 430{
387 struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; 431 struct s3c_sdhci_platdata *pdata;
432 struct sdhci_s3c_drv_data *drv_data;
388 struct device *dev = &pdev->dev; 433 struct device *dev = &pdev->dev;
389 struct sdhci_host *host; 434 struct sdhci_host *host;
390 struct sdhci_s3c *sc; 435 struct sdhci_s3c *sc;
391 struct resource *res; 436 struct resource *res;
392 int ret, irq, ptr, clks; 437 int ret, irq, ptr, clks;
393 438
394 if (!pdata) { 439 if (!pdev->dev.platform_data) {
395 dev_err(dev, "no device data specified\n"); 440 dev_err(dev, "no device data specified\n");
396 return -ENOENT; 441 return -ENOENT;
397 } 442 }
@@ -402,18 +447,20 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
402 return irq; 447 return irq;
403 } 448 }
404 449
405 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
406 if (!res) {
407 dev_err(dev, "no memory specified\n");
408 return -ENOENT;
409 }
410
411 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); 450 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
412 if (IS_ERR(host)) { 451 if (IS_ERR(host)) {
413 dev_err(dev, "sdhci_alloc_host() failed\n"); 452 dev_err(dev, "sdhci_alloc_host() failed\n");
414 return PTR_ERR(host); 453 return PTR_ERR(host);
415 } 454 }
416 455
456 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
457 if (!pdata) {
458 ret = -ENOMEM;
459 goto err_io_clk;
460 }
461 memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata));
462
463 drv_data = sdhci_s3c_get_driver_data(pdev);
417 sc = sdhci_priv(host); 464 sc = sdhci_priv(host);
418 465
419 sc->host = host; 466 sc->host = host;
@@ -464,15 +511,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
464 goto err_no_busclks; 511 goto err_no_busclks;
465 } 512 }
466 513
467 sc->ioarea = request_mem_region(res->start, resource_size(res), 514 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
468 mmc_hostname(host->mmc)); 515 host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
469 if (!sc->ioarea) {
470 dev_err(dev, "failed to reserve register area\n");
471 ret = -ENXIO;
472 goto err_req_regs;
473 }
474
475 host->ioaddr = ioremap_nocache(res->start, resource_size(res));
476 if (!host->ioaddr) { 516 if (!host->ioaddr) {
477 dev_err(dev, "failed to map registers\n"); 517 dev_err(dev, "failed to map registers\n");
478 ret = -ENXIO; 518 ret = -ENXIO;
@@ -491,6 +531,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
491 /* Setup quirks for the controller */ 531 /* Setup quirks for the controller */
492 host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; 532 host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
493 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; 533 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
534 if (drv_data)
535 host->quirks |= drv_data->sdhci_quirks;
494 536
495#ifndef CONFIG_MMC_SDHCI_S3C_DMA 537#ifndef CONFIG_MMC_SDHCI_S3C_DMA
496 538
@@ -518,6 +560,14 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
518 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) 560 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
519 host->mmc->caps = MMC_CAP_NONREMOVABLE; 561 host->mmc->caps = MMC_CAP_NONREMOVABLE;
520 562
563 switch (pdata->max_width) {
564 case 8:
565 host->mmc->caps |= MMC_CAP_8_BIT_DATA;
566 case 4:
567 host->mmc->caps |= MMC_CAP_4_BIT_DATA;
568 break;
569 }
570
521 if (pdata->pm_caps) 571 if (pdata->pm_caps)
522 host->mmc->pm_caps |= pdata->pm_caps; 572 host->mmc->pm_caps |= pdata->pm_caps;
523 573
@@ -531,7 +581,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
531 * If controller does not have internal clock divider, 581 * If controller does not have internal clock divider,
532 * we can use overriding functions instead of default. 582 * we can use overriding functions instead of default.
533 */ 583 */
534 if (pdata->clk_type) { 584 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
535 sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock; 585 sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
536 sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock; 586 sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
537 sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock; 587 sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
@@ -544,10 +594,17 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
544 if (pdata->host_caps2) 594 if (pdata->host_caps2)
545 host->mmc->caps2 |= pdata->host_caps2; 595 host->mmc->caps2 |= pdata->host_caps2;
546 596
597 pm_runtime_enable(&pdev->dev);
598 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
599 pm_runtime_use_autosuspend(&pdev->dev);
600 pm_suspend_ignore_children(&pdev->dev, 1);
601
547 ret = sdhci_add_host(host); 602 ret = sdhci_add_host(host);
548 if (ret) { 603 if (ret) {
549 dev_err(dev, "sdhci_add_host() failed\n"); 604 dev_err(dev, "sdhci_add_host() failed\n");
550 goto err_add_host; 605 pm_runtime_forbid(&pdev->dev);
606 pm_runtime_get_noresume(&pdev->dev);
607 goto err_req_regs;
551 } 608 }
552 609
553 /* The following two methods of card detection might call 610 /* The following two methods of card detection might call
@@ -561,10 +618,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
561 618
562 return 0; 619 return 0;
563 620
564 err_add_host:
565 release_resource(sc->ioarea);
566 kfree(sc->ioarea);
567
568 err_req_regs: 621 err_req_regs:
569 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 622 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
570 if (sc->clk_bus[ptr]) { 623 if (sc->clk_bus[ptr]) {
@@ -601,6 +654,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
601 654
602 sdhci_remove_host(host, 1); 655 sdhci_remove_host(host, 1);
603 656
657 pm_runtime_disable(&pdev->dev);
658
604 for (ptr = 0; ptr < 3; ptr++) { 659 for (ptr = 0; ptr < 3; ptr++) {
605 if (sc->clk_bus[ptr]) { 660 if (sc->clk_bus[ptr]) {
606 clk_disable(sc->clk_bus[ptr]); 661 clk_disable(sc->clk_bus[ptr]);
@@ -610,18 +665,13 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
610 clk_disable(sc->clk_io); 665 clk_disable(sc->clk_io);
611 clk_put(sc->clk_io); 666 clk_put(sc->clk_io);
612 667
613 iounmap(host->ioaddr);
614 release_resource(sc->ioarea);
615 kfree(sc->ioarea);
616
617 sdhci_free_host(host); 668 sdhci_free_host(host);
618 platform_set_drvdata(pdev, NULL); 669 platform_set_drvdata(pdev, NULL);
619 670
620 return 0; 671 return 0;
621} 672}
622 673
623#ifdef CONFIG_PM 674#ifdef CONFIG_PM_SLEEP
624
625static int sdhci_s3c_suspend(struct device *dev) 675static int sdhci_s3c_suspend(struct device *dev)
626{ 676{
627 struct sdhci_host *host = dev_get_drvdata(dev); 677 struct sdhci_host *host = dev_get_drvdata(dev);
@@ -635,10 +685,29 @@ static int sdhci_s3c_resume(struct device *dev)
635 685
636 return sdhci_resume_host(host); 686 return sdhci_resume_host(host);
637} 687}
688#endif
689
690#ifdef CONFIG_PM_RUNTIME
691static int sdhci_s3c_runtime_suspend(struct device *dev)
692{
693 struct sdhci_host *host = dev_get_drvdata(dev);
694
695 return sdhci_runtime_suspend_host(host);
696}
638 697
698static int sdhci_s3c_runtime_resume(struct device *dev)
699{
700 struct sdhci_host *host = dev_get_drvdata(dev);
701
702 return sdhci_runtime_resume_host(host);
703}
704#endif
705
706#ifdef CONFIG_PM
639static const struct dev_pm_ops sdhci_s3c_pmops = { 707static const struct dev_pm_ops sdhci_s3c_pmops = {
640 .suspend = sdhci_s3c_suspend, 708 SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
641 .resume = sdhci_s3c_resume, 709 SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
710 NULL)
642}; 711};
643 712
644#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops) 713#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
@@ -647,9 +716,31 @@ static const struct dev_pm_ops sdhci_s3c_pmops = {
647#define SDHCI_S3C_PMOPS NULL 716#define SDHCI_S3C_PMOPS NULL
648#endif 717#endif
649 718
719#if defined(CONFIG_CPU_EXYNOS4210) || defined(CONFIG_SOC_EXYNOS4212)
720static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
721 .sdhci_quirks = SDHCI_QUIRK_NONSTANDARD_CLOCK,
722};
723#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)&exynos4_sdhci_drv_data)
724#else
725#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)NULL)
726#endif
727
728static struct platform_device_id sdhci_s3c_driver_ids[] = {
729 {
730 .name = "s3c-sdhci",
731 .driver_data = (kernel_ulong_t)NULL,
732 }, {
733 .name = "exynos4-sdhci",
734 .driver_data = EXYNOS4_SDHCI_DRV_DATA,
735 },
736 { }
737};
738MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
739
650static struct platform_driver sdhci_s3c_driver = { 740static struct platform_driver sdhci_s3c_driver = {
651 .probe = sdhci_s3c_probe, 741 .probe = sdhci_s3c_probe,
652 .remove = __devexit_p(sdhci_s3c_remove), 742 .remove = __devexit_p(sdhci_s3c_remove),
743 .id_table = sdhci_s3c_driver_ids,
653 .driver = { 744 .driver = {
654 .owner = THIS_MODULE, 745 .owner = THIS_MODULE,
655 .name = "s3c-sdhci", 746 .name = "s3c-sdhci",
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8262cadfdab..9aa77f3f04a 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2782,8 +2782,9 @@ int sdhci_add_host(struct sdhci_host *host)
2782 mmc_card_is_removable(mmc)) 2782 mmc_card_is_removable(mmc))
2783 mmc->caps |= MMC_CAP_NEEDS_POLL; 2783 mmc->caps |= MMC_CAP_NEEDS_POLL;
2784 2784
2785 /* UHS-I mode(s) supported by the host controller. */ 2785 /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
2786 if (host->version >= SDHCI_SPEC_300) 2786 if (caps[1] & (SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
2787 SDHCI_SUPPORT_DDR50))
2787 mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25; 2788 mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25;
2788 2789
2789 /* SDR104 supports also implies SDR50 support */ 2790 /* SDR104 supports also implies SDR50 support */
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index aafaf0b6eb1..724b35e85a2 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -454,7 +454,8 @@ static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk)
454 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK); 454 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK);
455 else 455 else
456 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR & 456 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR &
457 ((fls(host->clk / clk) - 1) << 16)); 457 ((fls(DIV_ROUND_UP(host->clk,
458 clk) - 1) - 1) << 16));
458 459
459 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE); 460 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE);
460} 461}
@@ -1297,14 +1298,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1297 spin_lock_init(&host->lock); 1298 spin_lock_init(&host->lock);
1298 1299
1299 mmc->ops = &sh_mmcif_ops; 1300 mmc->ops = &sh_mmcif_ops;
1300 mmc->f_max = host->clk; 1301 mmc->f_max = host->clk / 2;
1301 /* close to 400KHz */ 1302 mmc->f_min = host->clk / 512;
1302 if (mmc->f_max < 51200000)
1303 mmc->f_min = mmc->f_max / 128;
1304 else if (mmc->f_max < 102400000)
1305 mmc->f_min = mmc->f_max / 256;
1306 else
1307 mmc->f_min = mmc->f_max / 512;
1308 if (pd->ocr) 1303 if (pd->ocr)
1309 mmc->ocr_avail = pd->ocr; 1304 mmc->ocr_avail = pd->ocr;
1310 mmc->caps = MMC_CAP_MMC_HIGHSPEED; 1305 mmc->caps = MMC_CAP_MMC_HIGHSPEED;
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 94eb05b1afd..58fc65f5c81 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -106,16 +106,14 @@ static int mtdchar_open(struct inode *inode, struct file *file)
106 } 106 }
107 107
108 if (mtd->type == MTD_ABSENT) { 108 if (mtd->type == MTD_ABSENT) {
109 put_mtd_device(mtd);
110 ret = -ENODEV; 109 ret = -ENODEV;
111 goto out; 110 goto out1;
112 } 111 }
113 112
114 mtd_ino = iget_locked(mnt->mnt_sb, devnum); 113 mtd_ino = iget_locked(mnt->mnt_sb, devnum);
115 if (!mtd_ino) { 114 if (!mtd_ino) {
116 put_mtd_device(mtd);
117 ret = -ENOMEM; 115 ret = -ENOMEM;
118 goto out; 116 goto out1;
119 } 117 }
120 if (mtd_ino->i_state & I_NEW) { 118 if (mtd_ino->i_state & I_NEW) {
121 mtd_ino->i_private = mtd; 119 mtd_ino->i_private = mtd;
@@ -127,23 +125,25 @@ static int mtdchar_open(struct inode *inode, struct file *file)
127 125
128 /* You can't open it RW if it's not a writeable device */ 126 /* You can't open it RW if it's not a writeable device */
129 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { 127 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
130 iput(mtd_ino);
131 put_mtd_device(mtd);
132 ret = -EACCES; 128 ret = -EACCES;
133 goto out; 129 goto out2;
134 } 130 }
135 131
136 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); 132 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
137 if (!mfi) { 133 if (!mfi) {
138 iput(mtd_ino);
139 put_mtd_device(mtd);
140 ret = -ENOMEM; 134 ret = -ENOMEM;
141 goto out; 135 goto out2;
142 } 136 }
143 mfi->ino = mtd_ino; 137 mfi->ino = mtd_ino;
144 mfi->mtd = mtd; 138 mfi->mtd = mtd;
145 file->private_data = mfi; 139 file->private_data = mfi;
140 mutex_unlock(&mtd_mutex);
141 return 0;
146 142
143out2:
144 iput(mtd_ino);
145out1:
146 put_mtd_device(mtd);
147out: 147out:
148 mutex_unlock(&mtd_mutex); 148 mutex_unlock(&mtd_mutex);
149 simple_release_fs(&mnt, &count); 149 simple_release_fs(&mnt, &count);
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index 261356c2dc9..3d501ec7fad 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -342,6 +342,21 @@ inline int __netio_fastio1(u32 fastio_index, u32 arg0)
342} 342}
343 343
344 344
345static void tile_net_return_credit(struct tile_net_cpu *info)
346{
347 struct tile_netio_queue *queue = &info->queue;
348 netio_queue_user_impl_t *qup = &queue->__user_part;
349
350 /* Return four credits after every fourth packet. */
351 if (--qup->__receive_credit_remaining == 0) {
352 u32 interval = qup->__receive_credit_interval;
353 qup->__receive_credit_remaining = interval;
354 __netio_fastio_return_credits(qup->__fastio_index, interval);
355 }
356}
357
358
359
345/* 360/*
346 * Provide a linux buffer to LIPP. 361 * Provide a linux buffer to LIPP.
347 */ 362 */
@@ -433,7 +448,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
433 struct sk_buff **skb_ptr; 448 struct sk_buff **skb_ptr;
434 449
435 /* Request 96 extra bytes for alignment purposes. */ 450 /* Request 96 extra bytes for alignment purposes. */
436 skb = netdev_alloc_skb(info->napi->dev, len + padding); 451 skb = netdev_alloc_skb(info->napi.dev, len + padding);
437 if (skb == NULL) 452 if (skb == NULL)
438 return false; 453 return false;
439 454
@@ -864,19 +879,11 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
864 879
865 stats->rx_packets++; 880 stats->rx_packets++;
866 stats->rx_bytes += len; 881 stats->rx_bytes += len;
867
868 if (small)
869 info->num_needed_small_buffers++;
870 else
871 info->num_needed_large_buffers++;
872 } 882 }
873 883
874 /* Return four credits after every fourth packet. */ 884 /* ISSUE: It would be nice to defer this until the packet has */
875 if (--qup->__receive_credit_remaining == 0) { 885 /* actually been processed. */
876 u32 interval = qup->__receive_credit_interval; 886 tile_net_return_credit(info);
877 qup->__receive_credit_remaining = interval;
878 __netio_fastio_return_credits(qup->__fastio_index, interval);
879 }
880 887
881 /* Consume this packet. */ 888 /* Consume this packet. */
882 qup->__packet_receive_read = index2; 889 qup->__packet_receive_read = index2;
@@ -1543,7 +1550,7 @@ static int tile_net_drain_lipp_buffers(struct tile_net_priv *priv)
1543 1550
1544 /* Drain all the LIPP buffers. */ 1551 /* Drain all the LIPP buffers. */
1545 while (true) { 1552 while (true) {
1546 int buffer; 1553 unsigned int buffer;
1547 1554
1548 /* NOTE: This should never fail. */ 1555 /* NOTE: This should never fail. */
1549 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer, 1556 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer,
@@ -1707,7 +1714,7 @@ static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1707 if (!hash_default) { 1714 if (!hash_default) {
1708 void *va = pfn_to_kaddr(pfn) + f->page_offset; 1715 void *va = pfn_to_kaddr(pfn) + f->page_offset;
1709 BUG_ON(PageHighMem(skb_frag_page(f))); 1716 BUG_ON(PageHighMem(skb_frag_page(f)));
1710 finv_buffer_remote(va, f->size, 0); 1717 finv_buffer_remote(va, skb_frag_size(f), 0);
1711 } 1718 }
1712 1719
1713 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset; 1720 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset;
@@ -1735,8 +1742,8 @@ static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1735 * Sometimes, if "sendfile()" requires copying, we will be called with 1742 * Sometimes, if "sendfile()" requires copying, we will be called with
1736 * "data" containing the header and payload, with "frags" being empty. 1743 * "data" containing the header and payload, with "frags" being empty.
1737 * 1744 *
1738 * In theory, "sh->nr_frags" could be 3, but in practice, it seems 1745 * Sometimes, for example when using NFS over TCP, a single segment can
1739 * that this will never actually happen. 1746 * span 3 fragments, which must be handled carefully in LEPP.
1740 * 1747 *
1741 * See "emulate_large_send_offload()" for some reference code, which 1748 * See "emulate_large_send_offload()" for some reference code, which
1742 * does not handle checksumming. 1749 * does not handle checksumming.
@@ -1844,10 +1851,8 @@ static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev)
1844 1851
1845 spin_lock_irqsave(&priv->eq_lock, irqflags); 1852 spin_lock_irqsave(&priv->eq_lock, irqflags);
1846 1853
1847 /* 1854 /* Handle completions if needed to make room. */
1848 * Handle completions if needed to make room. 1855 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
1849 * HACK: Spin until there is sufficient room.
1850 */
1851 if (lepp_num_free_comp_slots(eq) == 0) { 1856 if (lepp_num_free_comp_slots(eq) == 0) {
1852 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0); 1857 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
1853 if (nolds == 0) { 1858 if (nolds == 0) {
@@ -1861,6 +1866,7 @@ busy:
1861 cmd_tail = eq->cmd_tail; 1866 cmd_tail = eq->cmd_tail;
1862 1867
1863 /* Prepare to advance, detecting full queue. */ 1868 /* Prepare to advance, detecting full queue. */
1869 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
1864 cmd_next = cmd_tail + cmd_size; 1870 cmd_next = cmd_tail + cmd_size;
1865 if (cmd_tail < cmd_head && cmd_next >= cmd_head) 1871 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1866 goto busy; 1872 goto busy;
@@ -2023,10 +2029,8 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
2023 2029
2024 spin_lock_irqsave(&priv->eq_lock, irqflags); 2030 spin_lock_irqsave(&priv->eq_lock, irqflags);
2025 2031
2026 /* 2032 /* Handle completions if needed to make room. */
2027 * Handle completions if needed to make room. 2033 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
2028 * HACK: Spin until there is sufficient room.
2029 */
2030 if (lepp_num_free_comp_slots(eq) == 0) { 2034 if (lepp_num_free_comp_slots(eq) == 0) {
2031 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0); 2035 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
2032 if (nolds == 0) { 2036 if (nolds == 0) {
@@ -2040,6 +2044,7 @@ busy:
2040 cmd_tail = eq->cmd_tail; 2044 cmd_tail = eq->cmd_tail;
2041 2045
2042 /* Copy the commands, or fail. */ 2046 /* Copy the commands, or fail. */
2047 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
2043 for (i = 0; i < num_frags; i++) { 2048 for (i = 0; i < num_frags; i++) {
2044 2049
2045 /* Prepare to advance, detecting full queue. */ 2050 /* Prepare to advance, detecting full queue. */
@@ -2261,6 +2266,23 @@ static int tile_net_get_mac(struct net_device *dev)
2261 return 0; 2266 return 0;
2262} 2267}
2263 2268
2269
2270#ifdef CONFIG_NET_POLL_CONTROLLER
2271/*
2272 * Polling 'interrupt' - used by things like netconsole to send skbs
2273 * without having to re-enable interrupts. It's not called while
2274 * the interrupt routine is executing.
2275 */
2276static void tile_net_netpoll(struct net_device *dev)
2277{
2278 struct tile_net_priv *priv = netdev_priv(dev);
2279 disable_percpu_irq(priv->intr_id);
2280 tile_net_handle_ingress_interrupt(priv->intr_id, dev);
2281 enable_percpu_irq(priv->intr_id, 0);
2282}
2283#endif
2284
2285
2264static const struct net_device_ops tile_net_ops = { 2286static const struct net_device_ops tile_net_ops = {
2265 .ndo_open = tile_net_open, 2287 .ndo_open = tile_net_open,
2266 .ndo_stop = tile_net_stop, 2288 .ndo_stop = tile_net_stop,
@@ -2269,7 +2291,10 @@ static const struct net_device_ops tile_net_ops = {
2269 .ndo_get_stats = tile_net_get_stats, 2291 .ndo_get_stats = tile_net_get_stats,
2270 .ndo_change_mtu = tile_net_change_mtu, 2292 .ndo_change_mtu = tile_net_change_mtu,
2271 .ndo_tx_timeout = tile_net_tx_timeout, 2293 .ndo_tx_timeout = tile_net_tx_timeout,
2272 .ndo_set_mac_address = tile_net_set_mac_address 2294 .ndo_set_mac_address = tile_net_set_mac_address,
2295#ifdef CONFIG_NET_POLL_CONTROLLER
2296 .ndo_poll_controller = tile_net_netpoll,
2297#endif
2273}; 2298};
2274 2299
2275 2300
@@ -2409,7 +2434,7 @@ static void tile_net_cleanup(void)
2409 */ 2434 */
2410static int tile_net_init_module(void) 2435static int tile_net_init_module(void)
2411{ 2436{
2412 pr_info("Tilera IPP Net Driver\n"); 2437 pr_info("Tilera Network Driver\n");
2413 2438
2414 tile_net_devs[0] = tile_net_dev_init("xgbe0"); 2439 tile_net_devs[0] = tile_net_dev_init("xgbe0");
2415 tile_net_devs[1] = tile_net_dev_init("xgbe1"); 2440 tile_net_devs[1] = tile_net_dev_init("xgbe1");
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 215eb2536b1..2504ab00558 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -118,15 +118,13 @@ void ath9k_ps_restore(struct ath_softc *sc)
118 if (--sc->ps_usecount != 0) 118 if (--sc->ps_usecount != 0)
119 goto unlock; 119 goto unlock;
120 120
121 if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) 121 if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
122 goto unlock;
123
124 if (sc->ps_idle)
125 mode = ATH9K_PM_FULL_SLEEP; 122 mode = ATH9K_PM_FULL_SLEEP;
126 else if (sc->ps_enabled && 123 else if (sc->ps_enabled &&
127 !(sc->ps_flags & (PS_WAIT_FOR_BEACON | 124 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
128 PS_WAIT_FOR_CAB | 125 PS_WAIT_FOR_CAB |
129 PS_WAIT_FOR_PSPOLL_DATA))) 126 PS_WAIT_FOR_PSPOLL_DATA |
127 PS_WAIT_FOR_TX_ACK)))
130 mode = ATH9K_PM_NETWORK_SLEEP; 128 mode = ATH9K_PM_NETWORK_SLEEP;
131 else 129 else
132 goto unlock; 130 goto unlock;
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index fc9901e027c..90cc5e77265 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1062,11 +1062,6 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1062 1062
1063 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags); 1063 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
1064 1064
1065 /*
1066 * Register the extra components.
1067 */
1068 rt2x00rfkill_register(rt2x00dev);
1069
1070 return 0; 1065 return 0;
1071} 1066}
1072 1067
@@ -1210,6 +1205,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1210 rt2x00link_register(rt2x00dev); 1205 rt2x00link_register(rt2x00dev);
1211 rt2x00leds_register(rt2x00dev); 1206 rt2x00leds_register(rt2x00dev);
1212 rt2x00debug_register(rt2x00dev); 1207 rt2x00debug_register(rt2x00dev);
1208 rt2x00rfkill_register(rt2x00dev);
1213 1209
1214 return 0; 1210 return 0;
1215 1211
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 510023554e5..e54488db0e1 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -838,7 +838,10 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
838 __le16 fc = hdr->frame_control; 838 __le16 fc = hdr->frame_control;
839 839
840 txrate = ieee80211_get_tx_rate(hw, info); 840 txrate = ieee80211_get_tx_rate(hw, info);
841 tcb_desc->hw_rate = txrate->hw_value; 841 if (txrate)
842 tcb_desc->hw_rate = txrate->hw_value;
843 else
844 tcb_desc->hw_rate = 0;
842 845
843 if (ieee80211_is_data(fc)) { 846 if (ieee80211_is_data(fc)) {
844 /* 847 /*
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 07dd38efe62..288b035a357 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -912,8 +912,13 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
912 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 912 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
913 ring = &rtlpci->tx_ring[BEACON_QUEUE]; 913 ring = &rtlpci->tx_ring[BEACON_QUEUE];
914 pskb = __skb_dequeue(&ring->queue); 914 pskb = __skb_dequeue(&ring->queue);
915 if (pskb) 915 if (pskb) {
916 struct rtl_tx_desc *entry = &ring->desc[ring->idx];
917 pci_unmap_single(rtlpci->pdev, rtlpriv->cfg->ops->get_desc(
918 (u8 *) entry, true, HW_DESC_TXBUFF_ADDR),
919 pskb->len, PCI_DMA_TODEVICE);
916 kfree_skb(pskb); 920 kfree_skb(pskb);
921 }
917 922
918 /*NB: the beacon data buffer must be 32-bit aligned. */ 923 /*NB: the beacon data buffer must be 32-bit aligned. */
919 pskb = ieee80211_beacon_get(hw, mac->vif); 924 pskb = ieee80211_beacon_get(hw, mac->vif);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index 4898c502974..480862c07f9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -91,7 +91,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
91 u8 tid; 91 u8 tid;
92 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
94 static int header_print;
95 94
96 rtlpriv->dm.dm_initialgain_enable = true; 95 rtlpriv->dm.dm_initialgain_enable = true;
97 rtlpriv->dm.dm_flag = 0; 96 rtlpriv->dm.dm_flag = 0;
@@ -171,10 +170,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
171 for (tid = 0; tid < 8; tid++) 170 for (tid = 0; tid < 8; tid++)
172 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]); 171 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]);
173 172
174 /* Only load firmware for first MAC */
175 if (header_print)
176 return 0;
177
178 /* for firmware buf */ 173 /* for firmware buf */
179 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); 174 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
180 if (!rtlpriv->rtlhal.pfirmware) { 175 if (!rtlpriv->rtlhal.pfirmware) {
@@ -186,7 +181,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
186 rtlpriv->max_fw_size = 0x8000; 181 rtlpriv->max_fw_size = 0x8000;
187 pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); 182 pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
188 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); 183 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
189 header_print++;
190 184
191 /* request fw */ 185 /* request fw */
192 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, 186 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 2e1e352864b..d04dbda13f5 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -124,46 +124,38 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
124 return status; 124 return status;
125} 125}
126 126
127static u32 _usb_read_sync(struct usb_device *udev, u32 addr, u16 len) 127static u32 _usb_read_sync(struct rtl_priv *rtlpriv, u32 addr, u16 len)
128{ 128{
129 struct device *dev = rtlpriv->io.dev;
130 struct usb_device *udev = to_usb_device(dev);
129 u8 request; 131 u8 request;
130 u16 wvalue; 132 u16 wvalue;
131 u16 index; 133 u16 index;
132 u32 *data; 134 __le32 *data = &rtlpriv->usb_data[rtlpriv->usb_data_index];
133 u32 ret;
134 135
135 data = kmalloc(sizeof(u32), GFP_KERNEL);
136 if (!data)
137 return -ENOMEM;
138 request = REALTEK_USB_VENQT_CMD_REQ; 136 request = REALTEK_USB_VENQT_CMD_REQ;
139 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */ 137 index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */
140 138
141 wvalue = (u16)addr; 139 wvalue = (u16)addr;
142 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len); 140 _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len);
143 ret = le32_to_cpu(*data); 141 if (++rtlpriv->usb_data_index >= RTL_USB_MAX_RX_COUNT)
144 kfree(data); 142 rtlpriv->usb_data_index = 0;
145 return ret; 143 return le32_to_cpu(*data);
146} 144}
147 145
148static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr) 146static u8 _usb_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
149{ 147{
150 struct device *dev = rtlpriv->io.dev; 148 return (u8)_usb_read_sync(rtlpriv, addr, 1);
151
152 return (u8)_usb_read_sync(to_usb_device(dev), addr, 1);
153} 149}
154 150
155static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr) 151static u16 _usb_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
156{ 152{
157 struct device *dev = rtlpriv->io.dev; 153 return (u16)_usb_read_sync(rtlpriv, addr, 2);
158
159 return (u16)_usb_read_sync(to_usb_device(dev), addr, 2);
160} 154}
161 155
162static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr) 156static u32 _usb_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
163{ 157{
164 struct device *dev = rtlpriv->io.dev; 158 return _usb_read_sync(rtlpriv, addr, 4);
165
166 return _usb_read_sync(to_usb_device(dev), addr, 4);
167} 159}
168 160
169static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val, 161static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val,
@@ -955,6 +947,11 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
955 return -ENOMEM; 947 return -ENOMEM;
956 } 948 }
957 rtlpriv = hw->priv; 949 rtlpriv = hw->priv;
950 rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
951 GFP_KERNEL);
952 if (!rtlpriv->usb_data)
953 return -ENOMEM;
954 rtlpriv->usb_data_index = 0;
958 init_completion(&rtlpriv->firmware_loading_complete); 955 init_completion(&rtlpriv->firmware_loading_complete);
959 SET_IEEE80211_DEV(hw, &intf->dev); 956 SET_IEEE80211_DEV(hw, &intf->dev);
960 udev = interface_to_usbdev(intf); 957 udev = interface_to_usbdev(intf);
@@ -1025,6 +1022,7 @@ void rtl_usb_disconnect(struct usb_interface *intf)
1025 /* rtl_deinit_rfkill(hw); */ 1022 /* rtl_deinit_rfkill(hw); */
1026 rtl_usb_deinit(hw); 1023 rtl_usb_deinit(hw);
1027 rtl_deinit_core(hw); 1024 rtl_deinit_core(hw);
1025 kfree(rtlpriv->usb_data);
1028 rtlpriv->cfg->ops->deinit_sw_leds(hw); 1026 rtlpriv->cfg->ops->deinit_sw_leds(hw);
1029 rtlpriv->cfg->ops->deinit_sw_vars(hw); 1027 rtlpriv->cfg->ops->deinit_sw_vars(hw);
1030 _rtl_usb_io_handler_release(hw); 1028 _rtl_usb_io_handler_release(hw);
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index b591614c3b9..28ebc69218a 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -67,7 +67,7 @@
67#define QOS_QUEUE_NUM 4 67#define QOS_QUEUE_NUM 4
68#define RTL_MAC80211_NUM_QUEUE 5 68#define RTL_MAC80211_NUM_QUEUE 5
69#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 69#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254
70 70#define RTL_USB_MAX_RX_COUNT 100
71#define QBSS_LOAD_SIZE 5 71#define QBSS_LOAD_SIZE 5
72#define MAX_WMMELE_LENGTH 64 72#define MAX_WMMELE_LENGTH 64
73 73
@@ -1629,6 +1629,10 @@ struct rtl_priv {
1629 interface or hardware */ 1629 interface or hardware */
1630 unsigned long status; 1630 unsigned long status;
1631 1631
1632 /* data buffer pointer for USB reads */
1633 __le32 *usb_data;
1634 int usb_data_index;
1635
1632 /*This must be the last item so 1636 /*This must be the last item so
1633 that it points to the data allocated 1637 that it points to the data allocated
1634 beyond this structure like: 1638 beyond this structure like:
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 663b32c2e93..0ebbb1906c3 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1965,7 +1965,7 @@ static int __init netif_init(void)
1965 if (xen_initial_domain()) 1965 if (xen_initial_domain())
1966 return 0; 1966 return 0;
1967 1967
1968 if (!xen_platform_pci_unplug) 1968 if (xen_hvm_domain() && !xen_platform_pci_unplug)
1969 return -ENODEV; 1969 return -ENODEV;
1970 1970
1971 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n"); 1971 printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n");
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index fd00ff02ab4..d6cc62cb4cf 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -290,6 +290,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
290 } else { 290 } else {
291 printk(KERN_DEBUG "enable msix get value %x\n", 291 printk(KERN_DEBUG "enable msix get value %x\n",
292 op.value); 292 op.value);
293 err = op.value;
293 } 294 }
294 } else { 295 } else {
295 dev_err(&dev->dev, "enable msix get err %x\n", err); 296 dev_err(&dev->dev, "enable msix get err %x\n", err);
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 53969af1755..81fd606e47b 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -214,7 +214,7 @@ static struct of_device_id __devinitdata of_anatop_regulator_match_tbl[] = {
214 { /* end */ } 214 { /* end */ }
215}; 215};
216 216
217static struct platform_driver anatop_regulator = { 217static struct platform_driver anatop_regulator_driver = {
218 .driver = { 218 .driver = {
219 .name = "anatop_regulator", 219 .name = "anatop_regulator",
220 .owner = THIS_MODULE, 220 .owner = THIS_MODULE,
@@ -226,13 +226,13 @@ static struct platform_driver anatop_regulator = {
226 226
227static int __init anatop_regulator_init(void) 227static int __init anatop_regulator_init(void)
228{ 228{
229 return platform_driver_register(&anatop_regulator); 229 return platform_driver_register(&anatop_regulator_driver);
230} 230}
231postcore_initcall(anatop_regulator_init); 231postcore_initcall(anatop_regulator_init);
232 232
233static void __exit anatop_regulator_exit(void) 233static void __exit anatop_regulator_exit(void)
234{ 234{
235 platform_driver_unregister(&anatop_regulator); 235 platform_driver_unregister(&anatop_regulator_driver);
236} 236}
237module_exit(anatop_regulator_exit); 237module_exit(anatop_regulator_exit);
238 238
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 550292304b0..c9f890b088d 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -213,7 +213,6 @@ static struct platform_driver efi_rtc_driver = {
213 .name = "rtc-efi", 213 .name = "rtc-efi",
214 .owner = THIS_MODULE, 214 .owner = THIS_MODULE,
215 }, 215 },
216 .probe = efi_rtc_probe,
217 .remove = __exit_p(efi_rtc_remove), 216 .remove = __exit_p(efi_rtc_remove),
218}; 217};
219 218
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index 692de7360e9..684ef4bbfce 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -339,8 +339,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
339 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision); 339 dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision);
340 340
341 /* Enable the clockwatch on ST Variants */ 341 /* Enable the clockwatch on ST Variants */
342 if ((ldata->hw_designer == AMBA_VENDOR_ST) && 342 if (ldata->hw_designer == AMBA_VENDOR_ST)
343 (ldata->hw_revision > 1))
344 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, 343 writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
345 ldata->base + RTC_CR); 344 ldata->base + RTC_CR);
346 345
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c
index 7f8e6c24793..33b6ba0afa0 100644
--- a/drivers/rtc/rtc-r9701.c
+++ b/drivers/rtc/rtc-r9701.c
@@ -122,6 +122,7 @@ static const struct rtc_class_ops r9701_rtc_ops = {
122static int __devinit r9701_probe(struct spi_device *spi) 122static int __devinit r9701_probe(struct spi_device *spi)
123{ 123{
124 struct rtc_device *rtc; 124 struct rtc_device *rtc;
125 struct rtc_time dt;
125 unsigned char tmp; 126 unsigned char tmp;
126 int res; 127 int res;
127 128
@@ -132,6 +133,27 @@ static int __devinit r9701_probe(struct spi_device *spi)
132 return -ENODEV; 133 return -ENODEV;
133 } 134 }
134 135
136 /*
137 * The device seems to be present. Now check if the registers
138 * contain invalid values. If so, try to write a default date:
139 * 2000/1/1 00:00:00
140 */
141 r9701_get_datetime(&spi->dev, &dt);
142 if (rtc_valid_tm(&dt)) {
143 dev_info(&spi->dev, "trying to repair invalid date/time\n");
144 dt.tm_sec = 0;
145 dt.tm_min = 0;
146 dt.tm_hour = 0;
147 dt.tm_mday = 1;
148 dt.tm_mon = 0;
149 dt.tm_year = 100;
150
151 if (r9701_set_datetime(&spi->dev, &dt)) {
152 dev_err(&spi->dev, "cannot repair RTC register\n");
153 return -ENODEV;
154 }
155 }
156
135 rtc = rtc_device_register("r9701", 157 rtc = rtc_device_register("r9701",
136 &spi->dev, &r9701_rtc_ops, THIS_MODULE); 158 &spi->dev, &r9701_rtc_ops, THIS_MODULE);
137 if (IS_ERR(rtc)) 159 if (IS_ERR(rtc))
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 9ccea134a99..3f3a2975236 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -40,6 +40,10 @@ enum s3c_cpu_type {
40 TYPE_S3C64XX, 40 TYPE_S3C64XX,
41}; 41};
42 42
43struct s3c_rtc_drv_data {
44 int cpu_type;
45};
46
43/* I have yet to find an S3C implementation with more than one 47/* I have yet to find an S3C implementation with more than one
44 * of these rtc blocks in */ 48 * of these rtc blocks in */
45 49
@@ -446,10 +450,12 @@ static const struct of_device_id s3c_rtc_dt_match[];
446static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) 450static inline int s3c_rtc_get_driver_data(struct platform_device *pdev)
447{ 451{
448#ifdef CONFIG_OF 452#ifdef CONFIG_OF
453 struct s3c_rtc_drv_data *data;
449 if (pdev->dev.of_node) { 454 if (pdev->dev.of_node) {
450 const struct of_device_id *match; 455 const struct of_device_id *match;
451 match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node); 456 match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node);
452 return match->data; 457 data = (struct s3c_rtc_drv_data *) match->data;
458 return data->cpu_type;
453 } 459 }
454#endif 460#endif
455 return platform_get_device_id(pdev)->driver_data; 461 return platform_get_device_id(pdev)->driver_data;
@@ -664,20 +670,27 @@ static int s3c_rtc_resume(struct platform_device *pdev)
664#define s3c_rtc_resume NULL 670#define s3c_rtc_resume NULL
665#endif 671#endif
666 672
673static struct s3c_rtc_drv_data s3c_rtc_drv_data_array[] = {
674 [TYPE_S3C2410] = { TYPE_S3C2410 },
675 [TYPE_S3C2416] = { TYPE_S3C2416 },
676 [TYPE_S3C2443] = { TYPE_S3C2443 },
677 [TYPE_S3C64XX] = { TYPE_S3C64XX },
678};
679
667#ifdef CONFIG_OF 680#ifdef CONFIG_OF
668static const struct of_device_id s3c_rtc_dt_match[] = { 681static const struct of_device_id s3c_rtc_dt_match[] = {
669 { 682 {
670 .compatible = "samsung,s3c2410-rtc" 683 .compatible = "samsung,s3c2410-rtc",
671 .data = TYPE_S3C2410, 684 .data = &s3c_rtc_drv_data_array[TYPE_S3C2410],
672 }, { 685 }, {
673 .compatible = "samsung,s3c2416-rtc" 686 .compatible = "samsung,s3c2416-rtc",
674 .data = TYPE_S3C2416, 687 .data = &s3c_rtc_drv_data_array[TYPE_S3C2416],
675 }, { 688 }, {
676 .compatible = "samsung,s3c2443-rtc" 689 .compatible = "samsung,s3c2443-rtc",
677 .data = TYPE_S3C2443, 690 .data = &s3c_rtc_drv_data_array[TYPE_S3C2443],
678 }, { 691 }, {
679 .compatible = "samsung,s3c6410-rtc" 692 .compatible = "samsung,s3c6410-rtc",
680 .data = TYPE_S3C64XX, 693 .data = &s3c_rtc_drv_data_array[TYPE_S3C64XX],
681 }, 694 },
682 {}, 695 {},
683}; 696};
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 4c2c6df2a9e..258abeabf62 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -112,6 +112,7 @@ static const u8 twl6030_rtc_reg_map[] = {
112#define BIT_RTC_CTRL_REG_TEST_MODE_M 0x10 112#define BIT_RTC_CTRL_REG_TEST_MODE_M 0x10
113#define BIT_RTC_CTRL_REG_SET_32_COUNTER_M 0x20 113#define BIT_RTC_CTRL_REG_SET_32_COUNTER_M 0x20
114#define BIT_RTC_CTRL_REG_GET_TIME_M 0x40 114#define BIT_RTC_CTRL_REG_GET_TIME_M 0x40
115#define BIT_RTC_CTRL_REG_RTC_V_OPT 0x80
115 116
116/* RTC_STATUS_REG bitfields */ 117/* RTC_STATUS_REG bitfields */
117#define BIT_RTC_STATUS_REG_RUN_M 0x02 118#define BIT_RTC_STATUS_REG_RUN_M 0x02
@@ -235,25 +236,57 @@ static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm)
235 unsigned char rtc_data[ALL_TIME_REGS + 1]; 236 unsigned char rtc_data[ALL_TIME_REGS + 1];
236 int ret; 237 int ret;
237 u8 save_control; 238 u8 save_control;
239 u8 rtc_control;
238 240
239 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG); 241 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
240 if (ret < 0) 242 if (ret < 0) {
243 dev_err(dev, "%s: reading CTRL_REG, error %d\n", __func__, ret);
241 return ret; 244 return ret;
245 }
246 /* for twl6030/32 make sure BIT_RTC_CTRL_REG_GET_TIME_M is clear */
247 if (twl_class_is_6030()) {
248 if (save_control & BIT_RTC_CTRL_REG_GET_TIME_M) {
249 save_control &= ~BIT_RTC_CTRL_REG_GET_TIME_M;
250 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
251 if (ret < 0) {
252 dev_err(dev, "%s clr GET_TIME, error %d\n",
253 __func__, ret);
254 return ret;
255 }
256 }
257 }
242 258
243 save_control |= BIT_RTC_CTRL_REG_GET_TIME_M; 259 /* Copy RTC counting registers to static registers or latches */
260 rtc_control = save_control | BIT_RTC_CTRL_REG_GET_TIME_M;
244 261
245 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG); 262 /* for twl6030/32 enable read access to static shadowed registers */
246 if (ret < 0) 263 if (twl_class_is_6030())
264 rtc_control |= BIT_RTC_CTRL_REG_RTC_V_OPT;
265
266 ret = twl_rtc_write_u8(rtc_control, REG_RTC_CTRL_REG);
267 if (ret < 0) {
268 dev_err(dev, "%s: writing CTRL_REG, error %d\n", __func__, ret);
247 return ret; 269 return ret;
270 }
248 271
249 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data, 272 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
250 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS); 273 (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
251 274
252 if (ret < 0) { 275 if (ret < 0) {
253 dev_err(dev, "rtc_read_time error %d\n", ret); 276 dev_err(dev, "%s: reading data, error %d\n", __func__, ret);
254 return ret; 277 return ret;
255 } 278 }
256 279
280 /* for twl6030 restore original state of rtc control register */
281 if (twl_class_is_6030()) {
282 ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
283 if (ret < 0) {
284 dev_err(dev, "%s: restore CTRL_REG, error %d\n",
285 __func__, ret);
286 return ret;
287 }
288 }
289
257 tm->tm_sec = bcd2bin(rtc_data[0]); 290 tm->tm_sec = bcd2bin(rtc_data[0]);
258 tm->tm_min = bcd2bin(rtc_data[1]); 291 tm->tm_min = bcd2bin(rtc_data[1]);
259 tm->tm_hour = bcd2bin(rtc_data[2]); 292 tm->tm_hour = bcd2bin(rtc_data[2]);
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 052b43e4e50..b91e4bc332a 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -55,7 +55,6 @@ static int lowmem_minfree[6] = {
55}; 55};
56static int lowmem_minfree_size = 4; 56static int lowmem_minfree_size = 4;
57 57
58static struct task_struct *lowmem_deathpending;
59static unsigned long lowmem_deathpending_timeout; 58static unsigned long lowmem_deathpending_timeout;
60 59
61#define lowmem_print(level, x...) \ 60#define lowmem_print(level, x...) \
@@ -64,24 +63,6 @@ static unsigned long lowmem_deathpending_timeout;
64 printk(x); \ 63 printk(x); \
65 } while (0) 64 } while (0)
66 65
67static int
68task_notify_func(struct notifier_block *self, unsigned long val, void *data);
69
70static struct notifier_block task_nb = {
71 .notifier_call = task_notify_func,
72};
73
74static int
75task_notify_func(struct notifier_block *self, unsigned long val, void *data)
76{
77 struct task_struct *task = data;
78
79 if (task == lowmem_deathpending)
80 lowmem_deathpending = NULL;
81
82 return NOTIFY_OK;
83}
84
85static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc) 66static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
86{ 67{
87 struct task_struct *tsk; 68 struct task_struct *tsk;
@@ -97,19 +78,6 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
97 int other_file = global_page_state(NR_FILE_PAGES) - 78 int other_file = global_page_state(NR_FILE_PAGES) -
98 global_page_state(NR_SHMEM); 79 global_page_state(NR_SHMEM);
99 80
100 /*
101 * If we already have a death outstanding, then
102 * bail out right away; indicating to vmscan
103 * that we have nothing further to offer on
104 * this pass.
105 *
106 * Note: Currently you need CONFIG_PROFILING
107 * for this to work correctly.
108 */
109 if (lowmem_deathpending &&
110 time_before_eq(jiffies, lowmem_deathpending_timeout))
111 return 0;
112
113 if (lowmem_adj_size < array_size) 81 if (lowmem_adj_size < array_size)
114 array_size = lowmem_adj_size; 82 array_size = lowmem_adj_size;
115 if (lowmem_minfree_size < array_size) 83 if (lowmem_minfree_size < array_size)
@@ -148,6 +116,12 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
148 if (!p) 116 if (!p)
149 continue; 117 continue;
150 118
119 if (test_tsk_thread_flag(p, TIF_MEMDIE) &&
120 time_before_eq(jiffies, lowmem_deathpending_timeout)) {
121 task_unlock(p);
122 rcu_read_unlock();
123 return 0;
124 }
151 oom_score_adj = p->signal->oom_score_adj; 125 oom_score_adj = p->signal->oom_score_adj;
152 if (oom_score_adj < min_score_adj) { 126 if (oom_score_adj < min_score_adj) {
153 task_unlock(p); 127 task_unlock(p);
@@ -174,15 +148,9 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
174 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n", 148 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
175 selected->pid, selected->comm, 149 selected->pid, selected->comm,
176 selected_oom_score_adj, selected_tasksize); 150 selected_oom_score_adj, selected_tasksize);
177 /*
178 * If CONFIG_PROFILING is off, then we don't want to stall
179 * the killer by setting lowmem_deathpending.
180 */
181#ifdef CONFIG_PROFILING
182 lowmem_deathpending = selected;
183 lowmem_deathpending_timeout = jiffies + HZ; 151 lowmem_deathpending_timeout = jiffies + HZ;
184#endif
185 send_sig(SIGKILL, selected, 0); 152 send_sig(SIGKILL, selected, 0);
153 set_tsk_thread_flag(selected, TIF_MEMDIE);
186 rem -= selected_tasksize; 154 rem -= selected_tasksize;
187 } 155 }
188 lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n", 156 lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
@@ -198,7 +166,6 @@ static struct shrinker lowmem_shrinker = {
198 166
199static int __init lowmem_init(void) 167static int __init lowmem_init(void)
200{ 168{
201 task_handoff_register(&task_nb);
202 register_shrinker(&lowmem_shrinker); 169 register_shrinker(&lowmem_shrinker);
203 return 0; 170 return 0;
204} 171}
@@ -206,7 +173,6 @@ static int __init lowmem_init(void)
206static void __exit lowmem_exit(void) 173static void __exit lowmem_exit(void)
207{ 174{
208 unregister_shrinker(&lowmem_shrinker); 175 unregister_shrinker(&lowmem_shrinker);
209 task_handoff_unregister(&task_nb);
210} 176}
211 177
212module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR); 178module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 830657908db..c5eb3c33c3d 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -122,6 +122,7 @@ struct ft_cmd {
122 /* Local sense buffer */ 122 /* Local sense buffer */
123 unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER]; 123 unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER];
124 u32 was_ddp_setup:1; /* Set only if ddp is setup */ 124 u32 was_ddp_setup:1; /* Set only if ddp is setup */
125 u32 aborted:1; /* Set if aborted by reset or timeout */
125 struct scatterlist *sg; /* Set only if DDP is setup */ 126 struct scatterlist *sg; /* Set only if DDP is setup */
126 u32 sg_cnt; /* No. of item in scatterlist */ 127 u32 sg_cnt; /* No. of item in scatterlist */
127}; 128};
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 62dec9715ce..a375f257aab 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -121,6 +121,8 @@ int ft_queue_status(struct se_cmd *se_cmd)
121 struct fc_exch *ep; 121 struct fc_exch *ep;
122 size_t len; 122 size_t len;
123 123
124 if (cmd->aborted)
125 return 0;
124 ft_dump_cmd(cmd, __func__); 126 ft_dump_cmd(cmd, __func__);
125 ep = fc_seq_exch(cmd->seq); 127 ep = fc_seq_exch(cmd->seq);
126 lport = ep->lp; 128 lport = ep->lp;
@@ -187,6 +189,8 @@ int ft_write_pending(struct se_cmd *se_cmd)
187 189
188 ft_dump_cmd(cmd, __func__); 190 ft_dump_cmd(cmd, __func__);
189 191
192 if (cmd->aborted)
193 return 0;
190 ep = fc_seq_exch(cmd->seq); 194 ep = fc_seq_exch(cmd->seq);
191 lport = ep->lp; 195 lport = ep->lp;
192 fp = fc_frame_alloc(lport, sizeof(*txrdy)); 196 fp = fc_frame_alloc(lport, sizeof(*txrdy));
@@ -252,10 +256,10 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
252 struct ft_cmd *cmd = arg; 256 struct ft_cmd *cmd = arg;
253 struct fc_frame_header *fh; 257 struct fc_frame_header *fh;
254 258
255 if (IS_ERR(fp)) { 259 if (unlikely(IS_ERR(fp))) {
256 /* XXX need to find cmd if queued */ 260 /* XXX need to find cmd if queued */
257 cmd->seq = NULL; 261 cmd->seq = NULL;
258 transport_generic_free_cmd(&cmd->se_cmd, 0); 262 cmd->aborted = true;
259 return; 263 return;
260 } 264 }
261 265
@@ -399,6 +403,8 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
399 struct se_tmr_req *tmr = se_cmd->se_tmr_req; 403 struct se_tmr_req *tmr = se_cmd->se_tmr_req;
400 enum fcp_resp_rsp_codes code; 404 enum fcp_resp_rsp_codes code;
401 405
406 if (cmd->aborted)
407 return 0;
402 switch (tmr->response) { 408 switch (tmr->response) {
403 case TMR_FUNCTION_COMPLETE: 409 case TMR_FUNCTION_COMPLETE:
404 code = FCP_TMF_CMPL; 410 code = FCP_TMF_CMPL;
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index f357039349b..2948dc94461 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -300,6 +300,7 @@ static struct se_portal_group *ft_add_tpg(
300{ 300{
301 struct ft_lport_acl *lacl; 301 struct ft_lport_acl *lacl;
302 struct ft_tpg *tpg; 302 struct ft_tpg *tpg;
303 struct workqueue_struct *wq;
303 unsigned long index; 304 unsigned long index;
304 int ret; 305 int ret;
305 306
@@ -321,18 +322,20 @@ static struct se_portal_group *ft_add_tpg(
321 tpg->lport_acl = lacl; 322 tpg->lport_acl = lacl;
322 INIT_LIST_HEAD(&tpg->lun_list); 323 INIT_LIST_HEAD(&tpg->lun_list);
323 324
324 ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg, 325 wq = alloc_workqueue("tcm_fc", 0, 1);
325 tpg, TRANSPORT_TPG_TYPE_NORMAL); 326 if (!wq) {
326 if (ret < 0) {
327 kfree(tpg); 327 kfree(tpg);
328 return NULL; 328 return NULL;
329 } 329 }
330 330
331 tpg->workqueue = alloc_workqueue("tcm_fc", 0, 1); 331 ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
332 if (!tpg->workqueue) { 332 tpg, TRANSPORT_TPG_TYPE_NORMAL);
333 if (ret < 0) {
334 destroy_workqueue(wq);
333 kfree(tpg); 335 kfree(tpg);
334 return NULL; 336 return NULL;
335 } 337 }
338 tpg->workqueue = wq;
336 339
337 mutex_lock(&ft_lport_lock); 340 mutex_lock(&ft_lport_lock);
338 list_add_tail(&tpg->list, &lacl->tpg_list); 341 list_add_tail(&tpg->list, &lacl->tpg_list);
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 2b693eefac5..dc7c0db26e2 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -81,6 +81,8 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
81 void *from; 81 void *from;
82 void *to = NULL; 82 void *to = NULL;
83 83
84 if (cmd->aborted)
85 return 0;
84 ep = fc_seq_exch(cmd->seq); 86 ep = fc_seq_exch(cmd->seq);
85 lport = ep->lp; 87 lport = ep->lp;
86 cmd->seq = lport->tt.seq_start_next(cmd->seq); 88 cmd->seq = lport->tt.seq_start_next(cmd->seq);
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index bf461cf9961..3158e17b665 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -355,9 +355,6 @@ static void sci_serial_out(struct uart_port *p, int offset, int value)
355 WARN(1, "Invalid register access\n"); 355 WARN(1, "Invalid register access\n");
356} 356}
357 357
358#define sci_in(up, offset) (up->serial_in(up, offset))
359#define sci_out(up, offset, value) (up->serial_out(up, offset, value))
360
361static int sci_probe_regmap(struct plat_sci_port *cfg) 358static int sci_probe_regmap(struct plat_sci_port *cfg)
362{ 359{
363 switch (cfg->type) { 360 switch (cfg->type) {
@@ -422,9 +419,9 @@ static int sci_poll_get_char(struct uart_port *port)
422 int c; 419 int c;
423 420
424 do { 421 do {
425 status = sci_in(port, SCxSR); 422 status = serial_port_in(port, SCxSR);
426 if (status & SCxSR_ERRORS(port)) { 423 if (status & SCxSR_ERRORS(port)) {
427 sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); 424 serial_port_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
428 continue; 425 continue;
429 } 426 }
430 break; 427 break;
@@ -433,11 +430,11 @@ static int sci_poll_get_char(struct uart_port *port)
433 if (!(status & SCxSR_RDxF(port))) 430 if (!(status & SCxSR_RDxF(port)))
434 return NO_POLL_CHAR; 431 return NO_POLL_CHAR;
435 432
436 c = sci_in(port, SCxRDR); 433 c = serial_port_in(port, SCxRDR);
437 434
438 /* Dummy read */ 435 /* Dummy read */
439 sci_in(port, SCxSR); 436 serial_port_in(port, SCxSR);
440 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 437 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
441 438
442 return c; 439 return c;
443} 440}
@@ -448,11 +445,11 @@ static void sci_poll_put_char(struct uart_port *port, unsigned char c)
448 unsigned short status; 445 unsigned short status;
449 446
450 do { 447 do {
451 status = sci_in(port, SCxSR); 448 status = serial_port_in(port, SCxSR);
452 } while (!(status & SCxSR_TDxE(port))); 449 } while (!(status & SCxSR_TDxE(port)));
453 450
454 sci_out(port, SCxTDR, c); 451 serial_port_out(port, SCxTDR, c);
455 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port)); 452 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port));
456} 453}
457#endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */ 454#endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */
458 455
@@ -480,10 +477,10 @@ static void sci_init_pins(struct uart_port *port, unsigned int cflag)
480 ((!(cflag & CRTSCTS)))) { 477 ((!(cflag & CRTSCTS)))) {
481 unsigned short status; 478 unsigned short status;
482 479
483 status = sci_in(port, SCSPTR); 480 status = serial_port_in(port, SCSPTR);
484 status &= ~SCSPTR_CTSIO; 481 status &= ~SCSPTR_CTSIO;
485 status |= SCSPTR_RTSIO; 482 status |= SCSPTR_RTSIO;
486 sci_out(port, SCSPTR, status); /* Set RTS = 1 */ 483 serial_port_out(port, SCSPTR, status); /* Set RTS = 1 */
487 } 484 }
488} 485}
489 486
@@ -493,13 +490,13 @@ static int sci_txfill(struct uart_port *port)
493 490
494 reg = sci_getreg(port, SCTFDR); 491 reg = sci_getreg(port, SCTFDR);
495 if (reg->size) 492 if (reg->size)
496 return sci_in(port, SCTFDR) & 0xff; 493 return serial_port_in(port, SCTFDR) & 0xff;
497 494
498 reg = sci_getreg(port, SCFDR); 495 reg = sci_getreg(port, SCFDR);
499 if (reg->size) 496 if (reg->size)
500 return sci_in(port, SCFDR) >> 8; 497 return serial_port_in(port, SCFDR) >> 8;
501 498
502 return !(sci_in(port, SCxSR) & SCI_TDRE); 499 return !(serial_port_in(port, SCxSR) & SCI_TDRE);
503} 500}
504 501
505static int sci_txroom(struct uart_port *port) 502static int sci_txroom(struct uart_port *port)
@@ -513,13 +510,13 @@ static int sci_rxfill(struct uart_port *port)
513 510
514 reg = sci_getreg(port, SCRFDR); 511 reg = sci_getreg(port, SCRFDR);
515 if (reg->size) 512 if (reg->size)
516 return sci_in(port, SCRFDR) & 0xff; 513 return serial_port_in(port, SCRFDR) & 0xff;
517 514
518 reg = sci_getreg(port, SCFDR); 515 reg = sci_getreg(port, SCFDR);
519 if (reg->size) 516 if (reg->size)
520 return sci_in(port, SCFDR) & ((port->fifosize << 1) - 1); 517 return serial_port_in(port, SCFDR) & ((port->fifosize << 1) - 1);
521 518
522 return (sci_in(port, SCxSR) & SCxSR_RDxF(port)) != 0; 519 return (serial_port_in(port, SCxSR) & SCxSR_RDxF(port)) != 0;
523} 520}
524 521
525/* 522/*
@@ -547,14 +544,14 @@ static void sci_transmit_chars(struct uart_port *port)
547 unsigned short ctrl; 544 unsigned short ctrl;
548 int count; 545 int count;
549 546
550 status = sci_in(port, SCxSR); 547 status = serial_port_in(port, SCxSR);
551 if (!(status & SCxSR_TDxE(port))) { 548 if (!(status & SCxSR_TDxE(port))) {
552 ctrl = sci_in(port, SCSCR); 549 ctrl = serial_port_in(port, SCSCR);
553 if (uart_circ_empty(xmit)) 550 if (uart_circ_empty(xmit))
554 ctrl &= ~SCSCR_TIE; 551 ctrl &= ~SCSCR_TIE;
555 else 552 else
556 ctrl |= SCSCR_TIE; 553 ctrl |= SCSCR_TIE;
557 sci_out(port, SCSCR, ctrl); 554 serial_port_out(port, SCSCR, ctrl);
558 return; 555 return;
559 } 556 }
560 557
@@ -573,27 +570,27 @@ static void sci_transmit_chars(struct uart_port *port)
573 break; 570 break;
574 } 571 }
575 572
576 sci_out(port, SCxTDR, c); 573 serial_port_out(port, SCxTDR, c);
577 574
578 port->icount.tx++; 575 port->icount.tx++;
579 } while (--count > 0); 576 } while (--count > 0);
580 577
581 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 578 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
582 579
583 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 580 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
584 uart_write_wakeup(port); 581 uart_write_wakeup(port);
585 if (uart_circ_empty(xmit)) { 582 if (uart_circ_empty(xmit)) {
586 sci_stop_tx(port); 583 sci_stop_tx(port);
587 } else { 584 } else {
588 ctrl = sci_in(port, SCSCR); 585 ctrl = serial_port_in(port, SCSCR);
589 586
590 if (port->type != PORT_SCI) { 587 if (port->type != PORT_SCI) {
591 sci_in(port, SCxSR); /* Dummy read */ 588 serial_port_in(port, SCxSR); /* Dummy read */
592 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 589 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
593 } 590 }
594 591
595 ctrl |= SCSCR_TIE; 592 ctrl |= SCSCR_TIE;
596 sci_out(port, SCSCR, ctrl); 593 serial_port_out(port, SCSCR, ctrl);
597 } 594 }
598} 595}
599 596
@@ -608,7 +605,7 @@ static void sci_receive_chars(struct uart_port *port)
608 unsigned short status; 605 unsigned short status;
609 unsigned char flag; 606 unsigned char flag;
610 607
611 status = sci_in(port, SCxSR); 608 status = serial_port_in(port, SCxSR);
612 if (!(status & SCxSR_RDxF(port))) 609 if (!(status & SCxSR_RDxF(port)))
613 return; 610 return;
614 611
@@ -621,7 +618,7 @@ static void sci_receive_chars(struct uart_port *port)
621 break; 618 break;
622 619
623 if (port->type == PORT_SCI) { 620 if (port->type == PORT_SCI) {
624 char c = sci_in(port, SCxRDR); 621 char c = serial_port_in(port, SCxRDR);
625 if (uart_handle_sysrq_char(port, c) || 622 if (uart_handle_sysrq_char(port, c) ||
626 sci_port->break_flag) 623 sci_port->break_flag)
627 count = 0; 624 count = 0;
@@ -629,9 +626,9 @@ static void sci_receive_chars(struct uart_port *port)
629 tty_insert_flip_char(tty, c, TTY_NORMAL); 626 tty_insert_flip_char(tty, c, TTY_NORMAL);
630 } else { 627 } else {
631 for (i = 0; i < count; i++) { 628 for (i = 0; i < count; i++) {
632 char c = sci_in(port, SCxRDR); 629 char c = serial_port_in(port, SCxRDR);
633 630
634 status = sci_in(port, SCxSR); 631 status = serial_port_in(port, SCxSR);
635#if defined(CONFIG_CPU_SH3) 632#if defined(CONFIG_CPU_SH3)
636 /* Skip "chars" during break */ 633 /* Skip "chars" during break */
637 if (sci_port->break_flag) { 634 if (sci_port->break_flag) {
@@ -672,8 +669,8 @@ static void sci_receive_chars(struct uart_port *port)
672 } 669 }
673 } 670 }
674 671
675 sci_in(port, SCxSR); /* dummy read */ 672 serial_port_in(port, SCxSR); /* dummy read */
676 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 673 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
677 674
678 copied += count; 675 copied += count;
679 port->icount.rx += count; 676 port->icount.rx += count;
@@ -683,8 +680,8 @@ static void sci_receive_chars(struct uart_port *port)
683 /* Tell the rest of the system the news. New characters! */ 680 /* Tell the rest of the system the news. New characters! */
684 tty_flip_buffer_push(tty); 681 tty_flip_buffer_push(tty);
685 } else { 682 } else {
686 sci_in(port, SCxSR); /* dummy read */ 683 serial_port_in(port, SCxSR); /* dummy read */
687 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 684 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
688 } 685 }
689} 686}
690 687
@@ -726,7 +723,7 @@ static void sci_break_timer(unsigned long data)
726static int sci_handle_errors(struct uart_port *port) 723static int sci_handle_errors(struct uart_port *port)
727{ 724{
728 int copied = 0; 725 int copied = 0;
729 unsigned short status = sci_in(port, SCxSR); 726 unsigned short status = serial_port_in(port, SCxSR);
730 struct tty_struct *tty = port->state->port.tty; 727 struct tty_struct *tty = port->state->port.tty;
731 struct sci_port *s = to_sci_port(port); 728 struct sci_port *s = to_sci_port(port);
732 729
@@ -804,8 +801,8 @@ static int sci_handle_fifo_overrun(struct uart_port *port)
804 if (!reg->size) 801 if (!reg->size)
805 return 0; 802 return 0;
806 803
807 if ((sci_in(port, SCLSR) & (1 << s->cfg->overrun_bit))) { 804 if ((serial_port_in(port, SCLSR) & (1 << s->cfg->overrun_bit))) {
808 sci_out(port, SCLSR, 0); 805 serial_port_out(port, SCLSR, 0);
809 806
810 port->icount.overrun++; 807 port->icount.overrun++;
811 808
@@ -822,7 +819,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port)
822static int sci_handle_breaks(struct uart_port *port) 819static int sci_handle_breaks(struct uart_port *port)
823{ 820{
824 int copied = 0; 821 int copied = 0;
825 unsigned short status = sci_in(port, SCxSR); 822 unsigned short status = serial_port_in(port, SCxSR);
826 struct tty_struct *tty = port->state->port.tty; 823 struct tty_struct *tty = port->state->port.tty;
827 struct sci_port *s = to_sci_port(port); 824 struct sci_port *s = to_sci_port(port);
828 825
@@ -859,8 +856,8 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
859 struct sci_port *s = to_sci_port(port); 856 struct sci_port *s = to_sci_port(port);
860 857
861 if (s->chan_rx) { 858 if (s->chan_rx) {
862 u16 scr = sci_in(port, SCSCR); 859 u16 scr = serial_port_in(port, SCSCR);
863 u16 ssr = sci_in(port, SCxSR); 860 u16 ssr = serial_port_in(port, SCxSR);
864 861
865 /* Disable future Rx interrupts */ 862 /* Disable future Rx interrupts */
866 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 863 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
@@ -869,9 +866,9 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
869 } else { 866 } else {
870 scr &= ~SCSCR_RIE; 867 scr &= ~SCSCR_RIE;
871 } 868 }
872 sci_out(port, SCSCR, scr); 869 serial_port_out(port, SCSCR, scr);
873 /* Clear current interrupt */ 870 /* Clear current interrupt */
874 sci_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); 871 serial_port_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port)));
875 dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n", 872 dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n",
876 jiffies, s->rx_timeout); 873 jiffies, s->rx_timeout);
877 mod_timer(&s->rx_timer, jiffies + s->rx_timeout); 874 mod_timer(&s->rx_timer, jiffies + s->rx_timeout);
@@ -909,15 +906,15 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr)
909 if (port->type == PORT_SCI) { 906 if (port->type == PORT_SCI) {
910 if (sci_handle_errors(port)) { 907 if (sci_handle_errors(port)) {
911 /* discard character in rx buffer */ 908 /* discard character in rx buffer */
912 sci_in(port, SCxSR); 909 serial_port_in(port, SCxSR);
913 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 910 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
914 } 911 }
915 } else { 912 } else {
916 sci_handle_fifo_overrun(port); 913 sci_handle_fifo_overrun(port);
917 sci_rx_interrupt(irq, ptr); 914 sci_rx_interrupt(irq, ptr);
918 } 915 }
919 916
920 sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); 917 serial_port_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
921 918
922 /* Kick the transmission */ 919 /* Kick the transmission */
923 sci_tx_interrupt(irq, ptr); 920 sci_tx_interrupt(irq, ptr);
@@ -931,7 +928,7 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr)
931 928
932 /* Handle BREAKs */ 929 /* Handle BREAKs */
933 sci_handle_breaks(port); 930 sci_handle_breaks(port);
934 sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port)); 931 serial_port_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
935 932
936 return IRQ_HANDLED; 933 return IRQ_HANDLED;
937} 934}
@@ -955,8 +952,8 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
955 struct sci_port *s = to_sci_port(port); 952 struct sci_port *s = to_sci_port(port);
956 irqreturn_t ret = IRQ_NONE; 953 irqreturn_t ret = IRQ_NONE;
957 954
958 ssr_status = sci_in(port, SCxSR); 955 ssr_status = serial_port_in(port, SCxSR);
959 scr_status = sci_in(port, SCSCR); 956 scr_status = serial_port_in(port, SCSCR);
960 err_enabled = scr_status & port_rx_irq_mask(port); 957 err_enabled = scr_status & port_rx_irq_mask(port);
961 958
962 /* Tx Interrupt */ 959 /* Tx Interrupt */
@@ -1170,7 +1167,7 @@ static void sci_free_gpios(struct sci_port *port)
1170 1167
1171static unsigned int sci_tx_empty(struct uart_port *port) 1168static unsigned int sci_tx_empty(struct uart_port *port)
1172{ 1169{
1173 unsigned short status = sci_in(port, SCxSR); 1170 unsigned short status = serial_port_in(port, SCxSR);
1174 unsigned short in_tx_fifo = sci_txfill(port); 1171 unsigned short in_tx_fifo = sci_txfill(port);
1175 1172
1176 return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0; 1173 return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0;
@@ -1198,7 +1195,7 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
1198 */ 1195 */
1199 reg = sci_getreg(port, SCFCR); 1196 reg = sci_getreg(port, SCFCR);
1200 if (reg->size) 1197 if (reg->size)
1201 sci_out(port, SCFCR, sci_in(port, SCFCR) | 1); 1198 serial_port_out(port, SCFCR, serial_port_in(port, SCFCR) | 1);
1202 } 1199 }
1203} 1200}
1204 1201
@@ -1240,8 +1237,8 @@ static void sci_dma_tx_complete(void *arg)
1240 } else { 1237 } else {
1241 s->cookie_tx = -EINVAL; 1238 s->cookie_tx = -EINVAL;
1242 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1239 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1243 u16 ctrl = sci_in(port, SCSCR); 1240 u16 ctrl = serial_port_in(port, SCSCR);
1244 sci_out(port, SCSCR, ctrl & ~SCSCR_TIE); 1241 serial_port_out(port, SCSCR, ctrl & ~SCSCR_TIE);
1245 } 1242 }
1246 } 1243 }
1247 1244
@@ -1494,13 +1491,13 @@ static void sci_start_tx(struct uart_port *port)
1494 1491
1495#ifdef CONFIG_SERIAL_SH_SCI_DMA 1492#ifdef CONFIG_SERIAL_SH_SCI_DMA
1496 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1493 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1497 u16 new, scr = sci_in(port, SCSCR); 1494 u16 new, scr = serial_port_in(port, SCSCR);
1498 if (s->chan_tx) 1495 if (s->chan_tx)
1499 new = scr | 0x8000; 1496 new = scr | 0x8000;
1500 else 1497 else
1501 new = scr & ~0x8000; 1498 new = scr & ~0x8000;
1502 if (new != scr) 1499 if (new != scr)
1503 sci_out(port, SCSCR, new); 1500 serial_port_out(port, SCSCR, new);
1504 } 1501 }
1505 1502
1506 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) && 1503 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) &&
@@ -1512,8 +1509,8 @@ static void sci_start_tx(struct uart_port *port)
1512 1509
1513 if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1510 if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1514 /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ 1511 /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */
1515 ctrl = sci_in(port, SCSCR); 1512 ctrl = serial_port_in(port, SCSCR);
1516 sci_out(port, SCSCR, ctrl | SCSCR_TIE); 1513 serial_port_out(port, SCSCR, ctrl | SCSCR_TIE);
1517 } 1514 }
1518} 1515}
1519 1516
@@ -1522,40 +1519,40 @@ static void sci_stop_tx(struct uart_port *port)
1522 unsigned short ctrl; 1519 unsigned short ctrl;
1523 1520
1524 /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ 1521 /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
1525 ctrl = sci_in(port, SCSCR); 1522 ctrl = serial_port_in(port, SCSCR);
1526 1523
1527 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 1524 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
1528 ctrl &= ~0x8000; 1525 ctrl &= ~0x8000;
1529 1526
1530 ctrl &= ~SCSCR_TIE; 1527 ctrl &= ~SCSCR_TIE;
1531 1528
1532 sci_out(port, SCSCR, ctrl); 1529 serial_port_out(port, SCSCR, ctrl);
1533} 1530}
1534 1531
1535static void sci_start_rx(struct uart_port *port) 1532static void sci_start_rx(struct uart_port *port)
1536{ 1533{
1537 unsigned short ctrl; 1534 unsigned short ctrl;
1538 1535
1539 ctrl = sci_in(port, SCSCR) | port_rx_irq_mask(port); 1536 ctrl = serial_port_in(port, SCSCR) | port_rx_irq_mask(port);
1540 1537
1541 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 1538 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
1542 ctrl &= ~0x4000; 1539 ctrl &= ~0x4000;
1543 1540
1544 sci_out(port, SCSCR, ctrl); 1541 serial_port_out(port, SCSCR, ctrl);
1545} 1542}
1546 1543
1547static void sci_stop_rx(struct uart_port *port) 1544static void sci_stop_rx(struct uart_port *port)
1548{ 1545{
1549 unsigned short ctrl; 1546 unsigned short ctrl;
1550 1547
1551 ctrl = sci_in(port, SCSCR); 1548 ctrl = serial_port_in(port, SCSCR);
1552 1549
1553 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 1550 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
1554 ctrl &= ~0x4000; 1551 ctrl &= ~0x4000;
1555 1552
1556 ctrl &= ~port_rx_irq_mask(port); 1553 ctrl &= ~port_rx_irq_mask(port);
1557 1554
1558 sci_out(port, SCSCR, ctrl); 1555 serial_port_out(port, SCSCR, ctrl);
1559} 1556}
1560 1557
1561static void sci_enable_ms(struct uart_port *port) 1558static void sci_enable_ms(struct uart_port *port)
@@ -1589,13 +1586,13 @@ static void rx_timer_fn(unsigned long arg)
1589{ 1586{
1590 struct sci_port *s = (struct sci_port *)arg; 1587 struct sci_port *s = (struct sci_port *)arg;
1591 struct uart_port *port = &s->port; 1588 struct uart_port *port = &s->port;
1592 u16 scr = sci_in(port, SCSCR); 1589 u16 scr = serial_port_in(port, SCSCR);
1593 1590
1594 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1591 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1595 scr &= ~0x4000; 1592 scr &= ~0x4000;
1596 enable_irq(s->cfg->irqs[1]); 1593 enable_irq(s->cfg->irqs[1]);
1597 } 1594 }
1598 sci_out(port, SCSCR, scr | SCSCR_RIE); 1595 serial_port_out(port, SCSCR, scr | SCSCR_RIE);
1599 dev_dbg(port->dev, "DMA Rx timed out\n"); 1596 dev_dbg(port->dev, "DMA Rx timed out\n");
1600 schedule_work(&s->work_rx); 1597 schedule_work(&s->work_rx);
1601} 1598}
@@ -1776,14 +1773,14 @@ static void sci_reset(struct uart_port *port)
1776 unsigned int status; 1773 unsigned int status;
1777 1774
1778 do { 1775 do {
1779 status = sci_in(port, SCxSR); 1776 status = serial_port_in(port, SCxSR);
1780 } while (!(status & SCxSR_TEND(port))); 1777 } while (!(status & SCxSR_TEND(port)));
1781 1778
1782 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ 1779 serial_port_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
1783 1780
1784 reg = sci_getreg(port, SCFCR); 1781 reg = sci_getreg(port, SCFCR);
1785 if (reg->size) 1782 if (reg->size)
1786 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); 1783 serial_port_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
1787} 1784}
1788 1785
1789static void sci_set_termios(struct uart_port *port, struct ktermios *termios, 1786static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
@@ -1812,7 +1809,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1812 1809
1813 sci_reset(port); 1810 sci_reset(port);
1814 1811
1815 smr_val = sci_in(port, SCSMR) & 3; 1812 smr_val = serial_port_in(port, SCSMR) & 3;
1816 1813
1817 if ((termios->c_cflag & CSIZE) == CS7) 1814 if ((termios->c_cflag & CSIZE) == CS7)
1818 smr_val |= 0x40; 1815 smr_val |= 0x40;
@@ -1825,19 +1822,19 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1825 1822
1826 uart_update_timeout(port, termios->c_cflag, baud); 1823 uart_update_timeout(port, termios->c_cflag, baud);
1827 1824
1828 sci_out(port, SCSMR, smr_val); 1825 serial_port_out(port, SCSMR, smr_val);
1829 1826
1830 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, 1827 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t,
1831 s->cfg->scscr); 1828 s->cfg->scscr);
1832 1829
1833 if (t > 0) { 1830 if (t > 0) {
1834 if (t >= 256) { 1831 if (t >= 256) {
1835 sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1); 1832 serial_port_out(port, SCSMR, (serial_port_in(port, SCSMR) & ~3) | 1);
1836 t >>= 2; 1833 t >>= 2;
1837 } else 1834 } else
1838 sci_out(port, SCSMR, sci_in(port, SCSMR) & ~3); 1835 serial_port_out(port, SCSMR, serial_port_in(port, SCSMR) & ~3);
1839 1836
1840 sci_out(port, SCBRR, t); 1837 serial_port_out(port, SCBRR, t);
1841 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ 1838 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
1842 } 1839 }
1843 1840
@@ -1845,7 +1842,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1845 1842
1846 reg = sci_getreg(port, SCFCR); 1843 reg = sci_getreg(port, SCFCR);
1847 if (reg->size) { 1844 if (reg->size) {
1848 unsigned short ctrl = sci_in(port, SCFCR); 1845 unsigned short ctrl = serial_port_in(port, SCFCR);
1849 1846
1850 if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) { 1847 if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) {
1851 if (termios->c_cflag & CRTSCTS) 1848 if (termios->c_cflag & CRTSCTS)
@@ -1861,10 +1858,10 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1861 */ 1858 */
1862 ctrl &= ~(SCFCR_RFRST | SCFCR_TFRST); 1859 ctrl &= ~(SCFCR_RFRST | SCFCR_TFRST);
1863 1860
1864 sci_out(port, SCFCR, ctrl); 1861 serial_port_out(port, SCFCR, ctrl);
1865 } 1862 }
1866 1863
1867 sci_out(port, SCSCR, s->cfg->scscr); 1864 serial_port_out(port, SCSCR, s->cfg->scscr);
1868 1865
1869#ifdef CONFIG_SERIAL_SH_SCI_DMA 1866#ifdef CONFIG_SERIAL_SH_SCI_DMA
1870 /* 1867 /*
@@ -2166,7 +2163,7 @@ static void serial_console_write(struct console *co, const char *s,
2166 2163
2167 /* wait until fifo is empty and last bit has been transmitted */ 2164 /* wait until fifo is empty and last bit has been transmitted */
2168 bits = SCxSR_TDxE(port) | SCxSR_TEND(port); 2165 bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
2169 while ((sci_in(port, SCxSR) & bits) != bits) 2166 while ((serial_port_in(port, SCxSR) & bits) != bits)
2170 cpu_relax(); 2167 cpu_relax();
2171 2168
2172 sci_port_disable(sci_port); 2169 sci_port_disable(sci_port);
@@ -2260,12 +2257,12 @@ static int sci_runtime_suspend(struct device *dev)
2260 if (uart_console(port)) { 2257 if (uart_console(port)) {
2261 struct plat_sci_reg *reg; 2258 struct plat_sci_reg *reg;
2262 2259
2263 sci_port->saved_smr = sci_in(port, SCSMR); 2260 sci_port->saved_smr = serial_port_in(port, SCSMR);
2264 sci_port->saved_brr = sci_in(port, SCBRR); 2261 sci_port->saved_brr = serial_port_in(port, SCBRR);
2265 2262
2266 reg = sci_getreg(port, SCFCR); 2263 reg = sci_getreg(port, SCFCR);
2267 if (reg->size) 2264 if (reg->size)
2268 sci_port->saved_fcr = sci_in(port, SCFCR); 2265 sci_port->saved_fcr = serial_port_in(port, SCFCR);
2269 else 2266 else
2270 sci_port->saved_fcr = 0; 2267 sci_port->saved_fcr = 0;
2271 } 2268 }
@@ -2279,13 +2276,13 @@ static int sci_runtime_resume(struct device *dev)
2279 2276
2280 if (uart_console(port)) { 2277 if (uart_console(port)) {
2281 sci_reset(port); 2278 sci_reset(port);
2282 sci_out(port, SCSMR, sci_port->saved_smr); 2279 serial_port_out(port, SCSMR, sci_port->saved_smr);
2283 sci_out(port, SCBRR, sci_port->saved_brr); 2280 serial_port_out(port, SCBRR, sci_port->saved_brr);
2284 2281
2285 if (sci_port->saved_fcr) 2282 if (sci_port->saved_fcr)
2286 sci_out(port, SCFCR, sci_port->saved_fcr); 2283 serial_port_out(port, SCFCR, sci_port->saved_fcr);
2287 2284
2288 sci_out(port, SCSCR, sci_port->cfg->scscr); 2285 serial_port_out(port, SCSCR, sci_port->cfg->scscr);
2289 } 2286 }
2290 return 0; 2287 return 0;
2291} 2288}
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index a1a2d364f92..4c22a1529aa 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -20,10 +20,10 @@
20 defined(CONFIG_ARCH_SH7372) || \ 20 defined(CONFIG_ARCH_SH7372) || \
21 defined(CONFIG_ARCH_R8A7740) 21 defined(CONFIG_ARCH_R8A7740)
22 22
23# define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) 23# define SCxSR_RDxF_CLEAR(port) (serial_port_in(port, SCxSR) & 0xfffc)
24# define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) 24# define SCxSR_ERROR_CLEAR(port) (serial_port_in(port, SCxSR) & 0xfd73)
25# define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) 25# define SCxSR_TDxE_CLEAR(port) (serial_port_in(port, SCxSR) & 0xffdf)
26# define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) 26# define SCxSR_BREAK_CLEAR(port) (serial_port_in(port, SCxSR) & 0xffe3)
27#else 27#else
28# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) 28# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
29# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) 29# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c
index 63616d7453e..97f5d264c31 100644
--- a/drivers/xen/xen-pciback/pciback_ops.c
+++ b/drivers/xen/xen-pciback/pciback_ops.c
@@ -234,7 +234,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
234 if (dev_data) 234 if (dev_data)
235 dev_data->ack_intr = 0; 235 dev_data->ack_intr = 0;
236 236
237 return result; 237 return result > 0 ? 0 : result;
238} 238}
239 239
240static 240static
diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig
index c465ae066c6..eb08c9e43c2 100644
--- a/fs/gfs2/Kconfig
+++ b/fs/gfs2/Kconfig
@@ -1,10 +1,6 @@
1config GFS2_FS 1config GFS2_FS
2 tristate "GFS2 file system support" 2 tristate "GFS2 file system support"
3 depends on (64BIT || LBDAF) 3 depends on (64BIT || LBDAF)
4 select DLM if GFS2_FS_LOCKING_DLM
5 select CONFIGFS_FS if GFS2_FS_LOCKING_DLM
6 select SYSFS if GFS2_FS_LOCKING_DLM
7 select IP_SCTP if DLM_SCTP
8 select FS_POSIX_ACL 4 select FS_POSIX_ACL
9 select CRC32 5 select CRC32
10 select QUOTACTL 6 select QUOTACTL
@@ -29,7 +25,8 @@ config GFS2_FS
29 25
30config GFS2_FS_LOCKING_DLM 26config GFS2_FS_LOCKING_DLM
31 bool "GFS2 DLM locking" 27 bool "GFS2 DLM locking"
32 depends on (GFS2_FS!=n) && NET && INET && (IPV6 || IPV6=n) && HOTPLUG 28 depends on (GFS2_FS!=n) && NET && INET && (IPV6 || IPV6=n) && \
29 HOTPLUG && DLM && CONFIGFS_FS && SYSFS
33 help 30 help
34 Multiple node locking module for GFS2 31 Multiple node locking module for GFS2
35 32
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 38b7a74a0f9..9b2ff0e851b 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -807,7 +807,7 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
807 807
808 if (inode == sdp->sd_rindex) { 808 if (inode == sdp->sd_rindex) {
809 adjust_fs_space(inode); 809 adjust_fs_space(inode);
810 ip->i_gh.gh_flags |= GL_NOCACHE; 810 sdp->sd_rindex_uptodate = 0;
811 } 811 }
812 812
813 brelse(dibh); 813 brelse(dibh);
@@ -873,7 +873,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
873 873
874 if (inode == sdp->sd_rindex) { 874 if (inode == sdp->sd_rindex) {
875 adjust_fs_space(inode); 875 adjust_fs_space(inode);
876 ip->i_gh.gh_flags |= GL_NOCACHE; 876 sdp->sd_rindex_uptodate = 0;
877 } 877 }
878 878
879 brelse(dibh); 879 brelse(dibh);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 197c5c47e57..03c04febe26 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -724,7 +724,11 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
724 int metadata; 724 int metadata;
725 unsigned int revokes = 0; 725 unsigned int revokes = 0;
726 int x; 726 int x;
727 int error = 0; 727 int error;
728
729 error = gfs2_rindex_update(sdp);
730 if (error)
731 return error;
728 732
729 if (!*top) 733 if (!*top)
730 sm->sm_first = 0; 734 sm->sm_first = 0;
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index c35573abd37..a836056343f 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1844,6 +1844,10 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1844 unsigned int x, size = len * sizeof(u64); 1844 unsigned int x, size = len * sizeof(u64);
1845 int error; 1845 int error;
1846 1846
1847 error = gfs2_rindex_update(sdp);
1848 if (error)
1849 return error;
1850
1847 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); 1851 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
1848 1852
1849 ht = kzalloc(size, GFP_NOFS); 1853 ht = kzalloc(size, GFP_NOFS);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index c98a60ee6df..a9ba2444e07 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1031,7 +1031,13 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
1031 struct buffer_head *bh; 1031 struct buffer_head *bh;
1032 struct gfs2_holder ghs[3]; 1032 struct gfs2_holder ghs[3];
1033 struct gfs2_rgrpd *rgd; 1033 struct gfs2_rgrpd *rgd;
1034 int error = -EROFS; 1034 int error;
1035
1036 error = gfs2_rindex_update(sdp);
1037 if (error)
1038 return error;
1039
1040 error = -EROFS;
1035 1041
1036 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 1042 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
1037 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); 1043 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
@@ -1224,6 +1230,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1224 return 0; 1230 return 0;
1225 } 1231 }
1226 1232
1233 error = gfs2_rindex_update(sdp);
1234 if (error)
1235 return error;
1236
1227 if (odip != ndip) { 1237 if (odip != ndip) {
1228 error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, 1238 error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
1229 0, &r_gh); 1239 0, &r_gh);
@@ -1345,7 +1355,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1345 error = alloc_required; 1355 error = alloc_required;
1346 if (error < 0) 1356 if (error < 0)
1347 goto out_gunlock; 1357 goto out_gunlock;
1348 error = 0;
1349 1358
1350 if (alloc_required) { 1359 if (alloc_required) {
1351 struct gfs2_qadata *qa = gfs2_qadata_get(ndip); 1360 struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 19bde40b486..3df65c9ab73 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -332,9 +332,6 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact)
332 struct rb_node *n, *next; 332 struct rb_node *n, *next;
333 struct gfs2_rgrpd *cur; 333 struct gfs2_rgrpd *cur;
334 334
335 if (gfs2_rindex_update(sdp))
336 return NULL;
337
338 spin_lock(&sdp->sd_rindex_spin); 335 spin_lock(&sdp->sd_rindex_spin);
339 n = sdp->sd_rindex_tree.rb_node; 336 n = sdp->sd_rindex_tree.rb_node;
340 while (n) { 337 while (n) {
@@ -640,6 +637,7 @@ static int read_rindex_entry(struct gfs2_inode *ip,
640 return 0; 637 return 0;
641 638
642 error = 0; /* someone else read in the rgrp; free it and ignore it */ 639 error = 0; /* someone else read in the rgrp; free it and ignore it */
640 gfs2_glock_put(rgd->rd_gl);
643 641
644fail: 642fail:
645 kfree(rgd->rd_bits); 643 kfree(rgd->rd_bits);
@@ -927,6 +925,10 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
927 } else if (copy_from_user(&r, argp, sizeof(r))) 925 } else if (copy_from_user(&r, argp, sizeof(r)))
928 return -EFAULT; 926 return -EFAULT;
929 927
928 ret = gfs2_rindex_update(sdp);
929 if (ret)
930 return ret;
931
930 rgd = gfs2_blk2rgrpd(sdp, r.start, 0); 932 rgd = gfs2_blk2rgrpd(sdp, r.start, 0);
931 rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0); 933 rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0);
932 934
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 2e5ba425cae..927f4df874a 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -238,6 +238,10 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
238 unsigned int x; 238 unsigned int x;
239 int error; 239 int error;
240 240
241 error = gfs2_rindex_update(sdp);
242 if (error)
243 return error;
244
241 if (GFS2_EA_IS_STUFFED(ea)) 245 if (GFS2_EA_IS_STUFFED(ea))
242 return 0; 246 return 0;
243 247
@@ -1330,6 +1334,10 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1330 unsigned int x; 1334 unsigned int x;
1331 int error; 1335 int error;
1332 1336
1337 error = gfs2_rindex_update(sdp);
1338 if (error)
1339 return error;
1340
1333 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); 1341 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
1334 1342
1335 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh); 1343 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh);
@@ -1439,6 +1447,10 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1439 struct gfs2_holder gh; 1447 struct gfs2_holder gh;
1440 int error; 1448 int error;
1441 1449
1450 error = gfs2_rindex_update(sdp);
1451 if (error)
1452 return error;
1453
1442 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); 1454 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1);
1443 if (!rgd) { 1455 if (!rgd) {
1444 gfs2_consist_inode(ip); 1456 gfs2_consist_inode(ip);
diff --git a/fs/libfs.c b/fs/libfs.c
index 358094f0433..18d08f5db53 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -529,6 +529,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
529 return 0; 529 return 0;
530out: 530out:
531 d_genocide(root); 531 d_genocide(root);
532 shrink_dcache_parent(root);
532 dput(root); 533 dput(root);
533 return -ENOMEM; 534 return -ENOMEM;
534} 535}
diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h
index 3963116083a..e478de4e5d5 100644
--- a/include/drm/exynos_drm.h
+++ b/include/drm/exynos_drm.h
@@ -85,7 +85,7 @@ struct drm_exynos_gem_mmap {
85struct drm_exynos_vidi_connection { 85struct drm_exynos_vidi_connection {
86 unsigned int connection; 86 unsigned int connection;
87 unsigned int extensions; 87 unsigned int extensions;
88 uint64_t *edid; 88 uint64_t edid;
89}; 89};
90 90
91struct drm_exynos_plane_set_zpos { 91struct drm_exynos_plane_set_zpos {
@@ -96,7 +96,8 @@ struct drm_exynos_plane_set_zpos {
96/* memory type definitions. */ 96/* memory type definitions. */
97enum e_drm_exynos_gem_mem_type { 97enum e_drm_exynos_gem_mem_type {
98 /* Physically Non-Continuous memory. */ 98 /* Physically Non-Continuous memory. */
99 EXYNOS_BO_NONCONTIG = 1 << 0 99 EXYNOS_BO_NONCONTIG = 1 << 0,
100 EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG
100}; 101};
101 102
102#define DRM_EXYNOS_GEM_CREATE 0x00 103#define DRM_EXYNOS_GEM_CREATE 0x00
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 676f967390a..f9a2e5e67a5 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -974,6 +974,7 @@ int dma_async_device_register(struct dma_device *device);
974void dma_async_device_unregister(struct dma_device *device); 974void dma_async_device_unregister(struct dma_device *device);
975void dma_run_dependencies(struct dma_async_tx_descriptor *tx); 975void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
976struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type); 976struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type);
977struct dma_chan *net_dma_find_channel(void);
977#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y) 978#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
978 979
979/* --- Helper iov-locking functions --- */ 980/* --- Helper iov-locking functions --- */
diff --git a/include/linux/irq.h b/include/linux/irq.h
index bff29c58da2..7810406f3d8 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -263,6 +263,11 @@ static inline void irqd_clr_chained_irq_inprogress(struct irq_data *d)
263 d->state_use_accessors &= ~IRQD_IRQ_INPROGRESS; 263 d->state_use_accessors &= ~IRQD_IRQ_INPROGRESS;
264} 264}
265 265
266static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
267{
268 return d->hwirq;
269}
270
266/** 271/**
267 * struct irq_chip - hardware interrupt chip descriptor 272 * struct irq_chip - hardware interrupt chip descriptor
268 * 273 *
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index ead4a421579..c65740d76e6 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -42,12 +42,6 @@ struct of_device_id;
42/* Number of irqs reserved for a legacy isa controller */ 42/* Number of irqs reserved for a legacy isa controller */
43#define NUM_ISA_INTERRUPTS 16 43#define NUM_ISA_INTERRUPTS 16
44 44
45/* This type is the placeholder for a hardware interrupt number. It has to
46 * be big enough to enclose whatever representation is used by a given
47 * platform.
48 */
49typedef unsigned long irq_hw_number_t;
50
51/** 45/**
52 * struct irq_domain_ops - Methods for irq_domain objects 46 * struct irq_domain_ops - Methods for irq_domain objects
53 * @match: Match an interrupt controller device node to a host, returns 47 * @match: Match an interrupt controller device node to a host, returns
@@ -104,6 +98,9 @@ struct irq_domain {
104 unsigned int size; 98 unsigned int size;
105 unsigned int *revmap; 99 unsigned int *revmap;
106 } linear; 100 } linear;
101 struct {
102 unsigned int max_irq;
103 } nomap;
107 struct radix_tree_root tree; 104 struct radix_tree_root tree;
108 } revmap_data; 105 } revmap_data;
109 const struct irq_domain_ops *ops; 106 const struct irq_domain_ops *ops;
@@ -126,6 +123,7 @@ struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
126 const struct irq_domain_ops *ops, 123 const struct irq_domain_ops *ops,
127 void *host_data); 124 void *host_data);
128struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, 125struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
126 unsigned int max_irq,
129 const struct irq_domain_ops *ops, 127 const struct irq_domain_ops *ops,
130 void *host_data); 128 void *host_data);
131struct irq_domain *irq_domain_add_tree(struct device_node *of_node, 129struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
@@ -134,7 +132,6 @@ struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
134 132
135extern struct irq_domain *irq_find_host(struct device_node *node); 133extern struct irq_domain *irq_find_host(struct device_node *node);
136extern void irq_set_default_host(struct irq_domain *host); 134extern void irq_set_default_host(struct irq_domain *host);
137extern void irq_set_virq_count(unsigned int count);
138 135
139static inline struct irq_domain *irq_domain_add_legacy_isa( 136static inline struct irq_domain *irq_domain_add_legacy_isa(
140 struct device_node *of_node, 137 struct device_node *of_node,
@@ -146,7 +143,6 @@ static inline struct irq_domain *irq_domain_add_legacy_isa(
146} 143}
147extern struct irq_domain *irq_find_host(struct device_node *node); 144extern struct irq_domain *irq_find_host(struct device_node *node);
148extern void irq_set_default_host(struct irq_domain *host); 145extern void irq_set_default_host(struct irq_domain *host);
149extern void irq_set_virq_count(unsigned int count);
150 146
151 147
152extern unsigned int irq_create_mapping(struct irq_domain *host, 148extern unsigned int irq_create_mapping(struct irq_domain *host,
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index f549adccc94..1bc898b14a8 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -287,7 +287,17 @@ extern unsigned int ip6t_do_table(struct sk_buff *skb,
287 struct xt_table *table); 287 struct xt_table *table);
288 288
289/* Check for an extension */ 289/* Check for an extension */
290extern int ip6t_ext_hdr(u8 nexthdr); 290static inline int
291ip6t_ext_hdr(u8 nexthdr)
292{ return (nexthdr == IPPROTO_HOPOPTS) ||
293 (nexthdr == IPPROTO_ROUTING) ||
294 (nexthdr == IPPROTO_FRAGMENT) ||
295 (nexthdr == IPPROTO_ESP) ||
296 (nexthdr == IPPROTO_AH) ||
297 (nexthdr == IPPROTO_NONE) ||
298 (nexthdr == IPPROTO_DSTOPTS);
299}
300
291/* find specified header and get offset to it */ 301/* find specified header and get offset to it */
292extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, 302extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
293 int target, unsigned short *fragoff); 303 int target, unsigned short *fragoff);
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 33370271b8b..70a3f8d4911 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -481,6 +481,7 @@ struct sk_buff {
481 union { 481 union {
482 __u32 mark; 482 __u32 mark;
483 __u32 dropcount; 483 __u32 dropcount;
484 __u32 avail_size;
484 }; 485 };
485 486
486 sk_buff_data_t transport_header; 487 sk_buff_data_t transport_header;
@@ -1366,6 +1367,18 @@ static inline int skb_tailroom(const struct sk_buff *skb)
1366} 1367}
1367 1368
1368/** 1369/**
1370 * skb_availroom - bytes at buffer end
1371 * @skb: buffer to check
1372 *
1373 * Return the number of bytes of free space at the tail of an sk_buff
1374 * allocated by sk_stream_alloc()
1375 */
1376static inline int skb_availroom(const struct sk_buff *skb)
1377{
1378 return skb_is_nonlinear(skb) ? 0 : skb->avail_size - skb->len;
1379}
1380
1381/**
1369 * skb_reserve - adjust headroom 1382 * skb_reserve - adjust headroom
1370 * @skb: buffer to alter 1383 * @skb: buffer to alter
1371 * @len: bytes to move 1384 * @len: bytes to move
diff --git a/include/linux/types.h b/include/linux/types.h
index e5fa5034551..7f480db6023 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -210,6 +210,12 @@ typedef u32 phys_addr_t;
210 210
211typedef phys_addr_t resource_size_t; 211typedef phys_addr_t resource_size_t;
212 212
213/*
214 * This type is the placeholder for a hardware interrupt number. It has to be
215 * big enough to enclose whatever representation is used by a given platform.
216 */
217typedef unsigned long irq_hw_number_t;
218
213typedef struct { 219typedef struct {
214 int counter; 220 int counter;
215} atomic_t; 221} atomic_t;
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 9c3120dca29..b572f80bdfd 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -47,6 +47,8 @@
47 */ 47 */
48#define VGA_DEFAULT_DEVICE (NULL) 48#define VGA_DEFAULT_DEVICE (NULL)
49 49
50struct pci_dev;
51
50/* For use by clients */ 52/* For use by clients */
51 53
52/** 54/**
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 344b0f97282..d47e523c9d8 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -92,6 +92,7 @@ enum {
92 HCI_SERVICE_CACHE, 92 HCI_SERVICE_CACHE,
93 HCI_LINK_KEYS, 93 HCI_LINK_KEYS,
94 HCI_DEBUG_KEYS, 94 HCI_DEBUG_KEYS,
95 HCI_UNREGISTER,
95 96
96 HCI_LE_SCAN, 97 HCI_LE_SCAN,
97 HCI_SSP_ENABLED, 98 HCI_SSP_ENABLED,
@@ -1327,8 +1328,8 @@ struct sockaddr_hci {
1327#define HCI_DEV_NONE 0xffff 1328#define HCI_DEV_NONE 0xffff
1328 1329
1329#define HCI_CHANNEL_RAW 0 1330#define HCI_CHANNEL_RAW 0
1330#define HCI_CHANNEL_CONTROL 1
1331#define HCI_CHANNEL_MONITOR 2 1331#define HCI_CHANNEL_MONITOR 2
1332#define HCI_CHANNEL_CONTROL 3
1332 1333
1333struct hci_filter { 1334struct hci_filter {
1334 unsigned long type_mask; 1335 unsigned long type_mask;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index daefaac5113..6822d2595af 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -427,7 +427,7 @@ enum {
427static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) 427static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
428{ 428{
429 struct hci_dev *hdev = conn->hdev; 429 struct hci_dev *hdev = conn->hdev;
430 return (test_bit(HCI_SSP_ENABLED, &hdev->flags) && 430 return (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
431 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)); 431 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags));
432} 432}
433 433
@@ -907,11 +907,13 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
907 907
908static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) 908static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
909{ 909{
910 u8 field_len; 910 size_t parsed = 0;
911 size_t parsed;
912 911
913 for (parsed = 0; parsed < data_len - 1; parsed += field_len) { 912 if (data_len < 2)
914 field_len = data[0]; 913 return false;
914
915 while (parsed < data_len - 1) {
916 u8 field_len = data[0];
915 917
916 if (field_len == 0) 918 if (field_len == 0)
917 break; 919 break;
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index ffc1377e092..ebfd91fc20f 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -117,7 +117,7 @@ struct mgmt_mode {
117#define MGMT_OP_SET_DISCOVERABLE 0x0006 117#define MGMT_OP_SET_DISCOVERABLE 0x0006
118struct mgmt_cp_set_discoverable { 118struct mgmt_cp_set_discoverable {
119 __u8 val; 119 __u8 val;
120 __u16 timeout; 120 __le16 timeout;
121} __packed; 121} __packed;
122#define MGMT_SET_DISCOVERABLE_SIZE 3 122#define MGMT_SET_DISCOVERABLE_SIZE 3
123 123
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 87d203ff7a8..9210bdc7bd8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1327,7 +1327,7 @@ static inline struct ieee80211_rate *
1327ieee80211_get_tx_rate(const struct ieee80211_hw *hw, 1327ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
1328 const struct ieee80211_tx_info *c) 1328 const struct ieee80211_tx_info *c)
1329{ 1329{
1330 if (WARN_ON(c->control.rates[0].idx < 0)) 1330 if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
1331 return NULL; 1331 return NULL;
1332 return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx]; 1332 return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
1333} 1333}
diff --git a/include/sound/core.h b/include/sound/core.h
index b6e0f57d451..bc056687f64 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -325,6 +325,13 @@ void release_and_free_resource(struct resource *res);
325 325
326/* --- */ 326/* --- */
327 327
328/* sound printk debug levels */
329enum {
330 SND_PR_ALWAYS,
331 SND_PR_DEBUG,
332 SND_PR_VERBOSE,
333};
334
328#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) 335#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK)
329__printf(4, 5) 336__printf(4, 5)
330void __snd_printk(unsigned int level, const char *file, int line, 337void __snd_printk(unsigned int level, const char *file, int line,
@@ -354,6 +361,8 @@ void __snd_printk(unsigned int level, const char *file, int line,
354 */ 361 */
355#define snd_printd(fmt, args...) \ 362#define snd_printd(fmt, args...) \
356 __snd_printk(1, __FILE__, __LINE__, fmt, ##args) 363 __snd_printk(1, __FILE__, __LINE__, fmt, ##args)
364#define _snd_printd(level, fmt, args...) \
365 __snd_printk(level, __FILE__, __LINE__, fmt, ##args)
357 366
358/** 367/**
359 * snd_BUG - give a BUG warning message and stack trace 368 * snd_BUG - give a BUG warning message and stack trace
@@ -383,6 +392,7 @@ void __snd_printk(unsigned int level, const char *file, int line,
383#else /* !CONFIG_SND_DEBUG */ 392#else /* !CONFIG_SND_DEBUG */
384 393
385#define snd_printd(fmt, args...) do { } while (0) 394#define snd_printd(fmt, args...) do { } while (0)
395#define _snd_printd(level, fmt, args...) do { } while (0)
386#define snd_BUG() do { } while (0) 396#define snd_BUG() do { } while (0)
387static inline int __snd_bug_on(int cond) 397static inline int __snd_bug_on(int cond)
388{ 398{
diff --git a/kernel/cred.c b/kernel/cred.c
index 97b36eeca4c..e70683d9ec3 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -386,6 +386,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
386 struct cred *new; 386 struct cred *new;
387 int ret; 387 int ret;
388 388
389 p->replacement_session_keyring = NULL;
390
389 if ( 391 if (
390#ifdef CONFIG_KEYS 392#ifdef CONFIG_KEYS
391 !p->cred->thread_keyring && 393 !p->cred->thread_keyring &&
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index cf1a4a68ce4..d1a758bc972 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -62,7 +62,7 @@ config IRQ_DOMAIN_DEBUG
62 help 62 help
63 This option will show the mapping relationship between hardware irq 63 This option will show the mapping relationship between hardware irq
64 numbers and Linux irq numbers. The mapping is exposed via debugfs 64 numbers and Linux irq numbers. The mapping is exposed via debugfs
65 in the file "virq_mapping". 65 in the file "irq_domain_mapping".
66 66
67 If you don't know what this means you don't need it. 67 If you don't know what this means you don't need it.
68 68
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 3601f3fbf67..d34413e7862 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -23,7 +23,6 @@ static LIST_HEAD(irq_domain_list);
23static DEFINE_MUTEX(irq_domain_mutex); 23static DEFINE_MUTEX(irq_domain_mutex);
24 24
25static DEFINE_MUTEX(revmap_trees_mutex); 25static DEFINE_MUTEX(revmap_trees_mutex);
26static unsigned int irq_virq_count = NR_IRQS;
27static struct irq_domain *irq_default_domain; 26static struct irq_domain *irq_default_domain;
28 27
29/** 28/**
@@ -184,13 +183,16 @@ struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
184} 183}
185 184
186struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, 185struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
186 unsigned int max_irq,
187 const struct irq_domain_ops *ops, 187 const struct irq_domain_ops *ops,
188 void *host_data) 188 void *host_data)
189{ 189{
190 struct irq_domain *domain = irq_domain_alloc(of_node, 190 struct irq_domain *domain = irq_domain_alloc(of_node,
191 IRQ_DOMAIN_MAP_NOMAP, ops, host_data); 191 IRQ_DOMAIN_MAP_NOMAP, ops, host_data);
192 if (domain) 192 if (domain) {
193 domain->revmap_data.nomap.max_irq = max_irq ? max_irq : ~0;
193 irq_domain_add(domain); 194 irq_domain_add(domain);
195 }
194 return domain; 196 return domain;
195} 197}
196 198
@@ -262,22 +264,6 @@ void irq_set_default_host(struct irq_domain *domain)
262 irq_default_domain = domain; 264 irq_default_domain = domain;
263} 265}
264 266
265/**
266 * irq_set_virq_count() - Set the maximum number of linux irqs
267 * @count: number of linux irqs, capped with NR_IRQS
268 *
269 * This is mainly for use by platforms like iSeries who want to program
270 * the virtual irq number in the controller to avoid the reverse mapping
271 */
272void irq_set_virq_count(unsigned int count)
273{
274 pr_debug("irq: Trying to set virq count to %d\n", count);
275
276 BUG_ON(count < NUM_ISA_INTERRUPTS);
277 if (count < NR_IRQS)
278 irq_virq_count = count;
279}
280
281static int irq_setup_virq(struct irq_domain *domain, unsigned int virq, 267static int irq_setup_virq(struct irq_domain *domain, unsigned int virq,
282 irq_hw_number_t hwirq) 268 irq_hw_number_t hwirq)
283{ 269{
@@ -320,13 +306,12 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain)
320 pr_debug("irq: create_direct virq allocation failed\n"); 306 pr_debug("irq: create_direct virq allocation failed\n");
321 return 0; 307 return 0;
322 } 308 }
323 if (virq >= irq_virq_count) { 309 if (virq >= domain->revmap_data.nomap.max_irq) {
324 pr_err("ERROR: no free irqs available below %i maximum\n", 310 pr_err("ERROR: no free irqs available below %i maximum\n",
325 irq_virq_count); 311 domain->revmap_data.nomap.max_irq);
326 irq_free_desc(virq); 312 irq_free_desc(virq);
327 return 0; 313 return 0;
328 } 314 }
329
330 pr_debug("irq: create_direct obtained virq %d\n", virq); 315 pr_debug("irq: create_direct obtained virq %d\n", virq);
331 316
332 if (irq_setup_virq(domain, virq, virq)) { 317 if (irq_setup_virq(domain, virq, virq)) {
@@ -350,7 +335,8 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain)
350unsigned int irq_create_mapping(struct irq_domain *domain, 335unsigned int irq_create_mapping(struct irq_domain *domain,
351 irq_hw_number_t hwirq) 336 irq_hw_number_t hwirq)
352{ 337{
353 unsigned int virq, hint; 338 unsigned int hint;
339 int virq;
354 340
355 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); 341 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
356 342
@@ -377,13 +363,13 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
377 return irq_domain_legacy_revmap(domain, hwirq); 363 return irq_domain_legacy_revmap(domain, hwirq);
378 364
379 /* Allocate a virtual interrupt number */ 365 /* Allocate a virtual interrupt number */
380 hint = hwirq % irq_virq_count; 366 hint = hwirq % nr_irqs;
381 if (hint == 0) 367 if (hint == 0)
382 hint++; 368 hint++;
383 virq = irq_alloc_desc_from(hint, 0); 369 virq = irq_alloc_desc_from(hint, 0);
384 if (!virq) 370 if (virq <= 0)
385 virq = irq_alloc_desc_from(1, 0); 371 virq = irq_alloc_desc_from(1, 0);
386 if (!virq) { 372 if (virq <= 0) {
387 pr_debug("irq: -> virq allocation failed\n"); 373 pr_debug("irq: -> virq allocation failed\n");
388 return 0; 374 return 0;
389 } 375 }
@@ -515,7 +501,7 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
515 irq_hw_number_t hwirq) 501 irq_hw_number_t hwirq)
516{ 502{
517 unsigned int i; 503 unsigned int i;
518 unsigned int hint = hwirq % irq_virq_count; 504 unsigned int hint = hwirq % nr_irqs;
519 505
520 /* Look for default domain if nececssary */ 506 /* Look for default domain if nececssary */
521 if (domain == NULL) 507 if (domain == NULL)
@@ -536,7 +522,7 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
536 if (data && (data->domain == domain) && (data->hwirq == hwirq)) 522 if (data && (data->domain == domain) && (data->hwirq == hwirq))
537 return i; 523 return i;
538 i++; 524 i++;
539 if (i >= irq_virq_count) 525 if (i >= nr_irqs)
540 i = 1; 526 i = 1;
541 } while(i != hint); 527 } while(i != hint);
542 return 0; 528 return 0;
@@ -642,8 +628,8 @@ static int virq_debug_show(struct seq_file *m, void *private)
642 void *data; 628 void *data;
643 int i; 629 int i;
644 630
645 seq_printf(m, "%-5s %-7s %-15s %-18s %s\n", "virq", "hwirq", 631 seq_printf(m, "%-5s %-7s %-15s %-*s %s\n", "irq", "hwirq",
646 "chip name", "chip data", "domain name"); 632 "chip name", 2 * sizeof(void *) + 2, "chip data", "domain name");
647 633
648 for (i = 1; i < nr_irqs; i++) { 634 for (i = 1; i < nr_irqs; i++) {
649 desc = irq_to_desc(i); 635 desc = irq_to_desc(i);
@@ -666,7 +652,7 @@ static int virq_debug_show(struct seq_file *m, void *private)
666 seq_printf(m, "%-15s ", p); 652 seq_printf(m, "%-15s ", p);
667 653
668 data = irq_desc_get_chip_data(desc); 654 data = irq_desc_get_chip_data(desc);
669 seq_printf(m, "0x%16p ", data); 655 seq_printf(m, data ? "0x%p " : " %p ", data);
670 656
671 if (desc->irq_data.domain && desc->irq_data.domain->of_node) 657 if (desc->irq_data.domain && desc->irq_data.domain->of_node)
672 p = desc->irq_data.domain->of_node->full_name; 658 p = desc->irq_data.domain->of_node->full_name;
diff --git a/kernel/panic.c b/kernel/panic.c
index 80aed44e345..8ed89a175d7 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -97,7 +97,7 @@ void panic(const char *fmt, ...)
97 /* 97 /*
98 * Avoid nested stack-dumping if a panic occurs during oops processing 98 * Avoid nested stack-dumping if a panic occurs during oops processing
99 */ 99 */
100 if (!oops_in_progress) 100 if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
101 dump_stack(); 101 dump_stack();
102#endif 102#endif
103 103
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 52b3a06a02f..4ab11879aeb 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -170,7 +170,7 @@ static int proc_taint(struct ctl_table *table, int write,
170#endif 170#endif
171 171
172#ifdef CONFIG_PRINTK 172#ifdef CONFIG_PRINTK
173static int proc_dmesg_restrict(struct ctl_table *table, int write, 173static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
174 void __user *buffer, size_t *lenp, loff_t *ppos); 174 void __user *buffer, size_t *lenp, loff_t *ppos);
175#endif 175#endif
176 176
@@ -703,7 +703,7 @@ static struct ctl_table kern_table[] = {
703 .data = &dmesg_restrict, 703 .data = &dmesg_restrict,
704 .maxlen = sizeof(int), 704 .maxlen = sizeof(int),
705 .mode = 0644, 705 .mode = 0644,
706 .proc_handler = proc_dointvec_minmax, 706 .proc_handler = proc_dointvec_minmax_sysadmin,
707 .extra1 = &zero, 707 .extra1 = &zero,
708 .extra2 = &one, 708 .extra2 = &one,
709 }, 709 },
@@ -712,7 +712,7 @@ static struct ctl_table kern_table[] = {
712 .data = &kptr_restrict, 712 .data = &kptr_restrict,
713 .maxlen = sizeof(int), 713 .maxlen = sizeof(int),
714 .mode = 0644, 714 .mode = 0644,
715 .proc_handler = proc_dmesg_restrict, 715 .proc_handler = proc_dointvec_minmax_sysadmin,
716 .extra1 = &zero, 716 .extra1 = &zero,
717 .extra2 = &two, 717 .extra2 = &two,
718 }, 718 },
@@ -1943,7 +1943,7 @@ static int proc_taint(struct ctl_table *table, int write,
1943} 1943}
1944 1944
1945#ifdef CONFIG_PRINTK 1945#ifdef CONFIG_PRINTK
1946static int proc_dmesg_restrict(struct ctl_table *table, int write, 1946static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
1947 void __user *buffer, size_t *lenp, loff_t *ppos) 1947 void __user *buffer, size_t *lenp, loff_t *ppos)
1948{ 1948{
1949 if (write && !capable(CAP_SYS_ADMIN)) 1949 if (write && !capable(CAP_SYS_ADMIN))
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b8ce6f45095..cd65cb19c94 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2791,6 +2791,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2791 * so no worry about deadlock. 2791 * so no worry about deadlock.
2792 */ 2792 */
2793 page = pte_page(entry); 2793 page = pte_page(entry);
2794 get_page(page);
2794 if (page != pagecache_page) 2795 if (page != pagecache_page)
2795 lock_page(page); 2796 lock_page(page);
2796 2797
@@ -2822,6 +2823,7 @@ out_page_table_lock:
2822 } 2823 }
2823 if (page != pagecache_page) 2824 if (page != pagecache_page)
2824 unlock_page(page); 2825 unlock_page(page);
2826 put_page(page);
2825 2827
2826out_mutex: 2828out_mutex:
2827 mutex_unlock(&hugetlb_instantiation_mutex); 2829 mutex_unlock(&hugetlb_instantiation_mutex);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7d698df4a06..a7165a60d0a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2165,7 +2165,7 @@ static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb,
2165 if (action == CPU_ONLINE) 2165 if (action == CPU_ONLINE)
2166 return NOTIFY_OK; 2166 return NOTIFY_OK;
2167 2167
2168 if ((action != CPU_DEAD) || action != CPU_DEAD_FROZEN) 2168 if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
2169 return NOTIFY_OK; 2169 return NOTIFY_OK;
2170 2170
2171 for_each_mem_cgroup(iter) 2171 for_each_mem_cgroup(iter)
@@ -3763,7 +3763,7 @@ move_account:
3763 goto try_to_free; 3763 goto try_to_free;
3764 cond_resched(); 3764 cond_resched();
3765 /* "ret" should also be checked to ensure all lists are empty. */ 3765 /* "ret" should also be checked to ensure all lists are empty. */
3766 } while (memcg->res.usage > 0 || ret); 3766 } while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0 || ret);
3767out: 3767out:
3768 css_put(&memcg->css); 3768 css_put(&memcg->css);
3769 return ret; 3769 return ret;
@@ -3778,7 +3778,7 @@ try_to_free:
3778 lru_add_drain_all(); 3778 lru_add_drain_all();
3779 /* try to free all pages in this cgroup */ 3779 /* try to free all pages in this cgroup */
3780 shrink = 1; 3780 shrink = 1;
3781 while (nr_retries && memcg->res.usage > 0) { 3781 while (nr_retries && res_counter_read_u64(&memcg->res, RES_USAGE) > 0) {
3782 int progress; 3782 int progress;
3783 3783
3784 if (signal_pending(current)) { 3784 if (signal_pending(current)) {
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 33c332bbab7..1a518684a32 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2107,12 +2107,7 @@ restart:
2107 * with multiple processes reclaiming pages, the total 2107 * with multiple processes reclaiming pages, the total
2108 * freeing target can get unreasonably large. 2108 * freeing target can get unreasonably large.
2109 */ 2109 */
2110 if (nr_reclaimed >= nr_to_reclaim) 2110 if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY)
2111 nr_to_reclaim = 0;
2112 else
2113 nr_to_reclaim -= nr_reclaimed;
2114
2115 if (!nr_to_reclaim && priority < DEF_PRIORITY)
2116 break; 2111 break;
2117 } 2112 }
2118 blk_finish_plug(&plug); 2113 blk_finish_plug(&plug);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e33af63a884..92a857e3786 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -665,6 +665,11 @@ int hci_dev_open(__u16 dev)
665 665
666 hci_req_lock(hdev); 666 hci_req_lock(hdev);
667 667
668 if (test_bit(HCI_UNREGISTER, &hdev->dev_flags)) {
669 ret = -ENODEV;
670 goto done;
671 }
672
668 if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) { 673 if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) {
669 ret = -ERFKILL; 674 ret = -ERFKILL;
670 goto done; 675 goto done;
@@ -1849,6 +1854,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
1849 1854
1850 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); 1855 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
1851 1856
1857 set_bit(HCI_UNREGISTER, &hdev->dev_flags);
1858
1852 write_lock(&hci_dev_list_lock); 1859 write_lock(&hci_dev_list_lock);
1853 list_del(&hdev->list); 1860 list_del(&hdev->list);
1854 write_unlock(&hci_dev_list_lock); 1861 write_unlock(&hci_dev_list_lock);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b8e17e4dac8..94552b33d52 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1308,6 +1308,7 @@ static void l2cap_monitor_timeout(struct work_struct *work)
1308 if (chan->retry_count >= chan->remote_max_tx) { 1308 if (chan->retry_count >= chan->remote_max_tx) {
1309 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED); 1309 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
1310 l2cap_chan_unlock(chan); 1310 l2cap_chan_unlock(chan);
1311 l2cap_chan_put(chan);
1311 return; 1312 return;
1312 } 1313 }
1313 1314
@@ -1316,6 +1317,7 @@ static void l2cap_monitor_timeout(struct work_struct *work)
1316 1317
1317 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); 1318 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL);
1318 l2cap_chan_unlock(chan); 1319 l2cap_chan_unlock(chan);
1320 l2cap_chan_put(chan);
1319} 1321}
1320 1322
1321static void l2cap_retrans_timeout(struct work_struct *work) 1323static void l2cap_retrans_timeout(struct work_struct *work)
@@ -1335,6 +1337,7 @@ static void l2cap_retrans_timeout(struct work_struct *work)
1335 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); 1337 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL);
1336 1338
1337 l2cap_chan_unlock(chan); 1339 l2cap_chan_unlock(chan);
1340 l2cap_chan_put(chan);
1338} 1341}
1339 1342
1340static void l2cap_drop_acked_frames(struct l2cap_chan *chan) 1343static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index c4fe583b0af..29122ed28ea 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -82,7 +82,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
82 } 82 }
83 83
84 if (la.l2_cid) 84 if (la.l2_cid)
85 err = l2cap_add_scid(chan, la.l2_cid); 85 err = l2cap_add_scid(chan, __le16_to_cpu(la.l2_cid));
86 else 86 else
87 err = l2cap_add_psm(chan, &la.l2_bdaddr, la.l2_psm); 87 err = l2cap_add_psm(chan, &la.l2_bdaddr, la.l2_psm);
88 88
@@ -123,7 +123,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
123 if (la.l2_cid && la.l2_psm) 123 if (la.l2_cid && la.l2_psm)
124 return -EINVAL; 124 return -EINVAL;
125 125
126 err = l2cap_chan_connect(chan, la.l2_psm, la.l2_cid, &la.l2_bdaddr); 126 err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
127 &la.l2_bdaddr);
127 if (err) 128 if (err)
128 return err; 129 return err;
129 130
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7fcff888713..4ef275c6967 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2523,13 +2523,18 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
2523 2523
2524 if (cp->val) { 2524 if (cp->val) {
2525 type = PAGE_SCAN_TYPE_INTERLACED; 2525 type = PAGE_SCAN_TYPE_INTERLACED;
2526 acp.interval = 0x0024; /* 22.5 msec page scan interval */ 2526
2527 /* 22.5 msec page scan interval */
2528 acp.interval = __constant_cpu_to_le16(0x0024);
2527 } else { 2529 } else {
2528 type = PAGE_SCAN_TYPE_STANDARD; /* default */ 2530 type = PAGE_SCAN_TYPE_STANDARD; /* default */
2529 acp.interval = 0x0800; /* default 1.28 sec page scan */ 2531
2532 /* default 1.28 sec page scan */
2533 acp.interval = __constant_cpu_to_le16(0x0800);
2530 } 2534 }
2531 2535
2532 acp.window = 0x0012; /* default 11.25 msec page scan window */ 2536 /* default 11.25 msec page scan window */
2537 acp.window = __constant_cpu_to_le16(0x0012);
2533 2538
2534 err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp), 2539 err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp),
2535 &acp); 2540 &acp);
@@ -2936,7 +2941,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
2936 name, name_len); 2941 name, name_len);
2937 2942
2938 if (dev_class && memcmp(dev_class, "\0\0\0", 3) != 0) 2943 if (dev_class && memcmp(dev_class, "\0\0\0", 3) != 0)
2939 eir_len = eir_append_data(&ev->eir[eir_len], eir_len, 2944 eir_len = eir_append_data(ev->eir, eir_len,
2940 EIR_CLASS_OF_DEV, dev_class, 3); 2945 EIR_CLASS_OF_DEV, dev_class, 3);
2941 2946
2942 put_unaligned_le16(eir_len, &ev->eir_len); 2947 put_unaligned_le16(eir_len, &ev->eir_len);
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 702a1ae9220..27ca25ed702 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -241,7 +241,6 @@ static void br_multicast_group_expired(unsigned long data)
241 hlist_del_rcu(&mp->hlist[mdb->ver]); 241 hlist_del_rcu(&mp->hlist[mdb->ver]);
242 mdb->size--; 242 mdb->size--;
243 243
244 del_timer(&mp->query_timer);
245 call_rcu_bh(&mp->rcu, br_multicast_free_group); 244 call_rcu_bh(&mp->rcu, br_multicast_free_group);
246 245
247out: 246out:
@@ -271,7 +270,6 @@ static void br_multicast_del_pg(struct net_bridge *br,
271 rcu_assign_pointer(*pp, p->next); 270 rcu_assign_pointer(*pp, p->next);
272 hlist_del_init(&p->mglist); 271 hlist_del_init(&p->mglist);
273 del_timer(&p->timer); 272 del_timer(&p->timer);
274 del_timer(&p->query_timer);
275 call_rcu_bh(&p->rcu, br_multicast_free_pg); 273 call_rcu_bh(&p->rcu, br_multicast_free_pg);
276 274
277 if (!mp->ports && !mp->mglist && 275 if (!mp->ports && !mp->mglist &&
@@ -507,74 +505,6 @@ static struct sk_buff *br_multicast_alloc_query(struct net_bridge *br,
507 return NULL; 505 return NULL;
508} 506}
509 507
510static void br_multicast_send_group_query(struct net_bridge_mdb_entry *mp)
511{
512 struct net_bridge *br = mp->br;
513 struct sk_buff *skb;
514
515 skb = br_multicast_alloc_query(br, &mp->addr);
516 if (!skb)
517 goto timer;
518
519 netif_rx(skb);
520
521timer:
522 if (++mp->queries_sent < br->multicast_last_member_count)
523 mod_timer(&mp->query_timer,
524 jiffies + br->multicast_last_member_interval);
525}
526
527static void br_multicast_group_query_expired(unsigned long data)
528{
529 struct net_bridge_mdb_entry *mp = (void *)data;
530 struct net_bridge *br = mp->br;
531
532 spin_lock(&br->multicast_lock);
533 if (!netif_running(br->dev) || !mp->mglist ||
534 mp->queries_sent >= br->multicast_last_member_count)
535 goto out;
536
537 br_multicast_send_group_query(mp);
538
539out:
540 spin_unlock(&br->multicast_lock);
541}
542
543static void br_multicast_send_port_group_query(struct net_bridge_port_group *pg)
544{
545 struct net_bridge_port *port = pg->port;
546 struct net_bridge *br = port->br;
547 struct sk_buff *skb;
548
549 skb = br_multicast_alloc_query(br, &pg->addr);
550 if (!skb)
551 goto timer;
552
553 br_deliver(port, skb);
554
555timer:
556 if (++pg->queries_sent < br->multicast_last_member_count)
557 mod_timer(&pg->query_timer,
558 jiffies + br->multicast_last_member_interval);
559}
560
561static void br_multicast_port_group_query_expired(unsigned long data)
562{
563 struct net_bridge_port_group *pg = (void *)data;
564 struct net_bridge_port *port = pg->port;
565 struct net_bridge *br = port->br;
566
567 spin_lock(&br->multicast_lock);
568 if (!netif_running(br->dev) || hlist_unhashed(&pg->mglist) ||
569 pg->queries_sent >= br->multicast_last_member_count)
570 goto out;
571
572 br_multicast_send_port_group_query(pg);
573
574out:
575 spin_unlock(&br->multicast_lock);
576}
577
578static struct net_bridge_mdb_entry *br_multicast_get_group( 508static struct net_bridge_mdb_entry *br_multicast_get_group(
579 struct net_bridge *br, struct net_bridge_port *port, 509 struct net_bridge *br, struct net_bridge_port *port,
580 struct br_ip *group, int hash) 510 struct br_ip *group, int hash)
@@ -690,8 +620,6 @@ rehash:
690 mp->addr = *group; 620 mp->addr = *group;
691 setup_timer(&mp->timer, br_multicast_group_expired, 621 setup_timer(&mp->timer, br_multicast_group_expired,
692 (unsigned long)mp); 622 (unsigned long)mp);
693 setup_timer(&mp->query_timer, br_multicast_group_query_expired,
694 (unsigned long)mp);
695 623
696 hlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]); 624 hlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]);
697 mdb->size++; 625 mdb->size++;
@@ -746,8 +674,6 @@ static int br_multicast_add_group(struct net_bridge *br,
746 hlist_add_head(&p->mglist, &port->mglist); 674 hlist_add_head(&p->mglist, &port->mglist);
747 setup_timer(&p->timer, br_multicast_port_group_expired, 675 setup_timer(&p->timer, br_multicast_port_group_expired,
748 (unsigned long)p); 676 (unsigned long)p);
749 setup_timer(&p->query_timer, br_multicast_port_group_query_expired,
750 (unsigned long)p);
751 677
752 rcu_assign_pointer(*pp, p); 678 rcu_assign_pointer(*pp, p);
753 679
@@ -1291,9 +1217,6 @@ static void br_multicast_leave_group(struct net_bridge *br,
1291 time_after(mp->timer.expires, time) : 1217 time_after(mp->timer.expires, time) :
1292 try_to_del_timer_sync(&mp->timer) >= 0)) { 1218 try_to_del_timer_sync(&mp->timer) >= 0)) {
1293 mod_timer(&mp->timer, time); 1219 mod_timer(&mp->timer, time);
1294
1295 mp->queries_sent = 0;
1296 mod_timer(&mp->query_timer, now);
1297 } 1220 }
1298 1221
1299 goto out; 1222 goto out;
@@ -1310,9 +1233,6 @@ static void br_multicast_leave_group(struct net_bridge *br,
1310 time_after(p->timer.expires, time) : 1233 time_after(p->timer.expires, time) :
1311 try_to_del_timer_sync(&p->timer) >= 0)) { 1234 try_to_del_timer_sync(&p->timer) >= 0)) {
1312 mod_timer(&p->timer, time); 1235 mod_timer(&p->timer, time);
1313
1314 p->queries_sent = 0;
1315 mod_timer(&p->query_timer, now);
1316 } 1236 }
1317 1237
1318 break; 1238 break;
@@ -1681,7 +1601,6 @@ void br_multicast_stop(struct net_bridge *br)
1681 hlist_for_each_entry_safe(mp, p, n, &mdb->mhash[i], 1601 hlist_for_each_entry_safe(mp, p, n, &mdb->mhash[i],
1682 hlist[ver]) { 1602 hlist[ver]) {
1683 del_timer(&mp->timer); 1603 del_timer(&mp->timer);
1684 del_timer(&mp->query_timer);
1685 call_rcu_bh(&mp->rcu, br_multicast_free_group); 1604 call_rcu_bh(&mp->rcu, br_multicast_free_group);
1686 } 1605 }
1687 } 1606 }
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 0b67a63ad7a..e1d88225787 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -82,9 +82,7 @@ struct net_bridge_port_group {
82 struct hlist_node mglist; 82 struct hlist_node mglist;
83 struct rcu_head rcu; 83 struct rcu_head rcu;
84 struct timer_list timer; 84 struct timer_list timer;
85 struct timer_list query_timer;
86 struct br_ip addr; 85 struct br_ip addr;
87 u32 queries_sent;
88}; 86};
89 87
90struct net_bridge_mdb_entry 88struct net_bridge_mdb_entry
@@ -94,10 +92,8 @@ struct net_bridge_mdb_entry
94 struct net_bridge_port_group __rcu *ports; 92 struct net_bridge_port_group __rcu *ports;
95 struct rcu_head rcu; 93 struct rcu_head rcu;
96 struct timer_list timer; 94 struct timer_list timer;
97 struct timer_list query_timer;
98 struct br_ip addr; 95 struct br_ip addr;
99 bool mglist; 96 bool mglist;
100 u32 queries_sent;
101}; 97};
102 98
103struct net_bridge_mdb_htable 99struct net_bridge_mdb_htable
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index a396a692623..35b3a685e34 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -951,9 +951,11 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
951 goto adjust_others; 951 goto adjust_others;
952 } 952 }
953 953
954 data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask); 954 data = kmalloc(size + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
955 gfp_mask);
955 if (!data) 956 if (!data)
956 goto nodata; 957 goto nodata;
958 size = SKB_WITH_OVERHEAD(ksize(data));
957 959
958 /* Copy only real data... and, alas, header. This should be 960 /* Copy only real data... and, alas, header. This should be
959 * optimized for the cases when header is void. 961 * optimized for the cases when header is void.
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 5c45e30cf78..345c7dc0848 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -74,16 +74,24 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
74 74
75 iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); 75 iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
76 if (iph == NULL) 76 if (iph == NULL)
77 return -NF_DROP; 77 return -NF_ACCEPT;
78 78
79 /* Conntrack defragments packets, we might still see fragments 79 /* Conntrack defragments packets, we might still see fragments
80 * inside ICMP packets though. */ 80 * inside ICMP packets though. */
81 if (iph->frag_off & htons(IP_OFFSET)) 81 if (iph->frag_off & htons(IP_OFFSET))
82 return -NF_DROP; 82 return -NF_ACCEPT;
83 83
84 *dataoff = nhoff + (iph->ihl << 2); 84 *dataoff = nhoff + (iph->ihl << 2);
85 *protonum = iph->protocol; 85 *protonum = iph->protocol;
86 86
87 /* Check bogus IP headers */
88 if (*dataoff > skb->len) {
89 pr_debug("nf_conntrack_ipv4: bogus IPv4 packet: "
90 "nhoff %u, ihl %u, skblen %u\n",
91 nhoff, iph->ihl << 2, skb->len);
92 return -NF_ACCEPT;
93 }
94
87 return NF_ACCEPT; 95 return NF_ACCEPT;
88} 96}
89 97
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5d54ed30e82..8bb6adeb62c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -701,11 +701,12 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp)
701 skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp); 701 skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);
702 if (skb) { 702 if (skb) {
703 if (sk_wmem_schedule(sk, skb->truesize)) { 703 if (sk_wmem_schedule(sk, skb->truesize)) {
704 skb_reserve(skb, sk->sk_prot->max_header);
704 /* 705 /*
705 * Make sure that we have exactly size bytes 706 * Make sure that we have exactly size bytes
706 * available to the caller, no more, no less. 707 * available to the caller, no more, no less.
707 */ 708 */
708 skb_reserve(skb, skb_tailroom(skb) - size); 709 skb->avail_size = size;
709 return skb; 710 return skb;
710 } 711 }
711 __kfree_skb(skb); 712 __kfree_skb(skb);
@@ -995,10 +996,9 @@ new_segment:
995 copy = seglen; 996 copy = seglen;
996 997
997 /* Where to copy to? */ 998 /* Where to copy to? */
998 if (skb_tailroom(skb) > 0) { 999 if (skb_availroom(skb) > 0) {
999 /* We have some space in skb head. Superb! */ 1000 /* We have some space in skb head. Superb! */
1000 if (copy > skb_tailroom(skb)) 1001 copy = min_t(int, copy, skb_availroom(skb));
1001 copy = skb_tailroom(skb);
1002 err = skb_add_data_nocache(sk, skb, from, copy); 1002 err = skb_add_data_nocache(sk, skb, from, copy);
1003 if (err) 1003 if (err)
1004 goto do_fault; 1004 goto do_fault;
@@ -1452,7 +1452,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1452 if ((available < target) && 1452 if ((available < target) &&
1453 (len > sysctl_tcp_dma_copybreak) && !(flags & MSG_PEEK) && 1453 (len > sysctl_tcp_dma_copybreak) && !(flags & MSG_PEEK) &&
1454 !sysctl_tcp_low_latency && 1454 !sysctl_tcp_low_latency &&
1455 dma_find_channel(DMA_MEMCPY)) { 1455 net_dma_find_channel()) {
1456 preempt_enable_no_resched(); 1456 preempt_enable_no_resched();
1457 tp->ucopy.pinned_list = 1457 tp->ucopy.pinned_list =
1458 dma_pin_iovec_pages(msg->msg_iov, len); 1458 dma_pin_iovec_pages(msg->msg_iov, len);
@@ -1667,7 +1667,7 @@ do_prequeue:
1667 if (!(flags & MSG_TRUNC)) { 1667 if (!(flags & MSG_TRUNC)) {
1668#ifdef CONFIG_NET_DMA 1668#ifdef CONFIG_NET_DMA
1669 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) 1669 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
1670 tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY); 1670 tp->ucopy.dma_chan = net_dma_find_channel();
1671 1671
1672 if (tp->ucopy.dma_chan) { 1672 if (tp->ucopy.dma_chan) {
1673 tp->ucopy.dma_cookie = dma_skb_copy_datagram_iovec( 1673 tp->ucopy.dma_cookie = dma_skb_copy_datagram_iovec(
@@ -3302,8 +3302,7 @@ void __init tcp_init(void)
3302 3302
3303 tcp_init_mem(&init_net); 3303 tcp_init_mem(&init_net);
3304 /* Set per-socket limits to no more than 1/128 the pressure threshold */ 3304 /* Set per-socket limits to no more than 1/128 the pressure threshold */
3305 limit = nr_free_buffer_pages() << (PAGE_SHIFT - 10); 3305 limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
3306 limit = max(limit, 128UL);
3307 max_share = min(4UL*1024*1024, limit); 3306 max_share = min(4UL*1024*1024, limit);
3308 3307
3309 sysctl_tcp_wmem[0] = SK_MEM_QUANTUM; 3308 sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e886e2f7fa8..9944c1d9a21 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -474,8 +474,11 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
474 if (!win_dep) { 474 if (!win_dep) {
475 m -= (new_sample >> 3); 475 m -= (new_sample >> 3);
476 new_sample += m; 476 new_sample += m;
477 } else if (m < new_sample) 477 } else {
478 new_sample = m << 3; 478 m <<= 3;
479 if (m < new_sample)
480 new_sample = m;
481 }
479 } else { 482 } else {
480 /* No previous measure. */ 483 /* No previous measure. */
481 new_sample = m << 3; 484 new_sample = m << 3;
@@ -5225,7 +5228,7 @@ static int tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb,
5225 return 0; 5228 return 0;
5226 5229
5227 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) 5230 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
5228 tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY); 5231 tp->ucopy.dma_chan = net_dma_find_channel();
5229 5232
5230 if (tp->ucopy.dma_chan && skb_csum_unnecessary(skb)) { 5233 if (tp->ucopy.dma_chan && skb_csum_unnecessary(skb)) {
5231 5234
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3a25cf743f8..0cb86ceb652 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1730,7 +1730,7 @@ process:
1730#ifdef CONFIG_NET_DMA 1730#ifdef CONFIG_NET_DMA
1731 struct tcp_sock *tp = tcp_sk(sk); 1731 struct tcp_sock *tp = tcp_sk(sk);
1732 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) 1732 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
1733 tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY); 1733 tp->ucopy.dma_chan = net_dma_find_channel();
1734 if (tp->ucopy.dma_chan) 1734 if (tp->ucopy.dma_chan)
1735 ret = tcp_v4_do_rcv(sk, skb); 1735 ret = tcp_v4_do_rcv(sk, skb);
1736 else 1736 else
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 364784a9193..376b2cfbb68 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2060,7 +2060,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
2060 /* Punt if not enough space exists in the first SKB for 2060 /* Punt if not enough space exists in the first SKB for
2061 * the data in the second 2061 * the data in the second
2062 */ 2062 */
2063 if (skb->len > skb_tailroom(to)) 2063 if (skb->len > skb_availroom(to))
2064 break; 2064 break;
2065 2065
2066 if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp))) 2066 if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp)))
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 94874b0bdcd..9d4e1555931 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -78,19 +78,6 @@ EXPORT_SYMBOL_GPL(ip6t_alloc_initial_table);
78 78
79 Hence the start of any table is given by get_table() below. */ 79 Hence the start of any table is given by get_table() below. */
80 80
81/* Check for an extension */
82int
83ip6t_ext_hdr(u8 nexthdr)
84{
85 return (nexthdr == IPPROTO_HOPOPTS) ||
86 (nexthdr == IPPROTO_ROUTING) ||
87 (nexthdr == IPPROTO_FRAGMENT) ||
88 (nexthdr == IPPROTO_ESP) ||
89 (nexthdr == IPPROTO_AH) ||
90 (nexthdr == IPPROTO_NONE) ||
91 (nexthdr == IPPROTO_DSTOPTS);
92}
93
94/* Returns whether matches rule or not. */ 81/* Returns whether matches rule or not. */
95/* Performance critical - called for every packet */ 82/* Performance critical - called for every packet */
96static inline bool 83static inline bool
@@ -2366,7 +2353,6 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
2366EXPORT_SYMBOL(ip6t_register_table); 2353EXPORT_SYMBOL(ip6t_register_table);
2367EXPORT_SYMBOL(ip6t_unregister_table); 2354EXPORT_SYMBOL(ip6t_unregister_table);
2368EXPORT_SYMBOL(ip6t_do_table); 2355EXPORT_SYMBOL(ip6t_do_table);
2369EXPORT_SYMBOL(ip6t_ext_hdr);
2370EXPORT_SYMBOL(ipv6_find_hdr); 2356EXPORT_SYMBOL(ipv6_find_hdr);
2371 2357
2372module_init(ip6_tables_init); 2358module_init(ip6_tables_init);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 12c6ece67f3..86cfe6005f4 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1645,7 +1645,7 @@ process:
1645#ifdef CONFIG_NET_DMA 1645#ifdef CONFIG_NET_DMA
1646 struct tcp_sock *tp = tcp_sk(sk); 1646 struct tcp_sock *tp = tcp_sk(sk);
1647 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) 1647 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
1648 tp->ucopy.dma_chan = dma_find_channel(DMA_MEMCPY); 1648 tp->ucopy.dma_chan = net_dma_find_channel();
1649 if (tp->ucopy.dma_chan) 1649 if (tp->ucopy.dma_chan)
1650 ret = tcp_v6_do_rcv(sk, skb); 1650 ret = tcp_v6_do_rcv(sk, skb);
1651 else 1651 else
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 576fb25456d..f76da5b3f5c 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3387,8 +3387,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3387 */ 3387 */
3388 printk(KERN_DEBUG "%s: waiting for beacon from %pM\n", 3388 printk(KERN_DEBUG "%s: waiting for beacon from %pM\n",
3389 sdata->name, ifmgd->bssid); 3389 sdata->name, ifmgd->bssid);
3390 assoc_data->timeout = jiffies + 3390 assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval);
3391 TU_TO_EXP_TIME(req->bss->beacon_interval);
3392 } else { 3391 } else {
3393 assoc_data->have_beacon = true; 3392 assoc_data->have_beacon = true;
3394 assoc_data->sent_assoc = false; 3393 assoc_data->sent_assoc = false;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 6cd8e32e281..cf0747c5741 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1593,7 +1593,7 @@ static int nf_conntrack_init_net(struct net *net)
1593 return 0; 1593 return 0;
1594 1594
1595err_timeout: 1595err_timeout:
1596 nf_conntrack_timeout_fini(net); 1596 nf_conntrack_ecache_fini(net);
1597err_ecache: 1597err_ecache:
1598 nf_conntrack_tstamp_fini(net); 1598 nf_conntrack_tstamp_fini(net);
1599err_tstamp: 1599err_tstamp:
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index cc558162493..4dfbfa840f8 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
584 * Let's try to use the data from the packet. 584 * Let's try to use the data from the packet.
585 */ 585 */
586 sender->td_end = end; 586 sender->td_end = end;
587 win <<= sender->td_scale; 587 swin = win << sender->td_scale;
588 sender->td_maxwin = (win == 0 ? 1 : win); 588 sender->td_maxwin = (swin == 0 ? 1 : swin);
589 sender->td_maxend = end + sender->td_maxwin; 589 sender->td_maxend = end + sender->td_maxwin;
590 /* 590 /*
591 * We haven't seen traffic in the other direction yet 591 * We haven't seen traffic in the other direction yet
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c
index 7b76eb7192f..ef10ffcb4b6 100644
--- a/net/nfc/llcp/commands.c
+++ b/net/nfc/llcp/commands.c
@@ -474,7 +474,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
474 474
475 while (remaining_len > 0) { 475 while (remaining_len > 0) {
476 476
477 frag_len = min_t(u16, local->remote_miu, remaining_len); 477 frag_len = min_t(size_t, local->remote_miu, remaining_len);
478 478
479 pr_debug("Fragment %zd bytes remaining %zd", 479 pr_debug("Fragment %zd bytes remaining %zd",
480 frag_len, remaining_len); 480 frag_len, remaining_len);
@@ -497,7 +497,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
497 release_sock(sk); 497 release_sock(sk);
498 498
499 remaining_len -= frag_len; 499 remaining_len -= frag_len;
500 msg_ptr += len; 500 msg_ptr += frag_len;
501 } 501 }
502 502
503 kfree(msg_data); 503 kfree(msg_data);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a4aab1d3628..65622e9c7c5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1332,6 +1332,11 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1332 goto bad_res; 1332 goto bad_res;
1333 } 1333 }
1334 1334
1335 if (!netif_running(netdev)) {
1336 result = -ENETDOWN;
1337 goto bad_res;
1338 }
1339
1335 nla_for_each_nested(nl_txq_params, 1340 nla_for_each_nested(nl_txq_params,
1336 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS], 1341 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
1337 rem_txq_params) { 1342 rem_txq_params) {
@@ -6467,7 +6472,7 @@ static struct genl_ops nl80211_ops[] = {
6467 .doit = nl80211_get_key, 6472 .doit = nl80211_get_key,
6468 .policy = nl80211_policy, 6473 .policy = nl80211_policy,
6469 .flags = GENL_ADMIN_PERM, 6474 .flags = GENL_ADMIN_PERM,
6470 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6475 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6471 NL80211_FLAG_NEED_RTNL, 6476 NL80211_FLAG_NEED_RTNL,
6472 }, 6477 },
6473 { 6478 {
@@ -6499,7 +6504,7 @@ static struct genl_ops nl80211_ops[] = {
6499 .policy = nl80211_policy, 6504 .policy = nl80211_policy,
6500 .flags = GENL_ADMIN_PERM, 6505 .flags = GENL_ADMIN_PERM,
6501 .doit = nl80211_set_beacon, 6506 .doit = nl80211_set_beacon,
6502 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6507 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6503 NL80211_FLAG_NEED_RTNL, 6508 NL80211_FLAG_NEED_RTNL,
6504 }, 6509 },
6505 { 6510 {
@@ -6507,7 +6512,7 @@ static struct genl_ops nl80211_ops[] = {
6507 .policy = nl80211_policy, 6512 .policy = nl80211_policy,
6508 .flags = GENL_ADMIN_PERM, 6513 .flags = GENL_ADMIN_PERM,
6509 .doit = nl80211_start_ap, 6514 .doit = nl80211_start_ap,
6510 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6515 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6511 NL80211_FLAG_NEED_RTNL, 6516 NL80211_FLAG_NEED_RTNL,
6512 }, 6517 },
6513 { 6518 {
@@ -6515,7 +6520,7 @@ static struct genl_ops nl80211_ops[] = {
6515 .policy = nl80211_policy, 6520 .policy = nl80211_policy,
6516 .flags = GENL_ADMIN_PERM, 6521 .flags = GENL_ADMIN_PERM,
6517 .doit = nl80211_stop_ap, 6522 .doit = nl80211_stop_ap,
6518 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6523 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6519 NL80211_FLAG_NEED_RTNL, 6524 NL80211_FLAG_NEED_RTNL,
6520 }, 6525 },
6521 { 6526 {
@@ -6531,7 +6536,7 @@ static struct genl_ops nl80211_ops[] = {
6531 .doit = nl80211_set_station, 6536 .doit = nl80211_set_station,
6532 .policy = nl80211_policy, 6537 .policy = nl80211_policy,
6533 .flags = GENL_ADMIN_PERM, 6538 .flags = GENL_ADMIN_PERM,
6534 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6539 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6535 NL80211_FLAG_NEED_RTNL, 6540 NL80211_FLAG_NEED_RTNL,
6536 }, 6541 },
6537 { 6542 {
@@ -6547,7 +6552,7 @@ static struct genl_ops nl80211_ops[] = {
6547 .doit = nl80211_del_station, 6552 .doit = nl80211_del_station,
6548 .policy = nl80211_policy, 6553 .policy = nl80211_policy,
6549 .flags = GENL_ADMIN_PERM, 6554 .flags = GENL_ADMIN_PERM,
6550 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6555 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6551 NL80211_FLAG_NEED_RTNL, 6556 NL80211_FLAG_NEED_RTNL,
6552 }, 6557 },
6553 { 6558 {
@@ -6580,7 +6585,7 @@ static struct genl_ops nl80211_ops[] = {
6580 .doit = nl80211_del_mpath, 6585 .doit = nl80211_del_mpath,
6581 .policy = nl80211_policy, 6586 .policy = nl80211_policy,
6582 .flags = GENL_ADMIN_PERM, 6587 .flags = GENL_ADMIN_PERM,
6583 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6588 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6584 NL80211_FLAG_NEED_RTNL, 6589 NL80211_FLAG_NEED_RTNL,
6585 }, 6590 },
6586 { 6591 {
@@ -6588,7 +6593,7 @@ static struct genl_ops nl80211_ops[] = {
6588 .doit = nl80211_set_bss, 6593 .doit = nl80211_set_bss,
6589 .policy = nl80211_policy, 6594 .policy = nl80211_policy,
6590 .flags = GENL_ADMIN_PERM, 6595 .flags = GENL_ADMIN_PERM,
6591 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6596 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6592 NL80211_FLAG_NEED_RTNL, 6597 NL80211_FLAG_NEED_RTNL,
6593 }, 6598 },
6594 { 6599 {
@@ -6614,7 +6619,7 @@ static struct genl_ops nl80211_ops[] = {
6614 .doit = nl80211_get_mesh_config, 6619 .doit = nl80211_get_mesh_config,
6615 .policy = nl80211_policy, 6620 .policy = nl80211_policy,
6616 /* can be retrieved by unprivileged users */ 6621 /* can be retrieved by unprivileged users */
6617 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6622 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6618 NL80211_FLAG_NEED_RTNL, 6623 NL80211_FLAG_NEED_RTNL,
6619 }, 6624 },
6620 { 6625 {
@@ -6747,7 +6752,7 @@ static struct genl_ops nl80211_ops[] = {
6747 .doit = nl80211_setdel_pmksa, 6752 .doit = nl80211_setdel_pmksa,
6748 .policy = nl80211_policy, 6753 .policy = nl80211_policy,
6749 .flags = GENL_ADMIN_PERM, 6754 .flags = GENL_ADMIN_PERM,
6750 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6755 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6751 NL80211_FLAG_NEED_RTNL, 6756 NL80211_FLAG_NEED_RTNL,
6752 }, 6757 },
6753 { 6758 {
@@ -6755,7 +6760,7 @@ static struct genl_ops nl80211_ops[] = {
6755 .doit = nl80211_setdel_pmksa, 6760 .doit = nl80211_setdel_pmksa,
6756 .policy = nl80211_policy, 6761 .policy = nl80211_policy,
6757 .flags = GENL_ADMIN_PERM, 6762 .flags = GENL_ADMIN_PERM,
6758 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6763 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6759 NL80211_FLAG_NEED_RTNL, 6764 NL80211_FLAG_NEED_RTNL,
6760 }, 6765 },
6761 { 6766 {
@@ -6763,7 +6768,7 @@ static struct genl_ops nl80211_ops[] = {
6763 .doit = nl80211_flush_pmksa, 6768 .doit = nl80211_flush_pmksa,
6764 .policy = nl80211_policy, 6769 .policy = nl80211_policy,
6765 .flags = GENL_ADMIN_PERM, 6770 .flags = GENL_ADMIN_PERM,
6766 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6771 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6767 NL80211_FLAG_NEED_RTNL, 6772 NL80211_FLAG_NEED_RTNL,
6768 }, 6773 },
6769 { 6774 {
@@ -6923,7 +6928,7 @@ static struct genl_ops nl80211_ops[] = {
6923 .doit = nl80211_probe_client, 6928 .doit = nl80211_probe_client,
6924 .policy = nl80211_policy, 6929 .policy = nl80211_policy,
6925 .flags = GENL_ADMIN_PERM, 6930 .flags = GENL_ADMIN_PERM,
6926 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6931 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
6927 NL80211_FLAG_NEED_RTNL, 6932 NL80211_FLAG_NEED_RTNL,
6928 }, 6933 },
6929 { 6934 {
diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
index 9f544c95171..22adfebaad2 100644
--- a/net/wireless/wext-core.c
+++ b/net/wireless/wext-core.c
@@ -781,8 +781,10 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
781 if (cmd == SIOCSIWENCODEEXT) { 781 if (cmd == SIOCSIWENCODEEXT) {
782 struct iw_encode_ext *ee = (void *) extra; 782 struct iw_encode_ext *ee = (void *) extra;
783 783
784 if (iwp->length < sizeof(*ee) + ee->key_len) 784 if (iwp->length < sizeof(*ee) + ee->key_len) {
785 return -EFAULT; 785 err = -EFAULT;
786 goto out;
787 }
786 } 788 }
787 } 789 }
788 790
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3f01fd90873..c4e7d1510f9 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -132,8 +132,10 @@ static struct module *new_module(char *modname)
132 /* strip trailing .o */ 132 /* strip trailing .o */
133 s = strrchr(p, '.'); 133 s = strrchr(p, '.');
134 if (s != NULL) 134 if (s != NULL)
135 if (strcmp(s, ".o") == 0) 135 if (strcmp(s, ".o") == 0) {
136 *s = '\0'; 136 *s = '\0';
137 mod->is_dot_o = 1;
138 }
137 139
138 /* add to list */ 140 /* add to list */
139 mod->name = p; 141 mod->name = p;
@@ -587,7 +589,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
587 unsigned int crc; 589 unsigned int crc;
588 enum export export; 590 enum export export;
589 591
590 if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0) 592 if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
593 strncmp(symname, "__ksymtab", 9) == 0)
591 export = export_from_secname(info, get_secindex(info, sym)); 594 export = export_from_secname(info, get_secindex(info, sym));
592 else 595 else
593 export = export_from_sec(info, get_secindex(info, sym)); 596 export = export_from_sec(info, get_secindex(info, sym));
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 2031119080d..51207e4d5f8 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -113,6 +113,7 @@ struct module {
113 int has_cleanup; 113 int has_cleanup;
114 struct buffer dev_table_buf; 114 struct buffer dev_table_buf;
115 char srcversion[25]; 115 char srcversion[25];
116 int is_dot_o;
116}; 117};
117 118
118struct elf_info { 119struct elf_info {
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 81c03a59711..10056f2f6df 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1939,18 +1939,19 @@ static int smack_netlabel_send(struct sock *sk, struct sockaddr_in *sap)
1939 char *hostsp; 1939 char *hostsp;
1940 struct socket_smack *ssp = sk->sk_security; 1940 struct socket_smack *ssp = sk->sk_security;
1941 struct smk_audit_info ad; 1941 struct smk_audit_info ad;
1942 struct lsm_network_audit net;
1943 1942
1944 rcu_read_lock(); 1943 rcu_read_lock();
1945 hostsp = smack_host_label(sap); 1944 hostsp = smack_host_label(sap);
1946 if (hostsp != NULL) { 1945 if (hostsp != NULL) {
1947 sk_lbl = SMACK_UNLABELED_SOCKET;
1948#ifdef CONFIG_AUDIT 1946#ifdef CONFIG_AUDIT
1947 struct lsm_network_audit net;
1948
1949 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net); 1949 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
1950 ad.a.u.net->family = sap->sin_family; 1950 ad.a.u.net->family = sap->sin_family;
1951 ad.a.u.net->dport = sap->sin_port; 1951 ad.a.u.net->dport = sap->sin_port;
1952 ad.a.u.net->v4info.daddr = sap->sin_addr.s_addr; 1952 ad.a.u.net->v4info.daddr = sap->sin_addr.s_addr;
1953#endif 1953#endif
1954 sk_lbl = SMACK_UNLABELED_SOCKET;
1954 rc = smk_access(ssp->smk_out, hostsp, MAY_WRITE, &ad); 1955 rc = smk_access(ssp->smk_out, hostsp, MAY_WRITE, &ad);
1955 } else { 1956 } else {
1956 sk_lbl = SMACK_CIPSO_SOCKET; 1957 sk_lbl = SMACK_CIPSO_SOCKET;
@@ -2809,11 +2810,14 @@ static int smack_unix_stream_connect(struct sock *sock,
2809 struct socket_smack *osp = other->sk_security; 2810 struct socket_smack *osp = other->sk_security;
2810 struct socket_smack *nsp = newsk->sk_security; 2811 struct socket_smack *nsp = newsk->sk_security;
2811 struct smk_audit_info ad; 2812 struct smk_audit_info ad;
2812 struct lsm_network_audit net;
2813 int rc = 0; 2813 int rc = 0;
2814 2814
2815#ifdef CONFIG_AUDIT
2816 struct lsm_network_audit net;
2817
2815 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net); 2818 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
2816 smk_ad_setfield_u_net_sk(&ad, other); 2819 smk_ad_setfield_u_net_sk(&ad, other);
2820#endif
2817 2821
2818 if (!capable(CAP_MAC_OVERRIDE)) 2822 if (!capable(CAP_MAC_OVERRIDE))
2819 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad); 2823 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad);
@@ -2842,11 +2846,14 @@ static int smack_unix_may_send(struct socket *sock, struct socket *other)
2842 struct socket_smack *ssp = sock->sk->sk_security; 2846 struct socket_smack *ssp = sock->sk->sk_security;
2843 struct socket_smack *osp = other->sk->sk_security; 2847 struct socket_smack *osp = other->sk->sk_security;
2844 struct smk_audit_info ad; 2848 struct smk_audit_info ad;
2845 struct lsm_network_audit net;
2846 int rc = 0; 2849 int rc = 0;
2847 2850
2851#ifdef CONFIG_AUDIT
2852 struct lsm_network_audit net;
2853
2848 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net); 2854 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
2849 smk_ad_setfield_u_net_sk(&ad, other->sk); 2855 smk_ad_setfield_u_net_sk(&ad, other->sk);
2856#endif
2850 2857
2851 if (!capable(CAP_MAC_OVERRIDE)) 2858 if (!capable(CAP_MAC_OVERRIDE))
2852 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad); 2859 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad);
@@ -2993,7 +3000,9 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
2993 char *csp; 3000 char *csp;
2994 int rc; 3001 int rc;
2995 struct smk_audit_info ad; 3002 struct smk_audit_info ad;
3003#ifdef CONFIG_AUDIT
2996 struct lsm_network_audit net; 3004 struct lsm_network_audit net;
3005#endif
2997 if (sk->sk_family != PF_INET && sk->sk_family != PF_INET6) 3006 if (sk->sk_family != PF_INET && sk->sk_family != PF_INET6)
2998 return 0; 3007 return 0;
2999 3008
@@ -3156,7 +3165,9 @@ static int smack_inet_conn_request(struct sock *sk, struct sk_buff *skb,
3156 char *sp; 3165 char *sp;
3157 int rc; 3166 int rc;
3158 struct smk_audit_info ad; 3167 struct smk_audit_info ad;
3168#ifdef CONFIG_AUDIT
3159 struct lsm_network_audit net; 3169 struct lsm_network_audit net;
3170#endif
3160 3171
3161 /* handle mapped IPv4 packets arriving via IPv6 sockets */ 3172 /* handle mapped IPv4 packets arriving via IPv6 sockets */
3162 if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP)) 3173 if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP))
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index b4a6aa960f4..8490f59709b 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -1019,13 +1019,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1019 irq_cfg = get_irq_config(sscape->type, irq[dev]); 1019 irq_cfg = get_irq_config(sscape->type, irq[dev]);
1020 if (irq_cfg == INVALID_IRQ) { 1020 if (irq_cfg == INVALID_IRQ) {
1021 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); 1021 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
1022 return -ENXIO; 1022 err = -ENXIO;
1023 goto _release_dma;
1023 } 1024 }
1024 1025
1025 mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); 1026 mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]);
1026 if (mpu_irq_cfg == INVALID_IRQ) { 1027 if (mpu_irq_cfg == INVALID_IRQ) {
1027 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); 1028 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1028 return -ENXIO; 1029 err = -ENXIO;
1030 goto _release_dma;
1029 } 1031 }
1030 1032
1031 /* 1033 /*
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index 2c79d60a725..536c4c0514d 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -1294,6 +1294,8 @@ static int __init calibrate_adc(WORD srate)
1294 1294
1295static int upload_dsp_code(void) 1295static int upload_dsp_code(void)
1296{ 1296{
1297 int ret = 0;
1298
1297 msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS); 1299 msnd_outb(HPBLKSEL_0, dev.io + HP_BLKS);
1298#ifndef HAVE_DSPCODEH 1300#ifndef HAVE_DSPCODEH
1299 INITCODESIZE = mod_firmware_load(INITCODEFILE, &INITCODE); 1301 INITCODESIZE = mod_firmware_load(INITCODEFILE, &INITCODE);
@@ -1312,7 +1314,8 @@ static int upload_dsp_code(void)
1312 memcpy_toio(dev.base, PERMCODE, PERMCODESIZE); 1314 memcpy_toio(dev.base, PERMCODE, PERMCODESIZE);
1313 if (msnd_upload_host(&dev, INITCODE, INITCODESIZE) < 0) { 1315 if (msnd_upload_host(&dev, INITCODE, INITCODESIZE) < 0) {
1314 printk(KERN_WARNING LOGNAME ": Error uploading to DSP\n"); 1316 printk(KERN_WARNING LOGNAME ": Error uploading to DSP\n");
1315 return -ENODEV; 1317 ret = -ENODEV;
1318 goto out;
1316 } 1319 }
1317#ifdef HAVE_DSPCODEH 1320#ifdef HAVE_DSPCODEH
1318 printk(KERN_INFO LOGNAME ": DSP firmware uploaded (resident)\n"); 1321 printk(KERN_INFO LOGNAME ": DSP firmware uploaded (resident)\n");
@@ -1320,12 +1323,13 @@ static int upload_dsp_code(void)
1320 printk(KERN_INFO LOGNAME ": DSP firmware uploaded\n"); 1323 printk(KERN_INFO LOGNAME ": DSP firmware uploaded\n");
1321#endif 1324#endif
1322 1325
1326out:
1323#ifndef HAVE_DSPCODEH 1327#ifndef HAVE_DSPCODEH
1324 vfree(INITCODE); 1328 vfree(INITCODE);
1325 vfree(PERMCODE); 1329 vfree(PERMCODE);
1326#endif 1330#endif
1327 1331
1328 return 0; 1332 return ret;
1329} 1333}
1330 1334
1331#ifdef MSND_CLASSIC 1335#ifdef MSND_CLASSIC
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 88168044375..5ca0939e422 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -2,8 +2,8 @@
2 2
3config SND_TEA575X 3config SND_TEA575X
4 tristate 4 tristate
5 depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO || RADIO_SF16FMR2 5 depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO || RADIO_SF16FMR2 || RADIO_MAXIRADIO
6 default SND_FM801 || SND_ES1968 || RADIO_SF16FMR2 6 default SND_FM801 || SND_ES1968 || RADIO_SF16FMR2 || RADIO_MAXIRADIO
7 7
8menuconfig SND_PCI 8menuconfig SND_PCI
9 bool "PCI sound devices" 9 bool "PCI sound devices"
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index 8c63200cf33..bc86cb726d7 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2012 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -42,7 +42,7 @@ On error *pLockedMemHandle marked invalid, non-zero returned.
42If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and 42If this function succeeds, then HpiOs_LockedMem_GetVirtAddr() and
43HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle. 43HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle.
44*/ 44*/
45int hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle, 45u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
46 /**< memory handle */ 46 /**< memory handle */
47 u32 size, /**< Size in bytes to allocate */ 47 u32 size, /**< Size in bytes to allocate */
48 struct pci_dev *p_os_reference 48 struct pci_dev *p_os_reference
diff --git a/sound/pci/asihpi/hpios.c b/sound/pci/asihpi/hpios.c
index 87f4385fe8c..5ef4fe96436 100644
--- a/sound/pci/asihpi/hpios.c
+++ b/sound/pci/asihpi/hpios.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2012 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -39,11 +39,11 @@ void hpios_delay_micro_seconds(u32 num_micro_sec)
39 39
40} 40}
41 41
42/** Allocated an area of locked memory for bus master DMA operations. 42/** Allocate an area of locked memory for bus master DMA operations.
43 43
44On error, return -ENOMEM, and *pMemArea.size = 0 44If allocation fails, return 1, and *pMemArea.size = 0
45*/ 45*/
46int hpios_locked_mem_alloc(struct consistent_dma_area *p_mem_area, u32 size, 46u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_mem_area, u32 size,
47 struct pci_dev *pdev) 47 struct pci_dev *pdev)
48{ 48{
49 /*?? any benefit in using managed dmam_alloc_coherent? */ 49 /*?? any benefit in using managed dmam_alloc_coherent? */
@@ -62,7 +62,7 @@ int hpios_locked_mem_alloc(struct consistent_dma_area *p_mem_area, u32 size,
62 HPI_DEBUG_LOG(WARNING, 62 HPI_DEBUG_LOG(WARNING,
63 "failed to allocate %d bytes locked memory\n", size); 63 "failed to allocate %d bytes locked memory\n", size);
64 p_mem_area->size = 0; 64 p_mem_area->size = 0;
65 return -ENOMEM; 65 return 1;
66 } 66 }
67} 67}
68 68
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 9a9f372e1be..56b4f74c0b1 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -851,6 +851,9 @@ struct hda_codec {
851 unsigned int pin_amp_workaround:1; /* pin out-amp takes index 851 unsigned int pin_amp_workaround:1; /* pin out-amp takes index
852 * (e.g. Conexant codecs) 852 * (e.g. Conexant codecs)
853 */ 853 */
854 unsigned int single_adc_amp:1; /* adc in-amp takes no index
855 * (e.g. CX20549 codec)
856 */
854 unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */ 857 unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */
855 unsigned int pins_shutup:1; /* pins are shut up */ 858 unsigned int pins_shutup:1; /* pins are shut up */
856 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ 859 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index b58b4b1687f..4c054f4486b 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -418,7 +418,7 @@ static void hdmi_show_short_audio_desc(struct cea_sad *a)
418 else 418 else
419 buf2[0] = '\0'; 419 buf2[0] = '\0';
420 420
421 printk(KERN_INFO "HDMI: supports coding type %s:" 421 _snd_printd(SND_PR_VERBOSE, "HDMI: supports coding type %s:"
422 " channels = %d, rates =%s%s\n", 422 " channels = %d, rates =%s%s\n",
423 cea_audio_coding_type_names[a->format], 423 cea_audio_coding_type_names[a->format],
424 a->channels, 424 a->channels,
@@ -442,14 +442,14 @@ void snd_hdmi_show_eld(struct hdmi_eld *e)
442{ 442{
443 int i; 443 int i;
444 444
445 printk(KERN_INFO "HDMI: detected monitor %s at connection type %s\n", 445 _snd_printd(SND_PR_VERBOSE, "HDMI: detected monitor %s at connection type %s\n",
446 e->monitor_name, 446 e->monitor_name,
447 eld_connection_type_names[e->conn_type]); 447 eld_connection_type_names[e->conn_type]);
448 448
449 if (e->spk_alloc) { 449 if (e->spk_alloc) {
450 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; 450 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
451 snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf)); 451 snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
452 printk(KERN_INFO "HDMI: available speakers:%s\n", buf); 452 _snd_printd(SND_PR_VERBOSE, "HDMI: available speakers:%s\n", buf);
453 } 453 }
454 454
455 for (i = 0; i < e->sad_count; i++) 455 for (i = 0; i < e->sad_count; i++)
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 254ab520460..e59e2f059b6 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -651,9 +651,16 @@ static void print_codec_info(struct snd_info_entry *entry,
651 snd_iprintf(buffer, " Amp-In caps: "); 651 snd_iprintf(buffer, " Amp-In caps: ");
652 print_amp_caps(buffer, codec, nid, HDA_INPUT); 652 print_amp_caps(buffer, codec, nid, HDA_INPUT);
653 snd_iprintf(buffer, " Amp-In vals: "); 653 snd_iprintf(buffer, " Amp-In vals: ");
654 print_amp_vals(buffer, codec, nid, HDA_INPUT, 654 if (wid_type == AC_WID_PIN ||
655 wid_caps & AC_WCAP_STEREO, 655 (codec->single_adc_amp &&
656 wid_type == AC_WID_PIN ? 1 : conn_len); 656 wid_type == AC_WID_AUD_IN))
657 print_amp_vals(buffer, codec, nid, HDA_INPUT,
658 wid_caps & AC_WCAP_STEREO,
659 1);
660 else
661 print_amp_vals(buffer, codec, nid, HDA_INPUT,
662 wid_caps & AC_WCAP_STEREO,
663 conn_len);
657 } 664 }
658 if (wid_caps & AC_WCAP_OUT_AMP) { 665 if (wid_caps & AC_WCAP_OUT_AMP) {
659 snd_iprintf(buffer, " Amp-Out caps: "); 666 snd_iprintf(buffer, " Amp-Out caps: ");
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 8c6523bbc79..a36488d94aa 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -141,7 +141,6 @@ struct conexant_spec {
141 unsigned int hp_laptop:1; 141 unsigned int hp_laptop:1;
142 unsigned int asus:1; 142 unsigned int asus:1;
143 unsigned int pin_eapd_ctrls:1; 143 unsigned int pin_eapd_ctrls:1;
144 unsigned int single_adc_amp:1;
145 144
146 unsigned int adc_switching:1; 145 unsigned int adc_switching:1;
147 146
@@ -687,27 +686,26 @@ static const struct hda_channel_mode cxt5045_modes[1] = {
687static const struct hda_input_mux cxt5045_capture_source = { 686static const struct hda_input_mux cxt5045_capture_source = {
688 .num_items = 2, 687 .num_items = 2,
689 .items = { 688 .items = {
690 { "IntMic", 0x1 }, 689 { "Internal Mic", 0x1 },
691 { "ExtMic", 0x2 }, 690 { "Mic", 0x2 },
692 } 691 }
693}; 692};
694 693
695static const struct hda_input_mux cxt5045_capture_source_benq = { 694static const struct hda_input_mux cxt5045_capture_source_benq = {
696 .num_items = 5, 695 .num_items = 4,
697 .items = { 696 .items = {
698 { "IntMic", 0x1 }, 697 { "Internal Mic", 0x1 },
699 { "ExtMic", 0x2 }, 698 { "Mic", 0x2 },
700 { "LineIn", 0x3 }, 699 { "Line", 0x3 },
701 { "CD", 0x4 }, 700 { "Mixer", 0x0 },
702 { "Mixer", 0x0 },
703 } 701 }
704}; 702};
705 703
706static const struct hda_input_mux cxt5045_capture_source_hp530 = { 704static const struct hda_input_mux cxt5045_capture_source_hp530 = {
707 .num_items = 2, 705 .num_items = 2,
708 .items = { 706 .items = {
709 { "ExtMic", 0x1 }, 707 { "Mic", 0x1 },
710 { "IntMic", 0x2 }, 708 { "Internal Mic", 0x2 },
711 } 709 }
712}; 710};
713 711
@@ -798,10 +796,8 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
798} 796}
799 797
800static const struct snd_kcontrol_new cxt5045_mixers[] = { 798static const struct snd_kcontrol_new cxt5045_mixers[] = {
801 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), 799 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
802 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), 800 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
803 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
804 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
805 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 801 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
806 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 802 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 803 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
@@ -822,27 +818,15 @@ static const struct snd_kcontrol_new cxt5045_mixers[] = {
822}; 818};
823 819
824static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 820static const struct snd_kcontrol_new cxt5045_benq_mixers[] = {
825 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT), 821 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT),
826 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT), 822 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT),
827 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT),
828 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT),
829
830 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
831 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
832 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
833 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
834
835 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT),
836 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT),
837 823
838 {} 824 {}
839}; 825};
840 826
841static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 827static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
842 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), 828 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
843 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), 829 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
844 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
845 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
846 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 830 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
847 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 831 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
848 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 832 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
@@ -946,10 +930,10 @@ static const struct snd_kcontrol_new cxt5045_test_mixer[] = {
946 /* Output controls */ 930 /* Output controls */
947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 931 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 932 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
949 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT), 933 HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT),
950 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT), 934 HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT),
951 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 935 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
952 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 936 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
953 937
954 /* Modes for retasking pin widgets */ 938 /* Modes for retasking pin widgets */
955 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 939 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
@@ -960,16 +944,16 @@ static const struct snd_kcontrol_new cxt5045_test_mixer[] = {
960 944
961 /* Loopback mixer controls */ 945 /* Loopback mixer controls */
962 946
963 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT), 947 HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT),
964 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT), 948 HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT),
965 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT), 949 HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT),
966 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT), 950 HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT),
967 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT), 951 HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT),
968 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT), 952 HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT),
969 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT), 953 HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT),
970 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT), 954 HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT),
971 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT), 955 HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT),
972 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT), 956 HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT),
973 { 957 {
974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
975 .name = "Input Source", 959 .name = "Input Source",
@@ -978,16 +962,8 @@ static const struct snd_kcontrol_new cxt5045_test_mixer[] = {
978 .put = conexant_mux_enum_put, 962 .put = conexant_mux_enum_put,
979 }, 963 },
980 /* Audio input controls */ 964 /* Audio input controls */
981 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT), 965 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
982 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT), 966 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
983 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
984 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
985 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
986 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
987 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
988 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
989 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
990 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
991 { } /* end */ 967 { } /* end */
992}; 968};
993 969
@@ -1009,10 +985,6 @@ static const struct hda_verb cxt5045_test_init_verbs[] = {
1009 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 985 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1010 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 986 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1011 987
1012 /* Start with output sum widgets muted and their output gains at min */
1013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1015
1016 /* Unmute retasking pin widget output buffers since the default 988 /* Unmute retasking pin widget output buffers since the default
1017 * state appears to be output. As the pin mode is changed by the 989 * state appears to be output. As the pin mode is changed by the
1018 * user the pin mode control will take care of enabling the pin's 990 * user the pin mode control will take care of enabling the pin's
@@ -1027,11 +999,11 @@ static const struct hda_verb cxt5045_test_init_verbs[] = {
1027 /* Set ADC connection select to match default mixer setting (mic1 999 /* Set ADC connection select to match default mixer setting (mic1
1028 * pin) 1000 * pin)
1029 */ 1001 */
1030 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1002 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1031 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, 1003 {0x17, AC_VERB_SET_CONNECT_SEL, 0x01},
1032 1004
1033 /* Mute all inputs to mixer widget (even unconnected ones) */ 1005 /* Mute all inputs to mixer widget (even unconnected ones) */
1034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ 1006 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */
1035 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 1007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
1036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 1008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
1037 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 1009 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
@@ -1110,7 +1082,7 @@ static int patch_cxt5045(struct hda_codec *codec)
1110 if (!spec) 1082 if (!spec)
1111 return -ENOMEM; 1083 return -ENOMEM;
1112 codec->spec = spec; 1084 codec->spec = spec;
1113 codec->pin_amp_workaround = 1; 1085 codec->single_adc_amp = 1;
1114 1086
1115 spec->multiout.max_channels = 2; 1087 spec->multiout.max_channels = 2;
1116 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1088 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
@@ -4220,7 +4192,7 @@ static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid,
4220 int idx = get_input_connection(codec, adc_nid, nid); 4192 int idx = get_input_connection(codec, adc_nid, nid);
4221 if (idx < 0) 4193 if (idx < 0)
4222 continue; 4194 continue;
4223 if (spec->single_adc_amp) 4195 if (codec->single_adc_amp)
4224 idx = 0; 4196 idx = 0;
4225 return cx_auto_add_volume_idx(codec, label, pfx, 4197 return cx_auto_add_volume_idx(codec, label, pfx,
4226 cidx, adc_nid, HDA_INPUT, idx); 4198 cidx, adc_nid, HDA_INPUT, idx);
@@ -4275,7 +4247,7 @@ static int cx_auto_build_input_controls(struct hda_codec *codec)
4275 if (cidx < 0) 4247 if (cidx < 0)
4276 continue; 4248 continue;
4277 input_conn[i] = spec->imux_info[i].adc; 4249 input_conn[i] = spec->imux_info[i].adc;
4278 if (!spec->single_adc_amp) 4250 if (!codec->single_adc_amp)
4279 input_conn[i] |= cidx << 8; 4251 input_conn[i] |= cidx << 8;
4280 if (i > 0 && input_conn[i] != input_conn[0]) 4252 if (i > 0 && input_conn[i] != input_conn[0])
4281 multi_connection = 1; 4253 multi_connection = 1;
@@ -4466,15 +4438,17 @@ static int patch_conexant_auto(struct hda_codec *codec)
4466 if (!spec) 4438 if (!spec)
4467 return -ENOMEM; 4439 return -ENOMEM;
4468 codec->spec = spec; 4440 codec->spec = spec;
4469 codec->pin_amp_workaround = 1;
4470 4441
4471 switch (codec->vendor_id) { 4442 switch (codec->vendor_id) {
4472 case 0x14f15045: 4443 case 0x14f15045:
4473 spec->single_adc_amp = 1; 4444 codec->single_adc_amp = 1;
4474 break; 4445 break;
4475 case 0x14f15051: 4446 case 0x14f15051:
4476 add_cx5051_fake_mutes(codec); 4447 add_cx5051_fake_mutes(codec);
4448 codec->pin_amp_workaround = 1;
4477 break; 4449 break;
4450 default:
4451 codec->pin_amp_workaround = 1;
4478 } 4452 }
4479 4453
4480 apply_pin_fixup(codec, cxt_fixups, cxt_pincfg_tbl); 4454 apply_pin_fixup(codec, cxt_fixups, cxt_pincfg_tbl);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 540cd13f7f1..83f345f3c96 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -757,8 +757,6 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
757 struct hdmi_spec *spec = codec->spec; 757 struct hdmi_spec *spec = codec->spec;
758 int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 758 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
759 int pin_nid; 759 int pin_nid;
760 int pd = !!(res & AC_UNSOL_RES_PD);
761 int eldv = !!(res & AC_UNSOL_RES_ELDV);
762 int pin_idx; 760 int pin_idx;
763 struct hda_jack_tbl *jack; 761 struct hda_jack_tbl *jack;
764 762
@@ -768,9 +766,10 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
768 pin_nid = jack->nid; 766 pin_nid = jack->nid;
769 jack->jack_dirty = 1; 767 jack->jack_dirty = 1;
770 768
771 printk(KERN_INFO 769 _snd_printd(SND_PR_VERBOSE,
772 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 770 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
773 codec->addr, pin_nid, pd, eldv); 771 codec->addr, pin_nid,
772 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
774 773
775 pin_idx = pin_nid_to_pin_index(spec, pin_nid); 774 pin_idx = pin_nid_to_pin_index(spec, pin_nid);
776 if (pin_idx < 0) 775 if (pin_idx < 0)
@@ -992,7 +991,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
992 if (eld->monitor_present) 991 if (eld->monitor_present)
993 eld_valid = !!(present & AC_PINSENSE_ELDV); 992 eld_valid = !!(present & AC_PINSENSE_ELDV);
994 993
995 printk(KERN_INFO 994 _snd_printd(SND_PR_VERBOSE,
996 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 995 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
997 codec->addr, pin_nid, eld->monitor_present, eld_valid); 996 codec->addr, pin_nid, eld->monitor_present, eld_valid);
998 997
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index f8e10ced244..b3e24f28942 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -140,7 +140,7 @@
140 * min : 0xFE : -115.0 dB 140 * min : 0xFE : -115.0 dB
141 * mute: 0xFF 141 * mute: 0xFF
142 */ 142 */
143static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1); 143static const DECLARE_TLV_DB_SCALE(out_tlv, -11550, 50, 1);
144 144
145static const struct snd_kcontrol_new ak4642_snd_controls[] = { 145static const struct snd_kcontrol_new ak4642_snd_controls[] = {
146 146
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index d1926266fe0..8e92fb88ed0 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -143,11 +143,11 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
143} 143}
144 144
145/* 145/*
146 * using codec assist to small pop, hp_powerup or lineout_powerup 146 * As manual described, ADC/DAC only works when VAG powerup,
147 * should stay setting until vag_powerup is fully ramped down, 147 * So enabled VAG before ADC/DAC up.
148 * vag fully ramped down require 400ms. 148 * In power down case, we need wait 400ms when vag fully ramped down.
149 */ 149 */
150static int small_pop_event(struct snd_soc_dapm_widget *w, 150static int power_vag_event(struct snd_soc_dapm_widget *w,
151 struct snd_kcontrol *kcontrol, int event) 151 struct snd_kcontrol *kcontrol, int event)
152{ 152{
153 switch (event) { 153 switch (event) {
@@ -156,7 +156,7 @@ static int small_pop_event(struct snd_soc_dapm_widget *w,
156 SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); 156 SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
157 break; 157 break;
158 158
159 case SND_SOC_DAPM_PRE_PMD: 159 case SND_SOC_DAPM_POST_PMD:
160 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, 160 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
161 SGTL5000_VAG_POWERUP, 0); 161 SGTL5000_VAG_POWERUP, 0);
162 msleep(400); 162 msleep(400);
@@ -201,12 +201,8 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
201 mic_bias_event, 201 mic_bias_event,
202 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 202 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
203 203
204 SND_SOC_DAPM_PGA_E("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0, 204 SND_SOC_DAPM_PGA("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0),
205 small_pop_event, 205 SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),
206 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
207 SND_SOC_DAPM_PGA_E("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0,
208 small_pop_event,
209 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
210 206
211 SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux), 207 SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux),
212 SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux), 208 SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux),
@@ -221,8 +217,11 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
221 0, SGTL5000_CHIP_DIG_POWER, 217 0, SGTL5000_CHIP_DIG_POWER,
222 1, 0), 218 1, 0),
223 219
224 SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0), 220 SND_SOC_DAPM_SUPPLY("VAG_POWER", SGTL5000_CHIP_ANA_POWER, 7, 0,
221 power_vag_event,
222 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
225 223
224 SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0),
226 SND_SOC_DAPM_DAC("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0), 225 SND_SOC_DAPM_DAC("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0),
227}; 226};
228 227
@@ -231,9 +230,11 @@ static const struct snd_soc_dapm_route sgtl5000_dapm_routes[] = {
231 {"Capture Mux", "LINE_IN", "LINE_IN"}, /* line_in --> adc_mux */ 230 {"Capture Mux", "LINE_IN", "LINE_IN"}, /* line_in --> adc_mux */
232 {"Capture Mux", "MIC_IN", "MIC_IN"}, /* mic_in --> adc_mux */ 231 {"Capture Mux", "MIC_IN", "MIC_IN"}, /* mic_in --> adc_mux */
233 232
233 {"ADC", NULL, "VAG_POWER"},
234 {"ADC", NULL, "Capture Mux"}, /* adc_mux --> adc */ 234 {"ADC", NULL, "Capture Mux"}, /* adc_mux --> adc */
235 {"AIFOUT", NULL, "ADC"}, /* adc --> i2s_out */ 235 {"AIFOUT", NULL, "ADC"}, /* adc --> i2s_out */
236 236
237 {"DAC", NULL, "VAG_POWER"},
237 {"DAC", NULL, "AIFIN"}, /* i2s-->dac,skip audio mux */ 238 {"DAC", NULL, "AIFIN"}, /* i2s-->dac,skip audio mux */
238 {"Headphone Mux", "DAC", "DAC"}, /* dac --> hp_mux */ 239 {"Headphone Mux", "DAC", "DAC"}, /* dac --> hp_mux */
239 {"LO", NULL, "DAC"}, /* dac --> line_out */ 240 {"LO", NULL, "DAC"}, /* dac --> line_out */
diff --git a/sound/soc/imx/imx-audmux.c b/sound/soc/imx/imx-audmux.c
index 1765a197acb..f23700359c6 100644
--- a/sound/soc/imx/imx-audmux.c
+++ b/sound/soc/imx/imx-audmux.c
@@ -73,6 +73,9 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
73 if (!buf) 73 if (!buf)
74 return -ENOMEM; 74 return -ENOMEM;
75 75
76 if (!audmux_base)
77 return -ENOSYS;
78
76 if (audmux_clk) 79 if (audmux_clk)
77 clk_prepare_enable(audmux_clk); 80 clk_prepare_enable(audmux_clk);
78 81
@@ -152,7 +155,7 @@ static void __init audmux_debugfs_init(void)
152 return; 155 return;
153 } 156 }
154 157
155 for (i = 1; i < 8; i++) { 158 for (i = 0; i < MX31_AUDMUX_PORT6_SSI_PINS_6 + 1; i++) {
156 snprintf(buf, sizeof(buf), "ssi%d", i); 159 snprintf(buf, sizeof(buf), "ssi%d", i);
157 if (!debugfs_create_file(buf, 0444, audmux_debugfs_root, 160 if (!debugfs_create_file(buf, 0444, audmux_debugfs_root,
158 (void *)i, &audmux_debugfs_fops)) 161 (void *)i, &audmux_debugfs_fops))
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index 609abd51e55..d08583790d2 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/io.h>
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
22#include <sound/initval.h> 23#include <sound/initval.h>
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e19c24ade41..accdcb7d4d9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1081,6 +1081,8 @@ static int soc_probe_platform(struct snd_soc_card *card,
1081 snd_soc_dapm_new_controls(&platform->dapm, 1081 snd_soc_dapm_new_controls(&platform->dapm,
1082 driver->dapm_widgets, driver->num_dapm_widgets); 1082 driver->dapm_widgets, driver->num_dapm_widgets);
1083 1083
1084 platform->dapm.idle_bias_off = 1;
1085
1084 if (driver->probe) { 1086 if (driver->probe) {
1085 ret = driver->probe(platform); 1087 ret = driver->probe(platform);
1086 if (ret < 0) { 1088 if (ret < 0) {
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index 33509de5254..e53349912b2 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -79,11 +79,15 @@ static int tegra_i2s_show(struct seq_file *s, void *unused)
79 struct tegra_i2s *i2s = s->private; 79 struct tegra_i2s *i2s = s->private;
80 int i; 80 int i;
81 81
82 clk_enable(i2s->clk_i2s);
83
82 for (i = 0; i < ARRAY_SIZE(regs); i++) { 84 for (i = 0; i < ARRAY_SIZE(regs); i++) {
83 u32 val = tegra_i2s_read(i2s, regs[i].offset); 85 u32 val = tegra_i2s_read(i2s, regs[i].offset);
84 seq_printf(s, "%s = %08x\n", regs[i].name, val); 86 seq_printf(s, "%s = %08x\n", regs[i].name, val);
85 } 87 }
86 88
89 clk_disable(i2s->clk_i2s);
90
87 return 0; 91 return 0;
88} 92}
89 93
@@ -112,7 +116,7 @@ static void tegra_i2s_debug_remove(struct tegra_i2s *i2s)
112 debugfs_remove(i2s->debug); 116 debugfs_remove(i2s->debug);
113} 117}
114#else 118#else
115static inline void tegra_i2s_debug_add(struct tegra_i2s *i2s, int id) 119static inline void tegra_i2s_debug_add(struct tegra_i2s *i2s)
116{ 120{
117} 121}
118 122
diff --git a/sound/soc/tegra/tegra_spdif.c b/sound/soc/tegra/tegra_spdif.c
index 475428cf270..9ff2c601445 100644
--- a/sound/soc/tegra/tegra_spdif.c
+++ b/sound/soc/tegra/tegra_spdif.c
@@ -79,11 +79,15 @@ static int tegra_spdif_show(struct seq_file *s, void *unused)
79 struct tegra_spdif *spdif = s->private; 79 struct tegra_spdif *spdif = s->private;
80 int i; 80 int i;
81 81
82 clk_enable(spdif->clk_spdif_out);
83
82 for (i = 0; i < ARRAY_SIZE(regs); i++) { 84 for (i = 0; i < ARRAY_SIZE(regs); i++) {
83 u32 val = tegra_spdif_read(spdif, regs[i].offset); 85 u32 val = tegra_spdif_read(spdif, regs[i].offset);
84 seq_printf(s, "%s = %08x\n", regs[i].name, val); 86 seq_printf(s, "%s = %08x\n", regs[i].name, val);
85 } 87 }
86 88
89 clk_disable(spdif->clk_spdif_out);
90
87 return 0; 91 return 0;
88} 92}
89 93