aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/00-INDEX42
-rw-r--r--Documentation/PCI/00-INDEX2
-rw-r--r--Documentation/PCI/MSI-HOWTO.txt (renamed from Documentation/MSI-HOWTO.txt)0
-rw-r--r--Documentation/blockdev/00-INDEX16
-rw-r--r--Documentation/blockdev/README.DAC960 (renamed from Documentation/README.DAC960)0
-rw-r--r--Documentation/blockdev/cciss.txt (renamed from Documentation/cciss.txt)0
-rw-r--r--Documentation/blockdev/cpqarray.txt (renamed from Documentation/cpqarray.txt)0
-rw-r--r--Documentation/blockdev/floppy.txt (renamed from Documentation/floppy.txt)0
-rw-r--r--Documentation/blockdev/nbd.txt (renamed from Documentation/nbd.txt)0
-rw-r--r--Documentation/blockdev/paride.txt (renamed from Documentation/paride.txt)0
-rw-r--r--Documentation/blockdev/ramdisk.txt (renamed from Documentation/ramdisk.txt)0
-rw-r--r--Documentation/ioctl/00-INDEX10
-rw-r--r--Documentation/ioctl/ioctl-number.txt (renamed from Documentation/ioctl-number.txt)0
-rw-r--r--Documentation/kernel-parameters.txt35
-rw-r--r--Documentation/lockstat.txt51
-rw-r--r--Documentation/networking/phy.txt2
-rw-r--r--Documentation/serial/00-INDEX24
-rw-r--r--Documentation/serial/README.cycladesZ (renamed from Documentation/README.cycladesZ)0
-rw-r--r--Documentation/serial/computone.txt (renamed from Documentation/computone.txt)2
-rw-r--r--Documentation/serial/digiepca.txt (renamed from Documentation/digiepca.txt)0
-rw-r--r--Documentation/serial/hayes-esp.txt (renamed from Documentation/hayes-esp.txt)0
-rw-r--r--Documentation/serial/moxa-smartio (renamed from Documentation/moxa-smartio)0
-rw-r--r--Documentation/serial/riscom8.txt (renamed from Documentation/riscom8.txt)0
-rw-r--r--Documentation/serial/rocket.txt (renamed from Documentation/rocket.txt)0
-rw-r--r--Documentation/serial/specialix.txt (renamed from Documentation/specialix.txt)0
-rw-r--r--Documentation/serial/stallion.txt (renamed from Documentation/stallion.txt)0
-rw-r--r--Documentation/serial/sx.txt (renamed from Documentation/sx.txt)0
-rw-r--r--Documentation/serial/tty.txt (renamed from Documentation/tty.txt)0
-rw-r--r--MAINTAINERS4
-rw-r--r--Makefile2
-rw-r--r--arch/arm/include/asm/dma-mapping.h13
-rw-r--r--arch/arm/include/asm/mach/map.h13
-rw-r--r--arch/arm/mach-clps711x/include/mach/hardware.h22
-rw-r--r--arch/arm/mach-clps7500/core.c6
-rw-r--r--arch/arm/mach-clps7500/include/mach/hardware.h6
-rw-r--r--arch/arm/mach-h720x/include/mach/boards.h6
-rw-r--r--arch/arm/mach-integrator/include/mach/platform.h19
-rw-r--r--arch/arm/mach-pxa/include/mach/pxafb.h1
-rw-r--r--arch/arm/mach-pxa/reset.c7
-rw-r--r--arch/arm/mach-pxa/spitz.c4
-rw-r--r--arch/arm/mach-realview/clock.c2
-rw-r--r--arch/arm/mach-realview/include/mach/platform.h19
-rw-r--r--arch/arm/mach-versatile/clock.c2
-rw-r--r--arch/arm/mach-versatile/include/mach/platform.h18
-rw-r--r--arch/arm/mm/cache-feroceon-l2.c4
-rw-r--r--arch/arm/mm/mmu.c6
-rw-r--r--arch/arm/plat-iop/setup.c5
-rw-r--r--arch/blackfin/include/asm/bfin-global.h2
-rw-r--r--arch/blackfin/include/asm/dma-mapping.h6
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c2
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbinit.c9
-rw-r--r--arch/blackfin/kernel/process.c7
-rw-r--r--arch/blackfin/kernel/setup.c12
-rw-r--r--arch/blackfin/kernel/traps.c11
-rw-r--r--arch/blackfin/mach-common/cache.S8
-rw-r--r--arch/blackfin/mach-common/cpufreq.c14
-rw-r--r--arch/blackfin/mach-common/entry.S2
-rw-r--r--arch/blackfin/mm/sram-alloc.c8
-rw-r--r--arch/ia64/include/asm/intrinsics.h2
-rw-r--r--arch/ia64/include/asm/paravirt_privop.h13
-rw-r--r--arch/ia64/kernel/entry.S1
-rw-r--r--arch/ia64/kernel/head.S2
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/kernel/paravirt.c2
-rw-r--r--arch/ia64/kernel/pci-dma.c1
-rw-r--r--arch/ia64/xen/hypercall.S2
-rw-r--r--arch/m68k/kernel/ints.c2
-rw-r--r--arch/mips/include/asm/mach-rc32434/gpio.h2
-rw-r--r--arch/mips/include/asm/mach-rc32434/rb.h14
-rw-r--r--arch/mips/include/asm/time.h2
-rw-r--r--arch/mips/kernel/csrc-r4k.c2
-rw-r--r--arch/mips/mm/sc-ip22.c2
-rw-r--r--arch/mips/mti-malta/malta-amon.c6
-rw-r--r--arch/mips/rb532/devices.c2
-rw-r--r--arch/mips/rb532/gpio.c193
-rw-r--r--arch/parisc/include/asm/smp.h2
-rw-r--r--arch/parisc/kernel/ptrace.c10
-rw-r--r--arch/s390/kernel/entry.S20
-rw-r--r--arch/s390/kernel/entry64.S11
-rw-r--r--arch/s390/kernel/process.c3
-rw-r--r--arch/s390/kernel/setup.c4
-rw-r--r--arch/s390/kernel/sys_s390.c2
-rw-r--r--arch/s390/kernel/topology.c11
-rw-r--r--arch/sh/include/asm/io.h4
-rw-r--r--arch/sh/include/asm/pgtable.h6
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7723.c6
-rw-r--r--arch/sh/kernel/early_printk.c3
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c2
-rw-r--r--arch/sh/lib/copy_page.S11
-rw-r--r--arch/sh/mm/Makefile_322
-rw-r--r--arch/sh/mm/Makefile_642
-rw-r--r--arch/sh/mm/init.c12
-rw-r--r--arch/sh/mm/mmap.c31
-rw-r--r--arch/sh/mm/pg-sh4.c17
-rw-r--r--arch/sparc/include/asm/termbits.h11
-rw-r--r--arch/sparc/include/asm/unistd_32.h3
-rw-r--r--arch/sparc/include/asm/unistd_64.h3
-rw-r--r--arch/sparc/kernel/of_device.c4
-rw-r--r--arch/sparc/kernel/systbls.S2
-rw-r--r--arch/sparc64/kernel/sys32.S13
-rw-r--r--arch/sparc64/kernel/systbls.S4
-rw-r--r--arch/um/include/asm/system.h14
-rw-r--r--arch/x86/Kconfig7
-rw-r--r--arch/x86/include/asm/iomap.h (renamed from include/asm-x86/iomap.h)0
-rw-r--r--arch/x86/include/asm/iommu.h1
-rw-r--r--arch/x86/include/asm/mmzone_32.h4
-rw-r--r--arch/x86/include/asm/uaccess.h2
-rw-r--r--arch/x86/include/asm/uaccess_32.h8
-rw-r--r--arch/x86/include/asm/uaccess_64.h8
-rw-r--r--arch/x86/include/asm/unistd_64.h4
-rw-r--r--arch/x86/kernel/amd_iommu.c2
-rw-r--r--arch/x86/kernel/amd_iommu_init.c6
-rw-r--r--arch/x86/kernel/ds.c25
-rw-r--r--arch/x86/kernel/early-quirks.c18
-rw-r--r--arch/x86/kernel/es7000_32.c9
-rw-r--r--arch/x86/kernel/io_apic.c14
-rw-r--r--arch/x86/kernel/reboot.c9
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/tsc_sync.c4
-rw-r--r--arch/x86/lib/usercopy_32.c8
-rw-r--r--arch/x86/lib/usercopy_64.c4
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c16
-rw-r--r--arch/x86/mm/numa_32.c35
-rw-r--r--arch/x86/power/hibernate_32.c4
-rw-r--r--block/blk-map.c6
-rw-r--r--block/genhd.c2
-rw-r--r--block/ioctl.c7
-rw-r--r--drivers/acpi/sleep/proc.c2
-rw-r--r--drivers/ata/libata-sff.c13
-rw-r--r--drivers/block/Kconfig29
-rw-r--r--drivers/block/cciss.c9
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/ub.c20
-rw-r--r--drivers/block/xen-blkfront.c8
-rw-r--r--drivers/char/Kconfig24
-rw-r--r--drivers/char/specialix.c2
-rw-r--r--drivers/gpio/gpiolib.c2
-rw-r--r--drivers/hid/hid-apple.c11
-rw-r--r--drivers/hid/hid-core.c12
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/hidraw.c30
-rw-r--r--drivers/hid/usbhid/hid-core.c25
-rw-r--r--drivers/hwmon/applesmc.c13
-rw-r--r--drivers/hwmon/lis3lv02d.c1
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c3
-rw-r--r--drivers/ide/ide-cs.c1
-rw-r--r--drivers/isdn/i4l/isdn_net.c6
-rw-r--r--drivers/md/dm-mpath.c8
-rw-r--r--drivers/md/dm-raid1.c1
-rw-r--r--drivers/md/dm-stripe.c4
-rw-r--r--drivers/md/dm.c34
-rw-r--r--drivers/media/video/tvaudio.c231
-rw-r--r--drivers/mfd/da903x.c2
-rw-r--r--drivers/mfd/wm8350-i2c.c15
-rw-r--r--drivers/misc/c2port/core.c1
-rw-r--r--drivers/misc/sgi-gru/Makefile4
-rw-r--r--drivers/mtd/maps/cdb89712.c13
-rw-r--r--drivers/mtd/maps/h720x-flash.c6
-rw-r--r--drivers/net/atl1e/atl1e_hw.c4
-rw-r--r--drivers/net/atlx/atl1.c17
-rw-r--r--drivers/net/atlx/atl2.c8
-rw-r--r--drivers/net/e100.c20
-rw-r--r--drivers/net/e1000/e1000_ethtool.c8
-rw-r--r--drivers/net/e1000/e1000_main.c1
-rw-r--r--drivers/net/e1000e/e1000.h5
-rw-r--r--drivers/net/e1000e/ethtool.c8
-rw-r--r--drivers/net/e1000e/netdev.c25
-rw-r--r--drivers/net/e1000e/param.c25
-rw-r--r--drivers/net/gianfar.c15
-rw-r--r--drivers/net/igb/igb_ethtool.c8
-rw-r--r--drivers/net/igb/igb_main.c8
-rw-r--r--drivers/net/ipg.c8
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c58
-rw-r--r--drivers/net/jme.c21
-rw-r--r--drivers/net/mlx4/en_netdev.c8
-rw-r--r--drivers/net/mlx4/en_params.c30
-rw-r--r--drivers/net/mlx4/mlx4_en.h8
-rw-r--r--drivers/net/mv643xx_eth.c5
-rw-r--r--drivers/net/niu.c290
-rw-r--r--drivers/net/niu.h13
-rw-r--r--drivers/net/phy/marvell.c66
-rw-r--r--drivers/net/phy/mdio_bus.c2
-rw-r--r--drivers/net/phy/phy_device.c38
-rw-r--r--drivers/net/qla3xxx.c19
-rw-r--r--drivers/net/sh_eth.c4
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/net/ucc_geth_ethtool.c6
-rw-r--r--drivers/net/usb/asix.c8
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c1
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c2
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/pci/intel-iommu.c6
-rw-r--r--drivers/pci/pci-acpi.c15
-rw-r--r--drivers/pci/pci.c4
-rw-r--r--drivers/pcmcia/cistpl.c3
-rw-r--r--drivers/pcmcia/cs.c14
-rw-r--r--drivers/pcmcia/ds.c11
-rw-r--r--drivers/pcmcia/pcmcia_resource.c3
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c6
-rw-r--r--drivers/rtc/rtc-sun4v.c69
-rw-r--r--drivers/s390/block/dasd.c5
-rw-r--r--drivers/s390/char/sclp_cmd.c3
-rw-r--r--drivers/s390/cio/device.c4
-rw-r--r--drivers/s390/kvm/kvm_virtio.c4
-rw-r--r--drivers/s390/scsi/zfcp_aux.c3
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c4
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c42
-rw-r--r--drivers/s390/scsi/zfcp_dbf.h8
-rw-r--r--drivers/s390/scsi/zfcp_erp.c1
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c23
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c12
-rw-r--r--drivers/scsi/dpt_i2o.c4
-rw-r--r--drivers/scsi/megaraid.c11
-rw-r--r--drivers/scsi/megaraid.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c26
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_error.c5
-rw-r--r--drivers/serial/sh-sci.c22
-rw-r--r--drivers/serial/sh-sci.h16
-rw-r--r--drivers/spi/pxa2xx_spi.c24
-rw-r--r--drivers/spi/spi_imx.c45
-rw-r--r--drivers/usb/class/cdc-acm.c9
-rw-r--r--drivers/usb/core/message.c1
-rw-r--r--drivers/usb/core/sysfs.c2
-rw-r--r--drivers/usb/core/urb.c4
-rw-r--r--drivers/usb/gadget/f_acm.c4
-rw-r--r--drivers/usb/gadget/f_rndis.c3
-rw-r--r--drivers/usb/host/Kconfig23
-rw-r--r--drivers/usb/host/ehci-hcd.c25
-rw-r--r--drivers/usb/host/ehci-pci.c21
-rw-r--r--drivers/usb/host/ehci-ps3.c1
-rw-r--r--drivers/usb/host/ehci-sched.c4
-rw-r--r--drivers/usb/host/isp1760-if.c22
-rw-r--r--drivers/usb/host/ohci-ps3.c3
-rw-r--r--drivers/usb/host/r8a66597-hcd.c5
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c1
-rw-r--r--drivers/usb/misc/vstusb.c2
-rw-r--r--drivers/usb/mon/mon_bin.c5
-rw-r--r--drivers/usb/musb/musb_core.c6
-rw-r--r--drivers/usb/musb/musb_debug.h4
-rw-r--r--drivers/usb/musb/musb_host.c159
-rw-r--r--drivers/usb/musb/musb_host.h1
-rw-r--r--drivers/usb/musb/omap2430.c2
-rw-r--r--drivers/usb/musb/tusb6010.c2
-rw-r--r--drivers/usb/serial/cp2101.c3
-rw-r--r--drivers/usb/serial/option.c6
-rw-r--r--drivers/usb/storage/Kconfig4
-rw-r--r--drivers/usb/storage/unusual_devs.h33
-rw-r--r--drivers/video/atmel_lcdfb.c2
-rw-r--r--drivers/video/backlight/da903x.c2
-rw-r--r--drivers/video/backlight/lcd.c11
-rw-r--r--drivers/video/cirrusfb.c3
-rw-r--r--drivers/video/fbmem.c2
-rw-r--r--drivers/video/pxafb.c5
-rw-r--r--drivers/video/tmiofb.c10
-rw-r--r--drivers/video/via/viafbdev.c17
-rw-r--r--drivers/w1/masters/omap_hdq.c10
-rw-r--r--drivers/xen/balloon.c9
-rw-r--r--fs/cifs/CHANGES6
-rw-r--r--fs/cifs/cifs_debug.c277
-rw-r--r--fs/cifs/cifs_dfs_ref.c71
-rw-r--r--fs/cifs/cifs_spnego.c4
-rw-r--r--fs/cifs/cifsfs.c30
-rw-r--r--fs/cifs/cifsglob.h49
-rw-r--r--fs/cifs/cifssmb.c134
-rw-r--r--fs/cifs/connect.c825
-rw-r--r--fs/cifs/file.c28
-rw-r--r--fs/cifs/misc.c93
-rw-r--r--fs/cifs/readdir.c5
-rw-r--r--fs/dlm/lockspace.c2
-rw-r--r--fs/ecryptfs/keystore.c31
-rw-r--r--fs/hostfs/hostfs.h2
-rw-r--r--fs/hostfs/hostfs_kern.c4
-rw-r--r--fs/hostfs/hostfs_user.c2
-rw-r--r--fs/inotify.c150
-rw-r--r--fs/namei.c2
-rw-r--r--fs/partitions/check.c31
-rw-r--r--fs/proc/proc_sysctl.c1
-rw-r--r--include/linux/cpuset.h4
-rw-r--r--include/linux/debug_locks.h2
-rw-r--r--include/linux/futex.h2
-rw-r--r--include/linux/genhd.h4
-rw-r--r--include/linux/inotify.h11
-rw-r--r--include/linux/input.h2
-rw-r--r--include/linux/kernel.h53
-rw-r--r--include/linux/lockdep.h36
-rw-r--r--include/linux/mutex.h2
-rw-r--r--include/linux/net.h6
-rw-r--r--include/linux/rcuclassic.h2
-rw-r--r--include/linux/ring_buffer.h3
-rw-r--r--include/linux/serial_core.h3
-rw-r--r--include/linux/slab.h28
-rw-r--r--include/linux/syscalls.h3
-rw-r--r--include/linux/uaccess.h2
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/net/mac80211.h20
-rw-r--r--include/net/sock.h2
-rw-r--r--init/Kconfig6
-rw-r--r--ipc/util.c14
-rw-r--r--kernel/Makefile4
-rw-r--r--kernel/audit_tree.c91
-rw-r--r--kernel/auditfilter.c14
-rw-r--r--kernel/cgroup.c21
-rw-r--r--kernel/cpuset.c31
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/extable.c16
-rw-r--r--kernel/fork.c11
-rw-r--r--kernel/futex.c290
-rw-r--r--kernel/kallsyms.c17
-rw-r--r--kernel/lockdep.c37
-rw-r--r--kernel/lockdep_proc.c28
-rw-r--r--kernel/mutex.c10
-rw-r--r--kernel/notifier.c8
-rw-r--r--kernel/power/main.c2
-rw-r--r--kernel/profile.c2
-rw-r--r--kernel/rcuclassic.c4
-rw-r--r--kernel/relay.c9
-rw-r--r--kernel/sched.c15
-rw-r--r--kernel/softlockup.c2
-rw-r--r--kernel/stop_machine.c5
-rw-r--r--kernel/sys_ni.c2
-rw-r--r--kernel/trace/ftrace.c147
-rw-r--r--kernel/trace/ring_buffer.c116
-rw-r--r--kernel/trace/trace.c1
-rw-r--r--lib/Kconfig.debug10
-rw-r--r--lib/scatterlist.c2
-rw-r--r--lib/swiotlb.c10
-rw-r--r--mm/memory.c15
-rw-r--r--mm/memory_hotplug.c3
-rw-r--r--mm/migrate.c5
-rw-r--r--mm/mlock.c2
-rw-r--r--mm/vmalloc.c21
-rw-r--r--mm/vmscan.c44
-rw-r--r--net/9p/Kconfig10
-rw-r--r--net/compat.c50
-rw-r--r--net/core/pktgen.c9
-rw-r--r--net/core/rtnetlink.c4
-rw-r--r--net/core/scm.c2
-rw-r--r--net/core/sock.c2
-rw-r--r--net/ipv4/af_inet.c1
-rw-r--r--net/ipv4/ip_input.c10
-rw-r--r--net/ipv4/ipmr.c9
-rw-r--r--net/ipv4/udp.c1
-rw-r--r--net/ipv6/datagram.c5
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/ipv6_sockglue.c5
-rw-r--r--net/ipv6/proc.c6
-rw-r--r--net/mac80211/mlme.c22
-rw-r--r--net/phonet/af_phonet.c56
-rw-r--r--net/sched/sch_api.c2
-rw-r--r--net/sched/sch_generic.c7
-rw-r--r--net/socket.c80
-rw-r--r--net/sunrpc/auth_generic.c20
-rw-r--r--sound/pci/hda/hda_beep.c8
-rw-r--r--sound/pci/hda/hda_beep.h1
-rw-r--r--sound/pci/hda/patch_sigmatel.c99
-rw-r--r--sound/pci/pcxhr/pcxhr.c5
365 files changed, 3930 insertions, 2700 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index 50f99eab0e1f..2a39aeba1464 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -42,14 +42,8 @@ IRQ.txt
42 - description of what an IRQ is. 42 - description of what an IRQ is.
43ManagementStyle 43ManagementStyle
44 - how to (attempt to) manage kernel hackers. 44 - how to (attempt to) manage kernel hackers.
45MSI-HOWTO.txt
46 - the Message Signaled Interrupts (MSI) Driver Guide HOWTO and FAQ.
47RCU/ 45RCU/
48 - directory with info on RCU (read-copy update). 46 - directory with info on RCU (read-copy update).
49README.DAC960
50 - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux.
51README.cycladesZ
52 - info on Cyclades-Z firmware loading.
53SAK.txt 47SAK.txt
54 - info on Secure Attention Keys. 48 - info on Secure Attention Keys.
55SM501.txt 49SM501.txt
@@ -86,20 +80,16 @@ blackfin/
86 - directory with documentation for the Blackfin arch. 80 - directory with documentation for the Blackfin arch.
87block/ 81block/
88 - info on the Block I/O (BIO) layer. 82 - info on the Block I/O (BIO) layer.
83blockdev/
84 - info on block devices & drivers
89cachetlb.txt 85cachetlb.txt
90 - describes the cache/TLB flushing interfaces Linux uses. 86 - describes the cache/TLB flushing interfaces Linux uses.
91cciss.txt
92 - info, major/minor #'s for Compaq's SMART Array Controllers.
93cdrom/ 87cdrom/
94 - directory with information on the CD-ROM drivers that Linux has. 88 - directory with information on the CD-ROM drivers that Linux has.
95computone.txt
96 - info on Computone Intelliport II/Plus Multiport Serial Driver.
97connector/ 89connector/
98 - docs on the netlink based userspace<->kernel space communication mod. 90 - docs on the netlink based userspace<->kernel space communication mod.
99console/ 91console/
100 - documentation on Linux console drivers. 92 - documentation on Linux console drivers.
101cpqarray.txt
102 - info on using Compaq's SMART2 Intelligent Disk Array Controllers.
103cpu-freq/ 93cpu-freq/
104 - info on CPU frequency and voltage scaling. 94 - info on CPU frequency and voltage scaling.
105cpu-hotplug.txt 95cpu-hotplug.txt
@@ -126,8 +116,6 @@ device-mapper/
126 - directory with info on Device Mapper. 116 - directory with info on Device Mapper.
127devices.txt 117devices.txt
128 - plain ASCII listing of all the nodes in /dev/ with major minor #'s. 118 - plain ASCII listing of all the nodes in /dev/ with major minor #'s.
129digiepca.txt
130 - info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards.
131dontdiff 119dontdiff
132 - file containing a list of files that should never be diff'ed. 120 - file containing a list of files that should never be diff'ed.
133driver-model/ 121driver-model/
@@ -152,14 +140,10 @@ filesystems/
152 - info on the vfs and the various filesystems that Linux supports. 140 - info on the vfs and the various filesystems that Linux supports.
153firmware_class/ 141firmware_class/
154 - request_firmware() hotplug interface info. 142 - request_firmware() hotplug interface info.
155floppy.txt
156 - notes and driver options for the floppy disk driver.
157frv/ 143frv/
158 - Fujitsu FR-V Linux documentation. 144 - Fujitsu FR-V Linux documentation.
159gpio.txt 145gpio.txt
160 - overview of GPIO (General Purpose Input/Output) access conventions. 146 - overview of GPIO (General Purpose Input/Output) access conventions.
161hayes-esp.txt
162 - info on using the Hayes ESP serial driver.
163highuid.txt 147highuid.txt
164 - notes on the change from 16 bit to 32 bit user/group IDs. 148 - notes on the change from 16 bit to 32 bit user/group IDs.
165timers/ 149timers/
@@ -186,8 +170,6 @@ io_ordering.txt
186 - info on ordering I/O writes to memory-mapped addresses. 170 - info on ordering I/O writes to memory-mapped addresses.
187ioctl/ 171ioctl/
188 - directory with documents describing various IOCTL calls. 172 - directory with documents describing various IOCTL calls.
189ioctl-number.txt
190 - how to implement and register device/driver ioctl calls.
191iostats.txt 173iostats.txt
192 - info on I/O statistics Linux kernel provides. 174 - info on I/O statistics Linux kernel provides.
193irqflags-tracing.txt 175irqflags-tracing.txt
@@ -250,14 +232,10 @@ mips/
250 - directory with info about Linux on MIPS architecture. 232 - directory with info about Linux on MIPS architecture.
251mono.txt 233mono.txt
252 - how to execute Mono-based .NET binaries with the help of BINFMT_MISC. 234 - how to execute Mono-based .NET binaries with the help of BINFMT_MISC.
253moxa-smartio
254 - file with info on installing/using Moxa multiport serial driver.
255mutex-design.txt 235mutex-design.txt
256 - info on the generic mutex subsystem. 236 - info on the generic mutex subsystem.
257namespaces/ 237namespaces/
258 - directory with various information about namespaces 238 - directory with various information about namespaces
259nbd.txt
260 - info on a TCP implementation of a network block device.
261netlabel/ 239netlabel/
262 - directory with information on the NetLabel subsystem. 240 - directory with information on the NetLabel subsystem.
263networking/ 241networking/
@@ -270,8 +248,6 @@ numastat.txt
270 - info on how to read Numa policy hit/miss statistics in sysfs. 248 - info on how to read Numa policy hit/miss statistics in sysfs.
271oops-tracing.txt 249oops-tracing.txt
272 - how to decode those nasty internal kernel error dump messages. 250 - how to decode those nasty internal kernel error dump messages.
273paride.txt
274 - information about the parallel port IDE subsystem.
275parisc/ 251parisc/
276 - directory with info on using Linux on PA-RISC architecture. 252 - directory with info on using Linux on PA-RISC architecture.
277parport.txt 253parport.txt
@@ -294,18 +270,12 @@ printk-formats.txt
294 - how to get printk format specifiers right 270 - how to get printk format specifiers right
295prio_tree.txt 271prio_tree.txt
296 - info on radix-priority-search-tree use for indexing vmas. 272 - info on radix-priority-search-tree use for indexing vmas.
297ramdisk.txt
298 - short guide on how to set up and use the RAM disk.
299rbtree.txt 273rbtree.txt
300 - info on what red-black trees are and what they are for. 274 - info on what red-black trees are and what they are for.
301riscom8.txt
302 - notes on using the RISCom/8 multi-port serial driver.
303robust-futex-ABI.txt 275robust-futex-ABI.txt
304 - documentation of the robust futex ABI. 276 - documentation of the robust futex ABI.
305robust-futexes.txt 277robust-futexes.txt
306 - a description of what robust futexes are. 278 - a description of what robust futexes are.
307rocket.txt
308 - info on the Comtrol RocketPort multiport serial driver.
309rt-mutex-design.txt 279rt-mutex-design.txt
310 - description of the RealTime mutex implementation design. 280 - description of the RealTime mutex implementation design.
311rt-mutex.txt 281rt-mutex.txt
@@ -334,8 +304,6 @@ sparc/
334 - directory with info on using Linux on Sparc architecture. 304 - directory with info on using Linux on Sparc architecture.
335sparse.txt 305sparse.txt
336 - info on how to obtain and use the sparse tool for typechecking. 306 - info on how to obtain and use the sparse tool for typechecking.
337specialix.txt
338 - info on hardware/driver for specialix IO8+ multiport serial card.
339spi/ 307spi/
340 - overview of Linux kernel Serial Peripheral Interface (SPI) support. 308 - overview of Linux kernel Serial Peripheral Interface (SPI) support.
341spinlocks.txt 309spinlocks.txt
@@ -344,14 +312,10 @@ stable_api_nonsense.txt
344 - info on why the kernel does not have a stable in-kernel api or abi. 312 - info on why the kernel does not have a stable in-kernel api or abi.
345stable_kernel_rules.txt 313stable_kernel_rules.txt
346 - rules and procedures for the -stable kernel releases. 314 - rules and procedures for the -stable kernel releases.
347stallion.txt
348 - info on using the Stallion multiport serial driver.
349svga.txt 315svga.txt
350 - short guide on selecting video modes at boot via VGA BIOS. 316 - short guide on selecting video modes at boot via VGA BIOS.
351sysfs-rules.txt 317sysfs-rules.txt
352 - How not to use sysfs. 318 - How not to use sysfs.
353sx.txt
354 - info on the Specialix SX/SI multiport serial driver.
355sysctl/ 319sysctl/
356 - directory with info on the /proc/sys/* files. 320 - directory with info on the /proc/sys/* files.
357sysrq.txt 321sysrq.txt
@@ -360,8 +324,6 @@ telephony/
360 - directory with info on telephony (e.g. voice over IP) support. 324 - directory with info on telephony (e.g. voice over IP) support.
361time_interpolators.txt 325time_interpolators.txt
362 - info on time interpolators. 326 - info on time interpolators.
363tty.txt
364 - guide to the locking policies of the tty layer.
365uml/ 327uml/
366 - directory with information about User Mode Linux. 328 - directory with information about User Mode Linux.
367unicode.txt 329unicode.txt
diff --git a/Documentation/PCI/00-INDEX b/Documentation/PCI/00-INDEX
index 49f43946c6b6..812b17fe3ed0 100644
--- a/Documentation/PCI/00-INDEX
+++ b/Documentation/PCI/00-INDEX
@@ -1,5 +1,7 @@
100-INDEX 100-INDEX
2 - this file 2 - this file
3MSI-HOWTO.txt
4 - the Message Signaled Interrupts (MSI) Driver Guide HOWTO and FAQ.
3PCI-DMA-mapping.txt 5PCI-DMA-mapping.txt
4 - info for PCI drivers using DMA portably across all platforms 6 - info for PCI drivers using DMA portably across all platforms
5PCIEBUS-HOWTO.txt 7PCIEBUS-HOWTO.txt
diff --git a/Documentation/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index 256defd7e174..256defd7e174 100644
--- a/Documentation/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
diff --git a/Documentation/blockdev/00-INDEX b/Documentation/blockdev/00-INDEX
new file mode 100644
index 000000000000..86f054c47013
--- /dev/null
+++ b/Documentation/blockdev/00-INDEX
@@ -0,0 +1,16 @@
100-INDEX
2 - this file
3README.DAC960
4 - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux.
5cciss.txt
6 - info, major/minor #'s for Compaq's SMART Array Controllers.
7cpqarray.txt
8 - info on using Compaq's SMART2 Intelligent Disk Array Controllers.
9floppy.txt
10 - notes and driver options for the floppy disk driver.
11nbd.txt
12 - info on a TCP implementation of a network block device.
13paride.txt
14 - information about the parallel port IDE subsystem.
15ramdisk.txt
16 - short guide on how to set up and use the RAM disk.
diff --git a/Documentation/README.DAC960 b/Documentation/blockdev/README.DAC960
index 0e8f618ab534..0e8f618ab534 100644
--- a/Documentation/README.DAC960
+++ b/Documentation/blockdev/README.DAC960
diff --git a/Documentation/cciss.txt b/Documentation/blockdev/cciss.txt
index 89698e8df7d4..89698e8df7d4 100644
--- a/Documentation/cciss.txt
+++ b/Documentation/blockdev/cciss.txt
diff --git a/Documentation/cpqarray.txt b/Documentation/blockdev/cpqarray.txt
index c7154e20ef5e..c7154e20ef5e 100644
--- a/Documentation/cpqarray.txt
+++ b/Documentation/blockdev/cpqarray.txt
diff --git a/Documentation/floppy.txt b/Documentation/blockdev/floppy.txt
index 6ccab88705cb..6ccab88705cb 100644
--- a/Documentation/floppy.txt
+++ b/Documentation/blockdev/floppy.txt
diff --git a/Documentation/nbd.txt b/Documentation/blockdev/nbd.txt
index aeb93ffe6416..aeb93ffe6416 100644
--- a/Documentation/nbd.txt
+++ b/Documentation/blockdev/nbd.txt
diff --git a/Documentation/paride.txt b/Documentation/blockdev/paride.txt
index e4312676bdda..e4312676bdda 100644
--- a/Documentation/paride.txt
+++ b/Documentation/blockdev/paride.txt
diff --git a/Documentation/ramdisk.txt b/Documentation/blockdev/ramdisk.txt
index 6c820baa19a6..6c820baa19a6 100644
--- a/Documentation/ramdisk.txt
+++ b/Documentation/blockdev/ramdisk.txt
diff --git a/Documentation/ioctl/00-INDEX b/Documentation/ioctl/00-INDEX
new file mode 100644
index 000000000000..d2fe4d4729ef
--- /dev/null
+++ b/Documentation/ioctl/00-INDEX
@@ -0,0 +1,10 @@
100-INDEX
2 - this file
3cdrom.txt
4 - summary of CDROM ioctl calls
5hdio.txt
6 - summary of HDIO_ ioctl calls
7ioctl-decoding.txt
8 - how to decode the bits of an IOCTL code
9ioctl-number.txt
10 - how to implement and register device/driver ioctl calls
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index b880ce5dbd33..b880ce5dbd33 100644
--- a/Documentation/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index c600c4ffc657..e0f346d201ed 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -294,7 +294,9 @@ and is between 256 and 4096 characters. It is defined in the file
294 Possible values are: 294 Possible values are:
295 isolate - enable device isolation (each device, as far 295 isolate - enable device isolation (each device, as far
296 as possible, will get its own protection 296 as possible, will get its own protection
297 domain) 297 domain) [default]
298 share - put every device behind one IOMMU into the
299 same protection domain
298 fullflush - enable flushing of IO/TLB entries when 300 fullflush - enable flushing of IO/TLB entries when
299 they are unmapped. Otherwise they are 301 they are unmapped. Otherwise they are
300 flushed before they will be reused, which 302 flushed before they will be reused, which
@@ -629,7 +631,7 @@ and is between 256 and 4096 characters. It is defined in the file
629 631
630 digiepca= [HW,SERIAL] 632 digiepca= [HW,SERIAL]
631 See drivers/char/README.epca and 633 See drivers/char/README.epca and
632 Documentation/digiepca.txt. 634 Documentation/serial/digiepca.txt.
633 635
634 disable_mtrr_cleanup [X86] 636 disable_mtrr_cleanup [X86]
635 enable_mtrr_cleanup [X86] 637 enable_mtrr_cleanup [X86]
@@ -740,7 +742,7 @@ and is between 256 and 4096 characters. It is defined in the file
740 See header of drivers/scsi/fdomain.c. 742 See header of drivers/scsi/fdomain.c.
741 743
742 floppy= [HW] 744 floppy= [HW]
743 See Documentation/floppy.txt. 745 See Documentation/blockdev/floppy.txt.
744 746
745 force_pal_cache_flush 747 force_pal_cache_flush
746 [IA-64] Avoid check_sal_cache_flush which may hang on 748 [IA-64] Avoid check_sal_cache_flush which may hang on
@@ -1101,7 +1103,7 @@ and is between 256 and 4096 characters. It is defined in the file
1101 the same attribute, the last one is used. 1103 the same attribute, the last one is used.
1102 1104
1103 load_ramdisk= [RAM] List of ramdisks to load from floppy 1105 load_ramdisk= [RAM] List of ramdisks to load from floppy
1104 See Documentation/ramdisk.txt. 1106 See Documentation/blockdev/ramdisk.txt.
1105 1107
1106 lockd.nlm_grace_period=P [NFS] Assign grace period. 1108 lockd.nlm_grace_period=P [NFS] Assign grace period.
1107 Format: <integer> 1109 Format: <integer>
@@ -1193,8 +1195,8 @@ and is between 256 and 4096 characters. It is defined in the file
1193 it is equivalent to "nosmp", which also disables 1195 it is equivalent to "nosmp", which also disables
1194 the IO APIC. 1196 the IO APIC.
1195 1197
1196 max_addr=[KMG] [KNL,BOOT,ia64] All physical memory greater than or 1198 max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater than
1197 equal to this physical address is ignored. 1199 or equal to this physical address is ignored.
1198 1200
1199 max_luns= [SCSI] Maximum number of LUNs to probe. 1201 max_luns= [SCSI] Maximum number of LUNs to probe.
1200 Should be between 1 and 2^32-1. 1202 Should be between 1 and 2^32-1.
@@ -1294,6 +1296,9 @@ and is between 256 and 4096 characters. It is defined in the file
1294 1296
1295 mga= [HW,DRM] 1297 mga= [HW,DRM]
1296 1298
1299 min_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory below this
1300 physical address is ignored.
1301
1297 mminit_loglevel= 1302 mminit_loglevel=
1298 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this 1303 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
1299 parameter allows control of the logging verbosity for 1304 parameter allows control of the logging verbosity for
@@ -1596,7 +1601,7 @@ and is between 256 and 4096 characters. It is defined in the file
1596 1601
1597 pcd. [PARIDE] 1602 pcd. [PARIDE]
1598 See header of drivers/block/paride/pcd.c. 1603 See header of drivers/block/paride/pcd.c.
1599 See also Documentation/paride.txt. 1604 See also Documentation/blockdev/paride.txt.
1600 1605
1601 pci=option[,option...] [PCI] various PCI subsystem options: 1606 pci=option[,option...] [PCI] various PCI subsystem options:
1602 off [X86] don't probe for the PCI bus 1607 off [X86] don't probe for the PCI bus
@@ -1697,7 +1702,7 @@ and is between 256 and 4096 characters. It is defined in the file
1697 pcmv= [HW,PCMCIA] BadgePAD 4 1702 pcmv= [HW,PCMCIA] BadgePAD 4
1698 1703
1699 pd. [PARIDE] 1704 pd. [PARIDE]
1700 See Documentation/paride.txt. 1705 See Documentation/blockdev/paride.txt.
1701 1706
1702 pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at 1707 pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at
1703 boot time. 1708 boot time.
@@ -1705,10 +1710,10 @@ and is between 256 and 4096 characters. It is defined in the file
1705 See arch/parisc/kernel/pdc_chassis.c 1710 See arch/parisc/kernel/pdc_chassis.c
1706 1711
1707 pf. [PARIDE] 1712 pf. [PARIDE]
1708 See Documentation/paride.txt. 1713 See Documentation/blockdev/paride.txt.
1709 1714
1710 pg. [PARIDE] 1715 pg. [PARIDE]
1711 See Documentation/paride.txt. 1716 See Documentation/blockdev/paride.txt.
1712 1717
1713 pirq= [SMP,APIC] Manual mp-table setup 1718 pirq= [SMP,APIC] Manual mp-table setup
1714 See Documentation/x86/i386/IO-APIC.txt. 1719 See Documentation/x86/i386/IO-APIC.txt.
@@ -1778,7 +1783,7 @@ and is between 256 and 4096 characters. It is defined in the file
1778 1783
1779 prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk 1784 prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk
1780 before loading. 1785 before loading.
1781 See Documentation/ramdisk.txt. 1786 See Documentation/blockdev/ramdisk.txt.
1782 1787
1783 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to 1788 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to
1784 probe for; one of (bare|imps|exps|lifebook|any). 1789 probe for; one of (bare|imps|exps|lifebook|any).
@@ -1798,7 +1803,7 @@ and is between 256 and 4096 characters. It is defined in the file
1798 <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq> 1803 <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq>
1799 1804
1800 pt. [PARIDE] 1805 pt. [PARIDE]
1801 See Documentation/paride.txt. 1806 See Documentation/blockdev/paride.txt.
1802 1807
1803 pty.legacy_count= 1808 pty.legacy_count=
1804 [KNL] Number of legacy pty's. Overwrites compiled-in 1809 [KNL] Number of legacy pty's. Overwrites compiled-in
@@ -1812,10 +1817,10 @@ and is between 256 and 4096 characters. It is defined in the file
1812 See Documentation/md.txt. 1817 See Documentation/md.txt.
1813 1818
1814 ramdisk_blocksize= [RAM] 1819 ramdisk_blocksize= [RAM]
1815 See Documentation/ramdisk.txt. 1820 See Documentation/blockdev/ramdisk.txt.
1816 1821
1817 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes 1822 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
1818 See Documentation/ramdisk.txt. 1823 See Documentation/blockdev/ramdisk.txt.
1819 1824
1820 rcupdate.blimit= [KNL,BOOT] 1825 rcupdate.blimit= [KNL,BOOT]
1821 Set maximum number of finished RCU callbacks to process 1826 Set maximum number of finished RCU callbacks to process
@@ -2147,7 +2152,7 @@ and is between 256 and 4096 characters. It is defined in the file
2147 See Documentation/sonypi.txt 2152 See Documentation/sonypi.txt
2148 2153
2149 specialix= [HW,SERIAL] Specialix multi-serial port adapter 2154 specialix= [HW,SERIAL] Specialix multi-serial port adapter
2150 See Documentation/specialix.txt. 2155 See Documentation/serial/specialix.txt.
2151 2156
2152 spia_io_base= [HW,MTD] 2157 spia_io_base= [HW,MTD]
2153 spia_fio_base= 2158 spia_fio_base=
diff --git a/Documentation/lockstat.txt b/Documentation/lockstat.txt
index 4ba4664ce5c3..9cb9138f7a79 100644
--- a/Documentation/lockstat.txt
+++ b/Documentation/lockstat.txt
@@ -71,35 +71,50 @@ Look at the current lock statistics:
71 71
72# less /proc/lock_stat 72# less /proc/lock_stat
73 73
7401 lock_stat version 0.2 7401 lock_stat version 0.3
7502 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 7502 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7603 class name con-bounces contentions waittime-min waittime-max waittime-total acq-bounces acquisitions holdtime-min holdtime-max holdtime-total 7603 class name con-bounces contentions waittime-min waittime-max waittime-total acq-bounces acquisitions holdtime-min holdtime-max holdtime-total
7704 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 7704 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7805 7805
7906 &inode->i_data.tree_lock-W: 15 21657 0.18 1093295.30 11547131054.85 58 10415 0.16 87.51 6387.60 7906 &mm->mmap_sem-W: 233 538 18446744073708 22924.27 607243.51 1342 45806 1.71 8595.89 1180582.34
8007 &inode->i_data.tree_lock-R: 0 0 0.00 0.00 0.00 23302 231198 0.25 8.45 98023.38 8007 &mm->mmap_sem-R: 205 587 18446744073708 28403.36 731975.00 1940 412426 0.58 187825.45 6307502.88
8108 -------------------------- 8108 ---------------
8209 &inode->i_data.tree_lock 0 [<ffffffff8027c08f>] add_to_page_cache+0x5f/0x190 8209 &mm->mmap_sem 487 [<ffffffff8053491f>] do_page_fault+0x466/0x928
8310 8310 &mm->mmap_sem 179 [<ffffffff802a6200>] sys_mprotect+0xcd/0x21d
8411 ............................................................................................................................................................................................... 8411 &mm->mmap_sem 279 [<ffffffff80210a57>] sys_mmap+0x75/0xce
8512 8512 &mm->mmap_sem 76 [<ffffffff802a490b>] sys_munmap+0x32/0x59
8613 dcache_lock: 1037 1161 0.38 45.32 774.51 6611 243371 0.15 306.48 77387.24 8613 ---------------
8714 ----------- 8714 &mm->mmap_sem 270 [<ffffffff80210a57>] sys_mmap+0x75/0xce
8815 dcache_lock 180 [<ffffffff802c0d7e>] sys_getcwd+0x11e/0x230 8815 &mm->mmap_sem 431 [<ffffffff8053491f>] do_page_fault+0x466/0x928
8916 dcache_lock 165 [<ffffffff802c002a>] d_alloc+0x15a/0x210 8916 &mm->mmap_sem 138 [<ffffffff802a490b>] sys_munmap+0x32/0x59
9017 dcache_lock 33 [<ffffffff8035818d>] _atomic_dec_and_lock+0x4d/0x70 9017 &mm->mmap_sem 145 [<ffffffff802a6200>] sys_mprotect+0xcd/0x21d
9118 dcache_lock 1 [<ffffffff802beef8>] shrink_dcache_parent+0x18/0x130 9118
9219 ...............................................................................................................................................................................................
9320
9421 dcache_lock: 621 623 0.52 118.26 1053.02 6745 91930 0.29 316.29 118423.41
9522 -----------
9623 dcache_lock 179 [<ffffffff80378274>] _atomic_dec_and_lock+0x34/0x54
9724 dcache_lock 113 [<ffffffff802cc17b>] d_alloc+0x19a/0x1eb
9825 dcache_lock 99 [<ffffffff802ca0dc>] d_rehash+0x1b/0x44
9926 dcache_lock 104 [<ffffffff802cbca0>] d_instantiate+0x36/0x8a
10027 -----------
10128 dcache_lock 192 [<ffffffff80378274>] _atomic_dec_and_lock+0x34/0x54
10229 dcache_lock 98 [<ffffffff802ca0dc>] d_rehash+0x1b/0x44
10330 dcache_lock 72 [<ffffffff802cc17b>] d_alloc+0x19a/0x1eb
10431 dcache_lock 112 [<ffffffff802cbca0>] d_instantiate+0x36/0x8a
92 105
93This excerpt shows the first two lock class statistics. Line 01 shows the 106This excerpt shows the first two lock class statistics. Line 01 shows the
94output version - each time the format changes this will be updated. Line 02-04 107output version - each time the format changes this will be updated. Line 02-04
95show the header with column descriptions. Lines 05-10 and 13-18 show the actual 108show the header with column descriptions. Lines 05-18 and 20-31 show the actual
96statistics. These statistics come in two parts; the actual stats separated by a 109statistics. These statistics come in two parts; the actual stats separated by a
97short separator (line 08, 14) from the contention points. 110short separator (line 08, 13) from the contention points.
98 111
99The first lock (05-10) is a read/write lock, and shows two lines above the 112The first lock (05-18) is a read/write lock, and shows two lines above the
100short separator. The contention points don't match the column descriptors, 113short separator. The contention points don't match the column descriptors,
101they have two: contentions and [<IP>] symbol. 114they have two: contentions and [<IP>] symbol. The second set of contention
115points are the points we're contending with.
102 116
117The integer part of the time values is in us.
103 118
104View the top contending locks: 119View the top contending locks:
105 120
diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index 8df6a7b0e66c..88bb71b46da4 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -96,7 +96,7 @@ Letting the PHY Abstraction Layer do Everything
96 static void adjust_link(struct net_device *dev); 96 static void adjust_link(struct net_device *dev);
97 97
98 Next, you need to know the device name of the PHY connected to this device. 98 Next, you need to know the device name of the PHY connected to this device.
99 The name will look something like, "phy0:0", where the first number is the 99 The name will look something like, "0:00", where the first number is the
100 bus id, and the second is the PHY's address on that bus. Typically, 100 bus id, and the second is the PHY's address on that bus. Typically,
101 the bus is responsible for making its ID unique. 101 the bus is responsible for making its ID unique.
102 102
diff --git a/Documentation/serial/00-INDEX b/Documentation/serial/00-INDEX
new file mode 100644
index 000000000000..07dcdb0d2a36
--- /dev/null
+++ b/Documentation/serial/00-INDEX
@@ -0,0 +1,24 @@
100-INDEX
2 - this file.
3README.cycladesZ
4 - info on Cyclades-Z firmware loading.
5computone.txt
6 - info on Computone Intelliport II/Plus Multiport Serial Driver.
7digiepca.txt
8 - info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards.
9hayes-esp.txt
10 - info on using the Hayes ESP serial driver.
11moxa-smartio
12 - file with info on installing/using Moxa multiport serial driver.
13riscom8.txt
14 - notes on using the RISCom/8 multi-port serial driver.
15rocket.txt
16 - info on the Comtrol RocketPort multiport serial driver.
17specialix.txt
18 - info on hardware/driver for specialix IO8+ multiport serial card.
19stallion.txt
20 - info on using the Stallion multiport serial driver.
21sx.txt
22 - info on the Specialix SX/SI multiport serial driver.
23tty.txt
24 - guide to the locking policies of the tty layer.
diff --git a/Documentation/README.cycladesZ b/Documentation/serial/README.cycladesZ
index 024a69443cc2..024a69443cc2 100644
--- a/Documentation/README.cycladesZ
+++ b/Documentation/serial/README.cycladesZ
diff --git a/Documentation/computone.txt b/Documentation/serial/computone.txt
index 5e2a0c76bfa0..c57ea4781e5d 100644
--- a/Documentation/computone.txt
+++ b/Documentation/serial/computone.txt
@@ -247,7 +247,7 @@ shar archive to make it easier to extract the script from the documentation.
247To create the ip2mkdev shell script change to a convenient directory (/tmp 247To create the ip2mkdev shell script change to a convenient directory (/tmp
248works just fine) and run the following command: 248works just fine) and run the following command:
249 249
250 unshar Documentation/computone.txt 250 unshar Documentation/serial/computone.txt
251 (This file) 251 (This file)
252 252
253You should now have a file ip2mkdev in your current working directory with 253You should now have a file ip2mkdev in your current working directory with
diff --git a/Documentation/digiepca.txt b/Documentation/serial/digiepca.txt
index f2560e22f2c9..f2560e22f2c9 100644
--- a/Documentation/digiepca.txt
+++ b/Documentation/serial/digiepca.txt
diff --git a/Documentation/hayes-esp.txt b/Documentation/serial/hayes-esp.txt
index 09b5d5856758..09b5d5856758 100644
--- a/Documentation/hayes-esp.txt
+++ b/Documentation/serial/hayes-esp.txt
diff --git a/Documentation/moxa-smartio b/Documentation/serial/moxa-smartio
index 5337e80a5b96..5337e80a5b96 100644
--- a/Documentation/moxa-smartio
+++ b/Documentation/serial/moxa-smartio
diff --git a/Documentation/riscom8.txt b/Documentation/serial/riscom8.txt
index 14f61fdad7ca..14f61fdad7ca 100644
--- a/Documentation/riscom8.txt
+++ b/Documentation/serial/riscom8.txt
diff --git a/Documentation/rocket.txt b/Documentation/serial/rocket.txt
index 1d8582990435..1d8582990435 100644
--- a/Documentation/rocket.txt
+++ b/Documentation/serial/rocket.txt
diff --git a/Documentation/specialix.txt b/Documentation/serial/specialix.txt
index 6eb6f3a3331c..6eb6f3a3331c 100644
--- a/Documentation/specialix.txt
+++ b/Documentation/serial/specialix.txt
diff --git a/Documentation/stallion.txt b/Documentation/serial/stallion.txt
index 5c4902d9a5be..5c4902d9a5be 100644
--- a/Documentation/stallion.txt
+++ b/Documentation/serial/stallion.txt
diff --git a/Documentation/sx.txt b/Documentation/serial/sx.txt
index cb4efa0fb5cc..cb4efa0fb5cc 100644
--- a/Documentation/sx.txt
+++ b/Documentation/serial/sx.txt
diff --git a/Documentation/tty.txt b/Documentation/serial/tty.txt
index 8e65c4498c52..8e65c4498c52 100644
--- a/Documentation/tty.txt
+++ b/Documentation/serial/tty.txt
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e0777fae3ce..618c1ef4a397 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1809,7 +1809,7 @@ S: Maintained
1809 1809
1810FTRACE 1810FTRACE
1811P: Steven Rostedt 1811P: Steven Rostedt
1812M: srostedt@redhat.com 1812M: rostedt@goodmis.org
1813S: Maintained 1813S: Maintained
1814 1814
1815FUJITSU FR-V (FRV) PORT 1815FUJITSU FR-V (FRV) PORT
@@ -3928,8 +3928,6 @@ M: bootc@bootc.net
3928S: Maintained 3928S: Maintained
3929 3929
3930SOFTWARE RAID (Multiple Disks) SUPPORT 3930SOFTWARE RAID (Multiple Disks) SUPPORT
3931P: Ingo Molnar
3932M: mingo@redhat.com
3933P: Neil Brown 3931P: Neil Brown
3934M: neilb@suse.de 3932M: neilb@suse.de
3935L: linux-raid@vger.kernel.org 3933L: linux-raid@vger.kernel.org
diff --git a/Makefile b/Makefile
index 7f9ff9bf1544..7b1f2384094f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 28 3SUBLEVEL = 28
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc6
5NAME = Killer Bat of Doom 5NAME = Killer Bat of Doom
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 1cb8602dd9d5..4ed149cbb32a 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -256,8 +256,17 @@ int dmabounce_sync_for_cpu(struct device *, dma_addr_t, unsigned long,
256int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long, 256int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long,
257 size_t, enum dma_data_direction); 257 size_t, enum dma_data_direction);
258#else 258#else
259#define dmabounce_sync_for_cpu(dev,dma,off,sz,dir) (1) 259static inline int dmabounce_sync_for_cpu(struct device *d, dma_addr_t addr,
260#define dmabounce_sync_for_device(dev,dma,off,sz,dir) (1) 260 unsigned long offset, size_t size, enum dma_data_direction dir)
261{
262 return 1;
263}
264
265static inline int dmabounce_sync_for_device(struct device *d, dma_addr_t addr,
266 unsigned long offset, size_t size, enum dma_data_direction dir)
267{
268 return 1;
269}
261 270
262 271
263/** 272/**
diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
index cb1139ac1943..39d949b63e80 100644
--- a/arch/arm/include/asm/mach/map.h
+++ b/arch/arm/include/asm/mach/map.h
@@ -19,12 +19,13 @@ struct map_desc {
19}; 19};
20 20
21/* types 0-3 are defined in asm/io.h */ 21/* types 0-3 are defined in asm/io.h */
22#define MT_CACHECLEAN 4 22#define MT_UNCACHED 4
23#define MT_MINICLEAN 5 23#define MT_CACHECLEAN 5
24#define MT_LOW_VECTORS 6 24#define MT_MINICLEAN 6
25#define MT_HIGH_VECTORS 7 25#define MT_LOW_VECTORS 7
26#define MT_MEMORY 8 26#define MT_HIGH_VECTORS 8
27#define MT_ROM 9 27#define MT_MEMORY 9
28#define MT_ROM 10
28 29
29#ifdef CONFIG_MMU 30#ifdef CONFIG_MMU
30extern void iotable_init(struct map_desc *, int); 31extern void iotable_init(struct map_desc *, int);
diff --git a/arch/arm/mach-clps711x/include/mach/hardware.h b/arch/arm/mach-clps711x/include/mach/hardware.h
index 4c3e101b96c9..b3ebe9e4871f 100644
--- a/arch/arm/mach-clps711x/include/mach/hardware.h
+++ b/arch/arm/mach-clps711x/include/mach/hardware.h
@@ -94,20 +94,6 @@
94#include <asm/hardware/ep7212.h> 94#include <asm/hardware/ep7212.h>
95#include <asm/hardware/cs89712.h> 95#include <asm/hardware/cs89712.h>
96 96
97/* dynamic ioremap() areas */
98#define FLASH_START 0x00000000
99#define FLASH_SIZE 0x800000
100#define FLASH_WIDTH 4
101
102#define SRAM_START 0x60000000
103#define SRAM_SIZE 0xc000
104#define SRAM_WIDTH 4
105
106#define BOOTROM_START 0x70000000
107#define BOOTROM_SIZE 0x80
108#define BOOTROM_WIDTH 4
109
110
111/* static cdb89712_map_io() areas */ 97/* static cdb89712_map_io() areas */
112#define REGISTER_START 0x80000000 98#define REGISTER_START 0x80000000
113#define REGISTER_SIZE 0x4000 99#define REGISTER_SIZE 0x4000
@@ -198,14 +184,6 @@
198#define CEIVA_FLASH_SIZE 0x100000 184#define CEIVA_FLASH_SIZE 0x100000
199#define CEIVA_FLASH_WIDTH 2 185#define CEIVA_FLASH_WIDTH 2
200 186
201#define SRAM_START 0x60000000
202#define SRAM_SIZE 0xc000
203#define SRAM_WIDTH 4
204
205#define BOOTROM_START 0x70000000
206#define BOOTROM_SIZE 0x80
207#define BOOTROM_WIDTH 4
208
209/* 187/*
210 * SED1355 LCD controller 188 * SED1355 LCD controller
211 */ 189 */
diff --git a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c
index c3a33b8a5aac..7e247c04d41c 100644
--- a/arch/arm/mach-clps7500/core.c
+++ b/arch/arm/mach-clps7500/core.c
@@ -275,9 +275,9 @@ static struct map_desc cl7500_io_desc[] __initdata = {
275 .length = ISA_SIZE, 275 .length = ISA_SIZE,
276 .type = MT_DEVICE 276 .type = MT_DEVICE
277 }, { /* Flash */ 277 }, { /* Flash */
278 .virtual = FLASH_BASE, 278 .virtual = CLPS7500_FLASH_BASE,
279 .pfn = __phys_to_pfn(FLASH_START), 279 .pfn = __phys_to_pfn(CLPS7500_FLASH_START),
280 .length = FLASH_SIZE, 280 .length = CLPS7500_FLASH_SIZE,
281 .type = MT_DEVICE 281 .type = MT_DEVICE
282 }, { /* LED */ 282 }, { /* LED */
283 .virtual = LED_BASE, 283 .virtual = LED_BASE,
diff --git a/arch/arm/mach-clps7500/include/mach/hardware.h b/arch/arm/mach-clps7500/include/mach/hardware.h
index d66578a3371c..a6ad1d44badf 100644
--- a/arch/arm/mach-clps7500/include/mach/hardware.h
+++ b/arch/arm/mach-clps7500/include/mach/hardware.h
@@ -39,9 +39,9 @@
39#define ISA_SIZE 0x00010000 39#define ISA_SIZE 0x00010000
40#define ISA_BASE 0xe1000000 40#define ISA_BASE 0xe1000000
41 41
42#define FLASH_START 0x01000000 /* XXX */ 42#define CLPS7500_FLASH_START 0x01000000 /* XXX */
43#define FLASH_SIZE 0x01000000 43#define CLPS7500_FLASH_SIZE 0x01000000
44#define FLASH_BASE 0xe2000000 44#define CLPS7500_FLASH_BASE 0xe2000000
45 45
46#define LED_START 0x0302B000 46#define LED_START 0x0302B000
47#define LED_SIZE 0x00001000 47#define LED_SIZE 0x00001000
diff --git a/arch/arm/mach-h720x/include/mach/boards.h b/arch/arm/mach-h720x/include/mach/boards.h
index 079b279e1242..38b8e0d61fbf 100644
--- a/arch/arm/mach-h720x/include/mach/boards.h
+++ b/arch/arm/mach-h720x/include/mach/boards.h
@@ -19,9 +19,9 @@
19#ifdef CONFIG_ARCH_H7202 19#ifdef CONFIG_ARCH_H7202
20 20
21/* FLASH */ 21/* FLASH */
22#define FLASH_VIRT 0xd0000000 22#define H720X_FLASH_VIRT 0xd0000000
23#define FLASH_PHYS 0x00000000 23#define H720X_FLASH_PHYS 0x00000000
24#define FLASH_SIZE 0x02000000 24#define H720X_FLASH_SIZE 0x02000000
25 25
26/* onboard LAN controller */ 26/* onboard LAN controller */
27# define ETH0_PHYS 0x08000000 27# define ETH0_PHYS 0x08000000
diff --git a/arch/arm/mach-integrator/include/mach/platform.h b/arch/arm/mach-integrator/include/mach/platform.h
index 028b87839c0f..e00a2624f269 100644
--- a/arch/arm/mach-integrator/include/mach/platform.h
+++ b/arch/arm/mach-integrator/include/mach/platform.h
@@ -408,27 +408,10 @@
408#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE 408#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE
409 409
410/* 410/*
411 * Application Flash
412 *
413 */
414#define FLASH_BASE INTEGRATOR_FLASH_BASE
415#define FLASH_SIZE INTEGRATOR_FLASH_SIZE
416#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
417#define FLASH_BLOCK_SIZE SZ_128K
418
419/*
420 * Boot Flash
421 *
422 */
423#define EPROM_BASE INTEGRATOR_BOOT_ROM_HI
424#define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE
425#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1)
426
427/*
428 * Clean base - dummy 411 * Clean base - dummy
429 * 412 *
430 */ 413 */
431#define CLEAN_BASE EPROM_BASE 414#define CLEAN_BASE INTEGRATOR_BOOT_ROM_HI
432 415
433/* 416/*
434 * Timer definitions 417 * Timer definitions
diff --git a/arch/arm/mach-pxa/include/mach/pxafb.h b/arch/arm/mach-pxa/include/mach/pxafb.h
index 8e591118371e..cbda4d35c421 100644
--- a/arch/arm/mach-pxa/include/mach/pxafb.h
+++ b/arch/arm/mach-pxa/include/mach/pxafb.h
@@ -33,6 +33,7 @@
33#define LCD_CONN_TYPE(_x) ((_x) & 0x0f) 33#define LCD_CONN_TYPE(_x) ((_x) & 0x0f)
34#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f) 34#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f)
35 35
36#define LCD_TYPE_MASK 0xf
36#define LCD_TYPE_UNKNOWN 0 37#define LCD_TYPE_UNKNOWN 0
37#define LCD_TYPE_MONO_STN 1 38#define LCD_TYPE_MONO_STN 1
38#define LCD_TYPE_MONO_DSTN 2 39#define LCD_TYPE_MONO_DSTN 2
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index 1b2af575c40f..00b2dc2a1074 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -90,12 +90,13 @@ void arch_reset(char mode)
90 /* Jump into ROM at address 0 */ 90 /* Jump into ROM at address 0 */
91 cpu_reset(0); 91 cpu_reset(0);
92 break; 92 break;
93 case 'h':
94 do_hw_reset();
95 break;
96 case 'g': 93 case 'g':
97 do_gpio_reset(); 94 do_gpio_reset();
98 break; 95 break;
96 case 'h':
97 default:
98 do_hw_reset();
99 break;
99 } 100 }
100} 101}
101 102
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index f0a5bbae0b45..3be76ee2bdbf 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -67,6 +67,7 @@
67static unsigned long spitz_pin_config[] __initdata = { 67static unsigned long spitz_pin_config[] __initdata = {
68 /* Chip Selects */ 68 /* Chip Selects */
69 GPIO78_nCS_2, /* SCOOP #2 */ 69 GPIO78_nCS_2, /* SCOOP #2 */
70 GPIO79_nCS_3, /* NAND */
70 GPIO80_nCS_4, /* SCOOP #1 */ 71 GPIO80_nCS_4, /* SCOOP #1 */
71 72
72 /* LCD - 16bpp Active TFT */ 73 /* LCD - 16bpp Active TFT */
@@ -97,10 +98,10 @@ static unsigned long spitz_pin_config[] __initdata = {
97 GPIO51_nPIOW, 98 GPIO51_nPIOW,
98 GPIO85_nPCE_1, 99 GPIO85_nPCE_1,
99 GPIO54_nPCE_2, 100 GPIO54_nPCE_2,
100 GPIO79_PSKTSEL,
101 GPIO55_nPREG, 101 GPIO55_nPREG,
102 GPIO56_nPWAIT, 102 GPIO56_nPWAIT,
103 GPIO57_nIOIS16, 103 GPIO57_nIOIS16,
104 GPIO104_PSKTSEL,
104 105
105 /* MMC */ 106 /* MMC */
106 GPIO32_MMC_CLK, 107 GPIO32_MMC_CLK,
@@ -686,7 +687,6 @@ static void __init akita_init(void)
686 spitz_pcmcia_config.num_devs = 1; 687 spitz_pcmcia_config.num_devs = 1;
687 platform_scoop_config = &spitz_pcmcia_config; 688 platform_scoop_config = &spitz_pcmcia_config;
688 689
689 pxa_set_i2c_info(NULL);
690 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info)); 690 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
691 691
692 common_init(); 692 common_init();
diff --git a/arch/arm/mach-realview/clock.c b/arch/arm/mach-realview/clock.c
index 3e706c57833a..3347c4236a60 100644
--- a/arch/arm/mach-realview/clock.c
+++ b/arch/arm/mach-realview/clock.c
@@ -104,7 +104,7 @@ static struct clk uart_clk = {
104 104
105static struct clk mmci_clk = { 105static struct clk mmci_clk = {
106 .name = "MCLK", 106 .name = "MCLK",
107 .rate = 33000000, 107 .rate = 24000000,
108}; 108};
109 109
110int clk_register(struct clk *clk) 110int clk_register(struct clk *clk)
diff --git a/arch/arm/mach-realview/include/mach/platform.h b/arch/arm/mach-realview/include/mach/platform.h
index 4034b54950c2..793a3a332712 100644
--- a/arch/arm/mach-realview/include/mach/platform.h
+++ b/arch/arm/mach-realview/include/mach/platform.h
@@ -239,27 +239,10 @@
239#define REALVIEW_DECODE_OFFSET 0xC /* Fitted logic modules */ 239#define REALVIEW_DECODE_OFFSET 0xC /* Fitted logic modules */
240 240
241/* 241/*
242 * Application Flash
243 *
244 */
245#define FLASH_BASE REALVIEW_FLASH_BASE
246#define FLASH_SIZE REALVIEW_FLASH_SIZE
247#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
248#define FLASH_BLOCK_SIZE SZ_128K
249
250/*
251 * Boot Flash
252 *
253 */
254#define EPROM_BASE REALVIEW_BOOT_ROM_HI
255#define EPROM_SIZE REALVIEW_BOOT_ROM_SIZE
256#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1)
257
258/*
259 * Clean base - dummy 242 * Clean base - dummy
260 * 243 *
261 */ 244 */
262#define CLEAN_BASE EPROM_BASE 245#define CLEAN_BASE REALVIEW_BOOT_ROM_HI
263 246
264/* 247/*
265 * System controller bit assignment 248 * System controller bit assignment
diff --git a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c
index 9336508ec0b2..58937f1fb38c 100644
--- a/arch/arm/mach-versatile/clock.c
+++ b/arch/arm/mach-versatile/clock.c
@@ -105,7 +105,7 @@ static struct clk uart_clk = {
105 105
106static struct clk mmci_clk = { 106static struct clk mmci_clk = {
107 .name = "MCLK", 107 .name = "MCLK",
108 .rate = 33000000, 108 .rate = 24000000,
109}; 109};
110 110
111int clk_register(struct clk *clk) 111int clk_register(struct clk *clk)
diff --git a/arch/arm/mach-versatile/include/mach/platform.h b/arch/arm/mach-versatile/include/mach/platform.h
index 27cbe6a3f220..f91ba930ca8a 100644
--- a/arch/arm/mach-versatile/include/mach/platform.h
+++ b/arch/arm/mach-versatile/include/mach/platform.h
@@ -436,28 +436,12 @@
436#define SIC_INTMASK_PCI1 (1 << SIC_INT_PCI1) 436#define SIC_INTMASK_PCI1 (1 << SIC_INT_PCI1)
437#define SIC_INTMASK_PCI2 (1 << SIC_INT_PCI2) 437#define SIC_INTMASK_PCI2 (1 << SIC_INT_PCI2)
438#define SIC_INTMASK_PCI3 (1 << SIC_INT_PCI3) 438#define SIC_INTMASK_PCI3 (1 << SIC_INT_PCI3)
439/*
440 * Application Flash
441 *
442 */
443#define FLASH_BASE VERSATILE_FLASH_BASE
444#define FLASH_SIZE VERSATILE_FLASH_SIZE
445#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
446#define FLASH_BLOCK_SIZE SZ_128K
447
448/*
449 * Boot Flash
450 *
451 */
452#define EPROM_BASE VERSATILE_BOOT_ROM_HI
453#define EPROM_SIZE VERSATILE_BOOT_ROM_SIZE
454#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1)
455 439
456/* 440/*
457 * Clean base - dummy 441 * Clean base - dummy
458 * 442 *
459 */ 443 */
460#define CLEAN_BASE EPROM_BASE 444#define CLEAN_BASE VERSATILE_BOOT_ROM_HI
461 445
462/* 446/*
463 * System controller bit assignment 447 * System controller bit assignment
diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
index 13cdae8b0d44..80cd207cbaea 100644
--- a/arch/arm/mm/cache-feroceon-l2.c
+++ b/arch/arm/mm/cache-feroceon-l2.c
@@ -150,7 +150,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end)
150 /* 150 /*
151 * Clean and invalidate partial last cache line. 151 * Clean and invalidate partial last cache line.
152 */ 152 */
153 if (end & (CACHE_LINE_SIZE - 1)) { 153 if (start < end && end & (CACHE_LINE_SIZE - 1)) {
154 l2_clean_inv_pa(end & ~(CACHE_LINE_SIZE - 1)); 154 l2_clean_inv_pa(end & ~(CACHE_LINE_SIZE - 1));
155 end &= ~(CACHE_LINE_SIZE - 1); 155 end &= ~(CACHE_LINE_SIZE - 1);
156 } 156 }
@@ -158,7 +158,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end)
158 /* 158 /*
159 * Invalidate all full cache lines between 'start' and 'end'. 159 * Invalidate all full cache lines between 'start' and 'end'.
160 */ 160 */
161 while (start != end) { 161 while (start < end) {
162 unsigned long range_end = calc_range_end(start, end); 162 unsigned long range_end = calc_range_end(start, end);
163 l2_inv_pa_range(start, range_end - CACHE_LINE_SIZE); 163 l2_inv_pa_range(start, range_end - CACHE_LINE_SIZE);
164 start = range_end; 164 start = range_end;
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index e63db11f16a8..7f36c825718d 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -208,6 +208,12 @@ static struct mem_type mem_types[] = {
208 .prot_sect = PROT_SECT_DEVICE, 208 .prot_sect = PROT_SECT_DEVICE,
209 .domain = DOMAIN_IO, 209 .domain = DOMAIN_IO,
210 }, 210 },
211 [MT_UNCACHED] = {
212 .prot_pte = PROT_PTE_DEVICE,
213 .prot_l1 = PMD_TYPE_TABLE,
214 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
215 .domain = DOMAIN_IO,
216 },
211 [MT_CACHECLEAN] = { 217 [MT_CACHECLEAN] = {
212 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN, 218 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
213 .domain = DOMAIN_KERNEL, 219 .domain = DOMAIN_KERNEL,
diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
index 4689db638e95..9e573e78176a 100644
--- a/arch/arm/plat-iop/setup.c
+++ b/arch/arm/plat-iop/setup.c
@@ -16,14 +16,15 @@
16#include <asm/hardware/iop3xx.h> 16#include <asm/hardware/iop3xx.h>
17 17
18/* 18/*
19 * Standard IO mapping for all IOP3xx based systems 19 * Standard IO mapping for all IOP3xx based systems. Note that
20 * the IOP3xx OCCDR must be mapped uncached and unbuffered.
20 */ 21 */
21static struct map_desc iop3xx_std_desc[] __initdata = { 22static struct map_desc iop3xx_std_desc[] __initdata = {
22 { /* mem mapped registers */ 23 { /* mem mapped registers */
23 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE, 24 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE,
24 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE), 25 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE),
25 .length = IOP3XX_PERIPHERAL_SIZE, 26 .length = IOP3XX_PERIPHERAL_SIZE,
26 .type = MT_DEVICE, 27 .type = MT_UNCACHED,
27 }, { /* PCI IO space */ 28 }, { /* PCI IO space */
28 .virtual = IOP3XX_PCI_LOWER_IO_VA, 29 .virtual = IOP3XX_PCI_LOWER_IO_VA,
29 .pfn = __phys_to_pfn(IOP3XX_PCI_LOWER_IO_PA), 30 .pfn = __phys_to_pfn(IOP3XX_PCI_LOWER_IO_PA),
diff --git a/arch/blackfin/include/asm/bfin-global.h b/arch/blackfin/include/asm/bfin-global.h
index 56dcb0a2d244..77295666c34b 100644
--- a/arch/blackfin/include/asm/bfin-global.h
+++ b/arch/blackfin/include/asm/bfin-global.h
@@ -101,7 +101,7 @@ extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */
101extern unsigned long _ramstart, _ramend, _rambase; 101extern unsigned long _ramstart, _ramend, _rambase;
102extern unsigned long memory_start, memory_end, physical_mem_end; 102extern unsigned long memory_start, memory_end, physical_mem_end;
103extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[], 103extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
104 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _ebss_b_l1[], 104 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _sbss_b_l1[], _ebss_b_l1[],
105 _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[], 105 _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
106 _ebss_l2[], _l2_lma_start[]; 106 _ebss_l2[], _l2_lma_start[];
107 107
diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h
index ede748d67efd..d7d9148e433c 100644
--- a/arch/blackfin/include/asm/dma-mapping.h
+++ b/arch/blackfin/include/asm/dma-mapping.h
@@ -15,7 +15,11 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
15#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 15#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
16#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 16#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
17 17
18#define dma_mapping_error 18static inline
19int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
20{
21 return 0;
22}
19 23
20/* 24/*
21 * Map a single buffer of the indicated size for DMA in streaming mode. 25 * Map a single buffer of the indicated size for DMA in streaming mode.
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 6e08f425bb44..5c0800adb4dd 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -218,7 +218,7 @@ inline int check_gpio(unsigned gpio)
218 if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 218 if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15
219 || gpio == GPIO_PH14 || gpio == GPIO_PH15 219 || gpio == GPIO_PH14 || gpio == GPIO_PH15
220 || gpio == GPIO_PJ14 || gpio == GPIO_PJ15 220 || gpio == GPIO_PJ14 || gpio == GPIO_PJ15
221 || gpio > MAX_BLACKFIN_GPIOS) 221 || gpio >= MAX_BLACKFIN_GPIOS)
222 return -EINVAL; 222 return -EINVAL;
223 return 0; 223 return 0;
224} 224}
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbinit.c b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
index 512f8c92ead5..2debc900e246 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbinit.c
+++ b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
@@ -188,10 +188,11 @@ static struct cplb_desc cplb_data[] = {
188 188
189static u16 __init lock_kernel_check(u32 start, u32 end) 189static u16 __init lock_kernel_check(u32 start, u32 end)
190{ 190{
191 if ((end <= (u32) _end && end >= (u32)_stext) || 191 if (start >= (u32)_end || end <= (u32)_stext)
192 (start <= (u32) _end && start >= (u32)_stext)) 192 return 0;
193 return IN_KERNEL; 193
194 return 0; 194 /* This cplb block overlapped with kernel area. */
195 return IN_KERNEL;
195} 196}
196 197
197static unsigned short __init 198static unsigned short __init
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 77800dd83e57..0c3ea118b657 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -351,10 +351,15 @@ int _access_ok(unsigned long addr, unsigned long size)
351 return 1; 351 return 1;
352#endif 352#endif
353#if L1_DATA_B_LENGTH != 0 353#if L1_DATA_B_LENGTH != 0
354 if (addr >= L1_DATA_B_START 354 if (addr >= L1_DATA_B_START + (_ebss_b_l1 - _sdata_b_l1)
355 && addr + size <= L1_DATA_B_START + L1_DATA_B_LENGTH) 355 && addr + size <= L1_DATA_B_START + L1_DATA_B_LENGTH)
356 return 1; 356 return 1;
357#endif 357#endif
358#if L2_LENGTH != 0
359 if (addr >= L2_START + (_ebss_l2 - _stext_l2)
360 && addr + size <= L2_START + L2_LENGTH)
361 return 1;
362#endif
358 return 0; 363 return 0;
359} 364}
360EXPORT_SYMBOL(_access_ok); 365EXPORT_SYMBOL(_access_ok);
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 7f35d1046cd8..71a9a8c53cea 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -119,23 +119,23 @@ void __init bfin_relocate_l1_mem(void)
119 /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ 119 /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
120 dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); 120 dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
121 121
122 l1_data_a_length = _ebss_l1 - _sdata_l1; 122 l1_data_a_length = _sbss_l1 - _sdata_l1;
123 if (l1_data_a_length > L1_DATA_A_LENGTH) 123 if (l1_data_a_length > L1_DATA_A_LENGTH)
124 panic("L1 Data SRAM Bank A Overflow\n"); 124 panic("L1 Data SRAM Bank A Overflow\n");
125 125
126 /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */ 126 /* Copy _sdata_l1 to _sbss_l1 to L1 data bank A SRAM */
127 dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); 127 dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
128 128
129 l1_data_b_length = _ebss_b_l1 - _sdata_b_l1; 129 l1_data_b_length = _sbss_b_l1 - _sdata_b_l1;
130 if (l1_data_b_length > L1_DATA_B_LENGTH) 130 if (l1_data_b_length > L1_DATA_B_LENGTH)
131 panic("L1 Data SRAM Bank B Overflow\n"); 131 panic("L1 Data SRAM Bank B Overflow\n");
132 132
133 /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */ 133 /* Copy _sdata_b_l1 to _sbss_b_l1 to L1 data bank B SRAM */
134 dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + 134 dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
135 l1_data_a_length, l1_data_b_length); 135 l1_data_a_length, l1_data_b_length);
136 136
137 if (L2_LENGTH != 0) { 137 if (L2_LENGTH != 0) {
138 l2_length = _ebss_l2 - _stext_l2; 138 l2_length = _sbss_l2 - _stext_l2;
139 if (l2_length > L2_LENGTH) 139 if (l2_length > L2_LENGTH)
140 panic("L2 SRAM Overflow\n"); 140 panic("L2 SRAM Overflow\n");
141 141
@@ -827,7 +827,7 @@ void __init setup_arch(char **cmdline_p)
827 printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", 827 printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
828 bfin_compiled_revid(), bfin_revid()); 828 bfin_compiled_revid(), bfin_revid());
829 } 829 }
830 if (bfin_revid() <= CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX) 830 if (bfin_revid() < CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX)
831 printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", 831 printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
832 CPU, bfin_revid()); 832 CPU, bfin_revid());
833 } 833 }
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 1aa2c788e228..bef025b07443 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -59,7 +59,7 @@
59#endif 59#endif
60 60
61 61
62#ifdef CONFIG_VERBOSE_DEBUG 62#ifdef CONFIG_DEBUG_VERBOSE
63#define verbose_printk(fmt, arg...) \ 63#define verbose_printk(fmt, arg...) \
64 printk(fmt, ##arg) 64 printk(fmt, ##arg)
65#else 65#else
@@ -147,9 +147,12 @@ static void decode_address(char *buf, unsigned long address)
147 char *name = p->comm; 147 char *name = p->comm;
148 struct file *file = vma->vm_file; 148 struct file *file = vma->vm_file;
149 149
150 if (file) 150 if (file) {
151 name = d_path(&file->f_path, _tmpbuf, 151 char *d_name = d_path(&file->f_path, _tmpbuf,
152 sizeof(_tmpbuf)); 152 sizeof(_tmpbuf));
153 if (!IS_ERR(d_name))
154 name = d_name;
155 }
153 156
154 /* FLAT does not have its text aligned to the start of 157 /* FLAT does not have its text aligned to the start of
155 * the map while FDPIC ELF does ... 158 * the map while FDPIC ELF does ...
@@ -571,7 +574,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
571#endif 574#endif
572 panic("Kernel exception"); 575 panic("Kernel exception");
573 } else { 576 } else {
574#ifdef CONFIG_VERBOSE_DEBUG 577#ifdef CONFIG_DEBUG_VERBOSE
575 unsigned long *stack; 578 unsigned long *stack;
576 /* Dump the user space stack */ 579 /* Dump the user space stack */
577 stack = (unsigned long *)rdusp(); 580 stack = (unsigned long *)rdusp();
diff --git a/arch/blackfin/mach-common/cache.S b/arch/blackfin/mach-common/cache.S
index db532181fbde..a028e9450419 100644
--- a/arch/blackfin/mach-common/cache.S
+++ b/arch/blackfin/mach-common/cache.S
@@ -25,9 +25,13 @@
25 */ 25 */
26.macro do_flush flushins:req optflushins optnopins label 26.macro do_flush flushins:req optflushins optnopins label
27 27
28 R2 = -L1_CACHE_BYTES;
29
30 /* start = (start & -L1_CACHE_BYTES) */
31 R0 = R0 & R2;
32
28 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */ 33 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
29 R1 += -1; 34 R1 += -1;
30 R2 = -L1_CACHE_BYTES;
31 R1 = R1 & R2; 35 R1 = R1 & R2;
32 R1 += L1_CACHE_BYTES; 36 R1 += L1_CACHE_BYTES;
33 37
@@ -63,7 +67,7 @@ ENDPROC(_blackfin_icache_flush_range)
63 67
64/* Flush all cache lines assocoiated with this area of memory. */ 68/* Flush all cache lines assocoiated with this area of memory. */
65ENTRY(_blackfin_icache_dcache_flush_range) 69ENTRY(_blackfin_icache_dcache_flush_range)
66 do_flush IFLUSH, FLUSH 70 do_flush FLUSH, IFLUSH
67ENDPROC(_blackfin_icache_dcache_flush_range) 71ENDPROC(_blackfin_icache_dcache_flush_range)
68 72
69/* Throw away all D-cached data in specified region without any obligation to 73/* Throw away all D-cached data in specified region without any obligation to
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index c22c47b60127..dda5443b37ed 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -72,13 +72,13 @@ unsigned int __bfin_cycles_mod;
72 72
73/**************************************************************************/ 73/**************************************************************************/
74 74
75static unsigned int bfin_getfreq(unsigned int cpu) 75static unsigned int bfin_getfreq_khz(unsigned int cpu)
76{ 76{
77 /* The driver only support single cpu */ 77 /* The driver only support single cpu */
78 if (cpu != 0) 78 if (cpu != 0)
79 return -1; 79 return -1;
80 80
81 return get_cclk(); 81 return get_cclk() / 1000;
82} 82}
83 83
84 84
@@ -96,7 +96,7 @@ static int bfin_target(struct cpufreq_policy *policy,
96 96
97 cclk_hz = bfin_freq_table[index].frequency; 97 cclk_hz = bfin_freq_table[index].frequency;
98 98
99 freqs.old = bfin_getfreq(0); 99 freqs.old = bfin_getfreq_khz(0);
100 freqs.new = cclk_hz; 100 freqs.new = cclk_hz;
101 freqs.cpu = 0; 101 freqs.cpu = 0;
102 102
@@ -137,8 +137,8 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy)
137 if (policy->cpu != 0) 137 if (policy->cpu != 0)
138 return -EINVAL; 138 return -EINVAL;
139 139
140 cclk = get_cclk(); 140 cclk = get_cclk() / 1000;
141 sclk = get_sclk(); 141 sclk = get_sclk() / 1000;
142 142
143#if ANOMALY_05000273 || (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_DCACHE)) 143#if ANOMALY_05000273 || (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_DCACHE))
144 min_cclk = sclk * 2; 144 min_cclk = sclk * 2;
@@ -152,7 +152,7 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy)
152 dpm_state_table[index].csel = csel << 4; /* Shift now into PLL_DIV bitpos */ 152 dpm_state_table[index].csel = csel << 4; /* Shift now into PLL_DIV bitpos */
153 dpm_state_table[index].tscale = (TIME_SCALE / (1 << csel)) - 1; 153 dpm_state_table[index].tscale = (TIME_SCALE / (1 << csel)) - 1;
154 154
155 pr_debug("cpufreq: freq:%d csel:%d tscale:%d\n", 155 pr_debug("cpufreq: freq:%d csel:0x%x tscale:%d\n",
156 bfin_freq_table[index].frequency, 156 bfin_freq_table[index].frequency,
157 dpm_state_table[index].csel, 157 dpm_state_table[index].csel,
158 dpm_state_table[index].tscale); 158 dpm_state_table[index].tscale);
@@ -173,7 +173,7 @@ static struct freq_attr *bfin_freq_attr[] = {
173static struct cpufreq_driver bfin_driver = { 173static struct cpufreq_driver bfin_driver = {
174 .verify = bfin_verify_speed, 174 .verify = bfin_verify_speed,
175 .target = bfin_target, 175 .target = bfin_target,
176 .get = bfin_getfreq, 176 .get = bfin_getfreq_khz,
177 .init = __bfin_cpu_init, 177 .init = __bfin_cpu_init,
178 .name = "bfin cpufreq", 178 .name = "bfin cpufreq",
179 .owner = THIS_MODULE, 179 .owner = THIS_MODULE,
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index c13fa8da28c7..bde6dc4e2614 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -277,7 +277,7 @@ ENTRY(_bfin_return_from_exception)
277 p5.h = hi(ILAT); 277 p5.h = hi(ILAT);
278 r6 = [p5]; 278 r6 = [p5];
279 r7 = 0x20; /* Did I just cause anther HW error? */ 279 r7 = 0x20; /* Did I just cause anther HW error? */
280 r7 = r7 & r1; 280 r6 = r7 & r6;
281 CC = R7 == R6; 281 CC = R7 == R6;
282 if CC JUMP _double_fault; 282 if CC JUMP _double_fault;
283#endif 283#endif
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c
index 0f1ca6930c16..cc6f336e7313 100644
--- a/arch/blackfin/mm/sram-alloc.c
+++ b/arch/blackfin/mm/sram-alloc.c
@@ -183,10 +183,10 @@ static void __init l2_sram_init(void)
183 return; 183 return;
184 } 184 }
185 185
186 free_l2_sram_head.next->paddr = (void *)L2_START + 186 free_l2_sram_head.next->paddr =
187 (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2); 187 (void *)L2_START + (_ebss_l2 - _stext_l2);
188 free_l2_sram_head.next->size = L2_LENGTH - 188 free_l2_sram_head.next->size =
189 (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2); 189 L2_LENGTH - (_ebss_l2 - _stext_l2);
190 free_l2_sram_head.next->pid = 0; 190 free_l2_sram_head.next->pid = 0;
191 free_l2_sram_head.next->next = NULL; 191 free_l2_sram_head.next->next = NULL;
192 192
diff --git a/arch/ia64/include/asm/intrinsics.h b/arch/ia64/include/asm/intrinsics.h
index 47d686dba1eb..a3e44a5ed497 100644
--- a/arch/ia64/include/asm/intrinsics.h
+++ b/arch/ia64/include/asm/intrinsics.h
@@ -226,7 +226,7 @@ extern long ia64_cmpxchg_called_with_bad_pointer (void);
226/************************************************/ 226/************************************************/
227#define ia64_ssm IA64_INTRINSIC_MACRO(ssm) 227#define ia64_ssm IA64_INTRINSIC_MACRO(ssm)
228#define ia64_rsm IA64_INTRINSIC_MACRO(rsm) 228#define ia64_rsm IA64_INTRINSIC_MACRO(rsm)
229#define ia64_getreg IA64_INTRINSIC_API(getreg) 229#define ia64_getreg IA64_INTRINSIC_MACRO(getreg)
230#define ia64_setreg IA64_INTRINSIC_API(setreg) 230#define ia64_setreg IA64_INTRINSIC_API(setreg)
231#define ia64_set_rr IA64_INTRINSIC_API(set_rr) 231#define ia64_set_rr IA64_INTRINSIC_API(set_rr)
232#define ia64_get_rr IA64_INTRINSIC_API(get_rr) 232#define ia64_get_rr IA64_INTRINSIC_API(get_rr)
diff --git a/arch/ia64/include/asm/paravirt_privop.h b/arch/ia64/include/asm/paravirt_privop.h
index d577aac11835..0b597424fcfc 100644
--- a/arch/ia64/include/asm/paravirt_privop.h
+++ b/arch/ia64/include/asm/paravirt_privop.h
@@ -78,6 +78,19 @@ extern unsigned long ia64_native_getreg_func(int regnum);
78 ia64_native_rsm(mask); \ 78 ia64_native_rsm(mask); \
79 } while (0) 79 } while (0)
80 80
81/* returned ip value should be the one in the caller,
82 * not in __paravirt_getreg() */
83#define paravirt_getreg(reg) \
84 ({ \
85 unsigned long res; \
86 BUILD_BUG_ON(!__builtin_constant_p(reg)); \
87 if ((reg) == _IA64_REG_IP) \
88 res = ia64_native_getreg(_IA64_REG_IP); \
89 else \
90 res = pv_cpu_ops.getreg(reg); \
91 res; \
92 })
93
81/****************************************************************************** 94/******************************************************************************
82 * replacement of hand written assembly codes. 95 * replacement of hand written assembly codes.
83 */ 96 */
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 7ef0c594f5ed..d435f4a7a96c 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -499,6 +499,7 @@ GLOBAL_ENTRY(prefetch_stack)
499END(prefetch_stack) 499END(prefetch_stack)
500 500
501GLOBAL_ENTRY(kernel_execve) 501GLOBAL_ENTRY(kernel_execve)
502 rum psr.ac
502 mov r15=__NR_execve // put syscall number in place 503 mov r15=__NR_execve // put syscall number in place
503 break __BREAK_SYSCALL 504 break __BREAK_SYSCALL
504 br.ret.sptk.many rp 505 br.ret.sptk.many rp
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 66e491d8baac..59301c472800 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -260,7 +260,7 @@ start_ap:
260 * Switch into virtual mode: 260 * Switch into virtual mode:
261 */ 261 */
262 movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \ 262 movl r16=(IA64_PSR_IT|IA64_PSR_IC|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_DFH|IA64_PSR_BN \
263 |IA64_PSR_DI) 263 |IA64_PSR_DI|IA64_PSR_AC)
264 ;; 264 ;;
265 mov cr.ipsr=r16 265 mov cr.ipsr=r16
266 movl r17=1f 266 movl r17=1f
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 7dd96c127177..bab1de2d2f6a 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1139,7 +1139,7 @@ ia64_mca_modify_original_stack(struct pt_regs *regs,
1139 return previous_current; 1139 return previous_current;
1140 1140
1141no_mod: 1141no_mod:
1142 printk(KERN_INFO "cpu %d, %s %s, original stack not modified\n", 1142 mprintk(KERN_INFO "cpu %d, %s %s, original stack not modified\n",
1143 smp_processor_id(), type, msg); 1143 smp_processor_id(), type, msg);
1144 return previous_current; 1144 return previous_current;
1145} 1145}
diff --git a/arch/ia64/kernel/paravirt.c b/arch/ia64/kernel/paravirt.c
index de35d8e8b7d2..9f14c16f6369 100644
--- a/arch/ia64/kernel/paravirt.c
+++ b/arch/ia64/kernel/paravirt.c
@@ -130,7 +130,7 @@ ia64_native_getreg_func(int regnum)
130 unsigned long res = -1; 130 unsigned long res = -1;
131 switch (regnum) { 131 switch (regnum) {
132 CASE_GET_REG(GP); 132 CASE_GET_REG(GP);
133 CASE_GET_REG(IP); 133 /*CASE_GET_REG(IP);*/ /* returned ip value shouldn't be constant */
134 CASE_GET_REG(PSR); 134 CASE_GET_REG(PSR);
135 CASE_GET_REG(TP); 135 CASE_GET_REG(TP);
136 CASE_GET_REG(SP); 136 CASE_GET_REG(SP);
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index dbdb778efa05..2a92f637431d 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20 20
21#include <asm/page.h> 21#include <asm/page.h>
22#include <asm/iommu.h>
23 22
24dma_addr_t bad_dma_address __read_mostly; 23dma_addr_t bad_dma_address __read_mostly;
25EXPORT_SYMBOL(bad_dma_address); 24EXPORT_SYMBOL(bad_dma_address);
diff --git a/arch/ia64/xen/hypercall.S b/arch/ia64/xen/hypercall.S
index d4ff0b9e79f1..45e02bb64a92 100644
--- a/arch/ia64/xen/hypercall.S
+++ b/arch/ia64/xen/hypercall.S
@@ -58,7 +58,7 @@ __HCALL2(xen_set_rr, HYPERPRIVOP_SET_RR)
58__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR) 58__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR)
59 59
60#ifdef CONFIG_IA32_SUPPORT 60#ifdef CONFIG_IA32_SUPPORT
61__HCALL1(xen_get_eflag, HYPERPRIVOP_GET_EFLAG) 61__HCALL0(xen_get_eflag, HYPERPRIVOP_GET_EFLAG)
62__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG) // refer SDM vol1 3.1.8 62__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG) // refer SDM vol1 3.1.8
63#endif /* CONFIG_IA32_SUPPORT */ 63#endif /* CONFIG_IA32_SUPPORT */
64 64
diff --git a/arch/m68k/kernel/ints.c b/arch/m68k/kernel/ints.c
index 7e8a0d394e61..761ee0440c99 100644
--- a/arch/m68k/kernel/ints.c
+++ b/arch/m68k/kernel/ints.c
@@ -133,7 +133,7 @@ void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt,
133{ 133{
134 int i; 134 int i;
135 135
136 BUG_ON(IRQ_USER + cnt >= NR_IRQS); 136 BUG_ON(IRQ_USER + cnt > NR_IRQS);
137 m68k_first_user_vec = vec; 137 m68k_first_user_vec = vec;
138 for (i = 0; i < cnt; i++) 138 for (i = 0; i < cnt; i++)
139 irq_controller[IRQ_USER + i] = &user_irq_controller; 139 irq_controller[IRQ_USER + i] = &user_irq_controller;
diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h
index c8e554eafce3..b5cf6457305a 100644
--- a/arch/mips/include/asm/mach-rc32434/gpio.h
+++ b/arch/mips/include/asm/mach-rc32434/gpio.h
@@ -84,5 +84,7 @@ extern void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned
84extern unsigned get_434_reg(unsigned reg_offs); 84extern unsigned get_434_reg(unsigned reg_offs);
85extern void set_latch_u5(unsigned char or_mask, unsigned char nand_mask); 85extern void set_latch_u5(unsigned char or_mask, unsigned char nand_mask);
86extern unsigned char get_latch_u5(void); 86extern unsigned char get_latch_u5(void);
87extern void rb532_gpio_set_ilevel(int bit, unsigned gpio);
88extern void rb532_gpio_set_istat(int bit, unsigned gpio);
87 89
88#endif /* _RC32434_GPIO_H_ */ 90#endif /* _RC32434_GPIO_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/rb.h b/arch/mips/include/asm/mach-rc32434/rb.h
index 79e8ef67d0d3..f25a84916703 100644
--- a/arch/mips/include/asm/mach-rc32434/rb.h
+++ b/arch/mips/include/asm/mach-rc32434/rb.h
@@ -40,12 +40,14 @@
40#define BTCS 0x010040 40#define BTCS 0x010040
41#define BTCOMPARE 0x010044 41#define BTCOMPARE 0x010044
42#define GPIOBASE 0x050000 42#define GPIOBASE 0x050000
43#define GPIOCFG 0x050004 43/* Offsets relative to GPIOBASE */
44#define GPIOD 0x050008 44#define GPIOFUNC 0x00
45#define GPIOILEVEL 0x05000C 45#define GPIOCFG 0x04
46#define GPIOISTAT 0x050010 46#define GPIOD 0x08
47#define GPIONMIEN 0x050014 47#define GPIOILEVEL 0x0C
48#define IMASK6 0x038038 48#define GPIOISTAT 0x10
49#define GPIONMIEN 0x14
50#define IMASK6 0x38
49#define LO_WPX (1 << 0) 51#define LO_WPX (1 << 0)
50#define LO_ALE (1 << 1) 52#define LO_ALE (1 << 1)
51#define LO_CLE (1 << 2) 53#define LO_CLE (1 << 2)
diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index d3bd5c5aa2ec..9601ea950542 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -63,7 +63,7 @@ static inline int mips_clockevent_init(void)
63/* 63/*
64 * Initialize the count register as a clocksource 64 * Initialize the count register as a clocksource
65 */ 65 */
66#ifdef CONFIG_CEVT_R4K 66#ifdef CONFIG_CSRC_R4K
67extern int init_mips_clocksource(void); 67extern int init_mips_clocksource(void);
68#else 68#else
69static inline int init_mips_clocksource(void) 69static inline int init_mips_clocksource(void)
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index 86e026f067bc..74fb74583b4e 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -27,7 +27,7 @@ int __init init_mips_clocksource(void)
27 if (!cpu_has_counter || !mips_hpt_frequency) 27 if (!cpu_has_counter || !mips_hpt_frequency)
28 return -ENXIO; 28 return -ENXIO;
29 29
30 /* Calclate a somewhat reasonable rating value */ 30 /* Calculate a somewhat reasonable rating value */
31 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000; 31 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
32 32
33 clocksource_set_clock(&clocksource_mips, mips_hpt_frequency); 33 clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
diff --git a/arch/mips/mm/sc-ip22.c b/arch/mips/mm/sc-ip22.c
index 1f602a110e10..13adb5782110 100644
--- a/arch/mips/mm/sc-ip22.c
+++ b/arch/mips/mm/sc-ip22.c
@@ -161,7 +161,7 @@ static inline int __init indy_sc_probe(void)
161 161
162/* XXX Check with wje if the Indy caches can differenciate between 162/* XXX Check with wje if the Indy caches can differenciate between
163 writeback + invalidate and just invalidate. */ 163 writeback + invalidate and just invalidate. */
164struct bcache_ops indy_sc_ops = { 164static struct bcache_ops indy_sc_ops = {
165 .bc_enable = indy_sc_enable, 165 .bc_enable = indy_sc_enable,
166 .bc_disable = indy_sc_disable, 166 .bc_disable = indy_sc_disable,
167 .bc_wback_inv = indy_sc_wback_invalidate, 167 .bc_wback_inv = indy_sc_wback_invalidate,
diff --git a/arch/mips/mti-malta/malta-amon.c b/arch/mips/mti-malta/malta-amon.c
index 96236bf33838..df9e526312a2 100644
--- a/arch/mips/mti-malta/malta-amon.c
+++ b/arch/mips/mti-malta/malta-amon.c
@@ -22,9 +22,9 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24 24
25#include <asm-mips/addrspace.h> 25#include <asm/addrspace.h>
26#include <asm-mips/mips-boards/launch.h> 26#include <asm/mips-boards/launch.h>
27#include <asm-mips/mipsmtregs.h> 27#include <asm/mipsmtregs.h>
28 28
29int amon_cpu_avail(int cpu) 29int amon_cpu_avail(int cpu)
30{ 30{
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 2f22d714d5b0..c1c29181bd46 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -118,7 +118,7 @@ static struct platform_device cf_slot0 = {
118/* Resources and device for NAND */ 118/* Resources and device for NAND */
119static int rb532_dev_ready(struct mtd_info *mtd) 119static int rb532_dev_ready(struct mtd_info *mtd)
120{ 120{
121 return readl(IDT434_REG_BASE + GPIOD) & GPIO_RDY; 121 return gpio_get_value(GPIO_RDY);
122} 122}
123 123
124static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 124static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index 70c4a6726377..0e84c8ab6a39 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -39,10 +39,6 @@
39struct rb532_gpio_chip { 39struct rb532_gpio_chip {
40 struct gpio_chip chip; 40 struct gpio_chip chip;
41 void __iomem *regbase; 41 void __iomem *regbase;
42 void (*set_int_level)(struct gpio_chip *chip, unsigned offset, int value);
43 int (*get_int_level)(struct gpio_chip *chip, unsigned offset);
44 void (*set_int_status)(struct gpio_chip *chip, unsigned offset, int value);
45 int (*get_int_status)(struct gpio_chip *chip, unsigned offset);
46}; 42};
47 43
48struct mpmc_device dev3; 44struct mpmc_device dev3;
@@ -111,15 +107,47 @@ unsigned char get_latch_u5(void)
111} 107}
112EXPORT_SYMBOL(get_latch_u5); 108EXPORT_SYMBOL(get_latch_u5);
113 109
110/* rb532_set_bit - sanely set a bit
111 *
112 * bitval: new value for the bit
113 * offset: bit index in the 4 byte address range
114 * ioaddr: 4 byte aligned address being altered
115 */
116static inline void rb532_set_bit(unsigned bitval,
117 unsigned offset, void __iomem *ioaddr)
118{
119 unsigned long flags;
120 u32 val;
121
122 bitval = !!bitval; /* map parameter to {0,1} */
123
124 local_irq_save(flags);
125
126 val = readl(ioaddr);
127 val &= ~( ~bitval << offset ); /* unset bit if bitval == 0 */
128 val |= ( bitval << offset ); /* set bit if bitval == 1 */
129 writel(val, ioaddr);
130
131 local_irq_restore(flags);
132}
133
134/* rb532_get_bit - read a bit
135 *
136 * returns the boolean state of the bit, which may be > 1
137 */
138static inline int rb532_get_bit(unsigned offset, void __iomem *ioaddr)
139{
140 return (readl(ioaddr) & (1 << offset));
141}
142
114/* 143/*
115 * Return GPIO level */ 144 * Return GPIO level */
116static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset) 145static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
117{ 146{
118 u32 mask = 1 << offset;
119 struct rb532_gpio_chip *gpch; 147 struct rb532_gpio_chip *gpch;
120 148
121 gpch = container_of(chip, struct rb532_gpio_chip, chip); 149 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 return readl(gpch->regbase + GPIOD) & mask; 150 return rb532_get_bit(offset, gpch->regbase + GPIOD);
123} 151}
124 152
125/* 153/*
@@ -128,23 +156,10 @@ static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
128static void rb532_gpio_set(struct gpio_chip *chip, 156static void rb532_gpio_set(struct gpio_chip *chip,
129 unsigned offset, int value) 157 unsigned offset, int value)
130{ 158{
131 unsigned long flags;
132 u32 mask = 1 << offset;
133 u32 tmp;
134 struct rb532_gpio_chip *gpch; 159 struct rb532_gpio_chip *gpch;
135 void __iomem *gpvr;
136 160
137 gpch = container_of(chip, struct rb532_gpio_chip, chip); 161 gpch = container_of(chip, struct rb532_gpio_chip, chip);
138 gpvr = gpch->regbase + GPIOD; 162 rb532_set_bit(value, offset, gpch->regbase + GPIOD);
139
140 local_irq_save(flags);
141 tmp = readl(gpvr);
142 if (value)
143 tmp |= mask;
144 else
145 tmp &= ~mask;
146 writel(tmp, gpvr);
147 local_irq_restore(flags);
148} 163}
149 164
150/* 165/*
@@ -152,21 +167,14 @@ static void rb532_gpio_set(struct gpio_chip *chip,
152 */ 167 */
153static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 168static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
154{ 169{
155 unsigned long flags;
156 u32 mask = 1 << offset;
157 u32 value;
158 struct rb532_gpio_chip *gpch; 170 struct rb532_gpio_chip *gpch;
159 void __iomem *gpdr;
160 171
161 gpch = container_of(chip, struct rb532_gpio_chip, chip); 172 gpch = container_of(chip, struct rb532_gpio_chip, chip);
162 gpdr = gpch->regbase + GPIOCFG;
163 173
164 local_irq_save(flags); 174 if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
165 value = readl(gpdr); 175 return 1; /* alternate function, GPIOCFG is ignored */
166 value &= ~mask;
167 writel(value, gpdr);
168 local_irq_restore(flags);
169 176
177 rb532_set_bit(0, offset, gpch->regbase + GPIOCFG);
170 return 0; 178 return 0;
171} 179}
172 180
@@ -176,117 +184,60 @@ static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
176static int rb532_gpio_direction_output(struct gpio_chip *chip, 184static int rb532_gpio_direction_output(struct gpio_chip *chip,
177 unsigned offset, int value) 185 unsigned offset, int value)
178{ 186{
179 unsigned long flags;
180 u32 mask = 1 << offset;
181 u32 tmp;
182 struct rb532_gpio_chip *gpch; 187 struct rb532_gpio_chip *gpch;
183 void __iomem *gpdr;
184 188
185 gpch = container_of(chip, struct rb532_gpio_chip, chip); 189 gpch = container_of(chip, struct rb532_gpio_chip, chip);
186 writel(mask, gpch->regbase + GPIOD);
187 gpdr = gpch->regbase + GPIOCFG;
188 190
189 local_irq_save(flags); 191 if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
190 tmp = readl(gpdr); 192 return 1; /* alternate function, GPIOCFG is ignored */
191 tmp |= mask;
192 writel(tmp, gpdr);
193 local_irq_restore(flags);
194 193
194 /* set the initial output value */
195 rb532_set_bit(value, offset, gpch->regbase + GPIOD);
196
197 rb532_set_bit(1, offset, gpch->regbase + GPIOCFG);
195 return 0; 198 return 0;
196} 199}
197 200
198/* 201static struct rb532_gpio_chip rb532_gpio_chip[] = {
199 * Set the GPIO interrupt level 202 [0] = {
200 */ 203 .chip = {
201static void rb532_gpio_set_int_level(struct gpio_chip *chip, 204 .label = "gpio0",
202 unsigned offset, int value) 205 .direction_input = rb532_gpio_direction_input,
203{ 206 .direction_output = rb532_gpio_direction_output,
204 unsigned long flags; 207 .get = rb532_gpio_get,
205 u32 mask = 1 << offset; 208 .set = rb532_gpio_set,
206 u32 tmp; 209 .base = 0,
207 struct rb532_gpio_chip *gpch; 210 .ngpio = 32,
208 void __iomem *gpil; 211 },
209 212 },
210 gpch = container_of(chip, struct rb532_gpio_chip, chip); 213};
211 gpil = gpch->regbase + GPIOILEVEL;
212
213 local_irq_save(flags);
214 tmp = readl(gpil);
215 if (value)
216 tmp |= mask;
217 else
218 tmp &= ~mask;
219 writel(tmp, gpil);
220 local_irq_restore(flags);
221}
222 214
223/* 215/*
224 * Get the GPIO interrupt level 216 * Set GPIO interrupt level
225 */ 217 */
226static int rb532_gpio_get_int_level(struct gpio_chip *chip, unsigned offset) 218void rb532_gpio_set_ilevel(int bit, unsigned gpio)
227{ 219{
228 u32 mask = 1 << offset; 220 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOILEVEL);
229 struct rb532_gpio_chip *gpch;
230
231 gpch = container_of(chip, struct rb532_gpio_chip, chip);
232 return readl(gpch->regbase + GPIOILEVEL) & mask;
233} 221}
222EXPORT_SYMBOL(rb532_gpio_set_ilevel);
234 223
235/* 224/*
236 * Set the GPIO interrupt status 225 * Set GPIO interrupt status
237 */ 226 */
238static void rb532_gpio_set_int_status(struct gpio_chip *chip, 227void rb532_gpio_set_istat(int bit, unsigned gpio)
239 unsigned offset, int value)
240{ 228{
241 unsigned long flags; 229 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOISTAT);
242 u32 mask = 1 << offset;
243 u32 tmp;
244 struct rb532_gpio_chip *gpch;
245 void __iomem *gpis;
246
247 gpch = container_of(chip, struct rb532_gpio_chip, chip);
248 gpis = gpch->regbase + GPIOISTAT;
249
250 local_irq_save(flags);
251 tmp = readl(gpis);
252 if (value)
253 tmp |= mask;
254 else
255 tmp &= ~mask;
256 writel(tmp, gpis);
257 local_irq_restore(flags);
258} 230}
231EXPORT_SYMBOL(rb532_gpio_set_istat);
259 232
260/* 233/*
261 * Get the GPIO interrupt status 234 * Configure GPIO alternate function
262 */ 235 */
263static int rb532_gpio_get_int_status(struct gpio_chip *chip, unsigned offset) 236static void rb532_gpio_set_func(int bit, unsigned gpio)
264{ 237{
265 u32 mask = 1 << offset; 238 rb532_set_bit(bit, gpio, rb532_gpio_chip->regbase + GPIOFUNC);
266 struct rb532_gpio_chip *gpch;
267
268 gpch = container_of(chip, struct rb532_gpio_chip, chip);
269 return readl(gpch->regbase + GPIOISTAT) & mask;
270} 239}
271 240
272static struct rb532_gpio_chip rb532_gpio_chip[] = {
273 [0] = {
274 .chip = {
275 .label = "gpio0",
276 .direction_input = rb532_gpio_direction_input,
277 .direction_output = rb532_gpio_direction_output,
278 .get = rb532_gpio_get,
279 .set = rb532_gpio_set,
280 .base = 0,
281 .ngpio = 32,
282 },
283 .get_int_level = rb532_gpio_get_int_level,
284 .set_int_level = rb532_gpio_set_int_level,
285 .get_int_status = rb532_gpio_get_int_status,
286 .set_int_status = rb532_gpio_set_int_status,
287 },
288};
289
290int __init rb532_gpio_init(void) 241int __init rb532_gpio_init(void)
291{ 242{
292 struct resource *r; 243 struct resource *r;
@@ -310,9 +261,11 @@ int __init rb532_gpio_init(void)
310 return -ENXIO; 261 return -ENXIO;
311 } 262 }
312 263
313 /* Set the interrupt status and level for the CF pin */ 264 /* configure CF_GPIO_NUM as CFRDY IRQ source */
314 rb532_gpio_set_int_level(&rb532_gpio_chip->chip, CF_GPIO_NUM, 1); 265 rb532_gpio_set_func(0, CF_GPIO_NUM);
315 rb532_gpio_set_int_status(&rb532_gpio_chip->chip, CF_GPIO_NUM, 0); 266 rb532_gpio_direction_input(&rb532_gpio_chip->chip, CF_GPIO_NUM);
267 rb532_gpio_set_ilevel(1, CF_GPIO_NUM);
268 rb532_gpio_set_istat(0, CF_GPIO_NUM);
316 269
317 return 0; 270 return 0;
318} 271}
diff --git a/arch/parisc/include/asm/smp.h b/arch/parisc/include/asm/smp.h
index 398cdbaf4e54..409e698f4361 100644
--- a/arch/parisc/include/asm/smp.h
+++ b/arch/parisc/include/asm/smp.h
@@ -44,8 +44,6 @@ extern void arch_send_call_function_ipi(cpumask_t mask);
44 44
45#define PROC_CHANGE_PENALTY 15 /* Schedule penalty */ 45#define PROC_CHANGE_PENALTY 15 /* Schedule penalty */
46 46
47extern unsigned long cpu_present_mask;
48
49#define raw_smp_processor_id() (current_thread_info()->cpu) 47#define raw_smp_processor_id() (current_thread_info()->cpu)
50 48
51#else /* CONFIG_SMP */ 49#else /* CONFIG_SMP */
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 90904f9dfc50..927db3668b6f 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -183,10 +183,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
183 * being 64 bit in both cases. 183 * being 64 bit in both cases.
184 */ 184 */
185 185
186static long translate_usr_offset(long offset) 186static compat_ulong_t translate_usr_offset(compat_ulong_t offset)
187{ 187{
188 if (offset < 0) 188 if (offset < 0)
189 return -1; 189 return sizeof(struct pt_regs);
190 else if (offset <= 32*4) /* gr[0..31] */ 190 else if (offset <= 32*4) /* gr[0..31] */
191 return offset * 2 + 4; 191 return offset * 2 + 4;
192 else if (offset <= 32*4+32*8) /* gr[0..31] + fr[0..31] */ 192 else if (offset <= 32*4+32*8) /* gr[0..31] + fr[0..31] */
@@ -194,7 +194,7 @@ static long translate_usr_offset(long offset)
194 else if (offset < sizeof(struct pt_regs)/2 + 32*4) 194 else if (offset < sizeof(struct pt_regs)/2 + 32*4)
195 return offset * 2 + 4 - 32*8; 195 return offset * 2 + 4 - 32*8;
196 else 196 else
197 return -1; 197 return sizeof(struct pt_regs);
198} 198}
199 199
200long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 200long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
@@ -209,7 +209,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
209 if (addr & (sizeof(compat_uint_t)-1)) 209 if (addr & (sizeof(compat_uint_t)-1))
210 break; 210 break;
211 addr = translate_usr_offset(addr); 211 addr = translate_usr_offset(addr);
212 if (addr < 0) 212 if (addr >= sizeof(struct pt_regs))
213 break; 213 break;
214 214
215 tmp = *(compat_uint_t *) ((char *) task_regs(child) + addr); 215 tmp = *(compat_uint_t *) ((char *) task_regs(child) + addr);
@@ -236,7 +236,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
236 if (addr & (sizeof(compat_uint_t)-1)) 236 if (addr & (sizeof(compat_uint_t)-1))
237 break; 237 break;
238 addr = translate_usr_offset(addr); 238 addr = translate_usr_offset(addr);
239 if (addr < 0) 239 if (addr >= sizeof(struct pt_regs))
240 break; 240 break;
241 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) { 241 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) {
242 /* Special case, fp regs are 64 bits anyway */ 242 /* Special case, fp regs are 64 bits anyway */
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index ed500ef799b7..08844fc24a2e 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -61,22 +61,25 @@ STACK_SIZE = 1 << STACK_SHIFT
61 61
62#ifdef CONFIG_TRACE_IRQFLAGS 62#ifdef CONFIG_TRACE_IRQFLAGS
63 .macro TRACE_IRQS_ON 63 .macro TRACE_IRQS_ON
64 l %r1,BASED(.Ltrace_irq_on) 64 basr %r2,%r0
65 l %r1,BASED(.Ltrace_irq_on_caller)
65 basr %r14,%r1 66 basr %r14,%r1
66 .endm 67 .endm
67 68
68 .macro TRACE_IRQS_OFF 69 .macro TRACE_IRQS_OFF
69 l %r1,BASED(.Ltrace_irq_off) 70 basr %r2,%r0
71 l %r1,BASED(.Ltrace_irq_off_caller)
70 basr %r14,%r1 72 basr %r14,%r1
71 .endm 73 .endm
72 74
73 .macro TRACE_IRQS_CHECK 75 .macro TRACE_IRQS_CHECK
76 basr %r2,%r0
74 tm SP_PSW(%r15),0x03 # irqs enabled? 77 tm SP_PSW(%r15),0x03 # irqs enabled?
75 jz 0f 78 jz 0f
76 l %r1,BASED(.Ltrace_irq_on) 79 l %r1,BASED(.Ltrace_irq_on_caller)
77 basr %r14,%r1 80 basr %r14,%r1
78 j 1f 81 j 1f
790: l %r1,BASED(.Ltrace_irq_off) 820: l %r1,BASED(.Ltrace_irq_off_caller)
80 basr %r14,%r1 83 basr %r14,%r1
811: 841:
82 .endm 85 .endm
@@ -1113,9 +1116,12 @@ cleanup_io_leave_insn:
1113.Lschedtail: .long schedule_tail 1116.Lschedtail: .long schedule_tail
1114.Lsysc_table: .long sys_call_table 1117.Lsysc_table: .long sys_call_table
1115#ifdef CONFIG_TRACE_IRQFLAGS 1118#ifdef CONFIG_TRACE_IRQFLAGS
1116.Ltrace_irq_on: .long trace_hardirqs_on 1119.Ltrace_irq_on_caller:
1117.Ltrace_irq_off: 1120 .long trace_hardirqs_on_caller
1118 .long trace_hardirqs_off 1121.Ltrace_irq_off_caller:
1122 .long trace_hardirqs_off_caller
1123#endif
1124#ifdef CONFIG_LOCKDEP
1119.Llockdep_sys_exit: 1125.Llockdep_sys_exit:
1120 .long lockdep_sys_exit 1126 .long lockdep_sys_exit
1121#endif 1127#endif
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index d7ce150453f2..41aca06682aa 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -61,19 +61,22 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
61 61
62#ifdef CONFIG_TRACE_IRQFLAGS 62#ifdef CONFIG_TRACE_IRQFLAGS
63 .macro TRACE_IRQS_ON 63 .macro TRACE_IRQS_ON
64 brasl %r14,trace_hardirqs_on 64 basr %r2,%r0
65 brasl %r14,trace_hardirqs_on_caller
65 .endm 66 .endm
66 67
67 .macro TRACE_IRQS_OFF 68 .macro TRACE_IRQS_OFF
68 brasl %r14,trace_hardirqs_off 69 basr %r2,%r0
70 brasl %r14,trace_hardirqs_off_caller
69 .endm 71 .endm
70 72
71 .macro TRACE_IRQS_CHECK 73 .macro TRACE_IRQS_CHECK
74 basr %r2,%r0
72 tm SP_PSW(%r15),0x03 # irqs enabled? 75 tm SP_PSW(%r15),0x03 # irqs enabled?
73 jz 0f 76 jz 0f
74 brasl %r14,trace_hardirqs_on 77 brasl %r14,trace_hardirqs_on_caller
75 j 1f 78 j 1f
760: brasl %r14,trace_hardirqs_off 790: brasl %r14,trace_hardirqs_off_caller
771: 801:
78 .endm 81 .endm
79#else 82#else
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 3e2c05cb6a87..04f8c67a6101 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -136,9 +136,12 @@ static void default_idle(void)
136 return; 136 return;
137 } 137 }
138 trace_hardirqs_on(); 138 trace_hardirqs_on();
139 /* Don't trace preempt off for idle. */
140 stop_critical_timings();
139 /* Wait for external, I/O or machine check interrupt. */ 141 /* Wait for external, I/O or machine check interrupt. */
140 __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT | 142 __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT |
141 PSW_MASK_IO | PSW_MASK_EXT); 143 PSW_MASK_IO | PSW_MASK_EXT);
144 start_critical_timings();
142} 145}
143 146
144void cpu_idle(void) 147void cpu_idle(void)
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 62122bad1e33..400b040df7fa 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -604,13 +604,13 @@ setup_memory(void)
604 if (memory_chunk[i].type != CHUNK_READ_WRITE) 604 if (memory_chunk[i].type != CHUNK_READ_WRITE)
605 continue; 605 continue;
606 start_chunk = PFN_DOWN(memory_chunk[i].addr); 606 start_chunk = PFN_DOWN(memory_chunk[i].addr);
607 end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1; 607 end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size);
608 end_chunk = min(end_chunk, end_pfn); 608 end_chunk = min(end_chunk, end_pfn);
609 if (start_chunk >= end_chunk) 609 if (start_chunk >= end_chunk)
610 continue; 610 continue;
611 add_active_range(0, start_chunk, end_chunk); 611 add_active_range(0, start_chunk, end_chunk);
612 pfn = max(start_chunk, start_pfn); 612 pfn = max(start_chunk, start_pfn);
613 for (; pfn <= end_chunk; pfn++) 613 for (; pfn < end_chunk; pfn++)
614 page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); 614 page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY);
615 } 615 }
616 616
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index 5fdb799062b7..4fe952e557ac 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -198,7 +198,7 @@ asmlinkage long s390x_newuname(struct new_utsname __user *name)
198{ 198{
199 int ret = sys_newuname(name); 199 int ret = sys_newuname(name);
200 200
201 if (current->personality == PER_LINUX32 && !ret) { 201 if (personality(current->personality) == PER_LINUX32 && !ret) {
202 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8); 202 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
203 if (ret) ret = -EFAULT; 203 if (ret) ret = -EFAULT;
204 } 204 }
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 632b13e10053..a947899dcba1 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -65,18 +65,21 @@ static int machine_has_topology_irq;
65static struct timer_list topology_timer; 65static struct timer_list topology_timer;
66static void set_topology_timer(void); 66static void set_topology_timer(void);
67static DECLARE_WORK(topology_work, topology_work_fn); 67static DECLARE_WORK(topology_work, topology_work_fn);
68/* topology_lock protects the core linked list */
69static DEFINE_SPINLOCK(topology_lock);
68 70
69cpumask_t cpu_core_map[NR_CPUS]; 71cpumask_t cpu_core_map[NR_CPUS];
70 72
71cpumask_t cpu_coregroup_map(unsigned int cpu) 73cpumask_t cpu_coregroup_map(unsigned int cpu)
72{ 74{
73 struct core_info *core = &core_info; 75 struct core_info *core = &core_info;
76 unsigned long flags;
74 cpumask_t mask; 77 cpumask_t mask;
75 78
76 cpus_clear(mask); 79 cpus_clear(mask);
77 if (!machine_has_topology) 80 if (!machine_has_topology)
78 return cpu_present_map; 81 return cpu_present_map;
79 mutex_lock(&smp_cpu_state_mutex); 82 spin_lock_irqsave(&topology_lock, flags);
80 while (core) { 83 while (core) {
81 if (cpu_isset(cpu, core->mask)) { 84 if (cpu_isset(cpu, core->mask)) {
82 mask = core->mask; 85 mask = core->mask;
@@ -84,7 +87,7 @@ cpumask_t cpu_coregroup_map(unsigned int cpu)
84 } 87 }
85 core = core->next; 88 core = core->next;
86 } 89 }
87 mutex_unlock(&smp_cpu_state_mutex); 90 spin_unlock_irqrestore(&topology_lock, flags);
88 if (cpus_empty(mask)) 91 if (cpus_empty(mask))
89 mask = cpumask_of_cpu(cpu); 92 mask = cpumask_of_cpu(cpu);
90 return mask; 93 return mask;
@@ -133,7 +136,7 @@ static void tl_to_cores(struct tl_info *info)
133 union tl_entry *tle, *end; 136 union tl_entry *tle, *end;
134 struct core_info *core = &core_info; 137 struct core_info *core = &core_info;
135 138
136 mutex_lock(&smp_cpu_state_mutex); 139 spin_lock_irq(&topology_lock);
137 clear_cores(); 140 clear_cores();
138 tle = info->tle; 141 tle = info->tle;
139 end = (union tl_entry *)((unsigned long)info + info->length); 142 end = (union tl_entry *)((unsigned long)info + info->length);
@@ -157,7 +160,7 @@ static void tl_to_cores(struct tl_info *info)
157 } 160 }
158 tle = next_tle(tle); 161 tle = next_tle(tle);
159 } 162 }
160 mutex_unlock(&smp_cpu_state_mutex); 163 spin_unlock_irq(&topology_lock);
161} 164}
162 165
163static void topology_update_polarization_simple(void) 166static void topology_update_polarization_simple(void)
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 436c28539577..65eaae34e753 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -293,6 +293,10 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
293 */ 293 */
294#define xlate_dev_kmem_ptr(p) p 294#define xlate_dev_kmem_ptr(p) p
295 295
296#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
297int valid_phys_addr_range(unsigned long addr, size_t size);
298int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
299
296#endif /* __KERNEL__ */ 300#endif /* __KERNEL__ */
297 301
298#endif /* __ASM_SH_IO_H */ 302#endif /* __ASM_SH_IO_H */
diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h
index 52220d70a096..b517ae08b9c0 100644
--- a/arch/sh/include/asm/pgtable.h
+++ b/arch/sh/include/asm/pgtable.h
@@ -148,6 +148,12 @@ extern void paging_init(void);
148extern void page_table_range_init(unsigned long start, unsigned long end, 148extern void page_table_range_init(unsigned long start, unsigned long end,
149 pgd_t *pgd); 149 pgd_t *pgd);
150 150
151#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_CPU_SH4) && defined(CONFIG_MMU)
152extern void kmap_coherent_init(void);
153#else
154#define kmap_coherent_init() do { } while (0)
155#endif
156
151#include <asm-generic/pgtable.h> 157#include <asm-generic/pgtable.h>
152 158
153#endif /* __ASM_SH_PGTABLE_H */ 159#endif /* __ASM_SH_PGTABLE_H */
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
index a7412cede534..6d9e6972cfc9 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
@@ -119,17 +119,17 @@ static struct plat_sci_port sci_platform_data[] = {
119 },{ 119 },{
120 .mapbase = 0xa4e30000, 120 .mapbase = 0xa4e30000,
121 .flags = UPF_BOOT_AUTOCONF, 121 .flags = UPF_BOOT_AUTOCONF,
122 .type = PORT_SCI, 122 .type = PORT_SCIFA,
123 .irqs = { 56, 56, 56, 56 }, 123 .irqs = { 56, 56, 56, 56 },
124 },{ 124 },{
125 .mapbase = 0xa4e40000, 125 .mapbase = 0xa4e40000,
126 .flags = UPF_BOOT_AUTOCONF, 126 .flags = UPF_BOOT_AUTOCONF,
127 .type = PORT_SCI, 127 .type = PORT_SCIFA,
128 .irqs = { 88, 88, 88, 88 }, 128 .irqs = { 88, 88, 88, 88 },
129 },{ 129 },{
130 .mapbase = 0xa4e50000, 130 .mapbase = 0xa4e50000,
131 .flags = UPF_BOOT_AUTOCONF, 131 .flags = UPF_BOOT_AUTOCONF,
132 .type = PORT_SCI, 132 .type = PORT_SCIFA,
133 .irqs = { 109, 109, 109, 109 }, 133 .irqs = { 109, 109, 109, 109 },
134 }, { 134 }, {
135 .flags = 0, 135 .flags = 0,
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
index 6b7d166694e2..a952dcf9999d 100644
--- a/arch/sh/kernel/early_printk.c
+++ b/arch/sh/kernel/early_printk.c
@@ -75,6 +75,7 @@ static struct console bios_console = {
75#endif 75#endif
76 76
77static struct uart_port scif_port = { 77static struct uart_port scif_port = {
78 .type = PORT_SCIF,
78 .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT, 79 .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT,
79 .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT, 80 .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT,
80}; 81};
@@ -84,9 +85,9 @@ static void scif_sercon_putc(int c)
84 while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE)) 85 while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE))
85 ; 86 ;
86 87
87 sci_out(&scif_port, SCxTDR, c);
88 sci_in(&scif_port, SCxSR); 88 sci_in(&scif_port, SCxSR);
89 sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40)); 89 sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40));
90 sci_out(&scif_port, SCxTDR, c);
90 91
91 while ((sci_in(&scif_port, SCxSR) & 0x40) == 0) 92 while ((sci_in(&scif_port, SCxSR) & 0x40) == 0)
92 ; 93 ;
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index aaaf90d06b85..3c61ddd4d43e 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -120,7 +120,7 @@ static void tmu_set_mode(enum clock_event_mode mode,
120{ 120{
121 switch (mode) { 121 switch (mode) {
122 case CLOCK_EVT_MODE_PERIODIC: 122 case CLOCK_EVT_MODE_PERIODIC:
123 ctrl_outl(ctrl_inl(TMU0_TCNT), TMU0_TCOR); 123 ctrl_outl(tmu_latest_interval[TMU0], TMU0_TCOR);
124 break; 124 break;
125 case CLOCK_EVT_MODE_ONESHOT: 125 case CLOCK_EVT_MODE_ONESHOT:
126 ctrl_outl(0, TMU0_TCOR); 126 ctrl_outl(0, TMU0_TCOR);
diff --git a/arch/sh/lib/copy_page.S b/arch/sh/lib/copy_page.S
index 5d12e657be34..43de7e8e4e17 100644
--- a/arch/sh/lib/copy_page.S
+++ b/arch/sh/lib/copy_page.S
@@ -80,6 +80,11 @@ ENTRY(copy_page)
80 .section __ex_table, "a"; \ 80 .section __ex_table, "a"; \
81 .long 9999b, 6000f ; \ 81 .long 9999b, 6000f ; \
82 .previous 82 .previous
83#define EX_NO_POP(...) \
84 9999: __VA_ARGS__ ; \
85 .section __ex_table, "a"; \
86 .long 9999b, 6005f ; \
87 .previous
83ENTRY(__copy_user) 88ENTRY(__copy_user)
84 ! Check if small number of bytes 89 ! Check if small number of bytes
85 mov #11,r0 90 mov #11,r0
@@ -139,9 +144,9 @@ EX( mov.b r1,@r4 )
139 bt 1f 144 bt 1f
140 145
1412: 1462:
142EX( mov.b @r5+,r0 ) 147EX_NO_POP( mov.b @r5+,r0 )
143 dt r6 148 dt r6
144EX( mov.b r0,@r4 ) 149EX_NO_POP( mov.b r0,@r4 )
145 bf/s 2b 150 bf/s 2b
146 add #1,r4 151 add #1,r4
147 152
@@ -150,7 +155,7 @@ EX( mov.b r0,@r4 )
150 155
151# Exception handler: 156# Exception handler:
152.section .fixup, "ax" 157.section .fixup, "ax"
1536000: 1586005:
154 mov.l 8000f,r1 159 mov.l 8000f,r1
155 mov r3,r0 160 mov r3,r0
156 jmp @r1 161 jmp @r1
diff --git a/arch/sh/mm/Makefile_32 b/arch/sh/mm/Makefile_32
index 70e0906023cc..f066e76da204 100644
--- a/arch/sh/mm/Makefile_32
+++ b/arch/sh/mm/Makefile_32
@@ -2,7 +2,7 @@
2# Makefile for the Linux SuperH-specific parts of the memory manager. 2# Makefile for the Linux SuperH-specific parts of the memory manager.
3# 3#
4 4
5obj-y := init.o extable_32.o consistent.o 5obj-y := init.o extable_32.o consistent.o mmap.o
6 6
7ifndef CONFIG_CACHE_OFF 7ifndef CONFIG_CACHE_OFF
8cache-$(CONFIG_CPU_SH2) := cache-sh2.o 8cache-$(CONFIG_CPU_SH2) := cache-sh2.o
diff --git a/arch/sh/mm/Makefile_64 b/arch/sh/mm/Makefile_64
index 0d92a8a3ac9a..9481d0f54efd 100644
--- a/arch/sh/mm/Makefile_64
+++ b/arch/sh/mm/Makefile_64
@@ -2,7 +2,7 @@
2# Makefile for the Linux SuperH-specific parts of the memory manager. 2# Makefile for the Linux SuperH-specific parts of the memory manager.
3# 3#
4 4
5obj-y := init.o consistent.o 5obj-y := init.o consistent.o mmap.o
6 6
7mmu-y := tlb-nommu.o pg-nommu.o extable_32.o 7mmu-y := tlb-nommu.o pg-nommu.o extable_32.o
8mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o \ 8mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o \
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 4abf00031dae..6cbef8caeb56 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -137,6 +137,7 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
137void __init paging_init(void) 137void __init paging_init(void)
138{ 138{
139 unsigned long max_zone_pfns[MAX_NR_ZONES]; 139 unsigned long max_zone_pfns[MAX_NR_ZONES];
140 unsigned long vaddr;
140 int nid; 141 int nid;
141 142
142 /* We don't need to map the kernel through the TLB, as 143 /* We don't need to map the kernel through the TLB, as
@@ -148,10 +149,15 @@ void __init paging_init(void)
148 * check for a null value. */ 149 * check for a null value. */
149 set_TTB(swapper_pg_dir); 150 set_TTB(swapper_pg_dir);
150 151
151 /* Populate the relevant portions of swapper_pg_dir so that 152 /*
153 * Populate the relevant portions of swapper_pg_dir so that
152 * we can use the fixmap entries without calling kmalloc. 154 * we can use the fixmap entries without calling kmalloc.
153 * pte's will be filled in by __set_fixmap(). */ 155 * pte's will be filled in by __set_fixmap().
154 page_table_range_init(FIXADDR_START, FIXADDR_TOP, swapper_pg_dir); 156 */
157 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
158 page_table_range_init(vaddr, 0, swapper_pg_dir);
159
160 kmap_coherent_init();
155 161
156 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 162 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
157 163
diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
new file mode 100644
index 000000000000..8837d511710a
--- /dev/null
+++ b/arch/sh/mm/mmap.c
@@ -0,0 +1,31 @@
1/*
2 * arch/sh/mm/mmap.c
3 *
4 * Copyright (C) 2008 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/io.h>
11#include <linux/mm.h>
12#include <asm/page.h>
13
14/*
15 * You really shouldn't be using read() or write() on /dev/mem. This
16 * might go away in the future.
17 */
18int valid_phys_addr_range(unsigned long addr, size_t count)
19{
20 if (addr < __MEMORY_START)
21 return 0;
22 if (addr + count > __pa(high_memory))
23 return 0;
24
25 return 1;
26}
27
28int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
29{
30 return 1;
31}
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index 38870e0fc182..2fe14da1f839 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -7,6 +7,7 @@
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/init.h>
10#include <linux/mutex.h> 11#include <linux/mutex.h>
11#include <linux/fs.h> 12#include <linux/fs.h>
12#include <linux/highmem.h> 13#include <linux/highmem.h>
@@ -16,6 +17,20 @@
16 17
17#define CACHE_ALIAS (current_cpu_data.dcache.alias_mask) 18#define CACHE_ALIAS (current_cpu_data.dcache.alias_mask)
18 19
20#define kmap_get_fixmap_pte(vaddr) \
21 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr))
22
23static pte_t *kmap_coherent_pte;
24
25void __init kmap_coherent_init(void)
26{
27 unsigned long vaddr;
28
29 /* cache the first coherent kmap pte */
30 vaddr = __fix_to_virt(FIX_CMAP_BEGIN);
31 kmap_coherent_pte = kmap_get_fixmap_pte(vaddr);
32}
33
19static inline void *kmap_coherent(struct page *page, unsigned long addr) 34static inline void *kmap_coherent(struct page *page, unsigned long addr)
20{ 35{
21 enum fixed_addresses idx; 36 enum fixed_addresses idx;
@@ -34,6 +49,8 @@ static inline void *kmap_coherent(struct page *page, unsigned long addr)
34 49
35 update_mmu_cache(NULL, vaddr, pte); 50 update_mmu_cache(NULL, vaddr, pte);
36 51
52 set_pte(kmap_coherent_pte - (FIX_CMAP_END - idx), pte);
53
37 return (void *)vaddr; 54 return (void *)vaddr;
38} 55}
39 56
diff --git a/arch/sparc/include/asm/termbits.h b/arch/sparc/include/asm/termbits.h
index d6ca3e2754f5..d72dfed1f9d7 100644
--- a/arch/sparc/include/asm/termbits.h
+++ b/arch/sparc/include/asm/termbits.h
@@ -29,10 +29,11 @@ struct termios {
29 tcflag_t c_cflag; /* control mode flags */ 29 tcflag_t c_cflag; /* control mode flags */
30 tcflag_t c_lflag; /* local mode flags */ 30 tcflag_t c_lflag; /* local mode flags */
31 cc_t c_line; /* line discipline */ 31 cc_t c_line; /* line discipline */
32#ifndef __KERNEL__
32 cc_t c_cc[NCCS]; /* control characters */ 33 cc_t c_cc[NCCS]; /* control characters */
33#ifdef __KERNEL__ 34#else
35 cc_t c_cc[NCCS+2]; /* kernel needs 2 more to hold vmin/vtime */
34#define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t)) 36#define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t))
35 cc_t _x_cc[2]; /* We need them to hold vmin/vtime */
36#endif 37#endif
37}; 38};
38 39
@@ -42,8 +43,7 @@ struct termios2 {
42 tcflag_t c_cflag; /* control mode flags */ 43 tcflag_t c_cflag; /* control mode flags */
43 tcflag_t c_lflag; /* local mode flags */ 44 tcflag_t c_lflag; /* local mode flags */
44 cc_t c_line; /* line discipline */ 45 cc_t c_line; /* line discipline */
45 cc_t c_cc[NCCS]; /* control characters */ 46 cc_t c_cc[NCCS+2]; /* control characters */
46 cc_t _x_cc[2]; /* padding to match ktermios */
47 speed_t c_ispeed; /* input speed */ 47 speed_t c_ispeed; /* input speed */
48 speed_t c_ospeed; /* output speed */ 48 speed_t c_ospeed; /* output speed */
49}; 49};
@@ -54,8 +54,7 @@ struct ktermios {
54 tcflag_t c_cflag; /* control mode flags */ 54 tcflag_t c_cflag; /* control mode flags */
55 tcflag_t c_lflag; /* local mode flags */ 55 tcflag_t c_lflag; /* local mode flags */
56 cc_t c_line; /* line discipline */ 56 cc_t c_line; /* line discipline */
57 cc_t c_cc[NCCS]; /* control characters */ 57 cc_t c_cc[NCCS+2]; /* control characters */
58 cc_t _x_cc[2]; /* We need them to hold vmin/vtime */
59 speed_t c_ispeed; /* input speed */ 58 speed_t c_ispeed; /* input speed */
60 speed_t c_ospeed; /* output speed */ 59 speed_t c_ospeed; /* output speed */
61}; 60};
diff --git a/arch/sparc/include/asm/unistd_32.h b/arch/sparc/include/asm/unistd_32.h
index 648643a9f139..0d13d2a4c76f 100644
--- a/arch/sparc/include/asm/unistd_32.h
+++ b/arch/sparc/include/asm/unistd_32.h
@@ -338,8 +338,9 @@
338#define __NR_dup3 320 338#define __NR_dup3 320
339#define __NR_pipe2 321 339#define __NR_pipe2 321
340#define __NR_inotify_init1 322 340#define __NR_inotify_init1 322
341#define __NR_accept4 323
341 342
342#define NR_SYSCALLS 323 343#define NR_SYSCALLS 324
343 344
344/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, 345/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
345 * it never had the plain ones and there is no value to adding those 346 * it never had the plain ones and there is no value to adding those
diff --git a/arch/sparc/include/asm/unistd_64.h b/arch/sparc/include/asm/unistd_64.h
index c5cc0e052321..fa5d3c0343c7 100644
--- a/arch/sparc/include/asm/unistd_64.h
+++ b/arch/sparc/include/asm/unistd_64.h
@@ -340,8 +340,9 @@
340#define __NR_dup3 320 340#define __NR_dup3 320
341#define __NR_pipe2 321 341#define __NR_pipe2 321
342#define __NR_inotify_init1 322 342#define __NR_inotify_init1 322
343#define __NR_accept4 323
343 344
344#define NR_SYSCALLS 323 345#define NR_SYSCALLS 324
345 346
346#ifdef __KERNEL__ 347#ifdef __KERNEL__
347#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index 0837bd52e28f..0a83bd737654 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -563,9 +563,9 @@ build_resources:
563 op->dev.parent = parent; 563 op->dev.parent = parent;
564 op->dev.bus = &of_platform_bus_type; 564 op->dev.bus = &of_platform_bus_type;
565 if (!parent) 565 if (!parent)
566 strcpy(op->dev.bus_id, "root"); 566 dev_set_name(&op->dev, "root");
567 else 567 else
568 sprintf(op->dev.bus_id, "%08x", dp->node); 568 dev_set_name(&op->dev, "%08x", dp->node);
569 569
570 if (of_device_register(op)) { 570 if (of_device_register(op)) {
571 printk("%s: Could not register of device.\n", 571 printk("%s: Could not register of device.\n",
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index e1b9233b90ab..7d0807586442 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -81,4 +81,4 @@ sys_call_table:
81/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 81/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
82/*310*/ .long sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate 82/*310*/ .long sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate
83/*315*/ .long sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1 83/*315*/ .long sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1
84/*320*/ .long sys_dup3, sys_pipe2, sys_inotify_init1 84/*320*/ .long sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
diff --git a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
index ade18ba0c686..f061c4dda9ef 100644
--- a/arch/sparc64/kernel/sys32.S
+++ b/arch/sparc64/kernel/sys32.S
@@ -150,7 +150,7 @@ sys32_mmap2:
150sys32_socketcall: /* %o0=call, %o1=args */ 150sys32_socketcall: /* %o0=call, %o1=args */
151 cmp %o0, 1 151 cmp %o0, 1
152 bl,pn %xcc, do_einval 152 bl,pn %xcc, do_einval
153 cmp %o0, 17 153 cmp %o0, 18
154 bg,pn %xcc, do_einval 154 bg,pn %xcc, do_einval
155 sub %o0, 1, %o0 155 sub %o0, 1, %o0
156 sllx %o0, 5, %o0 156 sllx %o0, 5, %o0
@@ -319,6 +319,15 @@ do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int)
319 nop 319 nop
320 nop 320 nop
321 nop 321 nop
322do_sys_accept4: /* sys_accept4(int, struct sockaddr *, int *, int) */
32363: ldswa [%o1 + 0x0] %asi, %o0
324 sethi %hi(sys_accept4), %g1
32564: lduwa [%o1 + 0x8] %asi, %o2
32665: ldswa [%o1 + 0xc] %asi, %o3
327 jmpl %g1 + %lo(sys_accept4), %g0
32866: lduwa [%o1 + 0x4] %asi, %o1
329 nop
330 nop
322 331
323 .section __ex_table,"a" 332 .section __ex_table,"a"
324 .align 4 333 .align 4
@@ -353,4 +362,6 @@ do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int)
353 .word 57b, __retl_efault, 58b, __retl_efault 362 .word 57b, __retl_efault, 58b, __retl_efault
354 .word 59b, __retl_efault, 60b, __retl_efault 363 .word 59b, __retl_efault, 60b, __retl_efault
355 .word 61b, __retl_efault, 62b, __retl_efault 364 .word 61b, __retl_efault, 62b, __retl_efault
365 .word 63b, __retl_efault, 64b, __retl_efault
366 .word 65b, __retl_efault, 66b, __retl_efault
356 .previous 367 .previous
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index b2fa4c163638..9fc78cf354bd 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -82,7 +82,7 @@ sys_call_table32:
82 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait 82 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait
83/*310*/ .word compat_sys_utimensat, compat_sys_signalfd, sys_timerfd_create, sys_eventfd, compat_sys_fallocate 83/*310*/ .word compat_sys_utimensat, compat_sys_signalfd, sys_timerfd_create, sys_eventfd, compat_sys_fallocate
84 .word compat_sys_timerfd_settime, compat_sys_timerfd_gettime, compat_sys_signalfd4, sys_eventfd2, sys_epoll_create1 84 .word compat_sys_timerfd_settime, compat_sys_timerfd_gettime, compat_sys_signalfd4, sys_eventfd2, sys_epoll_create1
85/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1 85/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
86 86
87#endif /* CONFIG_COMPAT */ 87#endif /* CONFIG_COMPAT */
88 88
@@ -156,4 +156,4 @@ sys_call_table:
156 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 156 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
157/*310*/ .word sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate 157/*310*/ .word sys_utimensat, sys_signalfd, sys_timerfd_create, sys_eventfd, sys_fallocate
158 .word sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1 158 .word sys_timerfd_settime, sys_timerfd_gettime, sys_signalfd4, sys_eventfd2, sys_epoll_create1
159/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1 159/*320*/ .word sys_dup3, sys_pipe2, sys_inotify_init1, sys_accept4
diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h
index 753346e2cdfd..ae5f94d6317d 100644
--- a/arch/um/include/asm/system.h
+++ b/arch/um/include/asm/system.h
@@ -11,21 +11,21 @@ extern int get_signals(void);
11extern void block_signals(void); 11extern void block_signals(void);
12extern void unblock_signals(void); 12extern void unblock_signals(void);
13 13
14#define local_save_flags(flags) do { typecheck(unsigned long, flags); \ 14#define raw_local_save_flags(flags) do { typecheck(unsigned long, flags); \
15 (flags) = get_signals(); } while(0) 15 (flags) = get_signals(); } while(0)
16#define local_irq_restore(flags) do { typecheck(unsigned long, flags); \ 16#define raw_local_irq_restore(flags) do { typecheck(unsigned long, flags); \
17 set_signals(flags); } while(0) 17 set_signals(flags); } while(0)
18 18
19#define local_irq_save(flags) do { local_save_flags(flags); \ 19#define raw_local_irq_save(flags) do { raw_local_save_flags(flags); \
20 local_irq_disable(); } while(0) 20 raw_local_irq_disable(); } while(0)
21 21
22#define local_irq_enable() unblock_signals() 22#define raw_local_irq_enable() unblock_signals()
23#define local_irq_disable() block_signals() 23#define raw_local_irq_disable() block_signals()
24 24
25#define irqs_disabled() \ 25#define irqs_disabled() \
26({ \ 26({ \
27 unsigned long flags; \ 27 unsigned long flags; \
28 local_save_flags(flags); \ 28 raw_local_save_flags(flags); \
29 (flags == 0); \ 29 (flags == 0); \
30}) 30})
31 31
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 93224b569187..ac22bb7719f7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -167,9 +167,12 @@ config GENERIC_PENDING_IRQ
167config X86_SMP 167config X86_SMP
168 bool 168 bool
169 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64) 169 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64)
170 select USE_GENERIC_SMP_HELPERS
171 default y 170 default y
172 171
172config USE_GENERIC_SMP_HELPERS
173 def_bool y
174 depends on SMP
175
173config X86_32_SMP 176config X86_32_SMP
174 def_bool y 177 def_bool y
175 depends on X86_32 && SMP 178 depends on X86_32 && SMP
@@ -957,7 +960,7 @@ config ARCH_PHYS_ADDR_T_64BIT
957config NUMA 960config NUMA
958 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)" 961 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)"
959 depends on SMP 962 depends on SMP
960 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && BROKEN) 963 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL)
961 default n if X86_PC 964 default n if X86_PC
962 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP) 965 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP)
963 help 966 help
diff --git a/include/asm-x86/iomap.h b/arch/x86/include/asm/iomap.h
index c1f06289b14b..c1f06289b14b 100644
--- a/include/asm-x86/iomap.h
+++ b/arch/x86/include/asm/iomap.h
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index e4a552d44465..0b500c5b6446 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -6,7 +6,6 @@ extern void no_iommu_init(void);
6extern struct dma_mapping_ops nommu_dma_ops; 6extern struct dma_mapping_ops nommu_dma_ops;
7extern int force_iommu, no_iommu; 7extern int force_iommu, no_iommu;
8extern int iommu_detected; 8extern int iommu_detected;
9extern int dmar_disabled;
10 9
11extern unsigned long iommu_nr_pages(unsigned long addr, unsigned long len); 10extern unsigned long iommu_nr_pages(unsigned long addr, unsigned long len);
12 11
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 485bdf059ffb..07f1af494ca5 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -34,10 +34,14 @@ static inline void get_memcfg_numa(void)
34 34
35extern int early_pfn_to_nid(unsigned long pfn); 35extern int early_pfn_to_nid(unsigned long pfn);
36 36
37extern void resume_map_numa_kva(pgd_t *pgd);
38
37#else /* !CONFIG_NUMA */ 39#else /* !CONFIG_NUMA */
38 40
39#define get_memcfg_numa get_memcfg_numa_flat 41#define get_memcfg_numa get_memcfg_numa_flat
40 42
43static inline void resume_map_numa_kva(pgd_t *pgd) {}
44
41#endif /* CONFIG_NUMA */ 45#endif /* CONFIG_NUMA */
42 46
43#ifdef CONFIG_DISCONTIGMEM 47#ifdef CONFIG_DISCONTIGMEM
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 35c54921b2e4..99192bb55a53 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -157,6 +157,7 @@ extern int __get_user_bad(void);
157 int __ret_gu; \ 157 int __ret_gu; \
158 unsigned long __val_gu; \ 158 unsigned long __val_gu; \
159 __chk_user_ptr(ptr); \ 159 __chk_user_ptr(ptr); \
160 might_fault(); \
160 switch (sizeof(*(ptr))) { \ 161 switch (sizeof(*(ptr))) { \
161 case 1: \ 162 case 1: \
162 __get_user_x(1, __ret_gu, __val_gu, ptr); \ 163 __get_user_x(1, __ret_gu, __val_gu, ptr); \
@@ -241,6 +242,7 @@ extern void __put_user_8(void);
241 int __ret_pu; \ 242 int __ret_pu; \
242 __typeof__(*(ptr)) __pu_val; \ 243 __typeof__(*(ptr)) __pu_val; \
243 __chk_user_ptr(ptr); \ 244 __chk_user_ptr(ptr); \
245 might_fault(); \
244 __pu_val = x; \ 246 __pu_val = x; \
245 switch (sizeof(*(ptr))) { \ 247 switch (sizeof(*(ptr))) { \
246 case 1: \ 248 case 1: \
diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
index d095a3aeea1b..5e06259e90e5 100644
--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -82,8 +82,8 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
82static __always_inline unsigned long __must_check 82static __always_inline unsigned long __must_check
83__copy_to_user(void __user *to, const void *from, unsigned long n) 83__copy_to_user(void __user *to, const void *from, unsigned long n)
84{ 84{
85 might_sleep(); 85 might_fault();
86 return __copy_to_user_inatomic(to, from, n); 86 return __copy_to_user_inatomic(to, from, n);
87} 87}
88 88
89static __always_inline unsigned long 89static __always_inline unsigned long
@@ -137,7 +137,7 @@ __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
137static __always_inline unsigned long 137static __always_inline unsigned long
138__copy_from_user(void *to, const void __user *from, unsigned long n) 138__copy_from_user(void *to, const void __user *from, unsigned long n)
139{ 139{
140 might_sleep(); 140 might_fault();
141 if (__builtin_constant_p(n)) { 141 if (__builtin_constant_p(n)) {
142 unsigned long ret; 142 unsigned long ret;
143 143
@@ -159,7 +159,7 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
159static __always_inline unsigned long __copy_from_user_nocache(void *to, 159static __always_inline unsigned long __copy_from_user_nocache(void *to,
160 const void __user *from, unsigned long n) 160 const void __user *from, unsigned long n)
161{ 161{
162 might_sleep(); 162 might_fault();
163 if (__builtin_constant_p(n)) { 163 if (__builtin_constant_p(n)) {
164 unsigned long ret; 164 unsigned long ret;
165 165
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 664f15280f14..84210c479fca 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -29,6 +29,8 @@ static __always_inline __must_check
29int __copy_from_user(void *dst, const void __user *src, unsigned size) 29int __copy_from_user(void *dst, const void __user *src, unsigned size)
30{ 30{
31 int ret = 0; 31 int ret = 0;
32
33 might_fault();
32 if (!__builtin_constant_p(size)) 34 if (!__builtin_constant_p(size))
33 return copy_user_generic(dst, (__force void *)src, size); 35 return copy_user_generic(dst, (__force void *)src, size);
34 switch (size) { 36 switch (size) {
@@ -46,7 +48,7 @@ int __copy_from_user(void *dst, const void __user *src, unsigned size)
46 return ret; 48 return ret;
47 case 10: 49 case 10:
48 __get_user_asm(*(u64 *)dst, (u64 __user *)src, 50 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
49 ret, "q", "", "=r", 16); 51 ret, "q", "", "=r", 10);
50 if (unlikely(ret)) 52 if (unlikely(ret))
51 return ret; 53 return ret;
52 __get_user_asm(*(u16 *)(8 + (char *)dst), 54 __get_user_asm(*(u16 *)(8 + (char *)dst),
@@ -71,6 +73,8 @@ static __always_inline __must_check
71int __copy_to_user(void __user *dst, const void *src, unsigned size) 73int __copy_to_user(void __user *dst, const void *src, unsigned size)
72{ 74{
73 int ret = 0; 75 int ret = 0;
76
77 might_fault();
74 if (!__builtin_constant_p(size)) 78 if (!__builtin_constant_p(size))
75 return copy_user_generic((__force void *)dst, src, size); 79 return copy_user_generic((__force void *)dst, src, size);
76 switch (size) { 80 switch (size) {
@@ -113,6 +117,8 @@ static __always_inline __must_check
113int __copy_in_user(void __user *dst, const void __user *src, unsigned size) 117int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
114{ 118{
115 int ret = 0; 119 int ret = 0;
120
121 might_fault();
116 if (!__builtin_constant_p(size)) 122 if (!__builtin_constant_p(size))
117 return copy_user_generic((__force void *)dst, 123 return copy_user_generic((__force void *)dst,
118 (__force void *)src, size); 124 (__force void *)src, size);
diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
index 834b2c1d89fb..d2e415e6666f 100644
--- a/arch/x86/include/asm/unistd_64.h
+++ b/arch/x86/include/asm/unistd_64.h
@@ -639,8 +639,8 @@ __SYSCALL(__NR_fallocate, sys_fallocate)
639__SYSCALL(__NR_timerfd_settime, sys_timerfd_settime) 639__SYSCALL(__NR_timerfd_settime, sys_timerfd_settime)
640#define __NR_timerfd_gettime 287 640#define __NR_timerfd_gettime 287
641__SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime) 641__SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime)
642#define __NR_paccept 288 642#define __NR_accept4 288
643__SYSCALL(__NR_paccept, sys_paccept) 643__SYSCALL(__NR_accept4, sys_accept4)
644#define __NR_signalfd4 289 644#define __NR_signalfd4 289
645__SYSCALL(__NR_signalfd4, sys_signalfd4) 645__SYSCALL(__NR_signalfd4, sys_signalfd4)
646#define __NR_eventfd2 290 646#define __NR_eventfd2 290
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 331b318304eb..e4899e0e8787 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -537,7 +537,7 @@ static void dma_ops_free_addresses(struct dma_ops_domain *dom,
537 address >>= PAGE_SHIFT; 537 address >>= PAGE_SHIFT;
538 iommu_area_free(dom->bitmap, address, pages); 538 iommu_area_free(dom->bitmap, address, pages);
539 539
540 if (address + pages >= dom->next_bit) 540 if (address >= dom->next_bit)
541 dom->need_flush = true; 541 dom->need_flush = true;
542} 542}
543 543
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 0cdcda35a05f..30ae2701b3df 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -121,7 +121,7 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
121LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings 121LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
122 we find in ACPI */ 122 we find in ACPI */
123unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */ 123unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
124int amd_iommu_isolate; /* if 1, device isolation is enabled */ 124int amd_iommu_isolate = 1; /* if 1, device isolation is enabled */
125bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ 125bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
126 126
127LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the 127LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
@@ -1213,7 +1213,9 @@ static int __init parse_amd_iommu_options(char *str)
1213 for (; *str; ++str) { 1213 for (; *str; ++str) {
1214 if (strncmp(str, "isolate", 7) == 0) 1214 if (strncmp(str, "isolate", 7) == 0)
1215 amd_iommu_isolate = 1; 1215 amd_iommu_isolate = 1;
1216 if (strncmp(str, "fullflush", 11) == 0) 1216 if (strncmp(str, "share", 5) == 0)
1217 amd_iommu_isolate = 0;
1218 if (strncmp(str, "fullflush", 9) == 0)
1217 amd_iommu_unmap_flush = true; 1219 amd_iommu_unmap_flush = true;
1218 } 1220 }
1219 1221
diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c
index 2b69994fd3a8..d1a121443bde 100644
--- a/arch/x86/kernel/ds.c
+++ b/arch/x86/kernel/ds.c
@@ -236,17 +236,33 @@ static inline struct ds_context *ds_alloc_context(struct task_struct *task)
236 struct ds_context *context = *p_context; 236 struct ds_context *context = *p_context;
237 237
238 if (!context) { 238 if (!context) {
239 spin_unlock(&ds_lock);
240
239 context = kzalloc(sizeof(*context), GFP_KERNEL); 241 context = kzalloc(sizeof(*context), GFP_KERNEL);
240 242
241 if (!context) 243 if (!context) {
244 spin_lock(&ds_lock);
242 return NULL; 245 return NULL;
246 }
243 247
244 context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL); 248 context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL);
245 if (!context->ds) { 249 if (!context->ds) {
246 kfree(context); 250 kfree(context);
251 spin_lock(&ds_lock);
247 return NULL; 252 return NULL;
248 } 253 }
249 254
255 spin_lock(&ds_lock);
256 /*
257 * Check for race - another CPU could have allocated
258 * it meanwhile:
259 */
260 if (*p_context) {
261 kfree(context->ds);
262 kfree(context);
263 return *p_context;
264 }
265
250 *p_context = context; 266 *p_context = context;
251 267
252 context->this = p_context; 268 context->this = p_context;
@@ -384,14 +400,15 @@ static int ds_request(struct task_struct *task, void *base, size_t size,
384 400
385 spin_lock(&ds_lock); 401 spin_lock(&ds_lock);
386 402
387 if (!check_tracer(task))
388 return -EPERM;
389
390 error = -ENOMEM; 403 error = -ENOMEM;
391 context = ds_alloc_context(task); 404 context = ds_alloc_context(task);
392 if (!context) 405 if (!context)
393 goto out_unlock; 406 goto out_unlock;
394 407
408 error = -EPERM;
409 if (!check_tracer(task))
410 goto out_unlock;
411
395 error = -EALREADY; 412 error = -EALREADY;
396 if (context->owner[qual] == current) 413 if (context->owner[qual] == current)
397 goto out_unlock; 414 goto out_unlock;
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 3ce029ffaa55..1b894b72c0f5 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -188,20 +188,6 @@ static void __init ati_bugs_contd(int num, int slot, int func)
188} 188}
189#endif 189#endif
190 190
191#ifdef CONFIG_DMAR
192static void __init intel_g33_dmar(int num, int slot, int func)
193{
194 struct acpi_table_header *dmar_tbl;
195 acpi_status status;
196
197 status = acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_tbl);
198 if (ACPI_SUCCESS(status)) {
199 printk(KERN_INFO "BIOS BUG: DMAR advertised on Intel G31/G33 chipset -- ignoring\n");
200 dmar_disabled = 1;
201 }
202}
203#endif
204
205#define QFLAG_APPLY_ONCE 0x1 191#define QFLAG_APPLY_ONCE 0x1
206#define QFLAG_APPLIED 0x2 192#define QFLAG_APPLIED 0x2
207#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) 193#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -225,10 +211,6 @@ static struct chipset early_qrk[] __initdata = {
225 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs }, 211 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
226 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, 212 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
227 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, 213 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
228#ifdef CONFIG_DMAR
229 { PCI_VENDOR_ID_INTEL, 0x29c0,
230 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, intel_g33_dmar },
231#endif
232 {} 214 {}
233}; 215};
234 216
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c
index f454c78fcef6..0aa2c443d600 100644
--- a/arch/x86/kernel/es7000_32.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -250,31 +250,24 @@ int __init find_unisys_acpi_oem_table(unsigned long *oem_addr)
250{ 250{
251 struct acpi_table_header *header = NULL; 251 struct acpi_table_header *header = NULL;
252 int i = 0; 252 int i = 0;
253 acpi_size tbl_size;
254 253
255 while (ACPI_SUCCESS(acpi_get_table_with_size("OEM1", i++, &header, &tbl_size))) { 254 while (ACPI_SUCCESS(acpi_get_table("OEM1", i++, &header))) {
256 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) { 255 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) {
257 struct oem_table *t = (struct oem_table *)header; 256 struct oem_table *t = (struct oem_table *)header;
258 257
259 oem_addrX = t->OEMTableAddr; 258 oem_addrX = t->OEMTableAddr;
260 oem_size = t->OEMTableSize; 259 oem_size = t->OEMTableSize;
261 early_acpi_os_unmap_memory(header, tbl_size);
262 260
263 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX, 261 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX,
264 oem_size); 262 oem_size);
265 return 0; 263 return 0;
266 } 264 }
267 early_acpi_os_unmap_memory(header, tbl_size);
268 } 265 }
269 return -1; 266 return -1;
270} 267}
271 268
272void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr) 269void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr)
273{ 270{
274 if (!oem_addr)
275 return;
276
277 __acpi_unmap_table((char *)oem_addr, oem_size);
278} 271}
279#endif 272#endif
280 273
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 7a3f2028e2eb..c9513e1ff28d 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -1140,6 +1140,20 @@ static void __clear_irq_vector(int irq)
1140 1140
1141 cfg->vector = 0; 1141 cfg->vector = 0;
1142 cpus_clear(cfg->domain); 1142 cpus_clear(cfg->domain);
1143
1144 if (likely(!cfg->move_in_progress))
1145 return;
1146 cpus_and(mask, cfg->old_domain, cpu_online_map);
1147 for_each_cpu_mask_nr(cpu, mask) {
1148 for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
1149 vector++) {
1150 if (per_cpu(vector_irq, cpu)[vector] != irq)
1151 continue;
1152 per_cpu(vector_irq, cpu)[vector] = -1;
1153 break;
1154 }
1155 }
1156 cfg->move_in_progress = 0;
1143} 1157}
1144 1158
1145void __setup_vector_irq(int cpu) 1159void __setup_vector_irq(int cpu)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 724adfc63cb9..cc5a2545dd41 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -169,6 +169,15 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
169 DMI_MATCH(DMI_BOARD_NAME, "0KW626"), 169 DMI_MATCH(DMI_BOARD_NAME, "0KW626"),
170 }, 170 },
171 }, 171 },
172 { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */
173 .callback = set_bios_reboot,
174 .ident = "Dell OptiPlex 330",
175 .matches = {
176 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
177 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 330"),
178 DMI_MATCH(DMI_BOARD_NAME, "0KP561"),
179 },
180 },
172 { /* Handle problems with rebooting on Dell 2400's */ 181 { /* Handle problems with rebooting on Dell 2400's */
173 .callback = set_bios_reboot, 182 .callback = set_bios_reboot,
174 .ident = "Dell PowerEdge 2400", 183 .ident = "Dell PowerEdge 2400",
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 0fa6790c1dd3..9d5674f7b6cc 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -764,7 +764,7 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
764 .callback = dmi_low_memory_corruption, 764 .callback = dmi_low_memory_corruption,
765 .ident = "Phoenix BIOS", 765 .ident = "Phoenix BIOS",
766 .matches = { 766 .matches = {
767 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"), 767 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
768 }, 768 },
769 }, 769 },
770#endif 770#endif
diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index 9ffb01c31c40..1c0dfbca87c1 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -46,7 +46,9 @@ static __cpuinit void check_tsc_warp(void)
46 cycles_t start, now, prev, end; 46 cycles_t start, now, prev, end;
47 int i; 47 int i;
48 48
49 rdtsc_barrier();
49 start = get_cycles(); 50 start = get_cycles();
51 rdtsc_barrier();
50 /* 52 /*
51 * The measurement runs for 20 msecs: 53 * The measurement runs for 20 msecs:
52 */ 54 */
@@ -61,7 +63,9 @@ static __cpuinit void check_tsc_warp(void)
61 */ 63 */
62 __raw_spin_lock(&sync_lock); 64 __raw_spin_lock(&sync_lock);
63 prev = last_tsc; 65 prev = last_tsc;
66 rdtsc_barrier();
64 now = get_cycles(); 67 now = get_cycles();
68 rdtsc_barrier();
65 last_tsc = now; 69 last_tsc = now;
66 __raw_spin_unlock(&sync_lock); 70 __raw_spin_unlock(&sync_lock);
67 71
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index 9e68075544f6..4a20b2f9a381 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -39,7 +39,7 @@ static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned lon
39#define __do_strncpy_from_user(dst, src, count, res) \ 39#define __do_strncpy_from_user(dst, src, count, res) \
40do { \ 40do { \
41 int __d0, __d1, __d2; \ 41 int __d0, __d1, __d2; \
42 might_sleep(); \ 42 might_fault(); \
43 __asm__ __volatile__( \ 43 __asm__ __volatile__( \
44 " testl %1,%1\n" \ 44 " testl %1,%1\n" \
45 " jz 2f\n" \ 45 " jz 2f\n" \
@@ -126,7 +126,7 @@ EXPORT_SYMBOL(strncpy_from_user);
126#define __do_clear_user(addr,size) \ 126#define __do_clear_user(addr,size) \
127do { \ 127do { \
128 int __d0; \ 128 int __d0; \
129 might_sleep(); \ 129 might_fault(); \
130 __asm__ __volatile__( \ 130 __asm__ __volatile__( \
131 "0: rep; stosl\n" \ 131 "0: rep; stosl\n" \
132 " movl %2,%0\n" \ 132 " movl %2,%0\n" \
@@ -155,7 +155,7 @@ do { \
155unsigned long 155unsigned long
156clear_user(void __user *to, unsigned long n) 156clear_user(void __user *to, unsigned long n)
157{ 157{
158 might_sleep(); 158 might_fault();
159 if (access_ok(VERIFY_WRITE, to, n)) 159 if (access_ok(VERIFY_WRITE, to, n))
160 __do_clear_user(to, n); 160 __do_clear_user(to, n);
161 return n; 161 return n;
@@ -197,7 +197,7 @@ long strnlen_user(const char __user *s, long n)
197 unsigned long mask = -__addr_ok(s); 197 unsigned long mask = -__addr_ok(s);
198 unsigned long res, tmp; 198 unsigned long res, tmp;
199 199
200 might_sleep(); 200 might_fault();
201 201
202 __asm__ __volatile__( 202 __asm__ __volatile__(
203 " testl %0, %0\n" 203 " testl %0, %0\n"
diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
index f4df6e7c718b..64d6c84e6353 100644
--- a/arch/x86/lib/usercopy_64.c
+++ b/arch/x86/lib/usercopy_64.c
@@ -15,7 +15,7 @@
15#define __do_strncpy_from_user(dst,src,count,res) \ 15#define __do_strncpy_from_user(dst,src,count,res) \
16do { \ 16do { \
17 long __d0, __d1, __d2; \ 17 long __d0, __d1, __d2; \
18 might_sleep(); \ 18 might_fault(); \
19 __asm__ __volatile__( \ 19 __asm__ __volatile__( \
20 " testq %1,%1\n" \ 20 " testq %1,%1\n" \
21 " jz 2f\n" \ 21 " jz 2f\n" \
@@ -64,7 +64,7 @@ EXPORT_SYMBOL(strncpy_from_user);
64unsigned long __clear_user(void __user *addr, unsigned long size) 64unsigned long __clear_user(void __user *addr, unsigned long size)
65{ 65{
66 long __d0; 66 long __d0;
67 might_sleep(); 67 might_fault();
68 /* no memory constraint because it doesn't change any memory gcc knows 68 /* no memory constraint because it doesn't change any memory gcc knows
69 about */ 69 about */
70 asm volatile( 70 asm volatile(
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index 0e331652681e..52145007bd7e 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -7,6 +7,7 @@
7 * This file provides all the same external entries as smp.c but uses 7 * This file provides all the same external entries as smp.c but uses
8 * the voyager hal to provide the functionality 8 * the voyager hal to provide the functionality
9 */ 9 */
10#include <linux/cpu.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
12#include <linux/kernel_stat.h> 13#include <linux/kernel_stat.h>
@@ -1790,6 +1791,17 @@ void __init smp_setup_processor_id(void)
1790 x86_write_percpu(cpu_number, hard_smp_processor_id()); 1791 x86_write_percpu(cpu_number, hard_smp_processor_id());
1791} 1792}
1792 1793
1794static void voyager_send_call_func(cpumask_t callmask)
1795{
1796 __u32 mask = cpus_addr(callmask)[0] & ~(1 << smp_processor_id());
1797 send_CPI(mask, VIC_CALL_FUNCTION_CPI);
1798}
1799
1800static void voyager_send_call_func_single(int cpu)
1801{
1802 send_CPI(1 << cpu, VIC_CALL_FUNCTION_SINGLE_CPI);
1803}
1804
1793struct smp_ops smp_ops = { 1805struct smp_ops smp_ops = {
1794 .smp_prepare_boot_cpu = voyager_smp_prepare_boot_cpu, 1806 .smp_prepare_boot_cpu = voyager_smp_prepare_boot_cpu,
1795 .smp_prepare_cpus = voyager_smp_prepare_cpus, 1807 .smp_prepare_cpus = voyager_smp_prepare_cpus,
@@ -1799,6 +1811,6 @@ struct smp_ops smp_ops = {
1799 .smp_send_stop = voyager_smp_send_stop, 1811 .smp_send_stop = voyager_smp_send_stop,
1800 .smp_send_reschedule = voyager_smp_send_reschedule, 1812 .smp_send_reschedule = voyager_smp_send_reschedule,
1801 1813
1802 .send_call_func_ipi = native_send_call_func_ipi, 1814 .send_call_func_ipi = voyager_send_call_func,
1803 .send_call_func_single_ipi = native_send_call_func_single_ipi, 1815 .send_call_func_single_ipi = voyager_send_call_func_single,
1804}; 1816};
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 847c164725f4..8518c678d83f 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -222,6 +222,41 @@ static void __init remap_numa_kva(void)
222 } 222 }
223} 223}
224 224
225#ifdef CONFIG_HIBERNATION
226/**
227 * resume_map_numa_kva - add KVA mapping to the temporary page tables created
228 * during resume from hibernation
229 * @pgd_base - temporary resume page directory
230 */
231void resume_map_numa_kva(pgd_t *pgd_base)
232{
233 int node;
234
235 for_each_online_node(node) {
236 unsigned long start_va, start_pfn, size, pfn;
237
238 start_va = (unsigned long)node_remap_start_vaddr[node];
239 start_pfn = node_remap_start_pfn[node];
240 size = node_remap_size[node];
241
242 printk(KERN_DEBUG "%s: node %d\n", __FUNCTION__, node);
243
244 for (pfn = 0; pfn < size; pfn += PTRS_PER_PTE) {
245 unsigned long vaddr = start_va + (pfn << PAGE_SHIFT);
246 pgd_t *pgd = pgd_base + pgd_index(vaddr);
247 pud_t *pud = pud_offset(pgd, vaddr);
248 pmd_t *pmd = pmd_offset(pud, vaddr);
249
250 set_pmd(pmd, pfn_pmd(start_pfn + pfn,
251 PAGE_KERNEL_LARGE_EXEC));
252
253 printk(KERN_DEBUG "%s: %08lx -> pfn %08lx\n",
254 __FUNCTION__, vaddr, start_pfn + pfn);
255 }
256 }
257}
258#endif
259
225static unsigned long calculate_numa_remap_pages(void) 260static unsigned long calculate_numa_remap_pages(void)
226{ 261{
227 int nid; 262 int nid;
diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c
index f2b6e3f11bfc..81197c62d5b3 100644
--- a/arch/x86/power/hibernate_32.c
+++ b/arch/x86/power/hibernate_32.c
@@ -12,6 +12,7 @@
12#include <asm/system.h> 12#include <asm/system.h>
13#include <asm/page.h> 13#include <asm/page.h>
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15#include <asm/mmzone.h>
15 16
16/* Defined in hibernate_asm_32.S */ 17/* Defined in hibernate_asm_32.S */
17extern int restore_image(void); 18extern int restore_image(void);
@@ -127,6 +128,9 @@ static int resume_physical_mapping_init(pgd_t *pgd_base)
127 } 128 }
128 } 129 }
129 } 130 }
131
132 resume_map_numa_kva(pgd_base);
133
130 return 0; 134 return 0;
131} 135}
132 136
diff --git a/block/blk-map.c b/block/blk-map.c
index 4849fa36161e..0f4b4b881811 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -217,6 +217,12 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
217 return PTR_ERR(bio); 217 return PTR_ERR(bio);
218 218
219 if (bio->bi_size != len) { 219 if (bio->bi_size != len) {
220 /*
221 * Grab an extra reference to this bio, as bio_unmap_user()
222 * expects to be able to drop it twice as it happens on the
223 * normal IO completion path
224 */
225 bio_get(bio);
220 bio_endio(bio, 0); 226 bio_endio(bio, 0);
221 bio_unmap_user(bio); 227 bio_unmap_user(bio);
222 return -EINVAL; 228 return -EINVAL;
diff --git a/block/genhd.c b/block/genhd.c
index 4e5e7493f676..27549e470da5 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -768,6 +768,8 @@ static int __init genhd_device_init(void)
768 bdev_map = kobj_map_init(base_probe, &block_class_lock); 768 bdev_map = kobj_map_init(base_probe, &block_class_lock);
769 blk_dev_init(); 769 blk_dev_init();
770 770
771 register_blkdev(BLOCK_EXT_MAJOR, "blkext");
772
771#ifndef CONFIG_SYSFS_DEPRECATED 773#ifndef CONFIG_SYSFS_DEPRECATED
772 /* create top-level block dir */ 774 /* create top-level block dir */
773 block_depr = kobject_create_and_add("block", NULL); 775 block_depr = kobject_create_and_add("block", NULL);
diff --git a/block/ioctl.c b/block/ioctl.c
index c832d639b6e2..d03985b04d67 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -18,7 +18,6 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
18 struct disk_part_iter piter; 18 struct disk_part_iter piter;
19 long long start, length; 19 long long start, length;
20 int partno; 20 int partno;
21 int err;
22 21
23 if (!capable(CAP_SYS_ADMIN)) 22 if (!capable(CAP_SYS_ADMIN))
24 return -EACCES; 23 return -EACCES;
@@ -61,10 +60,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
61 disk_part_iter_exit(&piter); 60 disk_part_iter_exit(&piter);
62 61
63 /* all seems OK */ 62 /* all seems OK */
64 err = add_partition(disk, partno, start, length, 63 part = add_partition(disk, partno, start, length,
65 ADDPART_FLAG_NONE); 64 ADDPART_FLAG_NONE);
66 mutex_unlock(&bdev->bd_mutex); 65 mutex_unlock(&bdev->bd_mutex);
67 return err; 66 return IS_ERR(part) ? PTR_ERR(part) : 0;
68 case BLKPG_DEL_PARTITION: 67 case BLKPG_DEL_PARTITION:
69 part = disk_get_part(disk, partno); 68 part = disk_get_part(disk, partno);
70 if (!part) 69 if (!part)
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 64e591ba86f2..4dbc2271acf5 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -366,7 +366,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
366 dev->wakeup.state.enabled ? "enabled" : "disabled"); 366 dev->wakeup.state.enabled ? "enabled" : "disabled");
367 if (ldev) 367 if (ldev)
368 seq_printf(seq, "%s:%s", 368 seq_printf(seq, "%s:%s",
369 dev_name(ldev) ? ldev->bus->name : "no-bus", 369 ldev->bus ? ldev->bus->name : "no-bus",
370 dev_name(ldev)); 370 dev_name(ldev));
371 seq_printf(seq, "\n"); 371 seq_printf(seq, "\n");
372 put_device(ldev); 372 put_device(ldev);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 4b4739486327..9033d164c4ec 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1227,10 +1227,19 @@ fsm_start:
1227 /* ATA PIO protocol */ 1227 /* ATA PIO protocol */
1228 if (unlikely((status & ATA_DRQ) == 0)) { 1228 if (unlikely((status & ATA_DRQ) == 0)) {
1229 /* handle BSY=0, DRQ=0 as error */ 1229 /* handle BSY=0, DRQ=0 as error */
1230 if (likely(status & (ATA_ERR | ATA_DF))) 1230 if (likely(status & (ATA_ERR | ATA_DF))) {
1231 /* device stops HSM for abort/error */ 1231 /* device stops HSM for abort/error */
1232 qc->err_mask |= AC_ERR_DEV; 1232 qc->err_mask |= AC_ERR_DEV;
1233 else { 1233
1234 /* If diagnostic failed and this is
1235 * IDENTIFY, it's likely a phantom
1236 * device. Mark hint.
1237 */
1238 if (qc->dev->horkage &
1239 ATA_HORKAGE_DIAGNOSTIC)
1240 qc->err_mask |=
1241 AC_ERR_NODEV_HINT;
1242 } else {
1234 /* HSM violation. Let EH handle this. 1243 /* HSM violation. Let EH handle this.
1235 * Phantom devices also trigger this 1244 * Phantom devices also trigger this
1236 * condition. Mark hint. 1245 * condition. Mark hint.
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 61ad8d639ba3..0344a8a8321d 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -21,7 +21,8 @@ config BLK_DEV_FD
21 ---help--- 21 ---help---
22 If you want to use the floppy disk drive(s) of your PC under Linux, 22 If you want to use the floppy disk drive(s) of your PC under Linux,
23 say Y. Information about this driver, especially important for IBM 23 say Y. Information about this driver, especially important for IBM
24 Thinkpad users, is contained in <file:Documentation/floppy.txt>. 24 Thinkpad users, is contained in
25 <file:Documentation/blockdev/floppy.txt>.
25 That file also contains the location of the Floppy driver FAQ as 26 That file also contains the location of the Floppy driver FAQ as
26 well as location of the fdutils package used to configure additional 27 well as location of the fdutils package used to configure additional
27 parameters of the driver at run time. 28 parameters of the driver at run time.
@@ -76,7 +77,7 @@ config PARIDE
76 your computer's parallel port. Most of them are actually IDE devices 77 your computer's parallel port. Most of them are actually IDE devices
77 using a parallel port IDE adapter. This option enables the PARIDE 78 using a parallel port IDE adapter. This option enables the PARIDE
78 subsystem which contains drivers for many of these external drives. 79 subsystem which contains drivers for many of these external drives.
79 Read <file:Documentation/paride.txt> for more information. 80 Read <file:Documentation/blockdev/paride.txt> for more information.
80 81
81 If you have said Y to the "Parallel-port support" configuration 82 If you have said Y to the "Parallel-port support" configuration
82 option, you may share a single port between your printer and other 83 option, you may share a single port between your printer and other
@@ -114,9 +115,9 @@ config BLK_CPQ_DA
114 help 115 help
115 This is the driver for Compaq Smart Array controllers. Everyone 116 This is the driver for Compaq Smart Array controllers. Everyone
116 using these boards should say Y here. See the file 117 using these boards should say Y here. See the file
117 <file:Documentation/cpqarray.txt> for the current list of boards 118 <file:Documentation/blockdev/cpqarray.txt> for the current list of
118 supported by this driver, and for further information on the use of 119 boards supported by this driver, and for further information on the
119 this driver. 120 use of this driver.
120 121
121config BLK_CPQ_CISS_DA 122config BLK_CPQ_CISS_DA
122 tristate "Compaq Smart Array 5xxx support" 123 tristate "Compaq Smart Array 5xxx support"
@@ -124,7 +125,7 @@ config BLK_CPQ_CISS_DA
124 help 125 help
125 This is the driver for Compaq Smart Array 5xxx controllers. 126 This is the driver for Compaq Smart Array 5xxx controllers.
126 Everyone using these boards should say Y here. 127 Everyone using these boards should say Y here.
127 See <file:Documentation/cciss.txt> for the current list of 128 See <file:Documentation/blockdev/cciss.txt> for the current list of
128 boards supported by this driver, and for further information 129 boards supported by this driver, and for further information
129 on the use of this driver. 130 on the use of this driver.
130 131
@@ -135,7 +136,7 @@ config CISS_SCSI_TAPE
135 help 136 help
136 When enabled (Y), this option allows SCSI tape drives and SCSI medium 137 When enabled (Y), this option allows SCSI tape drives and SCSI medium
137 changers (tape robots) to be accessed via a Compaq 5xxx array 138 changers (tape robots) to be accessed via a Compaq 5xxx array
138 controller. (See <file:Documentation/cciss.txt> for more details.) 139 controller. (See <file:Documentation/blockdev/cciss.txt> for more details.)
139 140
140 "SCSI support" and "SCSI tape support" must also be enabled for this 141 "SCSI support" and "SCSI tape support" must also be enabled for this
141 option to work. 142 option to work.
@@ -149,8 +150,8 @@ config BLK_DEV_DAC960
149 help 150 help
150 This driver adds support for the Mylex DAC960, AcceleRAID, and 151 This driver adds support for the Mylex DAC960, AcceleRAID, and
151 eXtremeRAID PCI RAID controllers. See the file 152 eXtremeRAID PCI RAID controllers. See the file
152 <file:Documentation/README.DAC960> for further information about 153 <file:Documentation/blockdev/README.DAC960> for further information
153 this driver. 154 about this driver.
154 155
155 To compile this driver as a module, choose M here: the 156 To compile this driver as a module, choose M here: the
156 module will be called DAC960. 157 module will be called DAC960.
@@ -278,9 +279,9 @@ config BLK_DEV_NBD
278 userland (making server and client physically the same computer, 279 userland (making server and client physically the same computer,
279 communicating using the loopback network device). 280 communicating using the loopback network device).
280 281
281 Read <file:Documentation/nbd.txt> for more information, especially 282 Read <file:Documentation/blockdev/nbd.txt> for more information,
282 about where to find the server code, which runs in user space and 283 especially about where to find the server code, which runs in user
283 does not need special kernel support. 284 space and does not need special kernel support.
284 285
285 Note that this has nothing to do with the network file systems NFS 286 Note that this has nothing to do with the network file systems NFS
286 or Coda; you can say N here even if you intend to use NFS or Coda. 287 or Coda; you can say N here even if you intend to use NFS or Coda.
@@ -321,8 +322,8 @@ config BLK_DEV_RAM
321 store a copy of a minimal root file system off of a floppy into RAM 322 store a copy of a minimal root file system off of a floppy into RAM
322 during the initial install of Linux. 323 during the initial install of Linux.
323 324
324 Note that the kernel command line option "ramdisk=XX" is now 325 Note that the kernel command line option "ramdisk=XX" is now obsolete.
325 obsolete. For details, read <file:Documentation/ramdisk.txt>. 326 For details, read <file:Documentation/blockdev/ramdisk.txt>.
326 327
327 To compile this driver as a module, choose M here: the 328 To compile this driver as a module, choose M here: the
328 module will be called rd. 329 module will be called rd.
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 12de1fdaa6c6..9364dc554257 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2847,7 +2847,7 @@ static void do_cciss_request(struct request_queue *q)
2847 h->maxSG = seg; 2847 h->maxSG = seg;
2848 2848
2849#ifdef CCISS_DEBUG 2849#ifdef CCISS_DEBUG
2850 printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", 2850 printk(KERN_DEBUG "cciss: Submitting %lu sectors in %d segments\n",
2851 creq->nr_sectors, seg); 2851 creq->nr_sectors, seg);
2852#endif /* CCISS_DEBUG */ 2852#endif /* CCISS_DEBUG */
2853 2853
@@ -3197,7 +3197,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3197 3197
3198 c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */ 3198 c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */
3199#ifdef CCISS_DEBUG 3199#ifdef CCISS_DEBUG
3200 printk("address 0 = %x\n", c->paddr); 3200 printk("address 0 = %lx\n", c->paddr);
3201#endif /* CCISS_DEBUG */ 3201#endif /* CCISS_DEBUG */
3202 c->vaddr = remap_pci_mem(c->paddr, 0x250); 3202 c->vaddr = remap_pci_mem(c->paddr, 0x250);
3203 3203
@@ -3224,7 +3224,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3224#endif /* CCISS_DEBUG */ 3224#endif /* CCISS_DEBUG */
3225 cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); 3225 cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr);
3226#ifdef CCISS_DEBUG 3226#ifdef CCISS_DEBUG
3227 printk("cfg base address index = %x\n", cfg_base_addr_index); 3227 printk("cfg base address index = %llx\n",
3228 (unsigned long long)cfg_base_addr_index);
3228#endif /* CCISS_DEBUG */ 3229#endif /* CCISS_DEBUG */
3229 if (cfg_base_addr_index == -1) { 3230 if (cfg_base_addr_index == -1) {
3230 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); 3231 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
@@ -3234,7 +3235,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
3234 3235
3235 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); 3236 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
3236#ifdef CCISS_DEBUG 3237#ifdef CCISS_DEBUG
3237 printk("cfg offset = %x\n", cfg_offset); 3238 printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
3238#endif /* CCISS_DEBUG */ 3239#endif /* CCISS_DEBUG */
3239 c->cfgtable = remap_pci_mem(pci_resource_start(pdev, 3240 c->cfgtable = remap_pci_mem(pci_resource_start(pdev,
3240 cfg_base_addr_index) + 3241 cfg_base_addr_index) +
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 14db747a636e..cf29cc4e6ab7 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4124,7 +4124,7 @@ static int __init floppy_setup(char *str)
4124 printk("\n"); 4124 printk("\n");
4125 } else 4125 } else
4126 DPRINT("botched floppy option\n"); 4126 DPRINT("botched floppy option\n");
4127 DPRINT("Read Documentation/floppy.txt\n"); 4127 DPRINT("Read Documentation/blockdev/floppy.txt\n");
4128 return 0; 4128 return 0;
4129} 4129}
4130 4130
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index fccac18d3111..048d71d244d7 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1546,8 +1546,6 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd)
1546 1546
1547/* 1547/*
1548 * Reset management 1548 * Reset management
1549 * XXX Move usb_reset_device to khubd. Hogging kevent is not a good thing.
1550 * XXX Make usb_sync_reset asynchronous.
1551 */ 1549 */
1552 1550
1553static void ub_reset_enter(struct ub_dev *sc, int try) 1551static void ub_reset_enter(struct ub_dev *sc, int try)
@@ -1633,6 +1631,22 @@ static void ub_reset_task(struct work_struct *work)
1633} 1631}
1634 1632
1635/* 1633/*
1634 * XXX Reset brackets are too much hassle to implement, so just stub them
1635 * in order to prevent forced unbinding (which deadlocks solid when our
1636 * ->disconnect method waits for the reset to complete and this kills keventd).
1637 *
1638 * XXX Tell Alan to move usb_unlock_device inside of usb_reset_device,
1639 * or else the post_reset is invoked, and restats I/O on a locked device.
1640 */
1641static int ub_pre_reset(struct usb_interface *iface) {
1642 return 0;
1643}
1644
1645static int ub_post_reset(struct usb_interface *iface) {
1646 return 0;
1647}
1648
1649/*
1636 * This is called from a process context. 1650 * This is called from a process context.
1637 */ 1651 */
1638static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) 1652static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun)
@@ -2446,6 +2460,8 @@ static struct usb_driver ub_driver = {
2446 .probe = ub_probe, 2460 .probe = ub_probe,
2447 .disconnect = ub_disconnect, 2461 .disconnect = ub_disconnect,
2448 .id_table = ub_usb_ids, 2462 .id_table = ub_usb_ids,
2463 .pre_reset = ub_pre_reset,
2464 .post_reset = ub_post_reset,
2449}; 2465};
2450 2466
2451static int __init ub_init(void) 2467static int __init ub_init(void)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index b220c686089d..2d19f0cc47f2 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -338,12 +338,18 @@ wait:
338static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) 338static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
339{ 339{
340 struct request_queue *rq; 340 struct request_queue *rq;
341 elevator_t *old_e;
341 342
342 rq = blk_init_queue(do_blkif_request, &blkif_io_lock); 343 rq = blk_init_queue(do_blkif_request, &blkif_io_lock);
343 if (rq == NULL) 344 if (rq == NULL)
344 return -1; 345 return -1;
345 346
346 elevator_init(rq, "noop"); 347 old_e = rq->elevator;
348 if (IS_ERR_VALUE(elevator_init(rq, "noop")))
349 printk(KERN_WARNING
350 "blkfront: Switch elevator failed, use default\n");
351 else
352 elevator_exit(old_e);
347 353
348 /* Hard sector size and max sectors impersonate the equiv. hardware. */ 354 /* Hard sector size and max sectors impersonate the equiv. hardware. */
349 blk_queue_hardsect_size(rq, sector_size); 355 blk_queue_hardsect_size(rq, sector_size);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 43b35d0369d6..43d6ba83a191 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -124,7 +124,7 @@ config COMPUTONE
124 which give you many serial ports. You would need something like this 124 which give you many serial ports. You would need something like this
125 to connect more than two modems to your Linux box, for instance in 125 to connect more than two modems to your Linux box, for instance in
126 order to become a dial-in server. If you have a card like that, say 126 order to become a dial-in server. If you have a card like that, say
127 Y here and read <file:Documentation/computone.txt>. 127 Y here and read <file:Documentation/serial/computone.txt>.
128 128
129 To compile this driver as module, choose M here: the 129 To compile this driver as module, choose M here: the
130 module will be called ip2. 130 module will be called ip2.
@@ -136,7 +136,7 @@ config ROCKETPORT
136 This driver supports Comtrol RocketPort and RocketModem PCI boards. 136 This driver supports Comtrol RocketPort and RocketModem PCI boards.
137 These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or 137 These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or
138 modems. For information about the RocketPort/RocketModem boards 138 modems. For information about the RocketPort/RocketModem boards
139 and this driver read <file:Documentation/rocket.txt>. 139 and this driver read <file:Documentation/serial/rocket.txt>.
140 140
141 To compile this driver as a module, choose M here: the 141 To compile this driver as a module, choose M here: the
142 module will be called rocket. 142 module will be called rocket.
@@ -154,7 +154,7 @@ config CYCLADES
154 your Linux box, for instance in order to become a dial-in server. 154 your Linux box, for instance in order to become a dial-in server.
155 155
156 For information about the Cyclades-Z card, read 156 For information about the Cyclades-Z card, read
157 <file:Documentation/README.cycladesZ>. 157 <file:Documentation/serial/README.cycladesZ>.
158 158
159 To compile this driver as a module, choose M here: the 159 To compile this driver as a module, choose M here: the
160 module will be called cyclades. 160 module will be called cyclades.
@@ -183,7 +183,7 @@ config DIGIEPCA
183 box, for instance in order to become a dial-in server. This driver 183 box, for instance in order to become a dial-in server. This driver
184 supports the original PC (ISA) boards as well as PCI, and EISA. If 184 supports the original PC (ISA) boards as well as PCI, and EISA. If
185 you have a card like this, say Y here and read the file 185 you have a card like this, say Y here and read the file
186 <file:Documentation/digiepca.txt>. 186 <file:Documentation/serial/digiepca.txt>.
187 187
188 To compile this driver as a module, choose M here: the 188 To compile this driver as a module, choose M here: the
189 module will be called epca. 189 module will be called epca.
@@ -289,7 +289,7 @@ config RISCOM8
289 which gives you many serial ports. You would need something like 289 which gives you many serial ports. You would need something like
290 this to connect more than two modems to your Linux box, for instance 290 this to connect more than two modems to your Linux box, for instance
291 in order to become a dial-in server. If you have a card like that, 291 in order to become a dial-in server. If you have a card like that,
292 say Y here and read the file <file:Documentation/riscom8.txt>. 292 say Y here and read the file <file:Documentation/serial/riscom8.txt>.
293 293
294 Also it's possible to say M here and compile this driver as kernel 294 Also it's possible to say M here and compile this driver as kernel
295 loadable module; the module will be called riscom8. 295 loadable module; the module will be called riscom8.
@@ -304,8 +304,8 @@ config SPECIALIX
304 your Linux box, for instance in order to become a dial-in server. 304 your Linux box, for instance in order to become a dial-in server.
305 305
306 If you have a card like that, say Y here and read the file 306 If you have a card like that, say Y here and read the file
307 <file:Documentation/specialix.txt>. Also it's possible to say M here 307 <file:Documentation/serial/specialix.txt>. Also it's possible to say
308 and compile this driver as kernel loadable module which will be 308 M here and compile this driver as kernel loadable module which will be
309 called specialix. 309 called specialix.
310 310
311config SX 311config SX
@@ -313,7 +313,7 @@ config SX
313 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) 313 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
314 help 314 help
315 This is a driver for the SX and SI multiport serial cards. 315 This is a driver for the SX and SI multiport serial cards.
316 Please read the file <file:Documentation/sx.txt> for details. 316 Please read the file <file:Documentation/serial/sx.txt> for details.
317 317
318 This driver can only be built as a module ( = code which can be 318 This driver can only be built as a module ( = code which can be
319 inserted in and removed from the running kernel whenever you want). 319 inserted in and removed from the running kernel whenever you want).
@@ -344,8 +344,8 @@ config STALDRV
344 like this to connect more than two modems to your Linux box, for 344 like this to connect more than two modems to your Linux box, for
345 instance in order to become a dial-in server. If you say Y here, 345 instance in order to become a dial-in server. If you say Y here,
346 you will be asked for your specific card model in the next 346 you will be asked for your specific card model in the next
347 questions. Make sure to read <file:Documentation/stallion.txt> in 347 questions. Make sure to read <file:Documentation/serial/stallion.txt>
348 this case. If you have never heard about all this, it's safe to 348 in this case. If you have never heard about all this, it's safe to
349 say N. 349 say N.
350 350
351config STALLION 351config STALLION
@@ -354,7 +354,7 @@ config STALLION
354 help 354 help
355 If you have an EasyIO or EasyConnection 8/32 multiport Stallion 355 If you have an EasyIO or EasyConnection 8/32 multiport Stallion
356 card, then this is for you; say Y. Make sure to read 356 card, then this is for you; say Y. Make sure to read
357 <file:Documentation/stallion.txt>. 357 <file:Documentation/serial/stallion.txt>.
358 358
359 To compile this driver as a module, choose M here: the 359 To compile this driver as a module, choose M here: the
360 module will be called stallion. 360 module will be called stallion.
@@ -365,7 +365,7 @@ config ISTALLION
365 help 365 help
366 If you have an EasyConnection 8/64, ONboard, Brumby or Stallion 366 If you have an EasyConnection 8/64, ONboard, Brumby or Stallion
367 serial multiport card, say Y here. Make sure to read 367 serial multiport card, say Y here. Make sure to read
368 <file:Documentation/stallion.txt>. 368 <file:Documentation/serial/stallion.txt>.
369 369
370 To compile this driver as a module, choose M here: the 370 To compile this driver as a module, choose M here: the
371 module will be called istallion. 371 module will be called istallion.
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 242fd46fda22..a16b94f12eb2 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -72,7 +72,7 @@
72/* 72/*
73 * There is a bunch of documentation about the card, jumpers, config 73 * There is a bunch of documentation about the card, jumpers, config
74 * settings, restrictions, cables, device names and numbers in 74 * settings, restrictions, cables, device names and numbers in
75 * Documentation/specialix.txt 75 * Documentation/serial/specialix.txt
76 */ 76 */
77 77
78#include <linux/module.h> 78#include <linux/module.h>
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index faa1cc66e9cf..82020abc329e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1134,7 +1134,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
1134 continue; 1134 continue;
1135 1135
1136 is_out = test_bit(FLAG_IS_OUT, &gdesc->flags); 1136 is_out = test_bit(FLAG_IS_OUT, &gdesc->flags);
1137 seq_printf(s, " gpio-%-3d (%-12s) %s %s", 1137 seq_printf(s, " gpio-%-3d (%-20.20s) %s %s",
1138 gpio, gdesc->label, 1138 gpio, gdesc->label,
1139 is_out ? "out" : "in ", 1139 is_out ? "out" : "in ",
1140 chip->get 1140 chip->get
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index c6ab4ba60c52..9b97795e45ad 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -55,10 +55,11 @@ struct apple_key_translation {
55 55
56static struct apple_key_translation apple_fn_keys[] = { 56static struct apple_key_translation apple_fn_keys[] = {
57 { KEY_BACKSPACE, KEY_DELETE }, 57 { KEY_BACKSPACE, KEY_DELETE },
58 { KEY_ENTER, KEY_INSERT },
58 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, 59 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
59 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, 60 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
60 { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */ 61 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
61 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */ 62 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
62 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, 63 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
63 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, 64 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
64 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, 65 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
@@ -418,6 +419,12 @@ static const struct hid_device_id apple_devices[] = {
418 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, 419 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
419 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), 420 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
420 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, 421 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
422 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
423 .driver_data = APPLE_HAS_FN },
424 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
425 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
426 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
427 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
421 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), 428 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
422 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 429 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
423 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), 430 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d3671b4049c0..147ec591a806 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1250,9 +1250,11 @@ static const struct hid_device_id hid_blacklist[] = {
1250 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1250 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1251 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1251 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1252 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1252 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1253 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1254 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1255 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1253 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1254 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1255 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
1256 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1258 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1257 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) }, 1259 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
1258 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1260 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
@@ -1265,7 +1267,6 @@ static const struct hid_device_id hid_blacklist[] = {
1265 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1267 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1266 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, 1268 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
1267 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1269 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1270 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1271 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 1272 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
@@ -1409,6 +1410,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1409 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 1410 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
1410 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, 1411 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
1411 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, 1412 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)},
1413 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
1412 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1414 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1413 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1415 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
1414 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1416 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
@@ -1486,6 +1488,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1486 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1488 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1487 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1489 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1488 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1490 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
1489 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1492 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
1490 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1493 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1494 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
@@ -1573,6 +1576,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1573 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1576 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1574 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1575 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1578 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1580 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1576 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1582 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1583 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1578 { } 1584 { }
@@ -1730,7 +1736,7 @@ static int __init hid_init(void)
1730 goto err_bus; 1736 goto err_bus;
1731 1737
1732#ifdef CONFIG_HID_COMPAT 1738#ifdef CONFIG_HID_COMPAT
1733 hid_compat_wq = create_workqueue("hid_compat"); 1739 hid_compat_wq = create_singlethread_workqueue("hid_compat");
1734 if (!hid_compat_wq) { 1740 if (!hid_compat_wq) {
1735 hidraw_exit(); 1741 hidraw_exit();
1736 goto err; 1742 goto err;
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index f05bcbbbb0d5..d70075dd3d81 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -82,6 +82,9 @@
82#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 82#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
83#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 83#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
84#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 84#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
85#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
86#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
87#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238
85#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a 88#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
86#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b 89#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
87#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 90#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 894d52e05bf9..7685ae6808c4 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -38,7 +38,7 @@ static int hidraw_major;
38static struct cdev hidraw_cdev; 38static struct cdev hidraw_cdev;
39static struct class *hidraw_class; 39static struct class *hidraw_class;
40static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; 40static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES];
41static DEFINE_SPINLOCK(minors_lock); 41static DEFINE_MUTEX(minors_lock);
42 42
43static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 43static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
44{ 44{
@@ -159,13 +159,13 @@ static int hidraw_open(struct inode *inode, struct file *file)
159 struct hidraw_list *list; 159 struct hidraw_list *list;
160 int err = 0; 160 int err = 0;
161 161
162 lock_kernel();
163 if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { 162 if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) {
164 err = -ENOMEM; 163 err = -ENOMEM;
165 goto out; 164 goto out;
166 } 165 }
167 166
168 spin_lock(&minors_lock); 167 lock_kernel();
168 mutex_lock(&minors_lock);
169 if (!hidraw_table[minor]) { 169 if (!hidraw_table[minor]) {
170 printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n", 170 printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n",
171 minor); 171 minor);
@@ -180,13 +180,16 @@ static int hidraw_open(struct inode *inode, struct file *file)
180 file->private_data = list; 180 file->private_data = list;
181 181
182 dev = hidraw_table[minor]; 182 dev = hidraw_table[minor];
183 if (!dev->open++) 183 if (!dev->open++) {
184 dev->hid->ll_driver->open(dev->hid); 184 err = dev->hid->ll_driver->open(dev->hid);
185 if (err < 0)
186 dev->open--;
187 }
185 188
186out_unlock: 189out_unlock:
187 spin_unlock(&minors_lock); 190 mutex_unlock(&minors_lock);
188out:
189 unlock_kernel(); 191 unlock_kernel();
192out:
190 return err; 193 return err;
191 194
192} 195}
@@ -310,7 +313,7 @@ int hidraw_connect(struct hid_device *hid)
310 313
311 result = -EINVAL; 314 result = -EINVAL;
312 315
313 spin_lock(&minors_lock); 316 mutex_lock(&minors_lock);
314 317
315 for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) { 318 for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) {
316 if (hidraw_table[minor]) 319 if (hidraw_table[minor])
@@ -320,9 +323,8 @@ int hidraw_connect(struct hid_device *hid)
320 break; 323 break;
321 } 324 }
322 325
323 spin_unlock(&minors_lock);
324
325 if (result) { 326 if (result) {
327 mutex_unlock(&minors_lock);
326 kfree(dev); 328 kfree(dev);
327 goto out; 329 goto out;
328 } 330 }
@@ -331,14 +333,14 @@ int hidraw_connect(struct hid_device *hid)
331 NULL, "%s%d", "hidraw", minor); 333 NULL, "%s%d", "hidraw", minor);
332 334
333 if (IS_ERR(dev->dev)) { 335 if (IS_ERR(dev->dev)) {
334 spin_lock(&minors_lock);
335 hidraw_table[minor] = NULL; 336 hidraw_table[minor] = NULL;
336 spin_unlock(&minors_lock); 337 mutex_unlock(&minors_lock);
337 result = PTR_ERR(dev->dev); 338 result = PTR_ERR(dev->dev);
338 kfree(dev); 339 kfree(dev);
339 goto out; 340 goto out;
340 } 341 }
341 342
343 mutex_unlock(&minors_lock);
342 init_waitqueue_head(&dev->wait); 344 init_waitqueue_head(&dev->wait);
343 INIT_LIST_HEAD(&dev->list); 345 INIT_LIST_HEAD(&dev->list);
344 346
@@ -360,9 +362,9 @@ void hidraw_disconnect(struct hid_device *hid)
360 362
361 hidraw->exist = 0; 363 hidraw->exist = 0;
362 364
363 spin_lock(&minors_lock); 365 mutex_lock(&minors_lock);
364 hidraw_table[hidraw->minor] = NULL; 366 hidraw_table[hidraw->minor] = NULL;
365 spin_unlock(&minors_lock); 367 mutex_unlock(&minors_lock);
366 368
367 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); 369 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
368 370
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 18e5ddd722cd..d746bf8284dd 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -781,6 +781,8 @@ static int usbhid_start(struct hid_device *hid)
781 unsigned int n, insize = 0; 781 unsigned int n, insize = 0;
782 int ret; 782 int ret;
783 783
784 clear_bit(HID_DISCONNECTED, &usbhid->iofl);
785
784 usbhid->bufsize = HID_MIN_BUFFER_SIZE; 786 usbhid->bufsize = HID_MIN_BUFFER_SIZE;
785 hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); 787 hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize);
786 hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); 788 hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize);
@@ -847,12 +849,6 @@ static int usbhid_start(struct hid_device *hid)
847 } 849 }
848 } 850 }
849 851
850 if (!usbhid->urbin) {
851 err_hid("couldn't find an input interrupt endpoint");
852 ret = -ENODEV;
853 goto fail;
854 }
855
856 init_waitqueue_head(&usbhid->wait); 852 init_waitqueue_head(&usbhid->wait);
857 INIT_WORK(&usbhid->reset_work, hid_reset); 853 INIT_WORK(&usbhid->reset_work, hid_reset);
858 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); 854 setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
@@ -888,6 +884,9 @@ fail:
888 usb_free_urb(usbhid->urbin); 884 usb_free_urb(usbhid->urbin);
889 usb_free_urb(usbhid->urbout); 885 usb_free_urb(usbhid->urbout);
890 usb_free_urb(usbhid->urbctrl); 886 usb_free_urb(usbhid->urbctrl);
887 usbhid->urbin = NULL;
888 usbhid->urbout = NULL;
889 usbhid->urbctrl = NULL;
891 hid_free_buffers(dev, hid); 890 hid_free_buffers(dev, hid);
892 mutex_unlock(&usbhid->setup); 891 mutex_unlock(&usbhid->setup);
893 return ret; 892 return ret;
@@ -924,6 +923,9 @@ static void usbhid_stop(struct hid_device *hid)
924 usb_free_urb(usbhid->urbin); 923 usb_free_urb(usbhid->urbin);
925 usb_free_urb(usbhid->urbctrl); 924 usb_free_urb(usbhid->urbctrl);
926 usb_free_urb(usbhid->urbout); 925 usb_free_urb(usbhid->urbout);
926 usbhid->urbin = NULL; /* don't mess up next start */
927 usbhid->urbctrl = NULL;
928 usbhid->urbout = NULL;
927 929
928 hid_free_buffers(hid_to_usb_dev(hid), hid); 930 hid_free_buffers(hid_to_usb_dev(hid), hid);
929 mutex_unlock(&usbhid->setup); 931 mutex_unlock(&usbhid->setup);
@@ -940,15 +942,26 @@ static struct hid_ll_driver usb_hid_driver = {
940 942
941static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) 943static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
942{ 944{
945 struct usb_host_interface *interface = intf->cur_altsetting;
943 struct usb_device *dev = interface_to_usbdev(intf); 946 struct usb_device *dev = interface_to_usbdev(intf);
944 struct usbhid_device *usbhid; 947 struct usbhid_device *usbhid;
945 struct hid_device *hid; 948 struct hid_device *hid;
949 unsigned int n, has_in = 0;
946 size_t len; 950 size_t len;
947 int ret; 951 int ret;
948 952
949 dbg_hid("HID probe called for ifnum %d\n", 953 dbg_hid("HID probe called for ifnum %d\n",
950 intf->altsetting->desc.bInterfaceNumber); 954 intf->altsetting->desc.bInterfaceNumber);
951 955
956 for (n = 0; n < interface->desc.bNumEndpoints; n++)
957 if (usb_endpoint_is_int_in(&interface->endpoint[n].desc))
958 has_in++;
959 if (!has_in) {
960 dev_err(&intf->dev, "couldn't find an input interrupt "
961 "endpoint\n");
962 return -ENODEV;
963 }
964
952 hid = hid_allocate_device(); 965 hid = hid_allocate_device();
953 if (IS_ERR(hid)) 966 if (IS_ERR(hid))
954 return PTR_ERR(hid); 967 return PTR_ERR(hid);
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 488e45cd43d7..f7dce8b9f64b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -128,6 +128,9 @@ static const char* temperature_sensors_sets[][36] = {
128/* Set 13: iMac 8,1 */ 128/* Set 13: iMac 8,1 */
129 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P", 129 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P",
130 "TL0P", "TO0P", "TW0P", "Tm0P", "Tp0P", NULL }, 130 "TL0P", "TO0P", "TW0P", "Tm0P", "Tp0P", NULL },
131/* Set 14: iMac 6,1 */
132 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TG0P", "TH0P",
133 "TO0P", "Tp0P", NULL },
131}; 134};
132 135
133/* List of keys used to read/write fan speeds */ 136/* List of keys used to read/write fan speeds */
@@ -1296,6 +1299,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1296 { .accelerometer = 1, .light = 1, .temperature_set = 12 }, 1299 { .accelerometer = 1, .light = 1, .temperature_set = 12 },
1297/* iMac 8: light sensor only, temperature set 13 */ 1300/* iMac 8: light sensor only, temperature set 13 */
1298 { .accelerometer = 0, .light = 0, .temperature_set = 13 }, 1301 { .accelerometer = 0, .light = 0, .temperature_set = 13 },
1302/* iMac 6: light sensor only, temperature set 14 */
1303 { .accelerometer = 0, .light = 0, .temperature_set = 14 },
1299}; 1304};
1300 1305
1301/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1306/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1349,10 +1354,18 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1349 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1354 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1350 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, 1355 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1351 &applesmc_dmi_data[4]}, 1356 &applesmc_dmi_data[4]},
1357 { applesmc_dmi_match, "Apple MacPro", {
1358 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1359 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
1360 &applesmc_dmi_data[4]},
1352 { applesmc_dmi_match, "Apple iMac 8", { 1361 { applesmc_dmi_match, "Apple iMac 8", {
1353 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1362 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1354 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, 1363 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") },
1355 &applesmc_dmi_data[13]}, 1364 &applesmc_dmi_data[13]},
1365 { applesmc_dmi_match, "Apple iMac 6", {
1366 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1367 DMI_MATCH(DMI_PRODUCT_NAME, "iMac6") },
1368 &applesmc_dmi_data[14]},
1356 { applesmc_dmi_match, "Apple iMac 5", { 1369 { applesmc_dmi_match, "Apple iMac 5", {
1357 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1370 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1358 DMI_MATCH(DMI_PRODUCT_NAME, "iMac5") }, 1371 DMI_MATCH(DMI_PRODUCT_NAME, "iMac5") },
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index 752b5c44df9c..c002144c76bc 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -33,7 +33,6 @@
33#include <linux/wait.h> 33#include <linux/wait.h>
34#include <linux/poll.h> 34#include <linux/poll.h>
35#include <linux/freezer.h> 35#include <linux/freezer.h>
36#include <linux/version.h>
37#include <linux/uaccess.h> 36#include <linux/uaccess.h>
38#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
39#include <asm/atomic.h> 38#include <asm/atomic.h>
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 640cbb237328..3384a717fec0 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -318,7 +318,8 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
318 } else 318 } else
319 data = i2c_op(pd, OP_RX, 0); 319 data = i2c_op(pd, OP_RX, 0);
320 320
321 pd->msg->buf[real_pos] = data; 321 if (real_pos >= 0)
322 pd->msg->buf[real_pos] = data;
322 } while (0); 323 } while (0);
323 324
324 pd->pos++; 325 pd->pos++;
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index cb199c815b53..f50210fe558f 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -444,6 +444,7 @@ static struct pcmcia_device_id ide_ids[] = {
444 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 444 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
445 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 445 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
446 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), 446 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6),
447 PCMCIA_DEVICE_PROD_ID2("Flash Card", 0x5a362506),
447 PCMCIA_DEVICE_NULL, 448 PCMCIA_DEVICE_NULL,
448}; 449};
449MODULE_DEVICE_TABLE(pcmcia, ide_ids); 450MODULE_DEVICE_TABLE(pcmcia, ide_ids);
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index bb904a0a98bd..1bfc55d7a26c 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -1641,8 +1641,10 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
1641 /* slarp reply, send own ip/netmask; if values are nonsense remote 1641 /* slarp reply, send own ip/netmask; if values are nonsense remote
1642 * should think we are unable to provide it with an address via SLARP */ 1642 * should think we are unable to provide it with an address via SLARP */
1643 p += put_u32(p, CISCO_SLARP_REPLY); 1643 p += put_u32(p, CISCO_SLARP_REPLY);
1644 p += put_u32(p, addr); // address 1644 *(__be32 *)p = addr; // address
1645 p += put_u32(p, mask); // netmask 1645 p += 4;
1646 *(__be32 *)p = mask; // netmask
1647 p += 4;
1646 p += put_u16(p, 0); // unused 1648 p += put_u16(p, 0); // unused
1647 1649
1648 isdn_net_write_super(lp, skb); 1650 isdn_net_write_super(lp, skb);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 4840733cd903..3d7f4923cd13 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -441,13 +441,13 @@ static void process_queued_ios(struct work_struct *work)
441 __choose_pgpath(m); 441 __choose_pgpath(m);
442 442
443 pgpath = m->current_pgpath; 443 pgpath = m->current_pgpath;
444 m->pgpath_to_activate = m->current_pgpath;
445 444
446 if ((pgpath && !m->queue_io) || 445 if ((pgpath && !m->queue_io) ||
447 (!pgpath && !m->queue_if_no_path)) 446 (!pgpath && !m->queue_if_no_path))
448 must_queue = 0; 447 must_queue = 0;
449 448
450 if (m->pg_init_required && !m->pg_init_in_progress) { 449 if (m->pg_init_required && !m->pg_init_in_progress && pgpath) {
450 m->pgpath_to_activate = pgpath;
451 m->pg_init_count++; 451 m->pg_init_count++;
452 m->pg_init_required = 0; 452 m->pg_init_required = 0;
453 m->pg_init_in_progress = 1; 453 m->pg_init_in_progress = 1;
@@ -708,6 +708,10 @@ static int parse_hw_handler(struct arg_set *as, struct multipath *m)
708 m->hw_handler_name = NULL; 708 m->hw_handler_name = NULL;
709 return -EINVAL; 709 return -EINVAL;
710 } 710 }
711
712 if (hw_argc > 1)
713 DMWARN("Ignoring user-specified arguments for "
714 "hardware handler \"%s\"", m->hw_handler_name);
711 consume(as, hw_argc - 1); 715 consume(as, hw_argc - 1);
712 716
713 return 0; 717 return 0;
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 9d7b53ed75b2..ec43f9fa4b2a 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1032,6 +1032,7 @@ static void mirror_dtr(struct dm_target *ti)
1032 1032
1033 del_timer_sync(&ms->timer); 1033 del_timer_sync(&ms->timer);
1034 flush_workqueue(ms->kmirrord_wq); 1034 flush_workqueue(ms->kmirrord_wq);
1035 flush_scheduled_work();
1035 dm_kcopyd_client_destroy(ms->kcopyd_client); 1036 dm_kcopyd_client_destroy(ms->kcopyd_client);
1036 destroy_workqueue(ms->kmirrord_wq); 1037 destroy_workqueue(ms->kmirrord_wq);
1037 free_context(ms, ti, ms->nr_mirrors); 1038 free_context(ms, ti, ms->nr_mirrors);
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index a2d068dbe9e2..9e4ef88d421e 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -320,8 +320,10 @@ int __init dm_stripe_init(void)
320 int r; 320 int r;
321 321
322 r = dm_register_target(&stripe_target); 322 r = dm_register_target(&stripe_target);
323 if (r < 0) 323 if (r < 0) {
324 DMWARN("target registration failed"); 324 DMWARN("target registration failed");
325 return r;
326 }
325 327
326 kstriped = create_singlethread_workqueue("kstriped"); 328 kstriped = create_singlethread_workqueue("kstriped");
327 if (!kstriped) { 329 if (!kstriped) {
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 6963ad148408..c99e4728ff41 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -375,7 +375,7 @@ static void start_io_acct(struct dm_io *io)
375 dm_disk(md)->part0.in_flight = atomic_inc_return(&md->pending); 375 dm_disk(md)->part0.in_flight = atomic_inc_return(&md->pending);
376} 376}
377 377
378static int end_io_acct(struct dm_io *io) 378static void end_io_acct(struct dm_io *io)
379{ 379{
380 struct mapped_device *md = io->md; 380 struct mapped_device *md = io->md;
381 struct bio *bio = io->bio; 381 struct bio *bio = io->bio;
@@ -391,7 +391,9 @@ static int end_io_acct(struct dm_io *io)
391 dm_disk(md)->part0.in_flight = pending = 391 dm_disk(md)->part0.in_flight = pending =
392 atomic_dec_return(&md->pending); 392 atomic_dec_return(&md->pending);
393 393
394 return !pending; 394 /* nudge anyone waiting on suspend queue */
395 if (!pending)
396 wake_up(&md->wait);
395} 397}
396 398
397/* 399/*
@@ -499,9 +501,7 @@ static void dec_pending(struct dm_io *io, int error)
499 spin_unlock_irqrestore(&io->md->pushback_lock, flags); 501 spin_unlock_irqrestore(&io->md->pushback_lock, flags);
500 } 502 }
501 503
502 if (end_io_acct(io)) 504 end_io_acct(io);
503 /* nudge anyone waiting on suspend queue */
504 wake_up(&io->md->wait);
505 505
506 if (io->error != DM_ENDIO_REQUEUE) { 506 if (io->error != DM_ENDIO_REQUEUE) {
507 blk_add_trace_bio(io->md->queue, io->bio, 507 blk_add_trace_bio(io->md->queue, io->bio,
@@ -937,16 +937,24 @@ static void dm_unplug_all(struct request_queue *q)
937 937
938static int dm_any_congested(void *congested_data, int bdi_bits) 938static int dm_any_congested(void *congested_data, int bdi_bits)
939{ 939{
940 int r; 940 int r = bdi_bits;
941 struct mapped_device *md = (struct mapped_device *) congested_data; 941 struct mapped_device *md = congested_data;
942 struct dm_table *map = dm_get_table(md); 942 struct dm_table *map;
943 943
944 if (!map || test_bit(DMF_BLOCK_IO, &md->flags)) 944 atomic_inc(&md->pending);
945 r = bdi_bits; 945
946 else 946 if (!test_bit(DMF_BLOCK_IO, &md->flags)) {
947 r = dm_table_any_congested(map, bdi_bits); 947 map = dm_get_table(md);
948 if (map) {
949 r = dm_table_any_congested(map, bdi_bits);
950 dm_table_put(map);
951 }
952 }
953
954 if (!atomic_dec_return(&md->pending))
955 /* nudge anyone waiting on suspend queue */
956 wake_up(&md->wait);
948 957
949 dm_table_put(map);
950 return r; 958 return r;
951} 959}
952 960
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index b59e47272abf..3720f0e03a16 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * experimental driver for simple i2c audio chips. 2 * Driver for simple i2c audio chips.
3 * 3 *
4 * Copyright (c) 2000 Gerd Knorr 4 * Copyright (c) 2000 Gerd Knorr
5 * based on code by: 5 * based on code by:
@@ -7,6 +7,10 @@
7 * Steve VanDeBogart (vandebo@uclink.berkeley.edu) 7 * Steve VanDeBogart (vandebo@uclink.berkeley.edu)
8 * Greg Alexander (galexand@acm.org) 8 * Greg Alexander (galexand@acm.org)
9 * 9 *
10 * Copyright(c) 2005-2008 Mauro Carvalho Chehab
11 * - Some cleanups, code fixes, etc
12 * - Convert it to V4L2 API
13 *
10 * This code is placed under the terms of the GNU General Public License 14 * This code is placed under the terms of the GNU General Public License
11 * 15 *
12 * OPTIONS: 16 * OPTIONS:
@@ -30,6 +34,7 @@
30 34
31#include <media/tvaudio.h> 35#include <media/tvaudio.h>
32#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
33#include <media/v4l2-chip-ident.h> 38#include <media/v4l2-chip-ident.h>
34#include <media/v4l2-i2c-drv-legacy.h> 39#include <media/v4l2-i2c-drv-legacy.h>
35 40
@@ -58,7 +63,6 @@ typedef int (*checkit)(struct CHIPSTATE*);
58typedef int (*initialize)(struct CHIPSTATE*); 63typedef int (*initialize)(struct CHIPSTATE*);
59typedef int (*getmode)(struct CHIPSTATE*); 64typedef int (*getmode)(struct CHIPSTATE*);
60typedef void (*setmode)(struct CHIPSTATE*, int mode); 65typedef void (*setmode)(struct CHIPSTATE*, int mode);
61typedef void (*checkmode)(struct CHIPSTATE*);
62 66
63/* i2c command */ 67/* i2c command */
64typedef struct AUDIOCMD { 68typedef struct AUDIOCMD {
@@ -79,6 +83,7 @@ struct CHIPDESC {
79#define CHIP_HAS_VOLUME 1 83#define CHIP_HAS_VOLUME 1
80#define CHIP_HAS_BASSTREBLE 2 84#define CHIP_HAS_BASSTREBLE 2
81#define CHIP_HAS_INPUTSEL 4 85#define CHIP_HAS_INPUTSEL 4
86#define CHIP_NEED_CHECKMODE 8
82 87
83 /* various i2c command sequences */ 88 /* various i2c command sequences */
84 audiocmd init; 89 audiocmd init;
@@ -96,23 +101,20 @@ struct CHIPDESC {
96 getmode getmode; 101 getmode getmode;
97 setmode setmode; 102 setmode setmode;
98 103
99 /* check / autoswitch audio after channel switches */
100 checkmode checkmode;
101
102 /* input switch register + values for v4l inputs */ 104 /* input switch register + values for v4l inputs */
103 int inputreg; 105 int inputreg;
104 int inputmap[4]; 106 int inputmap[4];
105 int inputmute; 107 int inputmute;
106 int inputmask; 108 int inputmask;
107}; 109};
108static struct CHIPDESC chiplist[];
109 110
110/* current state of the chip */ 111/* current state of the chip */
111struct CHIPSTATE { 112struct CHIPSTATE {
112 struct i2c_client *c; 113 struct i2c_client *c;
113 114
114 /* index into CHIPDESC array */ 115 /* chip-specific description - should point to
115 int type; 116 an entry at CHIPDESC table */
117 struct CHIPDESC *desc;
116 118
117 /* shadow register set */ 119 /* shadow register set */
118 audiocmd shadow; 120 audiocmd shadow;
@@ -152,7 +154,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
152{ 154{
153 unsigned char buffer[2]; 155 unsigned char buffer[2];
154 156
155 if (-1 == subaddr) { 157 if (subaddr < 0) {
156 v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", 158 v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n",
157 chip->c->name, val); 159 chip->c->name, val);
158 chip->shadow.bytes[1] = val; 160 chip->shadow.bytes[1] = val;
@@ -163,6 +165,13 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
163 return -1; 165 return -1;
164 } 166 }
165 } else { 167 } else {
168 if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
169 v4l_info(chip->c,
170 "Tried to access a non-existent register: %d\n",
171 subaddr);
172 return -EINVAL;
173 }
174
166 v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", 175 v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n",
167 chip->c->name, subaddr, val); 176 chip->c->name, subaddr, val);
168 chip->shadow.bytes[subaddr+1] = val; 177 chip->shadow.bytes[subaddr+1] = val;
@@ -177,12 +186,20 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
177 return 0; 186 return 0;
178} 187}
179 188
180static int chip_write_masked(struct CHIPSTATE *chip, int subaddr, int val, int mask) 189static int chip_write_masked(struct CHIPSTATE *chip,
190 int subaddr, int val, int mask)
181{ 191{
182 if (mask != 0) { 192 if (mask != 0) {
183 if (-1 == subaddr) { 193 if (subaddr < 0) {
184 val = (chip->shadow.bytes[1] & ~mask) | (val & mask); 194 val = (chip->shadow.bytes[1] & ~mask) | (val & mask);
185 } else { 195 } else {
196 if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
197 v4l_info(chip->c,
198 "Tried to access a non-existent register: %d\n",
199 subaddr);
200 return -EINVAL;
201 }
202
186 val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); 203 val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask);
187 } 204 }
188 } 205 }
@@ -228,6 +245,15 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
228 if (0 == cmd->count) 245 if (0 == cmd->count)
229 return 0; 246 return 0;
230 247
248 if (cmd->count + cmd->bytes[0] - 1 >= ARRAY_SIZE(chip->shadow.bytes)) {
249 v4l_info(chip->c,
250 "Tried to access a non-existent register range: %d to %d\n",
251 cmd->bytes[0] + 1, cmd->bytes[0] + cmd->count - 1);
252 return -EINVAL;
253 }
254
255 /* FIXME: it seems that the shadow bytes are wrong bellow !*/
256
231 /* update our shadow register set; print bytes if (debug > 0) */ 257 /* update our shadow register set; print bytes if (debug > 0) */
232 v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", 258 v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:",
233 chip->c->name, name,cmd->bytes[0]); 259 chip->c->name, name,cmd->bytes[0]);
@@ -263,7 +289,8 @@ static void chip_thread_wake(unsigned long data)
263static int chip_thread(void *data) 289static int chip_thread(void *data)
264{ 290{
265 struct CHIPSTATE *chip = data; 291 struct CHIPSTATE *chip = data;
266 struct CHIPDESC *desc = chiplist + chip->type; 292 struct CHIPDESC *desc = chip->desc;
293 int mode;
267 294
268 v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); 295 v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name);
269 set_freezable(); 296 set_freezable();
@@ -282,7 +309,26 @@ static int chip_thread(void *data)
282 continue; 309 continue;
283 310
284 /* have a look what's going on */ 311 /* have a look what's going on */
285 desc->checkmode(chip); 312 mode = desc->getmode(chip);
313 if (mode == chip->prevmode)
314 continue;
315
316 /* chip detected a new audio mode - set it */
317 v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n",
318 chip->c->name);
319
320 chip->prevmode = mode;
321
322 if (mode & V4L2_TUNER_MODE_STEREO)
323 desc->setmode(chip, V4L2_TUNER_MODE_STEREO);
324 if (mode & V4L2_TUNER_MODE_LANG1_LANG2)
325 desc->setmode(chip, V4L2_TUNER_MODE_STEREO);
326 else if (mode & V4L2_TUNER_MODE_LANG1)
327 desc->setmode(chip, V4L2_TUNER_MODE_LANG1);
328 else if (mode & V4L2_TUNER_MODE_LANG2)
329 desc->setmode(chip, V4L2_TUNER_MODE_LANG2);
330 else
331 desc->setmode(chip, V4L2_TUNER_MODE_MONO);
286 332
287 /* schedule next check */ 333 /* schedule next check */
288 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 334 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
@@ -292,29 +338,6 @@ static int chip_thread(void *data)
292 return 0; 338 return 0;
293} 339}
294 340
295static void generic_checkmode(struct CHIPSTATE *chip)
296{
297 struct CHIPDESC *desc = chiplist + chip->type;
298 int mode = desc->getmode(chip);
299
300 if (mode == chip->prevmode)
301 return;
302
303 v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", chip->c->name);
304 chip->prevmode = mode;
305
306 if (mode & V4L2_TUNER_MODE_STEREO)
307 desc->setmode(chip,V4L2_TUNER_MODE_STEREO);
308 if (mode & V4L2_TUNER_MODE_LANG1_LANG2)
309 desc->setmode(chip,V4L2_TUNER_MODE_STEREO);
310 else if (mode & V4L2_TUNER_MODE_LANG1)
311 desc->setmode(chip,V4L2_TUNER_MODE_LANG1);
312 else if (mode & V4L2_TUNER_MODE_LANG2)
313 desc->setmode(chip,V4L2_TUNER_MODE_LANG2);
314 else
315 desc->setmode(chip,V4L2_TUNER_MODE_MONO);
316}
317
318/* ---------------------------------------------------------------------- */ 341/* ---------------------------------------------------------------------- */
319/* audio chip descriptions - defines+functions for tda9840 */ 342/* audio chip descriptions - defines+functions for tda9840 */
320 343
@@ -777,7 +800,7 @@ static struct tda9874a_MODES {
777 char *name; 800 char *name;
778 audiocmd cmd; 801 audiocmd cmd;
779} tda9874a_modelist[9] = { 802} tda9874a_modelist[9] = {
780 { "A2, B/G", 803 { "A2, B/G", /* default */
781 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, 804 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} },
782 { "A2, M (Korea)", 805 { "A2, M (Korea)",
783 { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, 806 { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} },
@@ -791,7 +814,7 @@ static struct tda9874a_MODES {
791 { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, 814 { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} },
792 { "NICAM, B/G", 815 { "NICAM, B/G",
793 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, 816 { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} },
794 { "NICAM, D/K", /* default */ 817 { "NICAM, D/K",
795 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, 818 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} },
796 { "NICAM, L", 819 { "NICAM, L",
797 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } 820 { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} }
@@ -981,7 +1004,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip)
981{ 1004{
982 if (tda9874a_SIF > 2) 1005 if (tda9874a_SIF > 2)
983 tda9874a_SIF = 1; 1006 tda9874a_SIF = 1;
984 if (tda9874a_STD > 8) 1007 if (tda9874a_STD >= ARRAY_SIZE(tda9874a_modelist))
985 tda9874a_STD = 0; 1008 tda9874a_STD = 0;
986 if(tda9874a_AMSEL > 1) 1009 if(tda9874a_AMSEL > 1)
987 tda9874a_AMSEL = 0; 1010 tda9874a_AMSEL = 0;
@@ -1089,7 +1112,7 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; }
1089 1112
1090static int tda8425_initialize(struct CHIPSTATE *chip) 1113static int tda8425_initialize(struct CHIPSTATE *chip)
1091{ 1114{
1092 struct CHIPDESC *desc = chiplist + chip->type; 1115 struct CHIPDESC *desc = chip->desc;
1093 int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, 1116 int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
1094 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; 1117 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF};
1095 1118
@@ -1259,27 +1282,28 @@ static struct CHIPDESC chiplist[] = {
1259 .addr_lo = I2C_ADDR_TDA9840 >> 1, 1282 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1260 .addr_hi = I2C_ADDR_TDA9840 >> 1, 1283 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1261 .registers = 5, 1284 .registers = 5,
1285 .flags = CHIP_NEED_CHECKMODE,
1262 1286
1287 /* callbacks */
1263 .checkit = tda9840_checkit, 1288 .checkit = tda9840_checkit,
1264 .getmode = tda9840_getmode, 1289 .getmode = tda9840_getmode,
1265 .setmode = tda9840_setmode, 1290 .setmode = tda9840_setmode,
1266 .checkmode = generic_checkmode,
1267 1291
1268 .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN 1292 .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN
1269 /* ,TDA9840_SW, TDA9840_MONO */} } 1293 /* ,TDA9840_SW, TDA9840_MONO */} }
1270 }, 1294 },
1271 { 1295 {
1272 .name = "tda9873h", 1296 .name = "tda9873h",
1273 .checkit = tda9873_checkit,
1274 .insmodopt = &tda9873, 1297 .insmodopt = &tda9873,
1275 .addr_lo = I2C_ADDR_TDA985x_L >> 1, 1298 .addr_lo = I2C_ADDR_TDA985x_L >> 1,
1276 .addr_hi = I2C_ADDR_TDA985x_H >> 1, 1299 .addr_hi = I2C_ADDR_TDA985x_H >> 1,
1277 .registers = 3, 1300 .registers = 3,
1278 .flags = CHIP_HAS_INPUTSEL, 1301 .flags = CHIP_HAS_INPUTSEL | CHIP_NEED_CHECKMODE,
1279 1302
1303 /* callbacks */
1304 .checkit = tda9873_checkit,
1280 .getmode = tda9873_getmode, 1305 .getmode = tda9873_getmode,
1281 .setmode = tda9873_setmode, 1306 .setmode = tda9873_setmode,
1282 .checkmode = generic_checkmode,
1283 1307
1284 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, 1308 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } },
1285 .inputreg = TDA9873_SW, 1309 .inputreg = TDA9873_SW,
@@ -1290,15 +1314,16 @@ static struct CHIPDESC chiplist[] = {
1290 }, 1314 },
1291 { 1315 {
1292 .name = "tda9874h/a", 1316 .name = "tda9874h/a",
1293 .checkit = tda9874a_checkit,
1294 .initialize = tda9874a_initialize,
1295 .insmodopt = &tda9874a, 1317 .insmodopt = &tda9874a,
1296 .addr_lo = I2C_ADDR_TDA9874 >> 1, 1318 .addr_lo = I2C_ADDR_TDA9874 >> 1,
1297 .addr_hi = I2C_ADDR_TDA9874 >> 1, 1319 .addr_hi = I2C_ADDR_TDA9874 >> 1,
1320 .flags = CHIP_NEED_CHECKMODE,
1298 1321
1322 /* callbacks */
1323 .initialize = tda9874a_initialize,
1324 .checkit = tda9874a_checkit,
1299 .getmode = tda9874a_getmode, 1325 .getmode = tda9874a_getmode,
1300 .setmode = tda9874a_setmode, 1326 .setmode = tda9874a_setmode,
1301 .checkmode = generic_checkmode,
1302 }, 1327 },
1303 { 1328 {
1304 .name = "tda9850", 1329 .name = "tda9850",
@@ -1324,10 +1349,11 @@ static struct CHIPDESC chiplist[] = {
1324 .rightreg = TDA9855_VR, 1349 .rightreg = TDA9855_VR,
1325 .bassreg = TDA9855_BA, 1350 .bassreg = TDA9855_BA,
1326 .treblereg = TDA9855_TR, 1351 .treblereg = TDA9855_TR,
1352
1353 /* callbacks */
1327 .volfunc = tda9855_volume, 1354 .volfunc = tda9855_volume,
1328 .bassfunc = tda9855_bass, 1355 .bassfunc = tda9855_bass,
1329 .treblefunc = tda9855_treble, 1356 .treblefunc = tda9855_treble,
1330
1331 .getmode = tda985x_getmode, 1357 .getmode = tda985x_getmode,
1332 .setmode = tda985x_setmode, 1358 .setmode = tda985x_setmode,
1333 1359
@@ -1348,6 +1374,8 @@ static struct CHIPDESC chiplist[] = {
1348 .rightreg = TEA6300_VL, 1374 .rightreg = TEA6300_VL,
1349 .bassreg = TEA6300_BA, 1375 .bassreg = TEA6300_BA,
1350 .treblereg = TEA6300_TR, 1376 .treblereg = TEA6300_TR,
1377
1378 /* callbacks */
1351 .volfunc = tea6300_shift10, 1379 .volfunc = tea6300_shift10,
1352 .bassfunc = tea6300_shift12, 1380 .bassfunc = tea6300_shift12,
1353 .treblefunc = tea6300_shift12, 1381 .treblefunc = tea6300_shift12,
@@ -1358,7 +1386,6 @@ static struct CHIPDESC chiplist[] = {
1358 }, 1386 },
1359 { 1387 {
1360 .name = "tea6320", 1388 .name = "tea6320",
1361 .initialize = tea6320_initialize,
1362 .insmodopt = &tea6320, 1389 .insmodopt = &tea6320,
1363 .addr_lo = I2C_ADDR_TEA6300 >> 1, 1390 .addr_lo = I2C_ADDR_TEA6300 >> 1,
1364 .addr_hi = I2C_ADDR_TEA6300 >> 1, 1391 .addr_hi = I2C_ADDR_TEA6300 >> 1,
@@ -1369,6 +1396,9 @@ static struct CHIPDESC chiplist[] = {
1369 .rightreg = TEA6320_V, 1396 .rightreg = TEA6320_V,
1370 .bassreg = TEA6320_BA, 1397 .bassreg = TEA6320_BA,
1371 .treblereg = TEA6320_TR, 1398 .treblereg = TEA6320_TR,
1399
1400 /* callbacks */
1401 .initialize = tea6320_initialize,
1372 .volfunc = tea6320_volume, 1402 .volfunc = tea6320_volume,
1373 .bassfunc = tea6320_shift11, 1403 .bassfunc = tea6320_shift11,
1374 .treblefunc = tea6320_shift11, 1404 .treblefunc = tea6320_shift11,
@@ -1401,16 +1431,18 @@ static struct CHIPDESC chiplist[] = {
1401 .rightreg = TDA8425_VR, 1431 .rightreg = TDA8425_VR,
1402 .bassreg = TDA8425_BA, 1432 .bassreg = TDA8425_BA,
1403 .treblereg = TDA8425_TR, 1433 .treblereg = TDA8425_TR,
1434
1435 /* callbacks */
1436 .initialize = tda8425_initialize,
1404 .volfunc = tda8425_shift10, 1437 .volfunc = tda8425_shift10,
1405 .bassfunc = tda8425_shift12, 1438 .bassfunc = tda8425_shift12,
1406 .treblefunc = tda8425_shift12, 1439 .treblefunc = tda8425_shift12,
1440 .setmode = tda8425_setmode,
1407 1441
1408 .inputreg = TDA8425_S1, 1442 .inputreg = TDA8425_S1,
1409 .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, 1443 .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 },
1410 .inputmute = TDA8425_S1_OFF, 1444 .inputmute = TDA8425_S1_OFF,
1411 1445
1412 .setmode = tda8425_setmode,
1413 .initialize = tda8425_initialize,
1414 }, 1446 },
1415 { 1447 {
1416 .name = "pic16c54 (PV951)", 1448 .name = "pic16c54 (PV951)",
@@ -1434,10 +1466,11 @@ static struct CHIPDESC chiplist[] = {
1434 .addr_lo = I2C_ADDR_TDA9840 >> 1, 1466 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1435 .addr_hi = I2C_ADDR_TDA9840 >> 1, 1467 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1436 .registers = 2, 1468 .registers = 2,
1469 .flags = CHIP_NEED_CHECKMODE,
1437 1470
1471 /* callbacks */
1438 .getmode = ta8874z_getmode, 1472 .getmode = ta8874z_getmode,
1439 .setmode = ta8874z_setmode, 1473 .setmode = ta8874z_setmode,
1440 .checkmode = generic_checkmode,
1441 1474
1442 .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, 1475 .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}},
1443 }, 1476 },
@@ -1481,6 +1514,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1481 } 1514 }
1482 if (desc->name == NULL) { 1515 if (desc->name == NULL) {
1483 v4l_dbg(1, debug, client, "no matching chip description found\n"); 1516 v4l_dbg(1, debug, client, "no matching chip description found\n");
1517 kfree(chip);
1484 return -EIO; 1518 return -EIO;
1485 } 1519 }
1486 v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); 1520 v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name);
@@ -1494,7 +1528,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1494 /* fill required data structures */ 1528 /* fill required data structures */
1495 if (!id) 1529 if (!id)
1496 strlcpy(client->name, desc->name, I2C_NAME_SIZE); 1530 strlcpy(client->name, desc->name, I2C_NAME_SIZE);
1497 chip->type = desc-chiplist; 1531 chip->desc = desc;
1498 chip->shadow.count = desc->registers+1; 1532 chip->shadow.count = desc->registers+1;
1499 chip->prevmode = -1; 1533 chip->prevmode = -1;
1500 chip->audmode = V4L2_TUNER_MODE_LANG1; 1534 chip->audmode = V4L2_TUNER_MODE_LANG1;
@@ -1506,20 +1540,49 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1506 chip_cmd(chip,"init",&desc->init); 1540 chip_cmd(chip,"init",&desc->init);
1507 1541
1508 if (desc->flags & CHIP_HAS_VOLUME) { 1542 if (desc->flags & CHIP_HAS_VOLUME) {
1509 chip->left = desc->leftinit ? desc->leftinit : 65535; 1543 if (!desc->volfunc) {
1510 chip->right = desc->rightinit ? desc->rightinit : 65535; 1544 /* This shouldn't be happen. Warn user, but keep working
1511 chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); 1545 without volume controls
1512 chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); 1546 */
1547 v4l_info(chip->c, "volume callback undefined!\n");
1548 desc->flags &= ~CHIP_HAS_VOLUME;
1549 } else {
1550 chip->left = desc->leftinit ? desc->leftinit : 65535;
1551 chip->right = desc->rightinit ? desc->rightinit : 65535;
1552 chip_write(chip, desc->leftreg,
1553 desc->volfunc(chip->left));
1554 chip_write(chip, desc->rightreg,
1555 desc->volfunc(chip->right));
1556 }
1513 } 1557 }
1514 if (desc->flags & CHIP_HAS_BASSTREBLE) { 1558 if (desc->flags & CHIP_HAS_BASSTREBLE) {
1515 chip->treble = desc->trebleinit ? desc->trebleinit : 32768; 1559 if (!desc->bassfunc || !desc->treblefunc) {
1516 chip->bass = desc->bassinit ? desc->bassinit : 32768; 1560 /* This shouldn't be happen. Warn user, but keep working
1517 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); 1561 without bass/treble controls
1518 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1562 */
1563 v4l_info(chip->c, "bass/treble callbacks undefined!\n");
1564 desc->flags &= ~CHIP_HAS_BASSTREBLE;
1565 } else {
1566 chip->treble = desc->trebleinit ?
1567 desc->trebleinit : 32768;
1568 chip->bass = desc->bassinit ?
1569 desc->bassinit : 32768;
1570 chip_write(chip, desc->bassreg,
1571 desc->bassfunc(chip->bass));
1572 chip_write(chip, desc->treblereg,
1573 desc->treblefunc(chip->treble));
1574 }
1519 } 1575 }
1520 1576
1521 chip->thread = NULL; 1577 chip->thread = NULL;
1522 if (desc->checkmode) { 1578 if (desc->flags & CHIP_NEED_CHECKMODE) {
1579 if (!desc->getmode || !desc->setmode) {
1580 /* This shouldn't be happen. Warn user, but keep working
1581 without kthread
1582 */
1583 v4l_info(chip->c, "set/get mode callbacks undefined!\n");
1584 return 0;
1585 }
1523 /* start async thread */ 1586 /* start async thread */
1524 init_timer(&chip->wt); 1587 init_timer(&chip->wt);
1525 chip->wt.function = chip_thread_wake; 1588 chip->wt.function = chip_thread_wake;
@@ -1552,7 +1615,7 @@ static int chip_remove(struct i2c_client *client)
1552static int tvaudio_get_ctrl(struct CHIPSTATE *chip, 1615static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1553 struct v4l2_control *ctrl) 1616 struct v4l2_control *ctrl)
1554{ 1617{
1555 struct CHIPDESC *desc = chiplist + chip->type; 1618 struct CHIPDESC *desc = chip->desc;
1556 1619
1557 switch (ctrl->id) { 1620 switch (ctrl->id) {
1558 case V4L2_CID_AUDIO_MUTE: 1621 case V4L2_CID_AUDIO_MUTE:
@@ -1576,13 +1639,13 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1576 return 0; 1639 return 0;
1577 } 1640 }
1578 case V4L2_CID_AUDIO_BASS: 1641 case V4L2_CID_AUDIO_BASS:
1579 if (desc->flags & CHIP_HAS_BASSTREBLE) 1642 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1580 break; 1643 break;
1581 ctrl->value = chip->bass; 1644 ctrl->value = chip->bass;
1582 return 0; 1645 return 0;
1583 case V4L2_CID_AUDIO_TREBLE: 1646 case V4L2_CID_AUDIO_TREBLE:
1584 if (desc->flags & CHIP_HAS_BASSTREBLE) 1647 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1585 return -EINVAL; 1648 break;
1586 ctrl->value = chip->treble; 1649 ctrl->value = chip->treble;
1587 return 0; 1650 return 0;
1588 } 1651 }
@@ -1592,7 +1655,7 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1592static int tvaudio_set_ctrl(struct CHIPSTATE *chip, 1655static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1593 struct v4l2_control *ctrl) 1656 struct v4l2_control *ctrl)
1594{ 1657{
1595 struct CHIPDESC *desc = chiplist + chip->type; 1658 struct CHIPDESC *desc = chip->desc;
1596 1659
1597 switch (ctrl->id) { 1660 switch (ctrl->id) {
1598 case V4L2_CID_AUDIO_MUTE: 1661 case V4L2_CID_AUDIO_MUTE:
@@ -1642,16 +1705,15 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1642 return 0; 1705 return 0;
1643 } 1706 }
1644 case V4L2_CID_AUDIO_BASS: 1707 case V4L2_CID_AUDIO_BASS:
1645 if (desc->flags & CHIP_HAS_BASSTREBLE) 1708 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1646 break; 1709 break;
1647 chip->bass = ctrl->value; 1710 chip->bass = ctrl->value;
1648 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); 1711 chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass));
1649 1712
1650 return 0; 1713 return 0;
1651 case V4L2_CID_AUDIO_TREBLE: 1714 case V4L2_CID_AUDIO_TREBLE:
1652 if (desc->flags & CHIP_HAS_BASSTREBLE) 1715 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1653 return -EINVAL; 1716 break;
1654
1655 chip->treble = ctrl->value; 1717 chip->treble = ctrl->value;
1656 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1718 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble));
1657 1719
@@ -1668,9 +1730,12 @@ static int chip_command(struct i2c_client *client,
1668 unsigned int cmd, void *arg) 1730 unsigned int cmd, void *arg)
1669{ 1731{
1670 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1732 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1671 struct CHIPDESC *desc = chiplist + chip->type; 1733 struct CHIPDESC *desc = chip->desc;
1672 1734
1673 v4l_dbg(1, debug, chip->c, "%s: chip_command 0x%x\n", chip->c->name, cmd); 1735 if (debug > 0) {
1736 v4l_i2c_print_ioctl(chip->c, cmd);
1737 printk("\n");
1738 }
1674 1739
1675 switch (cmd) { 1740 switch (cmd) {
1676 case AUDC_SET_RADIO: 1741 case AUDC_SET_RADIO:
@@ -1695,7 +1760,7 @@ static int chip_command(struct i2c_client *client,
1695 break; 1760 break;
1696 case V4L2_CID_AUDIO_BASS: 1761 case V4L2_CID_AUDIO_BASS:
1697 case V4L2_CID_AUDIO_TREBLE: 1762 case V4L2_CID_AUDIO_TREBLE:
1698 if (desc->flags & CHIP_HAS_BASSTREBLE) 1763 if (!(desc->flags & CHIP_HAS_BASSTREBLE))
1699 return -EINVAL; 1764 return -EINVAL;
1700 break; 1765 break;
1701 default: 1766 default:
@@ -1792,12 +1857,20 @@ static int chip_command(struct i2c_client *client,
1792 break; 1857 break;
1793 case VIDIOC_S_FREQUENCY: 1858 case VIDIOC_S_FREQUENCY:
1794 chip->mode = 0; /* automatic */ 1859 chip->mode = 0; /* automatic */
1795 if (desc->checkmode && desc->setmode) { 1860
1861 /* For chips that provide getmode and setmode, and doesn't
1862 automatically follows the stereo carrier, a kthread is
1863 created to set the audio standard. In this case, when then
1864 the video channel is changed, tvaudio starts on MONO mode.
1865 After waiting for 2 seconds, the kernel thread is called,
1866 to follow whatever audio standard is pointed by the
1867 audio carrier.
1868 */
1869 if (chip->thread) {
1796 desc->setmode(chip,V4L2_TUNER_MODE_MONO); 1870 desc->setmode(chip,V4L2_TUNER_MODE_MONO);
1797 if (chip->prevmode != V4L2_TUNER_MODE_MONO) 1871 if (chip->prevmode != V4L2_TUNER_MODE_MONO)
1798 chip->prevmode = -1; /* reset previous mode */ 1872 chip->prevmode = -1; /* reset previous mode */
1799 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 1873 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
1800 /* the thread will call checkmode() later */
1801 } 1874 }
1802 break; 1875 break;
1803 1876
@@ -1836,9 +1909,3 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1836 .legacy_probe = chip_legacy_probe, 1909 .legacy_probe = chip_legacy_probe,
1837 .id_table = chip_id, 1910 .id_table = chip_id,
1838}; 1911};
1839
1840/*
1841 * Local variables:
1842 * c-basic-offset: 8
1843 * End:
1844 */
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index b57326ae464d..0b5bd85dfcec 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -267,7 +267,7 @@ static int da9030_mask_events(struct da903x_chip *chip, unsigned int events)
267{ 267{
268 uint8_t v[3]; 268 uint8_t v[3];
269 269
270 chip->events_mask &= ~events; 270 chip->events_mask |= events;
271 271
272 v[0] = (chip->events_mask & 0xff); 272 v[0] = (chip->events_mask & 0xff);
273 v[1] = (chip->events_mask >> 8) & 0xff; 273 v[1] = (chip->events_mask >> 8) & 0xff;
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 8dfe21bb3bd1..3e0ce0e50ea2 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -30,7 +30,12 @@ static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
30 ret = i2c_master_send(wm8350->i2c_client, &reg, 1); 30 ret = i2c_master_send(wm8350->i2c_client, &reg, 1);
31 if (ret < 0) 31 if (ret < 0)
32 return ret; 32 return ret;
33 return i2c_master_recv(wm8350->i2c_client, dest, bytes); 33 ret = i2c_master_recv(wm8350->i2c_client, dest, bytes);
34 if (ret < 0)
35 return ret;
36 if (ret != bytes)
37 return -EIO;
38 return 0;
34} 39}
35 40
36static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, 41static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
@@ -38,13 +43,19 @@ static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
38{ 43{
39 /* we add 1 byte for device register */ 44 /* we add 1 byte for device register */
40 u8 msg[(WM8350_MAX_REGISTER << 1) + 1]; 45 u8 msg[(WM8350_MAX_REGISTER << 1) + 1];
46 int ret;
41 47
42 if (bytes > ((WM8350_MAX_REGISTER << 1) + 1)) 48 if (bytes > ((WM8350_MAX_REGISTER << 1) + 1))
43 return -EINVAL; 49 return -EINVAL;
44 50
45 msg[0] = reg; 51 msg[0] = reg;
46 memcpy(&msg[1], src, bytes); 52 memcpy(&msg[1], src, bytes);
47 return i2c_master_send(wm8350->i2c_client, msg, bytes + 1); 53 ret = i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
54 if (ret < 0)
55 return ret;
56 if (ret != bytes + 1)
57 return -EIO;
58 return 0;
48} 59}
49 60
50static int wm8350_i2c_probe(struct i2c_client *i2c, 61static int wm8350_i2c_probe(struct i2c_client *i2c,
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index 976b35d1d035..0207dd59090d 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -18,6 +18,7 @@
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/idr.h> 20#include <linux/idr.h>
21#include <linux/sched.h>
21 22
22#include <linux/c2port.h> 23#include <linux/c2port.h>
23 24
diff --git a/drivers/misc/sgi-gru/Makefile b/drivers/misc/sgi-gru/Makefile
index d03597a521b0..9e9170b3599a 100644
--- a/drivers/misc/sgi-gru/Makefile
+++ b/drivers/misc/sgi-gru/Makefile
@@ -1,3 +1,7 @@
1ifdef CONFIG_SGI_GRU_DEBUG
2 EXTRA_CFLAGS += -DDEBUG
3endif
4
1obj-$(CONFIG_SGI_GRU) := gru.o 5obj-$(CONFIG_SGI_GRU) := gru.o
2gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o 6gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o
3 7
diff --git a/drivers/mtd/maps/cdb89712.c b/drivers/mtd/maps/cdb89712.c
index e5059aa3c724..8d92d8db9a98 100644
--- a/drivers/mtd/maps/cdb89712.c
+++ b/drivers/mtd/maps/cdb89712.c
@@ -14,7 +14,18 @@
14#include <linux/mtd/map.h> 14#include <linux/mtd/map.h>
15#include <linux/mtd/partitions.h> 15#include <linux/mtd/partitions.h>
16 16
17 17/* dynamic ioremap() areas */
18#define FLASH_START 0x00000000
19#define FLASH_SIZE 0x800000
20#define FLASH_WIDTH 4
21
22#define SRAM_START 0x60000000
23#define SRAM_SIZE 0xc000
24#define SRAM_WIDTH 4
25
26#define BOOTROM_START 0x70000000
27#define BOOTROM_SIZE 0x80
28#define BOOTROM_WIDTH 4
18 29
19 30
20static struct mtd_info *flash_mtd; 31static struct mtd_info *flash_mtd;
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
index 35fef655ccc4..3b959fad1c4e 100644
--- a/drivers/mtd/maps/h720x-flash.c
+++ b/drivers/mtd/maps/h720x-flash.c
@@ -24,8 +24,8 @@ static struct mtd_info *mymtd;
24static struct map_info h720x_map = { 24static struct map_info h720x_map = {
25 .name = "H720X", 25 .name = "H720X",
26 .bankwidth = 4, 26 .bankwidth = 4,
27 .size = FLASH_SIZE, 27 .size = H720X_FLASH_SIZE,
28 .phys = FLASH_PHYS, 28 .phys = H720X_FLASH_PHYS,
29}; 29};
30 30
31static struct mtd_partition h720x_partitions[] = { 31static struct mtd_partition h720x_partitions[] = {
@@ -70,7 +70,7 @@ int __init h720x_mtd_init(void)
70 70
71 char *part_type = NULL; 71 char *part_type = NULL;
72 72
73 h720x_map.virt = ioremap(FLASH_PHYS, FLASH_SIZE); 73 h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size);
74 74
75 if (!h720x_map.virt) { 75 if (!h720x_map.virt) {
76 printk(KERN_ERR "H720x-MTD: ioremap failed\n"); 76 printk(KERN_ERR "H720x-MTD: ioremap failed\n");
diff --git a/drivers/net/atl1e/atl1e_hw.c b/drivers/net/atl1e/atl1e_hw.c
index 8cbc1b59bd62..4a7700620119 100644
--- a/drivers/net/atl1e/atl1e_hw.c
+++ b/drivers/net/atl1e/atl1e_hw.c
@@ -163,9 +163,6 @@ int atl1e_read_mac_addr(struct atl1e_hw *hw)
163 * atl1e_hash_mc_addr 163 * atl1e_hash_mc_addr
164 * purpose 164 * purpose
165 * set hash value for a multicast address 165 * set hash value for a multicast address
166 * hash calcu processing :
167 * 1. calcu 32bit CRC for multicast address
168 * 2. reverse crc with MSB to LSB
169 */ 166 */
170u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr) 167u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr)
171{ 168{
@@ -174,7 +171,6 @@ u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr)
174 int i; 171 int i;
175 172
176 crc32 = ether_crc_le(6, mc_addr); 173 crc32 = ether_crc_le(6, mc_addr);
177 crc32 = ~crc32;
178 for (i = 0; i < 32; i++) 174 for (i = 0; i < 32; i++)
179 value |= (((crc32 >> i) & 1) << (31 - i)); 175 value |= (((crc32 >> i) & 1) << (31 - i));
180 176
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 246d92b42636..aef403d299ee 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -3404,14 +3404,8 @@ static void atl1_get_wol(struct net_device *netdev,
3404{ 3404{
3405 struct atl1_adapter *adapter = netdev_priv(netdev); 3405 struct atl1_adapter *adapter = netdev_priv(netdev);
3406 3406
3407 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC; 3407 wol->supported = WAKE_MAGIC;
3408 wol->wolopts = 0; 3408 wol->wolopts = 0;
3409 if (adapter->wol & ATLX_WUFC_EX)
3410 wol->wolopts |= WAKE_UCAST;
3411 if (adapter->wol & ATLX_WUFC_MC)
3412 wol->wolopts |= WAKE_MCAST;
3413 if (adapter->wol & ATLX_WUFC_BC)
3414 wol->wolopts |= WAKE_BCAST;
3415 if (adapter->wol & ATLX_WUFC_MAG) 3409 if (adapter->wol & ATLX_WUFC_MAG)
3416 wol->wolopts |= WAKE_MAGIC; 3410 wol->wolopts |= WAKE_MAGIC;
3417 return; 3411 return;
@@ -3422,15 +3416,10 @@ static int atl1_set_wol(struct net_device *netdev,
3422{ 3416{
3423 struct atl1_adapter *adapter = netdev_priv(netdev); 3417 struct atl1_adapter *adapter = netdev_priv(netdev);
3424 3418
3425 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) 3419 if (wol->wolopts & (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST |
3420 WAKE_ARP | WAKE_MAGICSECURE))
3426 return -EOPNOTSUPP; 3421 return -EOPNOTSUPP;
3427 adapter->wol = 0; 3422 adapter->wol = 0;
3428 if (wol->wolopts & WAKE_UCAST)
3429 adapter->wol |= ATLX_WUFC_EX;
3430 if (wol->wolopts & WAKE_MCAST)
3431 adapter->wol |= ATLX_WUFC_MC;
3432 if (wol->wolopts & WAKE_BCAST)
3433 adapter->wol |= ATLX_WUFC_BC;
3434 if (wol->wolopts & WAKE_MAGIC) 3423 if (wol->wolopts & WAKE_MAGIC)
3435 adapter->wol |= ATLX_WUFC_MAG; 3424 adapter->wol |= ATLX_WUFC_MAG;
3436 return 0; 3425 return 0;
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index f5bdc92c1a65..8571e8c0bc67 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -1690,9 +1690,11 @@ static int atl2_resume(struct pci_dev *pdev)
1690 1690
1691 ATL2_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); 1691 ATL2_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0);
1692 1692
1693 err = atl2_request_irq(adapter); 1693 if (netif_running(netdev)) {
1694 if (netif_running(netdev) && err) 1694 err = atl2_request_irq(adapter);
1695 return err; 1695 if (err)
1696 return err;
1697 }
1696 1698
1697 atl2_reset_hw(&adapter->hw); 1699 atl2_reset_hw(&adapter->hw);
1698 1700
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 3d69fae781cf..e8bfcce6b319 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -166,7 +166,7 @@
166 166
167#define DRV_NAME "e100" 167#define DRV_NAME "e100"
168#define DRV_EXT "-NAPI" 168#define DRV_EXT "-NAPI"
169#define DRV_VERSION "3.5.23-k4"DRV_EXT 169#define DRV_VERSION "3.5.23-k6"DRV_EXT
170#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 170#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
171#define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" 171#define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation"
172#define PFX DRV_NAME ": " 172#define PFX DRV_NAME ": "
@@ -1804,7 +1804,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; 1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data;
1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link); 1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link);
1806 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, 1806 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr,
1807 sizeof(struct rfd), PCI_DMA_TODEVICE); 1807 sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL);
1808 } 1808 }
1809 1809
1810 return 0; 1810 return 0;
@@ -1823,7 +1823,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1823 1823
1824 /* Need to sync before taking a peek at cb_complete bit */ 1824 /* Need to sync before taking a peek at cb_complete bit */
1825 pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, 1825 pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr,
1826 sizeof(struct rfd), PCI_DMA_FROMDEVICE); 1826 sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL);
1827 rfd_status = le16_to_cpu(rfd->status); 1827 rfd_status = le16_to_cpu(rfd->status);
1828 1828
1829 DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); 1829 DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status);
@@ -1850,7 +1850,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1850 1850
1851 /* Get data */ 1851 /* Get data */
1852 pci_unmap_single(nic->pdev, rx->dma_addr, 1852 pci_unmap_single(nic->pdev, rx->dma_addr,
1853 RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1853 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1854 1854
1855 /* If this buffer has the el bit, but we think the receiver 1855 /* If this buffer has the el bit, but we think the receiver
1856 * is still running, check to see if it really stopped while 1856 * is still running, check to see if it really stopped while
@@ -1943,7 +1943,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1943 new_before_last_rfd->command |= cpu_to_le16(cb_el); 1943 new_before_last_rfd->command |= cpu_to_le16(cb_el);
1944 pci_dma_sync_single_for_device(nic->pdev, 1944 pci_dma_sync_single_for_device(nic->pdev,
1945 new_before_last_rx->dma_addr, sizeof(struct rfd), 1945 new_before_last_rx->dma_addr, sizeof(struct rfd),
1946 PCI_DMA_TODEVICE); 1946 PCI_DMA_BIDIRECTIONAL);
1947 1947
1948 /* Now that we have a new stopping point, we can clear the old 1948 /* Now that we have a new stopping point, we can clear the old
1949 * stopping point. We must sync twice to get the proper 1949 * stopping point. We must sync twice to get the proper
@@ -1951,11 +1951,11 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1951 old_before_last_rfd->command &= ~cpu_to_le16(cb_el); 1951 old_before_last_rfd->command &= ~cpu_to_le16(cb_el);
1952 pci_dma_sync_single_for_device(nic->pdev, 1952 pci_dma_sync_single_for_device(nic->pdev,
1953 old_before_last_rx->dma_addr, sizeof(struct rfd), 1953 old_before_last_rx->dma_addr, sizeof(struct rfd),
1954 PCI_DMA_TODEVICE); 1954 PCI_DMA_BIDIRECTIONAL);
1955 old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); 1955 old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN);
1956 pci_dma_sync_single_for_device(nic->pdev, 1956 pci_dma_sync_single_for_device(nic->pdev,
1957 old_before_last_rx->dma_addr, sizeof(struct rfd), 1957 old_before_last_rx->dma_addr, sizeof(struct rfd),
1958 PCI_DMA_TODEVICE); 1958 PCI_DMA_BIDIRECTIONAL);
1959 } 1959 }
1960 1960
1961 if(restart_required) { 1961 if(restart_required) {
@@ -1978,7 +1978,7 @@ static void e100_rx_clean_list(struct nic *nic)
1978 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1978 for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
1979 if(rx->skb) { 1979 if(rx->skb) {
1980 pci_unmap_single(nic->pdev, rx->dma_addr, 1980 pci_unmap_single(nic->pdev, rx->dma_addr,
1981 RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1981 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1982 dev_kfree_skb(rx->skb); 1982 dev_kfree_skb(rx->skb);
1983 } 1983 }
1984 } 1984 }
@@ -2021,7 +2021,7 @@ static int e100_rx_alloc_list(struct nic *nic)
2021 before_last->command |= cpu_to_le16(cb_el); 2021 before_last->command |= cpu_to_le16(cb_el);
2022 before_last->size = 0; 2022 before_last->size = 0;
2023 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, 2023 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr,
2024 sizeof(struct rfd), PCI_DMA_TODEVICE); 2024 sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL);
2025 2025
2026 nic->rx_to_use = nic->rx_to_clean = nic->rxs; 2026 nic->rx_to_use = nic->rx_to_clean = nic->rxs;
2027 nic->ru_running = RU_SUSPENDED; 2027 nic->ru_running = RU_SUSPENDED;
@@ -2222,7 +2222,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
2222 msleep(10); 2222 msleep(10);
2223 2223
2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, 2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr,
2225 RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 2225 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
2226 2226
2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), 2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd),
2228 skb->data, ETH_DATA_LEN)) 2228 skb->data, ETH_DATA_LEN))
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 6a3893acfe04..c854c96f5ab3 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1774,7 +1774,8 @@ static void e1000_get_wol(struct net_device *netdev,
1774 1774
1775 /* this function will set ->supported = 0 and return 1 if wol is not 1775 /* this function will set ->supported = 0 and return 1 if wol is not
1776 * supported by this hardware */ 1776 * supported by this hardware */
1777 if (e1000_wol_exclusion(adapter, wol)) 1777 if (e1000_wol_exclusion(adapter, wol) ||
1778 !device_can_wakeup(&adapter->pdev->dev))
1778 return; 1779 return;
1779 1780
1780 /* apply any specific unsupported masks here */ 1781 /* apply any specific unsupported masks here */
@@ -1811,7 +1812,8 @@ static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1811 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) 1812 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
1812 return -EOPNOTSUPP; 1813 return -EOPNOTSUPP;
1813 1814
1814 if (e1000_wol_exclusion(adapter, wol)) 1815 if (e1000_wol_exclusion(adapter, wol) ||
1816 !device_can_wakeup(&adapter->pdev->dev))
1815 return wol->wolopts ? -EOPNOTSUPP : 0; 1817 return wol->wolopts ? -EOPNOTSUPP : 0;
1816 1818
1817 switch (hw->device_id) { 1819 switch (hw->device_id) {
@@ -1838,6 +1840,8 @@ static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1838 if (wol->wolopts & WAKE_MAGIC) 1840 if (wol->wolopts & WAKE_MAGIC)
1839 adapter->wol |= E1000_WUFC_MAG; 1841 adapter->wol |= E1000_WUFC_MAG;
1840 1842
1843 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1844
1841 return 0; 1845 return 0;
1842} 1846}
1843 1847
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index fac82152e4c8..872799b746f5 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1179,6 +1179,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1179 1179
1180 /* initialize the wol settings based on the eeprom settings */ 1180 /* initialize the wol settings based on the eeprom settings */
1181 adapter->wol = adapter->eeprom_wol; 1181 adapter->wol = adapter->eeprom_wol;
1182 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1182 1183
1183 /* print bus type/speed/width info */ 1184 /* print bus type/speed/width info */
1184 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", 1185 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c55de1c027af..c55fd6fdb91c 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -299,6 +299,7 @@ struct e1000_adapter {
299 unsigned long led_status; 299 unsigned long led_status;
300 300
301 unsigned int flags; 301 unsigned int flags;
302 unsigned int flags2;
302 struct work_struct downshift_task; 303 struct work_struct downshift_task;
303 struct work_struct update_phy_task; 304 struct work_struct update_phy_task;
304}; 305};
@@ -306,6 +307,7 @@ struct e1000_adapter {
306struct e1000_info { 307struct e1000_info {
307 enum e1000_mac_type mac; 308 enum e1000_mac_type mac;
308 unsigned int flags; 309 unsigned int flags;
310 unsigned int flags2;
309 u32 pba; 311 u32 pba;
310 s32 (*get_variants)(struct e1000_adapter *); 312 s32 (*get_variants)(struct e1000_adapter *);
311 struct e1000_mac_operations *mac_ops; 313 struct e1000_mac_operations *mac_ops;
@@ -347,6 +349,9 @@ struct e1000_info {
347#define FLAG_RX_RESTART_NOW (1 << 30) 349#define FLAG_RX_RESTART_NOW (1 << 30)
348#define FLAG_MSI_TEST_FAILED (1 << 31) 350#define FLAG_MSI_TEST_FAILED (1 << 31)
349 351
352/* CRC Stripping defines */
353#define FLAG2_CRC_STRIPPING (1 << 0)
354
350#define E1000_RX_DESC_PS(R, i) \ 355#define E1000_RX_DESC_PS(R, i) \
351 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 356 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
352#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) 357#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 70c11c811a08..62421ce96311 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1713,7 +1713,8 @@ static void e1000_get_wol(struct net_device *netdev,
1713 wol->supported = 0; 1713 wol->supported = 0;
1714 wol->wolopts = 0; 1714 wol->wolopts = 0;
1715 1715
1716 if (!(adapter->flags & FLAG_HAS_WOL)) 1716 if (!(adapter->flags & FLAG_HAS_WOL) ||
1717 !device_can_wakeup(&adapter->pdev->dev))
1717 return; 1718 return;
1718 1719
1719 wol->supported = WAKE_UCAST | WAKE_MCAST | 1720 wol->supported = WAKE_UCAST | WAKE_MCAST |
@@ -1751,7 +1752,8 @@ static int e1000_set_wol(struct net_device *netdev,
1751 if (wol->wolopts & WAKE_MAGICSECURE) 1752 if (wol->wolopts & WAKE_MAGICSECURE)
1752 return -EOPNOTSUPP; 1753 return -EOPNOTSUPP;
1753 1754
1754 if (!(adapter->flags & FLAG_HAS_WOL)) 1755 if (!(adapter->flags & FLAG_HAS_WOL) ||
1756 !device_can_wakeup(&adapter->pdev->dev))
1755 return wol->wolopts ? -EOPNOTSUPP : 0; 1757 return wol->wolopts ? -EOPNOTSUPP : 0;
1756 1758
1757 /* these settings will always override what we currently have */ 1759 /* these settings will always override what we currently have */
@@ -1770,6 +1772,8 @@ static int e1000_set_wol(struct net_device *netdev,
1770 if (wol->wolopts & WAKE_ARP) 1772 if (wol->wolopts & WAKE_ARP)
1771 adapter->wol |= E1000_WUFC_ARP; 1773 adapter->wol |= E1000_WUFC_ARP;
1772 1774
1775 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1776
1773 return 0; 1777 return 0;
1774} 1778}
1775 1779
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index abd492b7336d..91795f78c3e4 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -499,6 +499,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
499 goto next_desc; 499 goto next_desc;
500 } 500 }
501 501
502 /* adjust length to remove Ethernet CRC */
503 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
504 length -= 4;
505
502 total_rx_bytes += length; 506 total_rx_bytes += length;
503 total_rx_packets++; 507 total_rx_packets++;
504 508
@@ -804,6 +808,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
804 pci_dma_sync_single_for_device(pdev, ps_page->dma, 808 pci_dma_sync_single_for_device(pdev, ps_page->dma,
805 PAGE_SIZE, PCI_DMA_FROMDEVICE); 809 PAGE_SIZE, PCI_DMA_FROMDEVICE);
806 810
811 /* remove the CRC */
812 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
813 l1 -= 4;
814
807 skb_put(skb, l1); 815 skb_put(skb, l1);
808 goto copydone; 816 goto copydone;
809 } /* if */ 817 } /* if */
@@ -825,6 +833,12 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
825 skb->truesize += length; 833 skb->truesize += length;
826 } 834 }
827 835
836 /* strip the ethernet crc, problem is we're using pages now so
837 * this whole operation can get a little cpu intensive
838 */
839 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
840 pskb_trim(skb, skb->len - 4);
841
828copydone: 842copydone:
829 total_rx_bytes += skb->len; 843 total_rx_bytes += skb->len;
830 total_rx_packets++; 844 total_rx_packets++;
@@ -2301,8 +2315,12 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2301 else 2315 else
2302 rctl |= E1000_RCTL_LPE; 2316 rctl |= E1000_RCTL_LPE;
2303 2317
2304 /* Enable hardware CRC frame stripping */ 2318 /* Some systems expect that the CRC is included in SMBUS traffic. The
2305 rctl |= E1000_RCTL_SECRC; 2319 * hardware strips the CRC before sending to both SMBUS (BMC) and to
2320 * host memory when this is enabled
2321 */
2322 if (adapter->flags2 & FLAG2_CRC_STRIPPING)
2323 rctl |= E1000_RCTL_SECRC;
2306 2324
2307 /* Setup buffer sizes */ 2325 /* Setup buffer sizes */
2308 rctl &= ~E1000_RCTL_SZ_4096; 2326 rctl &= ~E1000_RCTL_SZ_4096;
@@ -4766,6 +4784,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4766 adapter->ei = ei; 4784 adapter->ei = ei;
4767 adapter->pba = ei->pba; 4785 adapter->pba = ei->pba;
4768 adapter->flags = ei->flags; 4786 adapter->flags = ei->flags;
4787 adapter->flags2 = ei->flags2;
4769 adapter->hw.adapter = adapter; 4788 adapter->hw.adapter = adapter;
4770 adapter->hw.mac.type = ei->mac; 4789 adapter->hw.mac.type = ei->mac;
4771 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 4790 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
@@ -4970,6 +4989,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4970 4989
4971 /* initialize the wol settings based on the eeprom settings */ 4990 /* initialize the wol settings based on the eeprom settings */
4972 adapter->wol = adapter->eeprom_wol; 4991 adapter->wol = adapter->eeprom_wol;
4992 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
4973 4993
4974 /* reset the hardware with the new settings */ 4994 /* reset the hardware with the new settings */
4975 e1000e_reset(adapter); 4995 e1000e_reset(adapter);
@@ -5008,6 +5028,7 @@ err_hw_init:
5008err_sw_init: 5028err_sw_init:
5009 if (adapter->hw.flash_address) 5029 if (adapter->hw.flash_address)
5010 iounmap(adapter->hw.flash_address); 5030 iounmap(adapter->hw.flash_address);
5031 e1000e_reset_interrupt_capability(adapter);
5011err_flashmap: 5032err_flashmap:
5012 iounmap(adapter->hw.hw_addr); 5033 iounmap(adapter->hw.hw_addr);
5013err_ioremap: 5034err_ioremap:
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index 77a3d7207a5f..e909f96698e8 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -151,6 +151,16 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
151 */ 151 */
152E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); 152E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
153 153
154/*
155 * Enable CRC Stripping
156 *
157 * Valid Range: 0, 1
158 *
159 * Default Value: 1 (enabled)
160 */
161E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \
162 "the CRC");
163
154struct e1000_option { 164struct e1000_option {
155 enum { enable_option, range_option, list_option } type; 165 enum { enable_option, range_option, list_option } type;
156 const char *name; 166 const char *name;
@@ -404,6 +414,21 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
404 adapter->flags |= FLAG_SMART_POWER_DOWN; 414 adapter->flags |= FLAG_SMART_POWER_DOWN;
405 } 415 }
406 } 416 }
417 { /* CRC Stripping */
418 const struct e1000_option opt = {
419 .type = enable_option,
420 .name = "CRC Stripping",
421 .err = "defaulting to enabled",
422 .def = OPTION_ENABLED
423 };
424
425 if (num_CrcStripping > bd) {
426 unsigned int crc_stripping = CrcStripping[bd];
427 e1000_validate_option(&crc_stripping, &opt, adapter);
428 if (crc_stripping == OPTION_ENABLED)
429 adapter->flags2 |= FLAG2_CRC_STRIPPING;
430 }
431 }
407 { /* Kumeran Lock Loss Workaround */ 432 { /* Kumeran Lock Loss Workaround */
408 const struct e1000_option opt = { 433 const struct e1000_option opt = {
409 .type = enable_option, 434 .type = enable_option,
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 83a5cb6aa23b..c4af949bf860 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1407,6 +1407,10 @@ static int gfar_clean_tx_ring(struct net_device *dev)
1407 if (bdp->status & TXBD_DEF) 1407 if (bdp->status & TXBD_DEF)
1408 dev->stats.collisions++; 1408 dev->stats.collisions++;
1409 1409
1410 /* Unmap the DMA memory */
1411 dma_unmap_single(&priv->dev->dev, bdp->bufPtr,
1412 bdp->length, DMA_TO_DEVICE);
1413
1410 /* Free the sk buffer associated with this TxBD */ 1414 /* Free the sk buffer associated with this TxBD */
1411 dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]); 1415 dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]);
1412 1416
@@ -1666,6 +1670,9 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
1666 1670
1667 skb = priv->rx_skbuff[priv->skb_currx]; 1671 skb = priv->rx_skbuff[priv->skb_currx];
1668 1672
1673 dma_unmap_single(&priv->dev->dev, bdp->bufPtr,
1674 priv->rx_buffer_size, DMA_FROM_DEVICE);
1675
1669 /* We drop the frame if we failed to allocate a new buffer */ 1676 /* We drop the frame if we failed to allocate a new buffer */
1670 if (unlikely(!newskb || !(bdp->status & RXBD_LAST) || 1677 if (unlikely(!newskb || !(bdp->status & RXBD_LAST) ||
1671 bdp->status & RXBD_ERR)) { 1678 bdp->status & RXBD_ERR)) {
@@ -1674,14 +1681,8 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
1674 if (unlikely(!newskb)) 1681 if (unlikely(!newskb))
1675 newskb = skb; 1682 newskb = skb;
1676 1683
1677 if (skb) { 1684 if (skb)
1678 dma_unmap_single(&priv->dev->dev,
1679 bdp->bufPtr,
1680 priv->rx_buffer_size,
1681 DMA_FROM_DEVICE);
1682
1683 dev_kfree_skb_any(skb); 1685 dev_kfree_skb_any(skb);
1684 }
1685 } else { 1686 } else {
1686 /* Increment the number of packets */ 1687 /* Increment the number of packets */
1687 dev->stats.rx_packets++; 1688 dev->stats.rx_packets++;
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index 58906c984be9..89964fa739a0 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -1776,7 +1776,8 @@ static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1776 1776
1777 /* this function will set ->supported = 0 and return 1 if wol is not 1777 /* this function will set ->supported = 0 and return 1 if wol is not
1778 * supported by this hardware */ 1778 * supported by this hardware */
1779 if (igb_wol_exclusion(adapter, wol)) 1779 if (igb_wol_exclusion(adapter, wol) ||
1780 !device_can_wakeup(&adapter->pdev->dev))
1780 return; 1781 return;
1781 1782
1782 /* apply any specific unsupported masks here */ 1783 /* apply any specific unsupported masks here */
@@ -1805,7 +1806,8 @@ static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1805 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) 1806 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
1806 return -EOPNOTSUPP; 1807 return -EOPNOTSUPP;
1807 1808
1808 if (igb_wol_exclusion(adapter, wol)) 1809 if (igb_wol_exclusion(adapter, wol) ||
1810 !device_can_wakeup(&adapter->pdev->dev))
1809 return wol->wolopts ? -EOPNOTSUPP : 0; 1811 return wol->wolopts ? -EOPNOTSUPP : 0;
1810 1812
1811 switch (hw->device_id) { 1813 switch (hw->device_id) {
@@ -1825,6 +1827,8 @@ static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1825 if (wol->wolopts & WAKE_MAGIC) 1827 if (wol->wolopts & WAKE_MAGIC)
1826 adapter->wol |= E1000_WUFC_MAG; 1828 adapter->wol |= E1000_WUFC_MAG;
1827 1829
1830 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1831
1828 return 0; 1832 return 0;
1829} 1833}
1830 1834
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 1f397cd99414..1cbae85b1426 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1019,10 +1019,9 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1019 state &= ~PCIE_LINK_STATE_L0S; 1019 state &= ~PCIE_LINK_STATE_L0S;
1020 pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL, 1020 pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL,
1021 state); 1021 state);
1022 printk(KERN_INFO "Disabling ASPM L0s upstream switch " 1022 dev_info(&pdev->dev,
1023 "port %x:%x.%x\n", us_dev->bus->number, 1023 "Disabling ASPM L0s upstream switch port %s\n",
1024 PCI_SLOT(us_dev->devfn), 1024 pci_name(us_dev));
1025 PCI_FUNC(us_dev->devfn));
1026 } 1025 }
1027 default: 1026 default:
1028 break; 1027 break;
@@ -1244,6 +1243,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1244 1243
1245 /* initialize the wol settings based on the eeprom settings */ 1244 /* initialize the wol settings based on the eeprom settings */
1246 adapter->wol = adapter->eeprom_wol; 1245 adapter->wol = adapter->eeprom_wol;
1246 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1247 1247
1248 /* reset the hardware with the new settings */ 1248 /* reset the hardware with the new settings */
1249 igb_reset(adapter); 1249 igb_reset(adapter);
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 7373dafbb3f7..059369885be1 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -1112,7 +1112,7 @@ static void ipg_nic_rx_free_skb(struct net_device *dev)
1112 struct ipg_rx *rxfd = sp->rxd + entry; 1112 struct ipg_rx *rxfd = sp->rxd + entry;
1113 1113
1114 pci_unmap_single(sp->pdev, 1114 pci_unmap_single(sp->pdev,
1115 le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1115 le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1116 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1116 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1117 dev_kfree_skb_irq(sp->rx_buff[entry]); 1117 dev_kfree_skb_irq(sp->rx_buff[entry]);
1118 sp->rx_buff[entry] = NULL; 1118 sp->rx_buff[entry] = NULL;
@@ -1179,7 +1179,7 @@ static int ipg_nic_rx_check_error(struct net_device *dev)
1179 */ 1179 */
1180 if (sp->rx_buff[entry]) { 1180 if (sp->rx_buff[entry]) {
1181 pci_unmap_single(sp->pdev, 1181 pci_unmap_single(sp->pdev,
1182 le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1182 le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1183 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1183 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1184 1184
1185 dev_kfree_skb_irq(sp->rx_buff[entry]); 1185 dev_kfree_skb_irq(sp->rx_buff[entry]);
@@ -1246,7 +1246,7 @@ static void ipg_nic_rx_with_start(struct net_device *dev,
1246 if (jumbo->found_start) 1246 if (jumbo->found_start)
1247 dev_kfree_skb_irq(jumbo->skb); 1247 dev_kfree_skb_irq(jumbo->skb);
1248 1248
1249 pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN), 1249 pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
1250 sp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1250 sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1251 1251
1252 skb_put(skb, sp->rxfrag_size); 1252 skb_put(skb, sp->rxfrag_size);
@@ -1349,7 +1349,7 @@ static int ipg_nic_rx_jumbo(struct net_device *dev)
1349 unsigned int entry = curr % IPG_RFDLIST_LENGTH; 1349 unsigned int entry = curr % IPG_RFDLIST_LENGTH;
1350 struct ipg_rx *rxfd = sp->rxd + entry; 1350 struct ipg_rx *rxfd = sp->rxd + entry;
1351 1351
1352 if (!(rxfd->rfs & le64_to_cpu(IPG_RFS_RFDDONE))) 1352 if (!(rxfd->rfs & cpu_to_le64(IPG_RFS_RFDDONE)))
1353 break; 1353 break;
1354 1354
1355 switch (ipg_nic_rx_check_frame_type(dev)) { 1355 switch (ipg_nic_rx_check_frame_type(dev)) {
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 7548fb7360d9..36f2bb666bf7 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1287,7 +1287,34 @@ static void ixgbe_set_itr(struct ixgbe_adapter *adapter)
1287 return; 1287 return;
1288} 1288}
1289 1289
1290static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter); 1290/**
1291 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
1292 * @adapter: board private structure
1293 **/
1294static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
1295{
1296 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
1297 IXGBE_WRITE_FLUSH(&adapter->hw);
1298 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
1299 int i;
1300 for (i = 0; i < adapter->num_msix_vectors; i++)
1301 synchronize_irq(adapter->msix_entries[i].vector);
1302 } else {
1303 synchronize_irq(adapter->pdev->irq);
1304 }
1305}
1306
1307/**
1308 * ixgbe_irq_enable - Enable default interrupt generation settings
1309 * @adapter: board private structure
1310 **/
1311static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1312{
1313 u32 mask;
1314 mask = IXGBE_EIMS_ENABLE_MASK;
1315 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
1316 IXGBE_WRITE_FLUSH(&adapter->hw);
1317}
1291 1318
1292/** 1319/**
1293 * ixgbe_intr - legacy mode Interrupt Handler 1320 * ixgbe_intr - legacy mode Interrupt Handler
@@ -1394,35 +1421,6 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
1394} 1421}
1395 1422
1396/** 1423/**
1397 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
1398 * @adapter: board private structure
1399 **/
1400static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
1401{
1402 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
1403 IXGBE_WRITE_FLUSH(&adapter->hw);
1404 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
1405 int i;
1406 for (i = 0; i < adapter->num_msix_vectors; i++)
1407 synchronize_irq(adapter->msix_entries[i].vector);
1408 } else {
1409 synchronize_irq(adapter->pdev->irq);
1410 }
1411}
1412
1413/**
1414 * ixgbe_irq_enable - Enable default interrupt generation settings
1415 * @adapter: board private structure
1416 **/
1417static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
1418{
1419 u32 mask;
1420 mask = IXGBE_EIMS_ENABLE_MASK;
1421 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask);
1422 IXGBE_WRITE_FLUSH(&adapter->hw);
1423}
1424
1425/**
1426 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts 1424 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts
1427 * 1425 *
1428 **/ 1426 **/
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 81c6cdc3851f..665e70d620fc 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -912,23 +912,23 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
912 skb_put(skb, framesize); 912 skb_put(skb, framesize);
913 skb->protocol = eth_type_trans(skb, jme->dev); 913 skb->protocol = eth_type_trans(skb, jme->dev);
914 914
915 if (jme_rxsum_ok(jme, rxdesc->descwb.flags)) 915 if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags)))
916 skb->ip_summed = CHECKSUM_UNNECESSARY; 916 skb->ip_summed = CHECKSUM_UNNECESSARY;
917 else 917 else
918 skb->ip_summed = CHECKSUM_NONE; 918 skb->ip_summed = CHECKSUM_NONE;
919 919
920 if (rxdesc->descwb.flags & RXWBFLAG_TAGON) { 920 if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) {
921 if (jme->vlgrp) { 921 if (jme->vlgrp) {
922 jme->jme_vlan_rx(skb, jme->vlgrp, 922 jme->jme_vlan_rx(skb, jme->vlgrp,
923 le32_to_cpu(rxdesc->descwb.vlan)); 923 le16_to_cpu(rxdesc->descwb.vlan));
924 NET_STAT(jme).rx_bytes += 4; 924 NET_STAT(jme).rx_bytes += 4;
925 } 925 }
926 } else { 926 } else {
927 jme->jme_rx(skb); 927 jme->jme_rx(skb);
928 } 928 }
929 929
930 if ((le16_to_cpu(rxdesc->descwb.flags) & RXWBFLAG_DEST) == 930 if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_DEST)) ==
931 RXWBFLAG_DEST_MUL) 931 cpu_to_le16(RXWBFLAG_DEST_MUL))
932 ++(NET_STAT(jme).multicast); 932 ++(NET_STAT(jme).multicast);
933 933
934 jme->dev->last_rx = jiffies; 934 jme->dev->last_rx = jiffies;
@@ -961,7 +961,7 @@ jme_process_receive(struct jme_adapter *jme, int limit)
961 rxdesc = rxring->desc; 961 rxdesc = rxring->desc;
962 rxdesc += i; 962 rxdesc += i;
963 963
964 if ((rxdesc->descwb.flags & RXWBFLAG_OWN) || 964 if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) ||
965 !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) 965 !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL))
966 goto out; 966 goto out;
967 967
@@ -1763,10 +1763,9 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
1763} 1763}
1764 1764
1765static int 1765static int
1766jme_tx_tso(struct sk_buff *skb, 1766jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags)
1767 u16 *mss, u8 *flags)
1768{ 1767{
1769 *mss = skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT; 1768 *mss = cpu_to_le16(skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT);
1770 if (*mss) { 1769 if (*mss) {
1771 *flags |= TXFLAG_LSEN; 1770 *flags |= TXFLAG_LSEN;
1772 1771
@@ -1826,11 +1825,11 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
1826} 1825}
1827 1826
1828static inline void 1827static inline void
1829jme_tx_vlan(struct sk_buff *skb, u16 *vlan, u8 *flags) 1828jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags)
1830{ 1829{
1831 if (vlan_tx_tag_present(skb)) { 1830 if (vlan_tx_tag_present(skb)) {
1832 *flags |= TXFLAG_TAGON; 1831 *flags |= TXFLAG_TAGON;
1833 *vlan = vlan_tx_tag_get(skb); 1832 *vlan = cpu_to_le16(vlan_tx_tag_get(skb));
1834 } 1833 }
1835} 1834}
1836 1835
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index a3f732418c49..96e709d6440a 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -656,10 +656,10 @@ static int mlx4_en_start_port(struct net_device *dev)
656 /* Configure port */ 656 /* Configure port */
657 err = mlx4_SET_PORT_general(mdev->dev, priv->port, 657 err = mlx4_SET_PORT_general(mdev->dev, priv->port,
658 priv->rx_skb_size + ETH_FCS_LEN, 658 priv->rx_skb_size + ETH_FCS_LEN,
659 mdev->profile.tx_pause, 659 priv->prof->tx_pause,
660 mdev->profile.tx_ppp, 660 priv->prof->tx_ppp,
661 mdev->profile.rx_pause, 661 priv->prof->rx_pause,
662 mdev->profile.rx_ppp); 662 priv->prof->rx_ppp);
663 if (err) { 663 if (err) {
664 mlx4_err(mdev, "Failed setting port general configurations" 664 mlx4_err(mdev, "Failed setting port general configurations"
665 " for port %d, with error %d\n", priv->port, err); 665 " for port %d, with error %d\n", priv->port, err);
diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c
index c2e69b1bcd0a..95706ee1c019 100644
--- a/drivers/net/mlx4/en_params.c
+++ b/drivers/net/mlx4/en_params.c
@@ -90,6 +90,7 @@ MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2");
90int mlx4_en_get_profile(struct mlx4_en_dev *mdev) 90int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
91{ 91{
92 struct mlx4_en_profile *params = &mdev->profile; 92 struct mlx4_en_profile *params = &mdev->profile;
93 int i;
93 94
94 params->rx_moder_cnt = min_t(int, rx_moder_cnt, MLX4_EN_AUTO_CONF); 95 params->rx_moder_cnt = min_t(int, rx_moder_cnt, MLX4_EN_AUTO_CONF);
95 params->rx_moder_time = min_t(int, rx_moder_time, MLX4_EN_AUTO_CONF); 96 params->rx_moder_time = min_t(int, rx_moder_time, MLX4_EN_AUTO_CONF);
@@ -97,11 +98,13 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
97 params->rss_xor = (rss_xor != 0); 98 params->rss_xor = (rss_xor != 0);
98 params->rss_mask = rss_mask & 0x1f; 99 params->rss_mask = rss_mask & 0x1f;
99 params->num_lro = min_t(int, num_lro , MLX4_EN_MAX_LRO_DESCRIPTORS); 100 params->num_lro = min_t(int, num_lro , MLX4_EN_MAX_LRO_DESCRIPTORS);
100 params->rx_pause = pprx; 101 for (i = 1; i <= MLX4_MAX_PORTS; i++) {
101 params->rx_ppp = pfcrx; 102 params->prof[i].rx_pause = pprx;
102 params->tx_pause = pptx; 103 params->prof[i].rx_ppp = pfcrx;
103 params->tx_ppp = pfctx; 104 params->prof[i].tx_pause = pptx;
104 if (params->rx_ppp || params->tx_ppp) { 105 params->prof[i].tx_ppp = pfctx;
106 }
107 if (pfcrx || pfctx) {
105 params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; 108 params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM;
106 params->prof[2].tx_ring_num = MLX4_EN_TX_RING_NUM; 109 params->prof[2].tx_ring_num = MLX4_EN_TX_RING_NUM;
107 } else { 110 } else {
@@ -407,14 +410,14 @@ static int mlx4_en_set_pauseparam(struct net_device *dev,
407 struct mlx4_en_dev *mdev = priv->mdev; 410 struct mlx4_en_dev *mdev = priv->mdev;
408 int err; 411 int err;
409 412
410 mdev->profile.tx_pause = pause->tx_pause != 0; 413 priv->prof->tx_pause = pause->tx_pause != 0;
411 mdev->profile.rx_pause = pause->rx_pause != 0; 414 priv->prof->rx_pause = pause->rx_pause != 0;
412 err = mlx4_SET_PORT_general(mdev->dev, priv->port, 415 err = mlx4_SET_PORT_general(mdev->dev, priv->port,
413 priv->rx_skb_size + ETH_FCS_LEN, 416 priv->rx_skb_size + ETH_FCS_LEN,
414 mdev->profile.tx_pause, 417 priv->prof->tx_pause,
415 mdev->profile.tx_ppp, 418 priv->prof->tx_ppp,
416 mdev->profile.rx_pause, 419 priv->prof->rx_pause,
417 mdev->profile.rx_ppp); 420 priv->prof->rx_ppp);
418 if (err) 421 if (err)
419 mlx4_err(mdev, "Failed setting pause params to\n"); 422 mlx4_err(mdev, "Failed setting pause params to\n");
420 423
@@ -425,10 +428,9 @@ static void mlx4_en_get_pauseparam(struct net_device *dev,
425 struct ethtool_pauseparam *pause) 428 struct ethtool_pauseparam *pause)
426{ 429{
427 struct mlx4_en_priv *priv = netdev_priv(dev); 430 struct mlx4_en_priv *priv = netdev_priv(dev);
428 struct mlx4_en_dev *mdev = priv->mdev;
429 431
430 pause->tx_pause = mdev->profile.tx_pause; 432 pause->tx_pause = priv->prof->tx_pause;
431 pause->rx_pause = mdev->profile.rx_pause; 433 pause->rx_pause = priv->prof->rx_pause;
432} 434}
433 435
434static void mlx4_en_get_ringparam(struct net_device *dev, 436static void mlx4_en_get_ringparam(struct net_device *dev,
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index 11fb17c6e97b..98ddc0811f93 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -322,6 +322,10 @@ struct mlx4_en_port_profile {
322 u32 rx_ring_num; 322 u32 rx_ring_num;
323 u32 tx_ring_size; 323 u32 tx_ring_size;
324 u32 rx_ring_size; 324 u32 rx_ring_size;
325 u8 rx_pause;
326 u8 rx_ppp;
327 u8 tx_pause;
328 u8 tx_ppp;
325}; 329};
326 330
327struct mlx4_en_profile { 331struct mlx4_en_profile {
@@ -333,10 +337,6 @@ struct mlx4_en_profile {
333 int rx_moder_cnt; 337 int rx_moder_cnt;
334 int rx_moder_time; 338 int rx_moder_time;
335 int auto_moder; 339 int auto_moder;
336 u8 rx_pause;
337 u8 rx_ppp;
338 u8 tx_pause;
339 u8 tx_ppp;
340 u8 no_reset; 340 u8 no_reset;
341 struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1]; 341 struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1];
342}; 342};
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b9dcdbd369f8..e513f76f2a9f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -899,7 +899,8 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
899 if (skb != NULL) { 899 if (skb != NULL) {
900 if (skb_queue_len(&mp->rx_recycle) < 900 if (skb_queue_len(&mp->rx_recycle) <
901 mp->default_rx_ring_size && 901 mp->default_rx_ring_size &&
902 skb_recycle_check(skb, mp->skb_size)) 902 skb_recycle_check(skb, mp->skb_size +
903 dma_get_cache_alignment() - 1))
903 __skb_queue_head(&mp->rx_recycle, skb); 904 __skb_queue_head(&mp->rx_recycle, skb);
904 else 905 else
905 dev_kfree_skb(skb); 906 dev_kfree_skb(skb);
@@ -2435,8 +2436,8 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
2435 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data; 2436 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
2436 2437
2437 if (pd == NULL || pd->shared_smi == NULL) { 2438 if (pd == NULL || pd->shared_smi == NULL) {
2438 mdiobus_free(msp->smi_bus);
2439 mdiobus_unregister(msp->smi_bus); 2439 mdiobus_unregister(msp->smi_bus);
2440 mdiobus_free(msp->smi_bus);
2440 } 2441 }
2441 if (msp->err_interrupt != NO_IRQ) 2442 if (msp->err_interrupt != NO_IRQ)
2442 free_irq(msp->err_interrupt, msp); 2443 free_irq(msp->err_interrupt, msp);
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index d8463b1c3df3..1b6f548c4411 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -33,8 +33,8 @@
33 33
34#define DRV_MODULE_NAME "niu" 34#define DRV_MODULE_NAME "niu"
35#define PFX DRV_MODULE_NAME ": " 35#define PFX DRV_MODULE_NAME ": "
36#define DRV_MODULE_VERSION "0.9" 36#define DRV_MODULE_VERSION "1.0"
37#define DRV_MODULE_RELDATE "May 4, 2008" 37#define DRV_MODULE_RELDATE "Nov 14, 2008"
38 38
39static char version[] __devinitdata = 39static char version[] __devinitdata =
40 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 40 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
@@ -406,7 +406,7 @@ static int esr2_set_rx_cfg(struct niu *np, unsigned long channel, u32 val)
406} 406}
407 407
408/* Mode is always 10G fiber. */ 408/* Mode is always 10G fiber. */
409static int serdes_init_niu(struct niu *np) 409static int serdes_init_niu_10g_fiber(struct niu *np)
410{ 410{
411 struct niu_link_config *lp = &np->link_config; 411 struct niu_link_config *lp = &np->link_config;
412 u32 tx_cfg, rx_cfg; 412 u32 tx_cfg, rx_cfg;
@@ -443,6 +443,223 @@ static int serdes_init_niu(struct niu *np)
443 return 0; 443 return 0;
444} 444}
445 445
446static int serdes_init_niu_1g_serdes(struct niu *np)
447{
448 struct niu_link_config *lp = &np->link_config;
449 u16 pll_cfg, pll_sts;
450 int max_retry = 100;
451 u64 sig, mask, val;
452 u32 tx_cfg, rx_cfg;
453 unsigned long i;
454 int err;
455
456 tx_cfg = (PLL_TX_CFG_ENTX | PLL_TX_CFG_SWING_1375MV |
457 PLL_TX_CFG_RATE_HALF);
458 rx_cfg = (PLL_RX_CFG_ENRX | PLL_RX_CFG_TERM_0P8VDDT |
459 PLL_RX_CFG_ALIGN_ENA | PLL_RX_CFG_LOS_LTHRESH |
460 PLL_RX_CFG_RATE_HALF);
461
462 if (np->port == 0)
463 rx_cfg |= PLL_RX_CFG_EQ_LP_ADAPTIVE;
464
465 if (lp->loopback_mode == LOOPBACK_PHY) {
466 u16 test_cfg = PLL_TEST_CFG_LOOPBACK_CML_DIS;
467
468 mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
469 ESR2_TI_PLL_TEST_CFG_L, test_cfg);
470
471 tx_cfg |= PLL_TX_CFG_ENTEST;
472 rx_cfg |= PLL_RX_CFG_ENTEST;
473 }
474
475 /* Initialize PLL for 1G */
476 pll_cfg = (PLL_CFG_ENPLL | PLL_CFG_MPY_8X);
477
478 err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
479 ESR2_TI_PLL_CFG_L, pll_cfg);
480 if (err) {
481 dev_err(np->device, PFX "NIU Port %d "
482 "serdes_init_niu_1g_serdes: "
483 "mdio write to ESR2_TI_PLL_CFG_L failed", np->port);
484 return err;
485 }
486
487 pll_sts = PLL_CFG_ENPLL;
488
489 err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
490 ESR2_TI_PLL_STS_L, pll_sts);
491 if (err) {
492 dev_err(np->device, PFX "NIU Port %d "
493 "serdes_init_niu_1g_serdes: "
494 "mdio write to ESR2_TI_PLL_STS_L failed", np->port);
495 return err;
496 }
497
498 udelay(200);
499
500 /* Initialize all 4 lanes of the SERDES. */
501 for (i = 0; i < 4; i++) {
502 err = esr2_set_tx_cfg(np, i, tx_cfg);
503 if (err)
504 return err;
505 }
506
507 for (i = 0; i < 4; i++) {
508 err = esr2_set_rx_cfg(np, i, rx_cfg);
509 if (err)
510 return err;
511 }
512
513 switch (np->port) {
514 case 0:
515 val = (ESR_INT_SRDY0_P0 | ESR_INT_DET0_P0);
516 mask = val;
517 break;
518
519 case 1:
520 val = (ESR_INT_SRDY0_P1 | ESR_INT_DET0_P1);
521 mask = val;
522 break;
523
524 default:
525 return -EINVAL;
526 }
527
528 while (max_retry--) {
529 sig = nr64(ESR_INT_SIGNALS);
530 if ((sig & mask) == val)
531 break;
532
533 mdelay(500);
534 }
535
536 if ((sig & mask) != val) {
537 dev_err(np->device, PFX "Port %u signal bits [%08x] are not "
538 "[%08x]\n", np->port, (int) (sig & mask), (int) val);
539 return -ENODEV;
540 }
541
542 return 0;
543}
544
545static int serdes_init_niu_10g_serdes(struct niu *np)
546{
547 struct niu_link_config *lp = &np->link_config;
548 u32 tx_cfg, rx_cfg, pll_cfg, pll_sts;
549 int max_retry = 100;
550 u64 sig, mask, val;
551 unsigned long i;
552 int err;
553
554 tx_cfg = (PLL_TX_CFG_ENTX | PLL_TX_CFG_SWING_1375MV);
555 rx_cfg = (PLL_RX_CFG_ENRX | PLL_RX_CFG_TERM_0P8VDDT |
556 PLL_RX_CFG_ALIGN_ENA | PLL_RX_CFG_LOS_LTHRESH |
557 PLL_RX_CFG_EQ_LP_ADAPTIVE);
558
559 if (lp->loopback_mode == LOOPBACK_PHY) {
560 u16 test_cfg = PLL_TEST_CFG_LOOPBACK_CML_DIS;
561
562 mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
563 ESR2_TI_PLL_TEST_CFG_L, test_cfg);
564
565 tx_cfg |= PLL_TX_CFG_ENTEST;
566 rx_cfg |= PLL_RX_CFG_ENTEST;
567 }
568
569 /* Initialize PLL for 10G */
570 pll_cfg = (PLL_CFG_ENPLL | PLL_CFG_MPY_10X);
571
572 err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
573 ESR2_TI_PLL_CFG_L, pll_cfg & 0xffff);
574 if (err) {
575 dev_err(np->device, PFX "NIU Port %d "
576 "serdes_init_niu_10g_serdes: "
577 "mdio write to ESR2_TI_PLL_CFG_L failed", np->port);
578 return err;
579 }
580
581 pll_sts = PLL_CFG_ENPLL;
582
583 err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR,
584 ESR2_TI_PLL_STS_L, pll_sts & 0xffff);
585 if (err) {
586 dev_err(np->device, PFX "NIU Port %d "
587 "serdes_init_niu_10g_serdes: "
588 "mdio write to ESR2_TI_PLL_STS_L failed", np->port);
589 return err;
590 }
591
592 udelay(200);
593
594 /* Initialize all 4 lanes of the SERDES. */
595 for (i = 0; i < 4; i++) {
596 err = esr2_set_tx_cfg(np, i, tx_cfg);
597 if (err)
598 return err;
599 }
600
601 for (i = 0; i < 4; i++) {
602 err = esr2_set_rx_cfg(np, i, rx_cfg);
603 if (err)
604 return err;
605 }
606
607 /* check if serdes is ready */
608
609 switch (np->port) {
610 case 0:
611 mask = ESR_INT_SIGNALS_P0_BITS;
612 val = (ESR_INT_SRDY0_P0 |
613 ESR_INT_DET0_P0 |
614 ESR_INT_XSRDY_P0 |
615 ESR_INT_XDP_P0_CH3 |
616 ESR_INT_XDP_P0_CH2 |
617 ESR_INT_XDP_P0_CH1 |
618 ESR_INT_XDP_P0_CH0);
619 break;
620
621 case 1:
622 mask = ESR_INT_SIGNALS_P1_BITS;
623 val = (ESR_INT_SRDY0_P1 |
624 ESR_INT_DET0_P1 |
625 ESR_INT_XSRDY_P1 |
626 ESR_INT_XDP_P1_CH3 |
627 ESR_INT_XDP_P1_CH2 |
628 ESR_INT_XDP_P1_CH1 |
629 ESR_INT_XDP_P1_CH0);
630 break;
631
632 default:
633 return -EINVAL;
634 }
635
636 while (max_retry--) {
637 sig = nr64(ESR_INT_SIGNALS);
638 if ((sig & mask) == val)
639 break;
640
641 mdelay(500);
642 }
643
644 if ((sig & mask) != val) {
645 pr_info(PFX "NIU Port %u signal bits [%08x] are not "
646 "[%08x] for 10G...trying 1G\n",
647 np->port, (int) (sig & mask), (int) val);
648
649 /* 10G failed, try initializing at 1G */
650 err = serdes_init_niu_1g_serdes(np);
651 if (!err) {
652 np->flags &= ~NIU_FLAGS_10G;
653 np->mac_xcvr = MAC_XCVR_PCS;
654 } else {
655 dev_err(np->device, PFX "Port %u 10G/1G SERDES "
656 "Link Failed \n", np->port);
657 return -ENODEV;
658 }
659 }
660 return 0;
661}
662
446static int esr_read_rxtx_ctrl(struct niu *np, unsigned long chan, u32 *val) 663static int esr_read_rxtx_ctrl(struct niu *np, unsigned long chan, u32 *val)
447{ 664{
448 int err; 665 int err;
@@ -1954,13 +2171,23 @@ static const struct niu_phy_ops phy_ops_10g_serdes = {
1954 .link_status = link_status_10g_serdes, 2171 .link_status = link_status_10g_serdes,
1955}; 2172};
1956 2173
2174static const struct niu_phy_ops phy_ops_10g_serdes_niu = {
2175 .serdes_init = serdes_init_niu_10g_serdes,
2176 .link_status = link_status_10g_serdes,
2177};
2178
2179static const struct niu_phy_ops phy_ops_1g_serdes_niu = {
2180 .serdes_init = serdes_init_niu_1g_serdes,
2181 .link_status = link_status_1g_serdes,
2182};
2183
1957static const struct niu_phy_ops phy_ops_1g_rgmii = { 2184static const struct niu_phy_ops phy_ops_1g_rgmii = {
1958 .xcvr_init = xcvr_init_1g_rgmii, 2185 .xcvr_init = xcvr_init_1g_rgmii,
1959 .link_status = link_status_1g_rgmii, 2186 .link_status = link_status_1g_rgmii,
1960}; 2187};
1961 2188
1962static const struct niu_phy_ops phy_ops_10g_fiber_niu = { 2189static const struct niu_phy_ops phy_ops_10g_fiber_niu = {
1963 .serdes_init = serdes_init_niu, 2190 .serdes_init = serdes_init_niu_10g_fiber,
1964 .xcvr_init = xcvr_init_10g, 2191 .xcvr_init = xcvr_init_10g,
1965 .link_status = link_status_10g, 2192 .link_status = link_status_10g,
1966}; 2193};
@@ -1998,11 +2225,21 @@ struct niu_phy_template {
1998 u32 phy_addr_base; 2225 u32 phy_addr_base;
1999}; 2226};
2000 2227
2001static const struct niu_phy_template phy_template_niu = { 2228static const struct niu_phy_template phy_template_niu_10g_fiber = {
2002 .ops = &phy_ops_10g_fiber_niu, 2229 .ops = &phy_ops_10g_fiber_niu,
2003 .phy_addr_base = 16, 2230 .phy_addr_base = 16,
2004}; 2231};
2005 2232
2233static const struct niu_phy_template phy_template_niu_10g_serdes = {
2234 .ops = &phy_ops_10g_serdes_niu,
2235 .phy_addr_base = 0,
2236};
2237
2238static const struct niu_phy_template phy_template_niu_1g_serdes = {
2239 .ops = &phy_ops_1g_serdes_niu,
2240 .phy_addr_base = 0,
2241};
2242
2006static const struct niu_phy_template phy_template_10g_fiber = { 2243static const struct niu_phy_template phy_template_10g_fiber = {
2007 .ops = &phy_ops_10g_fiber, 2244 .ops = &phy_ops_10g_fiber,
2008 .phy_addr_base = 8, 2245 .phy_addr_base = 8,
@@ -2182,8 +2419,25 @@ static int niu_determine_phy_disposition(struct niu *np)
2182 u32 phy_addr_off = 0; 2419 u32 phy_addr_off = 0;
2183 2420
2184 if (plat_type == PLAT_TYPE_NIU) { 2421 if (plat_type == PLAT_TYPE_NIU) {
2185 tp = &phy_template_niu; 2422 switch (np->flags &
2186 phy_addr_off += np->port; 2423 (NIU_FLAGS_10G |
2424 NIU_FLAGS_FIBER |
2425 NIU_FLAGS_XCVR_SERDES)) {
2426 case NIU_FLAGS_10G | NIU_FLAGS_XCVR_SERDES:
2427 /* 10G Serdes */
2428 tp = &phy_template_niu_10g_serdes;
2429 break;
2430 case NIU_FLAGS_XCVR_SERDES:
2431 /* 1G Serdes */
2432 tp = &phy_template_niu_1g_serdes;
2433 break;
2434 case NIU_FLAGS_10G | NIU_FLAGS_FIBER:
2435 /* 10G Fiber */
2436 default:
2437 tp = &phy_template_niu_10g_fiber;
2438 phy_addr_off += np->port;
2439 break;
2440 }
2187 } else { 2441 } else {
2188 switch (np->flags & 2442 switch (np->flags &
2189 (NIU_FLAGS_10G | 2443 (NIU_FLAGS_10G |
@@ -7213,6 +7467,12 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np,
7213 np->flags |= NIU_FLAGS_10G; 7467 np->flags |= NIU_FLAGS_10G;
7214 np->flags &= ~NIU_FLAGS_FIBER; 7468 np->flags &= ~NIU_FLAGS_FIBER;
7215 np->mac_xcvr = MAC_XCVR_XPCS; 7469 np->mac_xcvr = MAC_XCVR_XPCS;
7470 } else if (!strcmp(phy_prop, "xgsd") || !strcmp(phy_prop, "gsd")) {
7471 /* 10G Serdes or 1G Serdes, default to 10G */
7472 np->flags |= NIU_FLAGS_10G;
7473 np->flags &= ~NIU_FLAGS_FIBER;
7474 np->flags |= NIU_FLAGS_XCVR_SERDES;
7475 np->mac_xcvr = MAC_XCVR_XPCS;
7216 } else { 7476 } else {
7217 return -EINVAL; 7477 return -EINVAL;
7218 } 7478 }
@@ -7741,6 +8001,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7741 u32 val; 8001 u32 val;
7742 int err; 8002 int err;
7743 8003
8004 num_10g = num_1g = 0;
8005
7744 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) || 8006 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7745 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) { 8007 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7746 num_10g = 0; 8008 num_10g = 0;
@@ -7757,6 +8019,16 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7757 parent->num_ports = 2; 8019 parent->num_ports = 2;
7758 val = (phy_encode(PORT_TYPE_10G, 0) | 8020 val = (phy_encode(PORT_TYPE_10G, 0) |
7759 phy_encode(PORT_TYPE_10G, 1)); 8021 phy_encode(PORT_TYPE_10G, 1));
8022 } else if ((np->flags & NIU_FLAGS_XCVR_SERDES) &&
8023 (parent->plat_type == PLAT_TYPE_NIU)) {
8024 /* this is the Monza case */
8025 if (np->flags & NIU_FLAGS_10G) {
8026 val = (phy_encode(PORT_TYPE_10G, 0) |
8027 phy_encode(PORT_TYPE_10G, 1));
8028 } else {
8029 val = (phy_encode(PORT_TYPE_1G, 0) |
8030 phy_encode(PORT_TYPE_1G, 1));
8031 }
7760 } else { 8032 } else {
7761 err = fill_phy_probe_info(np, parent, info); 8033 err = fill_phy_probe_info(np, parent, info);
7762 if (err) 8034 if (err)
@@ -8656,7 +8928,9 @@ static void __devinit niu_device_announce(struct niu *np)
8656 dev->name, 8928 dev->name,
8657 (np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"), 8929 (np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"),
8658 (np->flags & NIU_FLAGS_10G ? "10G" : "1G"), 8930 (np->flags & NIU_FLAGS_10G ? "10G" : "1G"),
8659 (np->flags & NIU_FLAGS_FIBER ? "FIBER" : "COPPER"), 8931 (np->flags & NIU_FLAGS_FIBER ? "FIBER" :
8932 (np->flags & NIU_FLAGS_XCVR_SERDES ? "SERDES" :
8933 "COPPER")),
8660 (np->mac_xcvr == MAC_XCVR_MII ? "MII" : 8934 (np->mac_xcvr == MAC_XCVR_MII ? "MII" :
8661 (np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")), 8935 (np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")),
8662 np->vpd.phy_type); 8936 np->vpd.phy_type);
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index c6fa883daa22..180ca8ae93de 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -1048,6 +1048,13 @@
1048#define PLL_CFG_LD_SHIFT 8 1048#define PLL_CFG_LD_SHIFT 8
1049#define PLL_CFG_MPY 0x0000001e 1049#define PLL_CFG_MPY 0x0000001e
1050#define PLL_CFG_MPY_SHIFT 1 1050#define PLL_CFG_MPY_SHIFT 1
1051#define PLL_CFG_MPY_4X 0x0
1052#define PLL_CFG_MPY_5X 0x00000002
1053#define PLL_CFG_MPY_6X 0x00000004
1054#define PLL_CFG_MPY_8X 0x00000008
1055#define PLL_CFG_MPY_10X 0x0000000a
1056#define PLL_CFG_MPY_12X 0x0000000c
1057#define PLL_CFG_MPY_12P5X 0x0000000e
1051#define PLL_CFG_ENPLL 0x00000001 1058#define PLL_CFG_ENPLL 0x00000001
1052 1059
1053#define ESR2_TI_PLL_STS_L (ESR2_BASE + 0x002) 1060#define ESR2_TI_PLL_STS_L (ESR2_BASE + 0x002)
@@ -1093,6 +1100,9 @@
1093#define PLL_TX_CFG_INVPAIR 0x00000080 1100#define PLL_TX_CFG_INVPAIR 0x00000080
1094#define PLL_TX_CFG_RATE 0x00000060 1101#define PLL_TX_CFG_RATE 0x00000060
1095#define PLL_TX_CFG_RATE_SHIFT 5 1102#define PLL_TX_CFG_RATE_SHIFT 5
1103#define PLL_TX_CFG_RATE_FULL 0x0
1104#define PLL_TX_CFG_RATE_HALF 0x20
1105#define PLL_TX_CFG_RATE_QUAD 0x40
1096#define PLL_TX_CFG_BUSWIDTH 0x0000001c 1106#define PLL_TX_CFG_BUSWIDTH 0x0000001c
1097#define PLL_TX_CFG_BUSWIDTH_SHIFT 2 1107#define PLL_TX_CFG_BUSWIDTH_SHIFT 2
1098#define PLL_TX_CFG_ENTEST 0x00000002 1108#define PLL_TX_CFG_ENTEST 0x00000002
@@ -1132,6 +1142,9 @@
1132#define PLL_RX_CFG_INVPAIR 0x00000080 1142#define PLL_RX_CFG_INVPAIR 0x00000080
1133#define PLL_RX_CFG_RATE 0x00000060 1143#define PLL_RX_CFG_RATE 0x00000060
1134#define PLL_RX_CFG_RATE_SHIFT 5 1144#define PLL_RX_CFG_RATE_SHIFT 5
1145#define PLL_RX_CFG_RATE_FULL 0x0
1146#define PLL_RX_CFG_RATE_HALF 0x20
1147#define PLL_RX_CFG_RATE_QUAD 0x40
1135#define PLL_RX_CFG_BUSWIDTH 0x0000001c 1148#define PLL_RX_CFG_BUSWIDTH 0x0000001c
1136#define PLL_RX_CFG_BUSWIDTH_SHIFT 2 1149#define PLL_RX_CFG_BUSWIDTH_SHIFT 2
1137#define PLL_RX_CFG_ENTEST 0x00000002 1150#define PLL_RX_CFG_ENTEST 0x00000002
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 4aa547947040..eb6411c4694f 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -227,6 +227,59 @@ static int m88e1111_config_init(struct phy_device *phydev)
227 return 0; 227 return 0;
228} 228}
229 229
230static int m88e1118_config_aneg(struct phy_device *phydev)
231{
232 int err;
233
234 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
235 if (err < 0)
236 return err;
237
238 err = phy_write(phydev, MII_M1011_PHY_SCR,
239 MII_M1011_PHY_SCR_AUTO_CROSS);
240 if (err < 0)
241 return err;
242
243 err = genphy_config_aneg(phydev);
244 return 0;
245}
246
247static int m88e1118_config_init(struct phy_device *phydev)
248{
249 int err;
250
251 /* Change address */
252 err = phy_write(phydev, 0x16, 0x0002);
253 if (err < 0)
254 return err;
255
256 /* Enable 1000 Mbit */
257 err = phy_write(phydev, 0x15, 0x1070);
258 if (err < 0)
259 return err;
260
261 /* Change address */
262 err = phy_write(phydev, 0x16, 0x0003);
263 if (err < 0)
264 return err;
265
266 /* Adjust LED Control */
267 err = phy_write(phydev, 0x10, 0x021e);
268 if (err < 0)
269 return err;
270
271 /* Reset address */
272 err = phy_write(phydev, 0x16, 0x0);
273 if (err < 0)
274 return err;
275
276 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
277 if (err < 0)
278 return err;
279
280 return 0;
281}
282
230static int m88e1145_config_init(struct phy_device *phydev) 283static int m88e1145_config_init(struct phy_device *phydev)
231{ 284{
232 int err; 285 int err;
@@ -416,6 +469,19 @@ static struct phy_driver marvell_drivers[] = {
416 .driver = { .owner = THIS_MODULE }, 469 .driver = { .owner = THIS_MODULE },
417 }, 470 },
418 { 471 {
472 .phy_id = 0x01410e10,
473 .phy_id_mask = 0xfffffff0,
474 .name = "Marvell 88E1118",
475 .features = PHY_GBIT_FEATURES,
476 .flags = PHY_HAS_INTERRUPT,
477 .config_init = &m88e1118_config_init,
478 .config_aneg = &m88e1118_config_aneg,
479 .read_status = &genphy_read_status,
480 .ack_interrupt = &marvell_ack_interrupt,
481 .config_intr = &marvell_config_intr,
482 .driver = {.owner = THIS_MODULE,},
483 },
484 {
419 .phy_id = 0x01410cd0, 485 .phy_id = 0x01410cd0,
420 .phy_id_mask = 0xfffffff0, 486 .phy_id_mask = 0xfffffff0,
421 .name = "Marvell 88E1145", 487 .name = "Marvell 88E1145",
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index d0ed1ef284a8..536bda1f428b 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -136,7 +136,7 @@ void mdiobus_unregister(struct mii_bus *bus)
136 BUG_ON(bus->state != MDIOBUS_REGISTERED); 136 BUG_ON(bus->state != MDIOBUS_REGISTERED);
137 bus->state = MDIOBUS_UNREGISTERED; 137 bus->state = MDIOBUS_UNREGISTERED;
138 138
139 device_unregister(&bus->dev); 139 device_del(&bus->dev);
140 for (i = 0; i < PHY_MAX_ADDR; i++) { 140 for (i = 0; i < PHY_MAX_ADDR; i++) {
141 if (bus->phy_map[i]) 141 if (bus->phy_map[i])
142 device_unregister(&bus->phy_map[i]->dev); 142 device_unregister(&bus->phy_map[i]->dev);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e11b03b2b25a..55bc24b234e3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -227,8 +227,8 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
227 if (r) 227 if (r)
228 return ERR_PTR(r); 228 return ERR_PTR(r);
229 229
230 /* If the phy_id is all Fs, there is no device there */ 230 /* If the phy_id is all Fs or all 0s, there is no device there */
231 if (0xffffffff == phy_id) 231 if ((0xffff == phy_id) || (0x00 == phy_id))
232 return NULL; 232 return NULL;
233 233
234 dev = phy_device_create(bus, addr, phy_id); 234 dev = phy_device_create(bus, addr, phy_id);
@@ -564,20 +564,32 @@ EXPORT_SYMBOL(genphy_restart_aneg);
564 */ 564 */
565int genphy_config_aneg(struct phy_device *phydev) 565int genphy_config_aneg(struct phy_device *phydev)
566{ 566{
567 int result = 0; 567 int result;
568 568
569 if (AUTONEG_ENABLE == phydev->autoneg) { 569 if (AUTONEG_ENABLE != phydev->autoneg)
570 int result = genphy_config_advert(phydev); 570 return genphy_setup_forced(phydev);
571
572 result = genphy_config_advert(phydev);
573
574 if (result < 0) /* error */
575 return result;
571 576
572 if (result < 0) /* error */ 577 if (result == 0) {
573 return result; 578 /* Advertisment hasn't changed, but maybe aneg was never on to
579 * begin with? Or maybe phy was isolated? */
580 int ctl = phy_read(phydev, MII_BMCR);
581
582 if (ctl < 0)
583 return ctl;
584
585 if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
586 result = 1; /* do restart aneg */
587 }
574 588
575 /* Only restart aneg if we are advertising something different 589 /* Only restart aneg if we are advertising something different
576 * than we were before. */ 590 * than we were before. */
577 if (result > 0) 591 if (result > 0)
578 result = genphy_restart_aneg(phydev); 592 result = genphy_restart_aneg(phydev);
579 } else
580 result = genphy_setup_forced(phydev);
581 593
582 return result; 594 return result;
583} 595}
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 3cdd07c45b6d..508452c02151 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -1515,9 +1515,6 @@ static u32 ql_get_link_state(struct ql3_adapter *qdev)
1515 linkState = LS_UP; 1515 linkState = LS_UP;
1516 } else { 1516 } else {
1517 linkState = LS_DOWN; 1517 linkState = LS_DOWN;
1518 if (netif_msg_link(qdev))
1519 printk(KERN_WARNING PFX
1520 "%s: Link is down.\n", qdev->ndev->name);
1521 } 1518 }
1522 return linkState; 1519 return linkState;
1523} 1520}
@@ -1581,10 +1578,6 @@ static int ql_finish_auto_neg(struct ql3_adapter *qdev)
1581 ql_mac_enable(qdev, 1); 1578 ql_mac_enable(qdev, 1);
1582 } 1579 }
1583 1580
1584 if (netif_msg_link(qdev))
1585 printk(KERN_DEBUG PFX
1586 "%s: Change port_link_state LS_DOWN to LS_UP.\n",
1587 qdev->ndev->name);
1588 qdev->port_link_state = LS_UP; 1581 qdev->port_link_state = LS_UP;
1589 netif_start_queue(qdev->ndev); 1582 netif_start_queue(qdev->ndev);
1590 netif_carrier_on(qdev->ndev); 1583 netif_carrier_on(qdev->ndev);
@@ -1655,14 +1648,9 @@ static void ql_link_state_machine_work(struct work_struct *work)
1655 /* Fall Through */ 1648 /* Fall Through */
1656 1649
1657 case LS_DOWN: 1650 case LS_DOWN:
1658 if (netif_msg_link(qdev))
1659 printk(KERN_DEBUG PFX
1660 "%s: port_link_state = LS_DOWN.\n",
1661 qdev->ndev->name);
1662 if (curr_link_state == LS_UP) { 1651 if (curr_link_state == LS_UP) {
1663 if (netif_msg_link(qdev)) 1652 if (netif_msg_link(qdev))
1664 printk(KERN_DEBUG PFX 1653 printk(KERN_INFO PFX "%s: Link is up.\n",
1665 "%s: curr_link_state = LS_UP.\n",
1666 qdev->ndev->name); 1654 qdev->ndev->name);
1667 if (ql_is_auto_neg_complete(qdev)) 1655 if (ql_is_auto_neg_complete(qdev))
1668 ql_finish_auto_neg(qdev); 1656 ql_finish_auto_neg(qdev);
@@ -1670,6 +1658,7 @@ static void ql_link_state_machine_work(struct work_struct *work)
1670 if (qdev->port_link_state == LS_UP) 1658 if (qdev->port_link_state == LS_UP)
1671 ql_link_down_detect_clear(qdev); 1659 ql_link_down_detect_clear(qdev);
1672 1660
1661 qdev->port_link_state = LS_UP;
1673 } 1662 }
1674 break; 1663 break;
1675 1664
@@ -1678,12 +1667,14 @@ static void ql_link_state_machine_work(struct work_struct *work)
1678 * See if the link is currently down or went down and came 1667 * See if the link is currently down or went down and came
1679 * back up 1668 * back up
1680 */ 1669 */
1681 if ((curr_link_state == LS_DOWN) || ql_link_down_detect(qdev)) { 1670 if (curr_link_state == LS_DOWN) {
1682 if (netif_msg_link(qdev)) 1671 if (netif_msg_link(qdev))
1683 printk(KERN_INFO PFX "%s: Link is down.\n", 1672 printk(KERN_INFO PFX "%s: Link is down.\n",
1684 qdev->ndev->name); 1673 qdev->ndev->name);
1685 qdev->port_link_state = LS_DOWN; 1674 qdev->port_link_state = LS_DOWN;
1686 } 1675 }
1676 if (ql_link_down_detect(qdev))
1677 qdev->port_link_state = LS_DOWN;
1687 break; 1678 break;
1688 } 1679 }
1689 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); 1680 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index a24bb68887ab..59f242a67714 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -927,7 +927,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
927 struct sh_eth_private *mdp = netdev_priv(ndev); 927 struct sh_eth_private *mdp = netdev_priv(ndev);
928 struct sh_eth_txdesc *txdesc; 928 struct sh_eth_txdesc *txdesc;
929 u32 entry; 929 u32 entry;
930 int flags; 930 unsigned long flags;
931 931
932 spin_lock_irqsave(&mdp->lock, flags); 932 spin_lock_irqsave(&mdp->lock, flags);
933 if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) { 933 if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) {
@@ -1141,7 +1141,7 @@ static int sh_mdio_init(struct net_device *ndev, int id)
1141 /* Hook up MII support for ethtool */ 1141 /* Hook up MII support for ethtool */
1142 mdp->mii_bus->name = "sh_mii"; 1142 mdp->mii_bus->name = "sh_mii";
1143 mdp->mii_bus->parent = &ndev->dev; 1143 mdp->mii_bus->parent = &ndev->dev;
1144 mdp->mii_bus->id[0] = id; 1144 snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%x", id);
1145 1145
1146 /* PHY IRQ */ 1146 /* PHY IRQ */
1147 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1147 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1f26ab0e7986..b185cd12269c 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -1813,7 +1813,7 @@ static int __init smc911x_probe(struct net_device *dev)
1813 val = SMC_GET_BYTE_TEST(lp); 1813 val = SMC_GET_BYTE_TEST(lp);
1814 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val); 1814 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val);
1815 if (val != 0x87654321) { 1815 if (val != 0x87654321) {
1816 printk(KERN_ERR "Invalid chip endian 0x08%x\n",val); 1816 printk(KERN_ERR "Invalid chip endian 0x%08x\n",val);
1817 retval = -ENODEV; 1817 retval = -ENODEV;
1818 goto err_out; 1818 goto err_out;
1819 } 1819 }
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index 85f38a6b6a49..68a7f5414133 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -323,17 +323,17 @@ static void uec_get_ethtool_stats(struct net_device *netdev,
323 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) { 323 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) {
324 base = (u32 __iomem *)&ugeth->ug_regs->tx64; 324 base = (u32 __iomem *)&ugeth->ug_regs->tx64;
325 for (i = 0; i < UEC_HW_STATS_LEN; i++) 325 for (i = 0; i < UEC_HW_STATS_LEN; i++)
326 data[j++] = (u64)in_be32(&base[i]); 326 data[j++] = in_be32(&base[i]);
327 } 327 }
328 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { 328 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
329 base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram; 329 base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram;
330 for (i = 0; i < UEC_TX_FW_STATS_LEN; i++) 330 for (i = 0; i < UEC_TX_FW_STATS_LEN; i++)
331 data[j++] = (u64)in_be32(&base[i]); 331 data[j++] = base ? in_be32(&base[i]) : 0;
332 } 332 }
333 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { 333 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) {
334 base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram; 334 base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram;
335 for (i = 0; i < UEC_RX_FW_STATS_LEN; i++) 335 for (i = 0; i < UEC_RX_FW_STATS_LEN; i++)
336 data[j++] = (u64)in_be32(&base[i]); 336 data[j++] = base ? in_be32(&base[i]) : 0;
337 } 337 }
338} 338}
339 339
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 37ecf845edfe..de57490103fc 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1102,12 +1102,14 @@ static int ax88178_link_reset(struct usbnet *dev)
1102 mode = AX88178_MEDIUM_DEFAULT; 1102 mode = AX88178_MEDIUM_DEFAULT;
1103 1103
1104 if (ecmd.speed == SPEED_1000) 1104 if (ecmd.speed == SPEED_1000)
1105 mode |= AX_MEDIUM_GM | AX_MEDIUM_ENCK; 1105 mode |= AX_MEDIUM_GM;
1106 else if (ecmd.speed == SPEED_100) 1106 else if (ecmd.speed == SPEED_100)
1107 mode |= AX_MEDIUM_PS; 1107 mode |= AX_MEDIUM_PS;
1108 else 1108 else
1109 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); 1109 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
1110 1110
1111 mode |= AX_MEDIUM_ENCK;
1112
1111 if (ecmd.duplex == DUPLEX_FULL) 1113 if (ecmd.duplex == DUPLEX_FULL)
1112 mode |= AX_MEDIUM_FD; 1114 mode |= AX_MEDIUM_FD;
1113 else 1115 else
@@ -1444,6 +1446,10 @@ static const struct usb_device_id products [] = {
1444 // Apple USB Ethernet Adapter 1446 // Apple USB Ethernet Adapter
1445 USB_DEVICE(0x05ac, 0x1402), 1447 USB_DEVICE(0x05ac, 0x1402),
1446 .driver_info = (unsigned long) &ax88772_info, 1448 .driver_info = (unsigned long) &ax88772_info,
1449}, {
1450 // Cables-to-Go USB Ethernet Adapter
1451 USB_DEVICE(0x0b95, 0x772a),
1452 .driver_info = (unsigned long) &ax88772_info,
1447}, 1453},
1448 { }, // END 1454 { }, // END
1449}; 1455};
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 3590ea5a902d..11cb3e504e1c 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -2296,7 +2296,7 @@ static void velocity_set_multi(struct net_device *dev)
2296 } 2296 }
2297 2297
2298 mac_set_cam_mask(regs, vptr->mCAMmask); 2298 mac_set_cam_mask(regs, vptr->mCAMmask);
2299 rx_mode = (RCR_AM | RCR_AB); 2299 rx_mode = RCR_AM | RCR_AB | RCR_AP;
2300 } 2300 }
2301 if (dev->mtu > 1500) 2301 if (dev->mtu > 1500)
2302 rx_mode |= RCR_AL; 2302 rx_mode |= RCR_AL;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8d690a0eb1a9..444c5cc05f03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1384,7 +1384,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
1384 1384
1385 rxq->queue[i] = NULL; 1385 rxq->queue[i] = NULL;
1386 1386
1387 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr, 1387 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->aligned_dma_addr,
1388 priv->hw_params.rx_buf_size, 1388 priv->hw_params.rx_buf_size,
1389 PCI_DMA_FROMDEVICE); 1389 PCI_DMA_FROMDEVICE);
1390 pkt = (struct iwl_rx_packet *)rxb->skb->data; 1390 pkt = (struct iwl_rx_packet *)rxb->skb->data;
@@ -1436,8 +1436,8 @@ void iwl_rx_handle(struct iwl_priv *priv)
1436 rxb->skb = NULL; 1436 rxb->skb = NULL;
1437 } 1437 }
1438 1438
1439 pci_unmap_single(priv->pci_dev, rxb->dma_addr, 1439 pci_unmap_single(priv->pci_dev, rxb->real_dma_addr,
1440 priv->hw_params.rx_buf_size, 1440 priv->hw_params.rx_buf_size + 256,
1441 PCI_DMA_FROMDEVICE); 1441 PCI_DMA_FROMDEVICE);
1442 spin_lock_irqsave(&rxq->lock, flags); 1442 spin_lock_irqsave(&rxq->lock, flags);
1443 list_add_tail(&rxb->list, &priv->rxq.rx_used); 1443 list_add_tail(&rxb->list, &priv->rxq.rx_used);
@@ -2341,7 +2341,6 @@ static void iwl_bg_alive_start(struct work_struct *data)
2341 mutex_lock(&priv->mutex); 2341 mutex_lock(&priv->mutex);
2342 iwl_alive_start(priv); 2342 iwl_alive_start(priv);
2343 mutex_unlock(&priv->mutex); 2343 mutex_unlock(&priv->mutex);
2344 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
2345} 2344}
2346 2345
2347static void iwl4965_bg_rf_kill(struct work_struct *work) 2346static void iwl4965_bg_rf_kill(struct work_struct *work)
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c018121085e9..9966d4e384ce 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -89,7 +89,8 @@ extern struct iwl_cfg iwl5100_abg_cfg;
89#define DEFAULT_LONG_RETRY_LIMIT 4U 89#define DEFAULT_LONG_RETRY_LIMIT 4U
90 90
91struct iwl_rx_mem_buffer { 91struct iwl_rx_mem_buffer {
92 dma_addr_t dma_addr; 92 dma_addr_t real_dma_addr;
93 dma_addr_t aligned_dma_addr;
93 struct sk_buff *skb; 94 struct sk_buff *skb;
94 struct list_head list; 95 struct list_head list;
95}; 96};
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 7cde9d76ff5d..0509c16dbe75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -204,7 +204,7 @@ int iwl_rx_queue_restock(struct iwl_priv *priv)
204 list_del(element); 204 list_del(element);
205 205
206 /* Point to Rx buffer via next RBD in circular buffer */ 206 /* Point to Rx buffer via next RBD in circular buffer */
207 rxq->bd[rxq->write] = iwl_dma_addr2rbd_ptr(priv, rxb->dma_addr); 207 rxq->bd[rxq->write] = iwl_dma_addr2rbd_ptr(priv, rxb->aligned_dma_addr);
208 rxq->queue[rxq->write] = rxb; 208 rxq->queue[rxq->write] = rxb;
209 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; 209 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK;
210 rxq->free_count--; 210 rxq->free_count--;
@@ -251,7 +251,7 @@ void iwl_rx_allocate(struct iwl_priv *priv)
251 rxb = list_entry(element, struct iwl_rx_mem_buffer, list); 251 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
252 252
253 /* Alloc a new receive buffer */ 253 /* Alloc a new receive buffer */
254 rxb->skb = alloc_skb(priv->hw_params.rx_buf_size, 254 rxb->skb = alloc_skb(priv->hw_params.rx_buf_size + 256,
255 __GFP_NOWARN | GFP_ATOMIC); 255 __GFP_NOWARN | GFP_ATOMIC);
256 if (!rxb->skb) { 256 if (!rxb->skb) {
257 if (net_ratelimit()) 257 if (net_ratelimit())
@@ -266,9 +266,17 @@ void iwl_rx_allocate(struct iwl_priv *priv)
266 list_del(element); 266 list_del(element);
267 267
268 /* Get physical address of RB/SKB */ 268 /* Get physical address of RB/SKB */
269 rxb->dma_addr = 269 rxb->real_dma_addr = pci_map_single(
270 pci_map_single(priv->pci_dev, rxb->skb->data, 270 priv->pci_dev,
271 priv->hw_params.rx_buf_size, PCI_DMA_FROMDEVICE); 271 rxb->skb->data,
272 priv->hw_params.rx_buf_size + 256,
273 PCI_DMA_FROMDEVICE);
274 /* dma address must be no more than 36 bits */
275 BUG_ON(rxb->real_dma_addr & ~DMA_BIT_MASK(36));
276 /* and also 256 byte aligned! */
277 rxb->aligned_dma_addr = ALIGN(rxb->real_dma_addr, 256);
278 skb_reserve(rxb->skb, rxb->aligned_dma_addr - rxb->real_dma_addr);
279
272 list_add_tail(&rxb->list, &rxq->rx_free); 280 list_add_tail(&rxb->list, &rxq->rx_free);
273 rxq->free_count++; 281 rxq->free_count++;
274 } 282 }
@@ -300,8 +308,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
300 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { 308 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
301 if (rxq->pool[i].skb != NULL) { 309 if (rxq->pool[i].skb != NULL) {
302 pci_unmap_single(priv->pci_dev, 310 pci_unmap_single(priv->pci_dev,
303 rxq->pool[i].dma_addr, 311 rxq->pool[i].real_dma_addr,
304 priv->hw_params.rx_buf_size, 312 priv->hw_params.rx_buf_size + 256,
305 PCI_DMA_FROMDEVICE); 313 PCI_DMA_FROMDEVICE);
306 dev_kfree_skb(rxq->pool[i].skb); 314 dev_kfree_skb(rxq->pool[i].skb);
307 } 315 }
@@ -354,8 +362,8 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
354 * to an SKB, so we need to unmap and free potential storage */ 362 * to an SKB, so we need to unmap and free potential storage */
355 if (rxq->pool[i].skb != NULL) { 363 if (rxq->pool[i].skb != NULL) {
356 pci_unmap_single(priv->pci_dev, 364 pci_unmap_single(priv->pci_dev,
357 rxq->pool[i].dma_addr, 365 rxq->pool[i].real_dma_addr,
358 priv->hw_params.rx_buf_size, 366 priv->hw_params.rx_buf_size + 256,
359 PCI_DMA_FROMDEVICE); 367 PCI_DMA_FROMDEVICE);
360 priv->alloc_rxb_skb--; 368 priv->alloc_rxb_skb--;
361 dev_kfree_skb(rxq->pool[i].skb); 369 dev_kfree_skb(rxq->pool[i].skb);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 285b53e7e261..45a6b0c35695 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6012,7 +6012,6 @@ static void iwl3945_bg_alive_start(struct work_struct *data)
6012 mutex_lock(&priv->mutex); 6012 mutex_lock(&priv->mutex);
6013 iwl3945_alive_start(priv); 6013 iwl3945_alive_start(priv);
6014 mutex_unlock(&priv->mutex); 6014 mutex_unlock(&priv->mutex);
6015 ieee80211_notify_mac(priv->hw, IEEE80211_NOTIFY_RE_ASSOC);
6016} 6015}
6017 6016
6018static void iwl3945_bg_rf_kill(struct work_struct *work) 6017static void iwl3945_bg_rf_kill(struct work_struct *work)
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index 1cc03a8dd67a..59634c33b1f9 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -331,7 +331,7 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
331 /* Fill the receive configuration URB and initialise the Rx call back */ 331 /* Fill the receive configuration URB and initialise the Rx call back */
332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, 332 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in), 333 usb_rcvbulkpipe(cardp->udev, cardp->ep_in),
334 (void *) (skb->tail), 334 skb_tail_pointer(skb),
335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp); 335 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp);
336 336
337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; 337 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 209b4a464bcf..855f389eea40 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -36,7 +36,7 @@ if PARPORT
36config PARPORT_PC 36config PARPORT_PC
37 tristate "PC-style hardware" 37 tristate "PC-style hardware"
38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \ 38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
39 (!M68K || ISA) && !MN10300 && !AVR32 39 (!M68K || ISA) && !MN10300 && !AVR32 && !BLACKFIN
40 ---help--- 40 ---help---
41 You should say Y here if you have a PC-style parallel port. All 41 You should say Y here if you have a PC-style parallel port. All
42 IBM PC compatible computers and some Alphas have PC-style 42 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index a2692724b68f..5c8baa43ac9c 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1655,12 +1655,14 @@ int __init init_dmars(void)
1655 iommu->flush.flush_context = __iommu_flush_context; 1655 iommu->flush.flush_context = __iommu_flush_context;
1656 iommu->flush.flush_iotlb = __iommu_flush_iotlb; 1656 iommu->flush.flush_iotlb = __iommu_flush_iotlb;
1657 printk(KERN_INFO "IOMMU 0x%Lx: using Register based " 1657 printk(KERN_INFO "IOMMU 0x%Lx: using Register based "
1658 "invalidation\n", drhd->reg_base_addr); 1658 "invalidation\n",
1659 (unsigned long long)drhd->reg_base_addr);
1659 } else { 1660 } else {
1660 iommu->flush.flush_context = qi_flush_context; 1661 iommu->flush.flush_context = qi_flush_context;
1661 iommu->flush.flush_iotlb = qi_flush_iotlb; 1662 iommu->flush.flush_iotlb = qi_flush_iotlb;
1662 printk(KERN_INFO "IOMMU 0x%Lx: using Queued " 1663 printk(KERN_INFO "IOMMU 0x%Lx: using Queued "
1663 "invalidation\n", drhd->reg_base_addr); 1664 "invalidation\n",
1665 (unsigned long long)drhd->reg_base_addr);
1664 } 1666 }
1665 } 1667 }
1666 1668
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index b3a63edb6901..ae5ec76dca77 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -63,7 +63,7 @@ static acpi_status acpi_run_osc(acpi_handle handle,
63 union acpi_object in_params[4]; 63 union acpi_object in_params[4];
64 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 64 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
65 union acpi_object *out_obj; 65 union acpi_object *out_obj;
66 u32 osc_dw0, flags = osc_args->capbuf[OSC_QUERY_TYPE]; 66 u32 errors, flags = osc_args->capbuf[OSC_QUERY_TYPE];
67 67
68 /* Setting up input parameters */ 68 /* Setting up input parameters */
69 input.count = 4; 69 input.count = 4;
@@ -92,15 +92,16 @@ static acpi_status acpi_run_osc(acpi_handle handle,
92 status = AE_TYPE; 92 status = AE_TYPE;
93 goto out_kfree; 93 goto out_kfree;
94 } 94 }
95 osc_dw0 = *((u32 *)out_obj->buffer.pointer); 95 /* Need to ignore the bit0 in result code */
96 if (osc_dw0) { 96 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
97 if (osc_dw0 & OSC_REQUEST_ERROR) 97 if (errors) {
98 if (errors & OSC_REQUEST_ERROR)
98 printk(KERN_DEBUG "_OSC request fails\n"); 99 printk(KERN_DEBUG "_OSC request fails\n");
99 if (osc_dw0 & OSC_INVALID_UUID_ERROR) 100 if (errors & OSC_INVALID_UUID_ERROR)
100 printk(KERN_DEBUG "_OSC invalid UUID\n"); 101 printk(KERN_DEBUG "_OSC invalid UUID\n");
101 if (osc_dw0 & OSC_INVALID_REVISION_ERROR) 102 if (errors & OSC_INVALID_REVISION_ERROR)
102 printk(KERN_DEBUG "_OSC invalid revision\n"); 103 printk(KERN_DEBUG "_OSC invalid revision\n");
103 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { 104 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
104 if (flags & OSC_QUERY_ENABLE) 105 if (flags & OSC_QUERY_ENABLE)
105 goto out_success; 106 goto out_success;
106 printk(KERN_DEBUG "_OSC FW not grant req. control\n"); 107 printk(KERN_DEBUG "_OSC FW not grant req. control\n");
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 21f2ac639cab..28af496b441e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1832,7 +1832,7 @@ int pci_reset_function(struct pci_dev *dev)
1832 if (!(cap & PCI_EXP_DEVCAP_FLR)) 1832 if (!(cap & PCI_EXP_DEVCAP_FLR))
1833 return -ENOTTY; 1833 return -ENOTTY;
1834 1834
1835 if (!dev->msi_enabled && !dev->msix_enabled) 1835 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0)
1836 disable_irq(dev->irq); 1836 disable_irq(dev->irq);
1837 pci_save_state(dev); 1837 pci_save_state(dev);
1838 1838
@@ -1841,7 +1841,7 @@ int pci_reset_function(struct pci_dev *dev)
1841 r = pci_execute_reset_function(dev); 1841 r = pci_execute_reset_function(dev);
1842 1842
1843 pci_restore_state(dev); 1843 pci_restore_state(dev);
1844 if (!dev->msi_enabled && !dev->msix_enabled) 1844 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0)
1845 enable_irq(dev->irq); 1845 enable_irq(dev->irq);
1846 1846
1847 return r; 1847 return r;
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index dcce9f5d8465..4a110b7b2673 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -351,10 +351,11 @@ int verify_cis_cache(struct pcmcia_socket *s)
351 char *buf; 351 char *buf;
352 352
353 buf = kmalloc(256, GFP_KERNEL); 353 buf = kmalloc(256, GFP_KERNEL);
354 if (buf == NULL) 354 if (buf == NULL) {
355 dev_printk(KERN_WARNING, &s->dev, 355 dev_printk(KERN_WARNING, &s->dev,
356 "no memory for verifying CIS\n"); 356 "no memory for verifying CIS\n");
357 return -ENOMEM; 357 return -ENOMEM;
358 }
358 list_for_each_entry(cis, &s->cis_cache, node) { 359 list_for_each_entry(cis, &s->cis_cache, node) {
359 int len = cis->len; 360 int len = cis->len;
360 361
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index c68c5d338285..0660ad182589 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -186,12 +186,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
186 186
187 spin_lock_init(&socket->lock); 187 spin_lock_init(&socket->lock);
188 188
189 if (socket->resource_ops->init) {
190 ret = socket->resource_ops->init(socket);
191 if (ret)
192 return (ret);
193 }
194
195 /* try to obtain a socket number [yes, it gets ugly if we 189 /* try to obtain a socket number [yes, it gets ugly if we
196 * register more than 2^sizeof(unsigned int) pcmcia 190 * register more than 2^sizeof(unsigned int) pcmcia
197 * sockets... but the socket number is deprecated 191 * sockets... but the socket number is deprecated
@@ -226,7 +220,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
226 /* set proper values in socket->dev */ 220 /* set proper values in socket->dev */
227 dev_set_drvdata(&socket->dev, socket); 221 dev_set_drvdata(&socket->dev, socket);
228 socket->dev.class = &pcmcia_socket_class; 222 socket->dev.class = &pcmcia_socket_class;
229 snprintf(socket->dev.bus_id, BUS_ID_SIZE, "pcmcia_socket%u", socket->sock); 223 dev_set_name(&socket->dev, "pcmcia_socket%u", socket->sock);
230 224
231 /* base address = 0, map = 0 */ 225 /* base address = 0, map = 0 */
232 socket->cis_mem.flags = 0; 226 socket->cis_mem.flags = 0;
@@ -239,6 +233,12 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
239 mutex_init(&socket->skt_mutex); 233 mutex_init(&socket->skt_mutex);
240 spin_lock_init(&socket->thread_lock); 234 spin_lock_init(&socket->thread_lock);
241 235
236 if (socket->resource_ops->init) {
237 ret = socket->resource_ops->init(socket);
238 if (ret)
239 goto err;
240 }
241
242 tsk = kthread_run(pccardd, socket, "pccardd"); 242 tsk = kthread_run(pccardd, socket, "pccardd");
243 if (IS_ERR(tsk)) { 243 if (IS_ERR(tsk)) {
244 ret = PTR_ERR(tsk); 244 ret = PTR_ERR(tsk);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 795660255490..47cab31ff6e4 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -622,7 +622,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
622{ 622{
623 struct pcmcia_device *p_dev, *tmp_dev; 623 struct pcmcia_device *p_dev, *tmp_dev;
624 unsigned long flags; 624 unsigned long flags;
625 int bus_id_len;
626 625
627 s = pcmcia_get_socket(s); 626 s = pcmcia_get_socket(s);
628 if (!s) 627 if (!s)
@@ -650,12 +649,12 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
650 /* by default don't allow DMA */ 649 /* by default don't allow DMA */
651 p_dev->dma_mask = DMA_MASK_NONE; 650 p_dev->dma_mask = DMA_MASK_NONE;
652 p_dev->dev.dma_mask = &p_dev->dma_mask; 651 p_dev->dev.dma_mask = &p_dev->dma_mask;
653 bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); 652 dev_set_name(&p_dev->dev, "%d.%d", p_dev->socket->sock, p_dev->device_no);
654 653 if (!dev_name(&p_dev->dev))
655 p_dev->devname = kmalloc(6 + bus_id_len + 1, GFP_KERNEL); 654 goto err_free;
655 p_dev->devname = kasprintf(GFP_KERNEL, "pcmcia%s", dev_name(&p_dev->dev));
656 if (!p_dev->devname) 656 if (!p_dev->devname)
657 goto err_free; 657 goto err_free;
658 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
659 ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); 658 ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname);
660 659
661 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 660 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
@@ -668,6 +667,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
668 list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list) 667 list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list)
669 if (p_dev->func == tmp_dev->func) { 668 if (p_dev->func == tmp_dev->func) {
670 p_dev->function_config = tmp_dev->function_config; 669 p_dev->function_config = tmp_dev->function_config;
670 p_dev->io = tmp_dev->io;
671 p_dev->irq = tmp_dev->irq;
671 kref_get(&p_dev->function_config->ref); 672 kref_get(&p_dev->function_config->ref);
672 } 673 }
673 674
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 76d4a98f0955..f5d0ba8e22d5 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -302,9 +302,10 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
302 /* We only allow changing Vpp1 and Vpp2 to the same value */ 302 /* We only allow changing Vpp1 and Vpp2 to the same value */
303 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && 303 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) &&
304 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { 304 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) {
305 if (mod->Vpp1 != mod->Vpp2) 305 if (mod->Vpp1 != mod->Vpp2) {
306 ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); 306 ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n");
307 return -EINVAL; 307 return -EINVAL;
308 }
308 s->socket.Vpp = mod->Vpp1; 309 s->socket.Vpp = mod->Vpp1;
309 if (s->ops->set_socket(s, &s->socket)) { 310 if (s->ops->set_socket(s, &s->socket)) {
310 dev_printk(KERN_WARNING, &s->dev, 311 dev_printk(KERN_WARNING, &s->dev,
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 17f4ecf1c0c5..9ca22c7aafb2 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -71,7 +71,7 @@ static DEFINE_MUTEX(rsrc_mutex);
71======================================================================*/ 71======================================================================*/
72 72
73static struct resource * 73static struct resource *
74make_resource(resource_size_t b, resource_size_t n, int flags, char *name) 74make_resource(resource_size_t b, resource_size_t n, int flags, const char *name)
75{ 75{
76 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); 76 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
77 77
@@ -624,7 +624,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
624static struct resource *nonstatic_find_io_region(unsigned long base, int num, 624static struct resource *nonstatic_find_io_region(unsigned long base, int num,
625 unsigned long align, struct pcmcia_socket *s) 625 unsigned long align, struct pcmcia_socket *s)
626{ 626{
627 struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.bus_id); 627 struct resource *res = make_resource(0, num, IORESOURCE_IO, dev_name(&s->dev));
628 struct socket_data *s_data = s->resource_data; 628 struct socket_data *s_data = s->resource_data;
629 struct pcmcia_align_data data; 629 struct pcmcia_align_data data;
630 unsigned long min = base; 630 unsigned long min = base;
@@ -658,7 +658,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
658static struct resource * nonstatic_find_mem_region(u_long base, u_long num, 658static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
659 u_long align, int low, struct pcmcia_socket *s) 659 u_long align, int low, struct pcmcia_socket *s)
660{ 660{
661 struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.bus_id); 661 struct resource *res = make_resource(0, num, IORESOURCE_MEM, dev_name(&s->dev));
662 struct socket_data *s_data = s->resource_data; 662 struct socket_data *s_data = s->resource_data;
663 struct pcmcia_align_data data; 663 struct pcmcia_align_data data;
664 unsigned long min, max; 664 unsigned long min, max;
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c
index 2012ccbb4a53..5b2261052a65 100644
--- a/drivers/rtc/rtc-sun4v.c
+++ b/drivers/rtc/rtc-sun4v.c
@@ -1,4 +1,4 @@
1/* rtc-sun4c.c: Hypervisor based RTC for SUN4V systems. 1/* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems.
2 * 2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */ 4 */
@@ -7,21 +7,11 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/time.h>
11#include <linux/rtc.h> 10#include <linux/rtc.h>
12#include <linux/platform_device.h> 11#include <linux/platform_device.h>
13 12
14#include <asm/hypervisor.h> 13#include <asm/hypervisor.h>
15 14
16MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
17MODULE_DESCRIPTION("SUN4V RTC driver");
18MODULE_LICENSE("GPL");
19
20struct sun4v_rtc {
21 struct rtc_device *rtc;
22 spinlock_t lock;
23};
24
25static unsigned long hypervisor_get_time(void) 15static unsigned long hypervisor_get_time(void)
26{ 16{
27 unsigned long ret, time; 17 unsigned long ret, time;
@@ -45,15 +35,7 @@ retry:
45 35
46static int sun4v_read_time(struct device *dev, struct rtc_time *tm) 36static int sun4v_read_time(struct device *dev, struct rtc_time *tm)
47{ 37{
48 struct sun4v_rtc *p = dev_get_drvdata(dev); 38 rtc_time_to_tm(hypervisor_get_time(), tm);
49 unsigned long flags, secs;
50
51 spin_lock_irqsave(&p->lock, flags);
52 secs = hypervisor_get_time();
53 spin_unlock_irqrestore(&p->lock, flags);
54
55 rtc_time_to_tm(secs, tm);
56
57 return 0; 39 return 0;
58} 40}
59 41
@@ -80,19 +62,14 @@ retry:
80 62
81static int sun4v_set_time(struct device *dev, struct rtc_time *tm) 63static int sun4v_set_time(struct device *dev, struct rtc_time *tm)
82{ 64{
83 struct sun4v_rtc *p = dev_get_drvdata(dev); 65 unsigned long secs;
84 unsigned long flags, secs;
85 int err; 66 int err;
86 67
87 err = rtc_tm_to_time(tm, &secs); 68 err = rtc_tm_to_time(tm, &secs);
88 if (err) 69 if (err)
89 return err; 70 return err;
90 71
91 spin_lock_irqsave(&p->lock, flags); 72 return hypervisor_set_time(secs);
92 err = hypervisor_set_time(secs);
93 spin_unlock_irqrestore(&p->lock, flags);
94
95 return err;
96} 73}
97 74
98static const struct rtc_class_ops sun4v_rtc_ops = { 75static const struct rtc_class_ops sun4v_rtc_ops = {
@@ -100,33 +77,22 @@ static const struct rtc_class_ops sun4v_rtc_ops = {
100 .set_time = sun4v_set_time, 77 .set_time = sun4v_set_time,
101}; 78};
102 79
103static int __devinit sun4v_rtc_probe(struct platform_device *pdev) 80static int __init sun4v_rtc_probe(struct platform_device *pdev)
104{ 81{
105 struct sun4v_rtc *p = kzalloc(sizeof(*p), GFP_KERNEL); 82 struct rtc_device *rtc = rtc_device_register("sun4v", &pdev->dev,
106
107 if (!p)
108 return -ENOMEM;
109
110 spin_lock_init(&p->lock);
111
112 p->rtc = rtc_device_register("sun4v", &pdev->dev,
113 &sun4v_rtc_ops, THIS_MODULE); 83 &sun4v_rtc_ops, THIS_MODULE);
114 if (IS_ERR(p->rtc)) { 84 if (IS_ERR(rtc))
115 int err = PTR_ERR(p->rtc); 85 return PTR_ERR(rtc);
116 kfree(p); 86
117 return err; 87 platform_set_drvdata(pdev, rtc);
118 }
119 platform_set_drvdata(pdev, p);
120 return 0; 88 return 0;
121} 89}
122 90
123static int __devexit sun4v_rtc_remove(struct platform_device *pdev) 91static int __exit sun4v_rtc_remove(struct platform_device *pdev)
124{ 92{
125 struct sun4v_rtc *p = platform_get_drvdata(pdev); 93 struct rtc_device *rtc = platform_get_drvdata(pdev);
126
127 rtc_device_unregister(p->rtc);
128 kfree(p);
129 94
95 rtc_device_unregister(rtc);
130 return 0; 96 return 0;
131} 97}
132 98
@@ -135,13 +101,12 @@ static struct platform_driver sun4v_rtc_driver = {
135 .name = "rtc-sun4v", 101 .name = "rtc-sun4v",
136 .owner = THIS_MODULE, 102 .owner = THIS_MODULE,
137 }, 103 },
138 .probe = sun4v_rtc_probe, 104 .remove = __exit_p(sun4v_rtc_remove),
139 .remove = __devexit_p(sun4v_rtc_remove),
140}; 105};
141 106
142static int __init sun4v_rtc_init(void) 107static int __init sun4v_rtc_init(void)
143{ 108{
144 return platform_driver_register(&sun4v_rtc_driver); 109 return platform_driver_probe(&sun4v_rtc_driver, sun4v_rtc_probe);
145} 110}
146 111
147static void __exit sun4v_rtc_exit(void) 112static void __exit sun4v_rtc_exit(void)
@@ -151,3 +116,7 @@ static void __exit sun4v_rtc_exit(void)
151 116
152module_init(sun4v_rtc_init); 117module_init(sun4v_rtc_init);
153module_exit(sun4v_rtc_exit); 118module_exit(sun4v_rtc_exit);
119
120MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
121MODULE_DESCRIPTION("SUN4V RTC driver");
122MODULE_LICENSE("GPL");
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 4b76fca64a6f..363bd1303d21 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1746,6 +1746,11 @@ restart:
1746 goto restart; 1746 goto restart;
1747 } 1747 }
1748 1748
1749 /* log sense for fatal error */
1750 if (cqr->status == DASD_CQR_FAILED) {
1751 dasd_log_sense(cqr, &cqr->irb);
1752 }
1753
1749 /* First of all call extended error reporting. */ 1754 /* First of all call extended error reporting. */
1750 if (dasd_eer_enabled(base) && 1755 if (dasd_eer_enabled(base) &&
1751 cqr->status == DASD_CQR_FAILED) { 1756 cqr->status == DASD_CQR_FAILED) {
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index eb5f1b8bc57f..ec9c0bcf66ee 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -324,6 +324,9 @@ static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
324 case 0x0120: 324 case 0x0120:
325 break; 325 break;
326 default: 326 default:
327 pr_warning("assign storage failed (cmd=0x%08x, "
328 "response=0x%04x, rn=0x%04x)\n", cmd,
329 sccb->header.response_code, rn);
327 rc = -EIO; 330 rc = -EIO;
328 break; 331 break;
329 } 332 }
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 4e78c82194b4..4e4008325e28 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -874,11 +874,15 @@ void ccw_device_move_to_orphanage(struct work_struct *work)
874 replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev); 874 replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
875 if (replacing_cdev) { 875 if (replacing_cdev) {
876 sch_attach_disconnected_device(sch, replacing_cdev); 876 sch_attach_disconnected_device(sch, replacing_cdev);
877 /* Release reference from get_disc_ccwdev_by_dev_id() */
878 put_device(&cdev->dev);
877 return; 879 return;
878 } 880 }
879 replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id); 881 replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id);
880 if (replacing_cdev) { 882 if (replacing_cdev) {
881 sch_attach_orphaned_device(sch, replacing_cdev); 883 sch_attach_orphaned_device(sch, replacing_cdev);
884 /* Release reference from get_orphaned_ccwdev_by_dev_id() */
885 put_device(&cdev->dev);
882 return; 886 return;
883 } 887 }
884 sch_create_and_recog_new_device(sch); 888 sch_create_and_recog_new_device(sch);
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index ff4a6931bb8e..3d442444c618 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -322,13 +322,13 @@ static int __init kvm_devices_init(void)
322 return rc; 322 return rc;
323 } 323 }
324 324
325 rc = vmem_add_mapping(PFN_PHYS(max_pfn), PAGE_SIZE); 325 rc = vmem_add_mapping(real_memory_size, PAGE_SIZE);
326 if (rc) { 326 if (rc) {
327 s390_root_dev_unregister(kvm_root); 327 s390_root_dev_unregister(kvm_root);
328 return rc; 328 return rc;
329 } 329 }
330 330
331 kvm_devices = (void *) PFN_PHYS(max_pfn); 331 kvm_devices = (void *) real_memory_size;
332 332
333 ctl_set_bit(0, 9); 333 ctl_set_bit(0, 9);
334 register_external_interrupt(0x2603, kvm_extint_handler); 334 register_external_interrupt(0x2603, kvm_extint_handler);
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 3b56220fb900..3d4e3e3f3fc0 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -610,7 +610,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
610 atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); 610 atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status);
611 atomic_set(&port->refcount, 0); 611 atomic_set(&port->refcount, 0);
612 612
613 dev_set_name(&port->sysfs_device, "0x%016llx", wwpn); 613 dev_set_name(&port->sysfs_device, "0x%016llx",
614 (unsigned long long)wwpn);
614 port->sysfs_device.parent = &adapter->ccw_device->dev; 615 port->sysfs_device.parent = &adapter->ccw_device->dev;
615 616
616 port->sysfs_device.release = zfcp_sysfs_port_release; 617 port->sysfs_device.release = zfcp_sysfs_port_release;
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index b04038c74786..951a8d409d1d 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -116,7 +116,9 @@ static int zfcp_ccw_set_online(struct ccw_device *ccw_device)
116 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, 116 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85,
117 NULL); 117 NULL);
118 zfcp_erp_wait(adapter); 118 zfcp_erp_wait(adapter);
119 goto out; 119 up(&zfcp_data.config_sema);
120 flush_work(&adapter->scan_work);
121 return 0;
120 122
121 out_scsi_register: 123 out_scsi_register:
122 zfcp_erp_thread_kill(adapter); 124 zfcp_erp_thread_kill(adapter);
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 060f5f2352ec..31012d58cfb7 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -30,7 +30,7 @@ static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len,
30 dump->offset = offset; 30 dump->offset = offset;
31 dump->size = min(from_len - offset, room); 31 dump->size = min(from_len - offset, room);
32 memcpy(dump->data, from + offset, dump->size); 32 memcpy(dump->data, from + offset, dump->size);
33 debug_event(dbf, level, dump, dump->size); 33 debug_event(dbf, level, dump, dump->size + sizeof(*dump));
34 } 34 }
35} 35}
36 36
@@ -108,7 +108,7 @@ static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view,
108 t.tv_sec, t.tv_nsec); 108 t.tv_sec, t.tv_nsec);
109 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); 109 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid);
110 } else { 110 } else {
111 zfcp_dbf_outd(&p, NULL, dump->data, dump->size, dump->offset, 111 zfcp_dbf_outd(&p, "", dump->data, dump->size, dump->offset,
112 dump->total_size); 112 dump->total_size);
113 if ((dump->offset + dump->size) == dump->total_size) 113 if ((dump->offset + dump->size) == dump->total_size)
114 p += sprintf(p, "\n"); 114 p += sprintf(p, "\n");
@@ -366,6 +366,7 @@ static void zfcp_hba_dbf_view_response(char **p,
366 break; 366 break;
367 zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); 367 zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd);
368 zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial); 368 zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial);
369 p += sprintf(*p, "\n");
369 break; 370 break;
370 371
371 case FSF_QTCB_OPEN_PORT_WITH_DID: 372 case FSF_QTCB_OPEN_PORT_WITH_DID:
@@ -465,7 +466,8 @@ static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view,
465 else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) 466 else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0)
466 zfcp_hba_dbf_view_berr(&p, &r->u.berr); 467 zfcp_hba_dbf_view_berr(&p, &r->u.berr);
467 468
468 p += sprintf(p, "\n"); 469 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0)
470 p += sprintf(p, "\n");
469 return p - out_buf; 471 return p - out_buf;
470} 472}
471 473
@@ -880,6 +882,7 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
880 struct ct_hdr *hdr = sg_virt(ct->req); 882 struct ct_hdr *hdr = sg_virt(ct->req);
881 struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; 883 struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf;
882 struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; 884 struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req;
885 int level = 3;
883 unsigned long flags; 886 unsigned long flags;
884 887
885 spin_lock_irqsave(&adapter->san_dbf_lock, flags); 888 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
@@ -896,9 +899,10 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
896 oct->options = hdr->options; 899 oct->options = hdr->options;
897 oct->max_res_size = hdr->max_res_size; 900 oct->max_res_size = hdr->max_res_size;
898 oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr), 901 oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr),
899 ZFCP_DBF_CT_PAYLOAD); 902 ZFCP_DBF_SAN_MAX_PAYLOAD);
900 memcpy(oct->payload, (void *)hdr + sizeof(struct ct_hdr), oct->len); 903 debug_event(adapter->san_dbf, level, r, sizeof(*r));
901 debug_event(adapter->san_dbf, 3, r, sizeof(*r)); 904 zfcp_dbf_hexdump(adapter->san_dbf, r, sizeof(*r), level,
905 (void *)hdr + sizeof(struct ct_hdr), oct->len);
902 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); 906 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
903} 907}
904 908
@@ -914,6 +918,7 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
914 struct ct_hdr *hdr = sg_virt(ct->resp); 918 struct ct_hdr *hdr = sg_virt(ct->resp);
915 struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; 919 struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf;
916 struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; 920 struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp;
921 int level = 3;
917 unsigned long flags; 922 unsigned long flags;
918 923
919 spin_lock_irqsave(&adapter->san_dbf_lock, flags); 924 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
@@ -929,9 +934,10 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
929 rct->expl = hdr->reason_code_expl; 934 rct->expl = hdr->reason_code_expl;
930 rct->vendor_unique = hdr->vendor_unique; 935 rct->vendor_unique = hdr->vendor_unique;
931 rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr), 936 rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr),
932 ZFCP_DBF_CT_PAYLOAD); 937 ZFCP_DBF_SAN_MAX_PAYLOAD);
933 memcpy(rct->payload, (void *)hdr + sizeof(struct ct_hdr), rct->len); 938 debug_event(adapter->san_dbf, level, r, sizeof(*r));
934 debug_event(adapter->san_dbf, 3, r, sizeof(*r)); 939 zfcp_dbf_hexdump(adapter->san_dbf, r, sizeof(*r), level,
940 (void *)hdr + sizeof(struct ct_hdr), rct->len);
935 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); 941 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
936} 942}
937 943
@@ -954,7 +960,7 @@ static void zfcp_san_dbf_event_els(const char *tag, int level,
954 rec->u.els.ls_code = ls_code; 960 rec->u.els.ls_code = ls_code;
955 debug_event(adapter->san_dbf, level, rec, sizeof(*rec)); 961 debug_event(adapter->san_dbf, level, rec, sizeof(*rec));
956 zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level, 962 zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level,
957 buffer, min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD)); 963 buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD));
958 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); 964 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
959} 965}
960 966
@@ -1008,8 +1014,6 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
1008 char *out_buf, const char *in_buf) 1014 char *out_buf, const char *in_buf)
1009{ 1015{
1010 struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf; 1016 struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf;
1011 char *buffer = NULL;
1012 int buflen = 0, total = 0;
1013 char *p = out_buf; 1017 char *p = out_buf;
1014 1018
1015 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) 1019 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
@@ -1029,9 +1033,6 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
1029 zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype); 1033 zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype);
1030 zfcp_dbf_out(&p, "options", "0x%02x", ct->options); 1034 zfcp_dbf_out(&p, "options", "0x%02x", ct->options);
1031 zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size); 1035 zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size);
1032 total = ct->len;
1033 buffer = ct->payload;
1034 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
1035 } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { 1036 } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
1036 struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp; 1037 struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp;
1037 zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); 1038 zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code);
@@ -1039,23 +1040,12 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
1039 zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); 1040 zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code);
1040 zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl); 1041 zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl);
1041 zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique); 1042 zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique);
1042 total = ct->len;
1043 buffer = ct->payload;
1044 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
1045 } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || 1043 } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
1046 strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || 1044 strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
1047 strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { 1045 strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
1048 struct zfcp_san_dbf_record_els *els = &r->u.els; 1046 struct zfcp_san_dbf_record_els *els = &r->u.els;
1049 zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code); 1047 zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code);
1050 total = els->len;
1051 buffer = els->payload;
1052 buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
1053 } 1048 }
1054
1055 zfcp_dbf_outd(&p, "payload", buffer, buflen, 0, total);
1056 if (buflen == total)
1057 p += sprintf(p, "\n");
1058
1059 return p - out_buf; 1049 return p - out_buf;
1060} 1050}
1061 1051
diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h
index e8f450801fea..5d6b2dff855b 100644
--- a/drivers/s390/scsi/zfcp_dbf.h
+++ b/drivers/s390/scsi/zfcp_dbf.h
@@ -163,8 +163,6 @@ struct zfcp_san_dbf_record_ct_request {
163 u8 options; 163 u8 options;
164 u16 max_res_size; 164 u16 max_res_size;
165 u32 len; 165 u32 len;
166#define ZFCP_DBF_CT_PAYLOAD 24
167 u8 payload[ZFCP_DBF_CT_PAYLOAD];
168} __attribute__ ((packed)); 166} __attribute__ ((packed));
169 167
170struct zfcp_san_dbf_record_ct_response { 168struct zfcp_san_dbf_record_ct_response {
@@ -174,15 +172,11 @@ struct zfcp_san_dbf_record_ct_response {
174 u8 expl; 172 u8 expl;
175 u8 vendor_unique; 173 u8 vendor_unique;
176 u32 len; 174 u32 len;
177 u8 payload[ZFCP_DBF_CT_PAYLOAD];
178} __attribute__ ((packed)); 175} __attribute__ ((packed));
179 176
180struct zfcp_san_dbf_record_els { 177struct zfcp_san_dbf_record_els {
181 u8 ls_code; 178 u8 ls_code;
182 u32 len; 179 u32 len;
183#define ZFCP_DBF_ELS_PAYLOAD 32
184#define ZFCP_DBF_ELS_MAX_PAYLOAD 1024
185 u8 payload[ZFCP_DBF_ELS_PAYLOAD];
186} __attribute__ ((packed)); 180} __attribute__ ((packed));
187 181
188struct zfcp_san_dbf_record { 182struct zfcp_san_dbf_record {
@@ -196,6 +190,8 @@ struct zfcp_san_dbf_record {
196 struct zfcp_san_dbf_record_ct_response ct_resp; 190 struct zfcp_san_dbf_record_ct_response ct_resp;
197 struct zfcp_san_dbf_record_els els; 191 struct zfcp_san_dbf_record_els els;
198 } u; 192 } u;
193#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
194 u8 payload[32];
199} __attribute__ ((packed)); 195} __attribute__ ((packed));
200 196
201struct zfcp_scsi_dbf_record { 197struct zfcp_scsi_dbf_record {
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 9040f738ff33..35364f64da7f 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -472,6 +472,7 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
472 ZFCP_STATUS_ERP_TIMEDOUT)) { 472 ZFCP_STATUS_ERP_TIMEDOUT)) {
473 act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; 473 act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
474 zfcp_rec_dbf_event_action(142, act); 474 zfcp_rec_dbf_event_action(142, act);
475 act->fsf_req->erp_action = NULL;
475 } 476 }
476 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) 477 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT)
477 zfcp_rec_dbf_event_action(143, act); 478 zfcp_rec_dbf_event_action(143, act);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 5ae1d497e5ed..d024442ee128 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -683,6 +683,7 @@ static struct zfcp_fsf_req *zfcp_fsf_alloc_noqtcb(mempool_t *pool)
683 if (!req) 683 if (!req)
684 return NULL; 684 return NULL;
685 memset(req, 0, sizeof(*req)); 685 memset(req, 0, sizeof(*req));
686 req->pool = pool;
686 return req; 687 return req;
687} 688}
688 689
@@ -769,28 +770,24 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
769static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) 770static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
770{ 771{
771 struct zfcp_adapter *adapter = req->adapter; 772 struct zfcp_adapter *adapter = req->adapter;
772 struct zfcp_qdio_queue *req_q = &adapter->req_q; 773 unsigned long flags;
773 int idx; 774 int idx;
774 775
775 /* put allocated FSF request into hash table */ 776 /* put allocated FSF request into hash table */
776 spin_lock(&adapter->req_list_lock); 777 spin_lock_irqsave(&adapter->req_list_lock, flags);
777 idx = zfcp_reqlist_hash(req->req_id); 778 idx = zfcp_reqlist_hash(req->req_id);
778 list_add_tail(&req->list, &adapter->req_list[idx]); 779 list_add_tail(&req->list, &adapter->req_list[idx]);
779 spin_unlock(&adapter->req_list_lock); 780 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
780 781
781 req->qdio_outb_usage = atomic_read(&req_q->count); 782 req->qdio_outb_usage = atomic_read(&adapter->req_q.count);
782 req->issued = get_clock(); 783 req->issued = get_clock();
783 if (zfcp_qdio_send(req)) { 784 if (zfcp_qdio_send(req)) {
784 /* Queues are down..... */
785 del_timer(&req->timer); 785 del_timer(&req->timer);
786 spin_lock(&adapter->req_list_lock); 786 spin_lock_irqsave(&adapter->req_list_lock, flags);
787 zfcp_reqlist_remove(adapter, req); 787 /* lookup request again, list might have changed */
788 spin_unlock(&adapter->req_list_lock); 788 if (zfcp_reqlist_find_safe(adapter, req))
789 /* undo changes in request queue made for this request */ 789 zfcp_reqlist_remove(adapter, req);
790 atomic_add(req->sbal_number, &req_q->count); 790 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
791 req_q->first -= req->sbal_number;
792 req_q->first += QDIO_MAX_BUFFERS_PER_Q;
793 req_q->first %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
794 zfcp_erp_adapter_reopen(adapter, 0, 116, req); 791 zfcp_erp_adapter_reopen(adapter, 0, 116, req);
795 return -EIO; 792 return -EIO;
796 } 793 }
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index ca8f85f3dad4..e46fd3e9f68f 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -24,14 +24,10 @@ char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu)
24static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) 24static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt)
25{ 25{
26 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; 26 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata;
27 WARN_ON(!unit); 27 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status);
28 if (unit) { 28 unit->device = NULL;
29 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status); 29 zfcp_erp_unit_failed(unit, 12, NULL);
30 sdpnt->hostdata = NULL; 30 zfcp_unit_put(unit);
31 unit->device = NULL;
32 zfcp_erp_unit_failed(unit, 12, NULL);
33 zfcp_unit_put(unit);
34 }
35} 31}
36 32
37static int zfcp_scsi_slave_configure(struct scsi_device *sdp) 33static int zfcp_scsi_slave_configure(struct scsi_device *sdp)
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 8aba4fdfb522..6194ed5d02c4 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -2445,7 +2445,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2445 hba_status = detailed_status >> 8; 2445 hba_status = detailed_status >> 8;
2446 2446
2447 // calculate resid for sg 2447 // calculate resid for sg
2448 scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+5)); 2448 scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+20));
2449 2449
2450 pHba = (adpt_hba*) cmd->device->host->hostdata[0]; 2450 pHba = (adpt_hba*) cmd->device->host->hostdata[0];
2451 2451
@@ -2456,7 +2456,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2456 case I2O_SCSI_DSC_SUCCESS: 2456 case I2O_SCSI_DSC_SUCCESS:
2457 cmd->result = (DID_OK << 16); 2457 cmd->result = (DID_OK << 16);
2458 // handle underflow 2458 // handle underflow
2459 if(readl(reply+5) < cmd->underflow ) { 2459 if (readl(reply+20) < cmd->underflow) {
2460 cmd->result = (DID_ERROR <<16); 2460 cmd->result = (DID_ERROR <<16);
2461 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); 2461 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name);
2462 } 2462 }
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 28c9da7d4a5c..7dc62deb4087 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4402,6 +4402,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4402 scb_t *scb; 4402 scb_t *scb;
4403 int rval; 4403 int rval;
4404 4404
4405 scmd = scsi_allocate_command(GFP_KERNEL);
4406 if (!scmd)
4407 return -ENOMEM;
4408
4405 /* 4409 /*
4406 * The internal commands share one command id and hence are 4410 * The internal commands share one command id and hence are
4407 * serialized. This is so because we want to reserve maximum number of 4411 * serialized. This is so because we want to reserve maximum number of
@@ -4412,12 +4416,11 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4412 scb = &adapter->int_scb; 4416 scb = &adapter->int_scb;
4413 memset(scb, 0, sizeof(scb_t)); 4417 memset(scb, 0, sizeof(scb_t));
4414 4418
4415 scmd = &adapter->int_scmd;
4416 memset(scmd, 0, sizeof(Scsi_Cmnd));
4417
4418 sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); 4419 sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
4419 scmd->device = sdev; 4420 scmd->device = sdev;
4420 4421
4422 memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
4423 scmd->cmnd = adapter->int_cdb;
4421 scmd->device->host = adapter->host; 4424 scmd->device->host = adapter->host;
4422 scmd->host_scribble = (void *)scb; 4425 scmd->host_scribble = (void *)scb;
4423 scmd->cmnd[0] = MEGA_INTERNAL_CMD; 4426 scmd->cmnd[0] = MEGA_INTERNAL_CMD;
@@ -4456,6 +4459,8 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4456 4459
4457 mutex_unlock(&adapter->int_mtx); 4460 mutex_unlock(&adapter->int_mtx);
4458 4461
4462 scsi_free_command(GFP_KERNEL, scmd);
4463
4459 return rval; 4464 return rval;
4460} 4465}
4461 4466
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index ee70bd4ae4ba..795201fa0b48 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -888,8 +888,8 @@ typedef struct {
888 888
889 u8 sglen; /* f/w supported scatter-gather list length */ 889 u8 sglen; /* f/w supported scatter-gather list length */
890 890
891 unsigned char int_cdb[MAX_COMMAND_SIZE];
891 scb_t int_scb; 892 scb_t int_scb;
892 Scsi_Cmnd int_scmd;
893 struct mutex int_mtx; /* To synchronize the internal 893 struct mutex int_mtx; /* To synchronize the internal
894 commands */ 894 commands */
895 struct completion int_waitq; /* wait queue for internal 895 struct completion int_waitq; /* wait queue for internal
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index f25f41a499e5..b97194096d8e 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2547,7 +2547,6 @@ typedef struct scsi_qla_host {
2547 uint8_t fcode_revision[16]; 2547 uint8_t fcode_revision[16];
2548 uint32_t fw_revision[4]; 2548 uint32_t fw_revision[4];
2549 2549
2550 uint16_t fdt_odd_index;
2551 uint32_t fdt_wrt_disable; 2550 uint32_t fdt_wrt_disable;
2552 uint32_t fdt_erase_cmd; 2551 uint32_t fdt_erase_cmd;
2553 uint32_t fdt_block_size; 2552 uint32_t fdt_block_size;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a470f2d3270d..4218f20f5ed5 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -140,7 +140,6 @@ int
140qla2100_pci_config(scsi_qla_host_t *ha) 140qla2100_pci_config(scsi_qla_host_t *ha)
141{ 141{
142 uint16_t w; 142 uint16_t w;
143 uint32_t d;
144 unsigned long flags; 143 unsigned long flags;
145 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 144 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
146 145
@@ -151,10 +150,7 @@ qla2100_pci_config(scsi_qla_host_t *ha)
151 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); 150 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
152 pci_write_config_word(ha->pdev, PCI_COMMAND, w); 151 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
153 152
154 /* Reset expansion ROM address decode enable */ 153 pci_disable_rom(ha->pdev);
155 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
156 d &= ~PCI_ROM_ADDRESS_ENABLE;
157 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
158 154
159 /* Get PCI bus information. */ 155 /* Get PCI bus information. */
160 spin_lock_irqsave(&ha->hardware_lock, flags); 156 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -174,7 +170,6 @@ int
174qla2300_pci_config(scsi_qla_host_t *ha) 170qla2300_pci_config(scsi_qla_host_t *ha)
175{ 171{
176 uint16_t w; 172 uint16_t w;
177 uint32_t d;
178 unsigned long flags = 0; 173 unsigned long flags = 0;
179 uint32_t cnt; 174 uint32_t cnt;
180 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 175 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -236,10 +231,7 @@ qla2300_pci_config(scsi_qla_host_t *ha)
236 231
237 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); 232 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
238 233
239 /* Reset expansion ROM address decode enable */ 234 pci_disable_rom(ha->pdev);
240 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
241 d &= ~PCI_ROM_ADDRESS_ENABLE;
242 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
243 235
244 /* Get PCI bus information. */ 236 /* Get PCI bus information. */
245 spin_lock_irqsave(&ha->hardware_lock, flags); 237 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -259,7 +251,6 @@ int
259qla24xx_pci_config(scsi_qla_host_t *ha) 251qla24xx_pci_config(scsi_qla_host_t *ha)
260{ 252{
261 uint16_t w; 253 uint16_t w;
262 uint32_t d;
263 unsigned long flags = 0; 254 unsigned long flags = 0;
264 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 255 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
265 256
@@ -281,10 +272,7 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
281 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) 272 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
282 pcie_set_readrq(ha->pdev, 2048); 273 pcie_set_readrq(ha->pdev, 2048);
283 274
284 /* Reset expansion ROM address decode enable */ 275 pci_disable_rom(ha->pdev);
285 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
286 d &= ~PCI_ROM_ADDRESS_ENABLE;
287 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
288 276
289 ha->chip_revision = ha->pdev->revision; 277 ha->chip_revision = ha->pdev->revision;
290 278
@@ -306,7 +294,6 @@ int
306qla25xx_pci_config(scsi_qla_host_t *ha) 294qla25xx_pci_config(scsi_qla_host_t *ha)
307{ 295{
308 uint16_t w; 296 uint16_t w;
309 uint32_t d;
310 297
311 pci_set_master(ha->pdev); 298 pci_set_master(ha->pdev);
312 pci_try_set_mwi(ha->pdev); 299 pci_try_set_mwi(ha->pdev);
@@ -320,10 +307,7 @@ qla25xx_pci_config(scsi_qla_host_t *ha)
320 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) 307 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
321 pcie_set_readrq(ha->pdev, 2048); 308 pcie_set_readrq(ha->pdev, 2048);
322 309
323 /* Reset expansion ROM address decode enable */ 310 pci_disable_rom(ha->pdev);
324 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
325 d &= ~PCI_ROM_ADDRESS_ENABLE;
326 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
327 311
328 ha->chip_revision = ha->pdev->revision; 312 ha->chip_revision = ha->pdev->revision;
329 313
@@ -980,7 +964,6 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
980 &ha->fw_minor_version, 964 &ha->fw_minor_version,
981 &ha->fw_subminor_version, 965 &ha->fw_subminor_version,
982 &ha->fw_attributes, &ha->fw_memory_size); 966 &ha->fw_attributes, &ha->fw_memory_size);
983 qla2x00_resize_request_q(ha);
984 ha->flags.npiv_supported = 0; 967 ha->flags.npiv_supported = 0;
985 if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) || 968 if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) ||
986 IS_QLA84XX(ha)) && 969 IS_QLA84XX(ha)) &&
@@ -992,6 +975,7 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
992 ha->max_npiv_vports = 975 ha->max_npiv_vports =
993 MIN_MULTI_ID_FABRIC - 1; 976 MIN_MULTI_ID_FABRIC - 1;
994 } 977 }
978 qla2x00_resize_request_q(ha);
995 979
996 if (ql2xallocfwdump) 980 if (ql2xallocfwdump)
997 qla2x00_alloc_fw_dump(ha); 981 qla2x00_alloc_fw_dump(ha);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 36bc6851e23d..3402746ec128 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1964,7 +1964,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1964 *cur_iocb_cnt = mcp->mb[7]; 1964 *cur_iocb_cnt = mcp->mb[7];
1965 if (orig_iocb_cnt) 1965 if (orig_iocb_cnt)
1966 *orig_iocb_cnt = mcp->mb[10]; 1966 *orig_iocb_cnt = mcp->mb[10];
1967 if (max_npiv_vports) 1967 if (ha->flags.npiv_supported && max_npiv_vports)
1968 *max_npiv_vports = mcp->mb[11]; 1968 *max_npiv_vports = mcp->mb[11];
1969 } 1969 }
1970 1970
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 21dd182ad512..35567203ef61 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -728,6 +728,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
728 if (ha->isp_ops->abort_command(ha, sp)) { 728 if (ha->isp_ops->abort_command(ha, sp)) {
729 DEBUG2(printk("%s(%ld): abort_command " 729 DEBUG2(printk("%s(%ld): abort_command "
730 "mbx failed.\n", __func__, ha->host_no)); 730 "mbx failed.\n", __func__, ha->host_no));
731 ret = FAILED;
731 } else { 732 } else {
732 DEBUG3(printk("%s(%ld): abort_command " 733 DEBUG3(printk("%s(%ld): abort_command "
733 "mbx success.\n", __func__, ha->host_no)); 734 "mbx success.\n", __func__, ha->host_no));
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 90a13211717f..e4af678eb2d6 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -722,6 +722,7 @@ done:
722static void 722static void
723qla2xxx_get_fdt_info(scsi_qla_host_t *ha) 723qla2xxx_get_fdt_info(scsi_qla_host_t *ha)
724{ 724{
725#define FLASH_BLK_SIZE_4K 0x1000
725#define FLASH_BLK_SIZE_32K 0x8000 726#define FLASH_BLK_SIZE_32K 0x8000
726#define FLASH_BLK_SIZE_64K 0x10000 727#define FLASH_BLK_SIZE_64K 0x10000
727 const char *loc, *locations[] = { "MID", "FDT" }; 728 const char *loc, *locations[] = { "MID", "FDT" };
@@ -755,7 +756,6 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *ha)
755 loc = locations[1]; 756 loc = locations[1];
756 mid = le16_to_cpu(fdt->man_id); 757 mid = le16_to_cpu(fdt->man_id);
757 fid = le16_to_cpu(fdt->id); 758 fid = le16_to_cpu(fdt->id);
758 ha->fdt_odd_index = mid == 0x1f;
759 ha->fdt_wrt_disable = fdt->wrt_disable_bits; 759 ha->fdt_wrt_disable = fdt->wrt_disable_bits;
760 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd); 760 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd);
761 ha->fdt_block_size = le32_to_cpu(fdt->block_size); 761 ha->fdt_block_size = le32_to_cpu(fdt->block_size);
@@ -788,8 +788,7 @@ no_flash_data:
788 ha->fdt_block_size = FLASH_BLK_SIZE_64K; 788 ha->fdt_block_size = FLASH_BLK_SIZE_64K;
789 break; 789 break;
790 case 0x1f: /* Atmel 26DF081A. */ 790 case 0x1f: /* Atmel 26DF081A. */
791 ha->fdt_odd_index = 1; 791 ha->fdt_block_size = FLASH_BLK_SIZE_4K;
792 ha->fdt_block_size = FLASH_BLK_SIZE_64K;
793 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320); 792 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320);
794 ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339); 793 ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339);
795 ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336); 794 ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336);
@@ -801,9 +800,9 @@ no_flash_data:
801 } 800 }
802done: 801done:
803 DEBUG2(qla_printk(KERN_DEBUG, ha, "FDT[%s]: (0x%x/0x%x) erase=0x%x " 802 DEBUG2(qla_printk(KERN_DEBUG, ha, "FDT[%s]: (0x%x/0x%x) erase=0x%x "
804 "pro=%x upro=%x idx=%d wrtd=0x%x blk=0x%x.\n", loc, mid, fid, 803 "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n", loc, mid, fid,
805 ha->fdt_erase_cmd, ha->fdt_protect_sec_cmd, 804 ha->fdt_erase_cmd, ha->fdt_protect_sec_cmd,
806 ha->fdt_unprotect_sec_cmd, ha->fdt_odd_index, ha->fdt_wrt_disable, 805 ha->fdt_unprotect_sec_cmd, ha->fdt_wrt_disable,
807 ha->fdt_block_size)); 806 ha->fdt_block_size));
808} 807}
809 808
@@ -987,13 +986,9 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
987 qla24xx_unprotect_flash(ha); 986 qla24xx_unprotect_flash(ha);
988 987
989 for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { 988 for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) {
990 if (ha->fdt_odd_index) { 989
991 findex = faddr << 2; 990 findex = faddr;
992 fdata = findex & sec_mask; 991 fdata = (findex & sec_mask) << 2;
993 } else {
994 findex = faddr;
995 fdata = (findex & sec_mask) << 2;
996 }
997 992
998 /* Are we at the beginning of a sector? */ 993 /* Are we at the beginning of a sector? */
999 if ((findex & rest_addr) == 0) { 994 if ((findex & rest_addr) == 0) {
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index be5e299df528..eea6720adf16 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.02.01-k8" 10#define QLA2XXX_VERSION "8.02.01-k9"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 2 13#define QLA_DRIVER_MINOR_VER 2
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 94ed262bdf0c..386361778ebb 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1340,9 +1340,10 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1340 * LLD/transport was disrupted during processing of the IO. 1340 * LLD/transport was disrupted during processing of the IO.
1341 * The transport class is now blocked/blocking, 1341 * The transport class is now blocked/blocking,
1342 * and the transport will decide what to do with the IO 1342 * and the transport will decide what to do with the IO
1343 * based on its timers and recovery capablilities. 1343 * based on its timers and recovery capablilities if
1344 * there are enough retries.
1344 */ 1345 */
1345 return ADD_TO_MLQUEUE; 1346 goto maybe_retry;
1346 case DID_TRANSPORT_FAILFAST: 1347 case DID_TRANSPORT_FAILFAST:
1347 /* 1348 /*
1348 * The transport decided to failfast the IO (most likely 1349 * The transport decided to failfast the IO (most likely
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 5c0f32c7fbf6..165fc010978c 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -144,9 +144,9 @@ static void put_char(struct uart_port *port, char c)
144 status = sci_in(port, SCxSR); 144 status = sci_in(port, SCxSR);
145 } while (!(status & SCxSR_TDxE(port))); 145 } while (!(status & SCxSR_TDxE(port)));
146 146
147 sci_out(port, SCxTDR, c);
148 sci_in(port, SCxSR); /* Dummy read */ 147 sci_in(port, SCxSR); /* Dummy read */
149 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 148 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
149 sci_out(port, SCxTDR, c);
150 150
151 spin_unlock_irqrestore(&port->lock, flags); 151 spin_unlock_irqrestore(&port->lock, flags);
152} 152}
@@ -478,10 +478,10 @@ static void sci_transmit_chars(struct uart_port *port)
478 return; 478 return;
479 } 479 }
480 480
481 if (port->type == PORT_SCIF) 481 if (port->type == PORT_SCI)
482 count = scif_txroom(port);
483 else
484 count = sci_txroom(port); 482 count = sci_txroom(port);
483 else
484 count = scif_txroom(port);
485 485
486 do { 486 do {
487 unsigned char c; 487 unsigned char c;
@@ -510,7 +510,7 @@ static void sci_transmit_chars(struct uart_port *port)
510 } else { 510 } else {
511 ctrl = sci_in(port, SCSCR); 511 ctrl = sci_in(port, SCSCR);
512 512
513 if (port->type == PORT_SCIF) { 513 if (port->type != PORT_SCI) {
514 sci_in(port, SCxSR); /* Dummy read */ 514 sci_in(port, SCxSR); /* Dummy read */
515 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 515 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
516 } 516 }
@@ -536,10 +536,10 @@ static inline void sci_receive_chars(struct uart_port *port)
536 return; 536 return;
537 537
538 while (1) { 538 while (1) {
539 if (port->type == PORT_SCIF) 539 if (port->type == PORT_SCI)
540 count = scif_rxroom(port);
541 else
542 count = sci_rxroom(port); 540 count = sci_rxroom(port);
541 else
542 count = scif_rxroom(port);
543 543
544 /* Don't copy more bytes than there is room for in the buffer */ 544 /* Don't copy more bytes than there is room for in the buffer */
545 count = tty_buffer_request_room(tty, count); 545 count = tty_buffer_request_room(tty, count);
@@ -714,7 +714,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
714 714
715#if defined(SCIF_ORER) 715#if defined(SCIF_ORER)
716 /* XXX: Handle SCIF overrun error */ 716 /* XXX: Handle SCIF overrun error */
717 if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { 717 if (port->type != PORT_SCI && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
718 sci_out(port, SCLSR, 0); 718 sci_out(port, SCLSR, 0);
719 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { 719 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) {
720 copied++; 720 copied++;
@@ -1042,7 +1042,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1042 1042
1043 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ 1043 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
1044 1044
1045 if (port->type == PORT_SCIF) 1045 if (port->type != PORT_SCI)
1046 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); 1046 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
1047 1047
1048 smr_val = sci_in(port, SCSMR) & 3; 1048 smr_val = sci_in(port, SCSMR) & 3;
@@ -1085,6 +1085,7 @@ static const char *sci_type(struct uart_port *port)
1085 case PORT_SCI: return "sci"; 1085 case PORT_SCI: return "sci";
1086 case PORT_SCIF: return "scif"; 1086 case PORT_SCIF: return "scif";
1087 case PORT_IRDA: return "irda"; 1087 case PORT_IRDA: return "irda";
1088 case PORT_SCIFA: return "scifa";
1088 } 1089 }
1089 1090
1090 return NULL; 1091 return NULL;
@@ -1112,6 +1113,7 @@ static void sci_config_port(struct uart_port *port, int flags)
1112 s->init_pins = sci_init_pins_sci; 1113 s->init_pins = sci_init_pins_sci;
1113 break; 1114 break;
1114 case PORT_SCIF: 1115 case PORT_SCIF:
1116 case PORT_SCIFA:
1115 s->init_pins = sci_init_pins_scif; 1117 s->init_pins = sci_init_pins_scif;
1116 break; 1118 break;
1117 case PORT_IRDA: 1119 case PORT_IRDA:
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 6163a45f968f..9f33b064172e 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -289,18 +289,18 @@
289#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ 289#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
290 static inline unsigned int sci_##name##_in(struct uart_port *port) \ 290 static inline unsigned int sci_##name##_in(struct uart_port *port) \
291 { \ 291 { \
292 if (port->type == PORT_SCI) { \ 292 if (port->type == PORT_SCIF) { \
293 SCI_IN(sci_size, sci_offset) \ 293 SCI_IN(scif_size, scif_offset) \
294 } else { \ 294 } else { /* PORT_SCI or PORT_SCIFA */ \
295 SCI_IN(scif_size, scif_offset); \ 295 SCI_IN(sci_size, sci_offset); \
296 } \ 296 } \
297 } \ 297 } \
298 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ 298 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
299 { \ 299 { \
300 if (port->type == PORT_SCI) { \ 300 if (port->type == PORT_SCIF) { \
301 SCI_OUT(sci_size, sci_offset, value) \ 301 SCI_OUT(scif_size, scif_offset, value) \
302 } else { \ 302 } else { /* PORT_SCI or PORT_SCIFA */ \
303 SCI_OUT(scif_size, scif_offset, value); \ 303 SCI_OUT(sci_size, sci_offset, value); \
304 } \ 304 } \
305 } 305 }
306 306
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index dae87b1a4c6e..cf12f2d84be2 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -352,21 +352,21 @@ static int map_dma_buffers(struct driver_data *drv_data)
352 } else 352 } else
353 drv_data->tx_map_len = drv_data->len; 353 drv_data->tx_map_len = drv_data->len;
354 354
355 /* Stream map the rx buffer */ 355 /* Stream map the tx buffer. Always do DMA_TO_DEVICE first
356 drv_data->rx_dma = dma_map_single(dev, drv_data->rx, 356 * so we flush the cache *before* invalidating it, in case
357 drv_data->rx_map_len, 357 * the tx and rx buffers overlap.
358 DMA_FROM_DEVICE); 358 */
359 if (dma_mapping_error(dev, drv_data->rx_dma))
360 return 0;
361
362 /* Stream map the tx buffer */
363 drv_data->tx_dma = dma_map_single(dev, drv_data->tx, 359 drv_data->tx_dma = dma_map_single(dev, drv_data->tx,
364 drv_data->tx_map_len, 360 drv_data->tx_map_len, DMA_TO_DEVICE);
365 DMA_TO_DEVICE); 361 if (dma_mapping_error(dev, drv_data->tx_dma))
362 return 0;
366 363
367 if (dma_mapping_error(dev, drv_data->tx_dma)) { 364 /* Stream map the rx buffer */
368 dma_unmap_single(dev, drv_data->rx_dma, 365 drv_data->rx_dma = dma_map_single(dev, drv_data->rx,
369 drv_data->rx_map_len, DMA_FROM_DEVICE); 366 drv_data->rx_map_len, DMA_FROM_DEVICE);
367 if (dma_mapping_error(dev, drv_data->rx_dma)) {
368 dma_unmap_single(dev, drv_data->tx_dma,
369 drv_data->tx_map_len, DMA_TO_DEVICE);
370 return 0; 370 return 0;
371 } 371 }
372 372
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 61ba147e384d..0b4db0ce78d6 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -506,20 +506,6 @@ static int map_dma_buffers(struct driver_data *drv_data)
506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx)) 506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx))
507 return -1; 507 return -1;
508 508
509 /* NULL rx means write-only transfer and no map needed
510 since rx DMA will not be used */
511 if (drv_data->rx) {
512 buf = drv_data->rx;
513 drv_data->rx_dma = dma_map_single(
514 dev,
515 buf,
516 drv_data->len,
517 DMA_FROM_DEVICE);
518 if (dma_mapping_error(dev, drv_data->rx_dma))
519 return -1;
520 drv_data->rx_dma_needs_unmap = 1;
521 }
522
523 if (drv_data->tx == NULL) { 509 if (drv_data->tx == NULL) {
524 /* Read only message --> use drv_data->dummy_dma_buf for dummy 510 /* Read only message --> use drv_data->dummy_dma_buf for dummy
525 writes to achive reads */ 511 writes to achive reads */
@@ -533,18 +519,31 @@ static int map_dma_buffers(struct driver_data *drv_data)
533 buf, 519 buf,
534 drv_data->tx_map_len, 520 drv_data->tx_map_len,
535 DMA_TO_DEVICE); 521 DMA_TO_DEVICE);
536 if (dma_mapping_error(dev, drv_data->tx_dma)) { 522 if (dma_mapping_error(dev, drv_data->tx_dma))
537 if (drv_data->rx_dma) {
538 dma_unmap_single(dev,
539 drv_data->rx_dma,
540 drv_data->len,
541 DMA_FROM_DEVICE);
542 drv_data->rx_dma_needs_unmap = 0;
543 }
544 return -1; 523 return -1;
545 }
546 drv_data->tx_dma_needs_unmap = 1; 524 drv_data->tx_dma_needs_unmap = 1;
547 525
526 /* NULL rx means write-only transfer and no map needed
527 * since rx DMA will not be used */
528 if (drv_data->rx) {
529 buf = drv_data->rx;
530 drv_data->rx_dma = dma_map_single(dev,
531 buf,
532 drv_data->len,
533 DMA_FROM_DEVICE);
534 if (dma_mapping_error(dev, drv_data->rx_dma)) {
535 if (drv_data->tx_dma) {
536 dma_unmap_single(dev,
537 drv_data->tx_dma,
538 drv_data->tx_map_len,
539 DMA_TO_DEVICE);
540 drv_data->tx_dma_needs_unmap = 0;
541 }
542 return -1;
543 }
544 drv_data->rx_dma_needs_unmap = 1;
545 }
546
548 return 0; 547 return 0;
549} 548}
550 549
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 20104443081a..d50a99f70aee 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -158,16 +158,12 @@ static int acm_wb_is_avail(struct acm *acm)
158} 158}
159 159
160/* 160/*
161 * Finish write. 161 * Finish write. Caller must hold acm->write_lock
162 */ 162 */
163static void acm_write_done(struct acm *acm, struct acm_wb *wb) 163static void acm_write_done(struct acm *acm, struct acm_wb *wb)
164{ 164{
165 unsigned long flags;
166
167 spin_lock_irqsave(&acm->write_lock, flags);
168 wb->use = 0; 165 wb->use = 0;
169 acm->transmitting--; 166 acm->transmitting--;
170 spin_unlock_irqrestore(&acm->write_lock, flags);
171} 167}
172 168
173/* 169/*
@@ -482,6 +478,7 @@ static void acm_write_bulk(struct urb *urb)
482{ 478{
483 struct acm_wb *wb = urb->context; 479 struct acm_wb *wb = urb->context;
484 struct acm *acm = wb->instance; 480 struct acm *acm = wb->instance;
481 unsigned long flags;
485 482
486 if (verbose || urb->status 483 if (verbose || urb->status
487 || (urb->actual_length != urb->transfer_buffer_length)) 484 || (urb->actual_length != urb->transfer_buffer_length))
@@ -490,7 +487,9 @@ static void acm_write_bulk(struct urb *urb)
490 urb->transfer_buffer_length, 487 urb->transfer_buffer_length,
491 urb->status); 488 urb->status);
492 489
490 spin_lock_irqsave(&acm->write_lock, flags);
493 acm_write_done(acm, wb); 491 acm_write_done(acm, wb);
492 spin_unlock_irqrestore(&acm->write_lock, flags);
494 if (ACM_READY(acm)) 493 if (ACM_READY(acm))
495 schedule_work(&acm->work); 494 schedule_work(&acm->work);
496 else 495 else
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 887738577b28..6d1048faf08e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1091,6 +1091,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1091 continue; 1091 continue;
1092 dev_dbg(&dev->dev, "unregistering interface %s\n", 1092 dev_dbg(&dev->dev, "unregistering interface %s\n",
1093 dev_name(&interface->dev)); 1093 dev_name(&interface->dev));
1094 interface->unregistering = 1;
1094 usb_remove_sysfs_intf_files(interface); 1095 usb_remove_sysfs_intf_files(interface);
1095 device_del(&interface->dev); 1096 device_del(&interface->dev);
1096 } 1097 }
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index f66fba11fbd5..4fb65fdc9dc3 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -840,7 +840,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
840 struct usb_host_interface *alt = intf->cur_altsetting; 840 struct usb_host_interface *alt = intf->cur_altsetting;
841 int retval; 841 int retval;
842 842
843 if (intf->sysfs_files_created) 843 if (intf->sysfs_files_created || intf->unregistering)
844 return 0; 844 return 0;
845 845
846 /* The interface string may be present in some altsettings 846 /* The interface string may be present in some altsettings
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 4342bd9c3bb6..1f68af9db3f7 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -85,8 +85,8 @@ EXPORT_SYMBOL_GPL(usb_alloc_urb);
85 * Must be called when a user of a urb is finished with it. When the last user 85 * Must be called when a user of a urb is finished with it. When the last user
86 * of the urb calls this function, the memory of the urb is freed. 86 * of the urb calls this function, the memory of the urb is freed.
87 * 87 *
88 * Note: The transfer buffer associated with the urb is not freed, that must be 88 * Note: The transfer buffer associated with the urb is not freed unless the
89 * done elsewhere. 89 * URB_FREE_BUFFER transfer flag is set.
90 */ 90 */
91void usb_free_urb(struct urb *urb) 91void usb_free_urb(struct urb *urb)
92{ 92{
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index 5ee1590b8e9c..c1d34df0b157 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -463,7 +463,11 @@ static int acm_cdc_notify(struct f_acm *acm, u8 type, u16 value,
463 notify->wLength = cpu_to_le16(length); 463 notify->wLength = cpu_to_le16(length);
464 memcpy(buf, data, length); 464 memcpy(buf, data, length);
465 465
466 /* ep_queue() can complete immediately if it fills the fifo... */
467 spin_unlock(&acm->lock);
466 status = usb_ep_queue(ep, req, GFP_ATOMIC); 468 status = usb_ep_queue(ep, req, GFP_ATOMIC);
469 spin_lock(&acm->lock);
470
467 if (status < 0) { 471 if (status < 0) {
468 ERROR(acm->port.func.config->cdev, 472 ERROR(acm->port.func.config->cdev,
469 "acm ttyGS%d can't notify serial state, %d\n", 473 "acm ttyGS%d can't notify serial state, %d\n",
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 659b3d9671c4..428b5993575a 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -172,7 +172,6 @@ static struct usb_interface_descriptor rndis_data_intf __initdata = {
172 .bDescriptorType = USB_DT_INTERFACE, 172 .bDescriptorType = USB_DT_INTERFACE,
173 173
174 /* .bInterfaceNumber = DYNAMIC */ 174 /* .bInterfaceNumber = DYNAMIC */
175 .bAlternateSetting = 1,
176 .bNumEndpoints = 2, 175 .bNumEndpoints = 2,
177 .bInterfaceClass = USB_CLASS_CDC_DATA, 176 .bInterfaceClass = USB_CLASS_CDC_DATA,
178 .bInterfaceSubClass = 0, 177 .bInterfaceSubClass = 0,
@@ -303,7 +302,7 @@ static void rndis_response_available(void *_rndis)
303 __le32 *data = req->buf; 302 __le32 *data = req->buf;
304 int status; 303 int status;
305 304
306 if (atomic_inc_return(&rndis->notify_count)) 305 if (atomic_inc_return(&rndis->notify_count) != 1)
307 return; 306 return;
308 307
309 /* Send RNDIS RESPONSE_AVAILABLE notification; a 308 /* Send RNDIS RESPONSE_AVAILABLE notification; a
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 56f592dc0b36..f3a75a929e0a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -110,29 +110,18 @@ config USB_ISP116X_HCD
110 110
111config USB_ISP1760_HCD 111config USB_ISP1760_HCD
112 tristate "ISP 1760 HCD support" 112 tristate "ISP 1760 HCD support"
113 depends on USB && EXPERIMENTAL 113 depends on USB && EXPERIMENTAL && (PCI || PPC_OF)
114 ---help--- 114 ---help---
115 The ISP1760 chip is a USB 2.0 host controller. 115 The ISP1760 chip is a USB 2.0 host controller.
116 116
117 This driver does not support isochronous transfers or OTG. 117 This driver does not support isochronous transfers or OTG.
118 This USB controller is usually attached to a non-DMA-Master
119 capable bus. NXP's eval kit brings this chip on PCI card
120 where the chip itself is behind a PLB to simulate such
121 a bus.
118 122
119 To compile this driver as a module, choose M here: the 123 To compile this driver as a module, choose M here: the
120 module will be called isp1760-hcd. 124 module will be called isp1760.
121
122config USB_ISP1760_PCI
123 bool "Support for the PCI bus"
124 depends on USB_ISP1760_HCD && PCI
125 ---help---
126 Enables support for the device present on the PCI bus.
127 This should only be required if you happen to have the eval kit from
128 NXP and you are going to test it.
129
130config USB_ISP1760_OF
131 bool "Support for the OF platform bus"
132 depends on USB_ISP1760_HCD && PPC_OF
133 ---help---
134 Enables support for the device present on the PowerPC
135 OpenFirmware platform bus.
136 125
137config USB_OHCI_HCD 126config USB_OHCI_HCD
138 tristate "OHCI HCD support" 127 tristate "OHCI HCD support"
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 15a803b206b8..4725d15d096f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -643,7 +643,7 @@ static int ehci_run (struct usb_hcd *hcd)
643static irqreturn_t ehci_irq (struct usb_hcd *hcd) 643static irqreturn_t ehci_irq (struct usb_hcd *hcd)
644{ 644{
645 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 645 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
646 u32 status, pcd_status = 0, cmd; 646 u32 status, masked_status, pcd_status = 0, cmd;
647 int bh; 647 int bh;
648 648
649 spin_lock (&ehci->lock); 649 spin_lock (&ehci->lock);
@@ -656,14 +656,14 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
656 goto dead; 656 goto dead;
657 } 657 }
658 658
659 status &= INTR_MASK; 659 masked_status = status & INTR_MASK;
660 if (!status) { /* irq sharing? */ 660 if (!masked_status) { /* irq sharing? */
661 spin_unlock(&ehci->lock); 661 spin_unlock(&ehci->lock);
662 return IRQ_NONE; 662 return IRQ_NONE;
663 } 663 }
664 664
665 /* clear (just) interrupts */ 665 /* clear (just) interrupts */
666 ehci_writel(ehci, status, &ehci->regs->status); 666 ehci_writel(ehci, masked_status, &ehci->regs->status);
667 cmd = ehci_readl(ehci, &ehci->regs->command); 667 cmd = ehci_readl(ehci, &ehci->regs->command);
668 bh = 0; 668 bh = 0;
669 669
@@ -734,18 +734,17 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
734 734
735 /* PCI errors [4.15.2.4] */ 735 /* PCI errors [4.15.2.4] */
736 if (unlikely ((status & STS_FATAL) != 0)) { 736 if (unlikely ((status & STS_FATAL) != 0)) {
737 ehci_err(ehci, "fatal error\n");
737 dbg_cmd(ehci, "fatal", cmd); 738 dbg_cmd(ehci, "fatal", cmd);
738 dbg_status(ehci, "fatal", status); 739 dbg_status(ehci, "fatal", status);
739 if (status & STS_HALT) { 740 ehci_halt(ehci);
740 ehci_err (ehci, "fatal error\n");
741dead: 741dead:
742 ehci_reset (ehci); 742 ehci_reset(ehci);
743 ehci_writel(ehci, 0, &ehci->regs->configured_flag); 743 ehci_writel(ehci, 0, &ehci->regs->configured_flag);
744 /* generic layer kills/unlinks all urbs, then 744 /* generic layer kills/unlinks all urbs, then
745 * uses ehci_stop to clean up the rest 745 * uses ehci_stop to clean up the rest
746 */ 746 */
747 bh = 1; 747 bh = 1;
748 }
749 } 748 }
750 749
751 if (bh) 750 if (bh)
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index c46a58f9181d..9d0ea573aef6 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -66,6 +66,8 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
66{ 66{
67 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 67 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
68 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 68 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
69 struct pci_dev *p_smbus;
70 u8 rev;
69 u32 temp; 71 u32 temp;
70 int retval; 72 int retval;
71 73
@@ -166,6 +168,25 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
166 pci_write_config_byte(pdev, 0x4b, tmp | 0x20); 168 pci_write_config_byte(pdev, 0x4b, tmp | 0x20);
167 } 169 }
168 break; 170 break;
171 case PCI_VENDOR_ID_ATI:
172 /* SB700 old version has a bug in EHCI controller,
173 * which causes usb devices lose response in some cases.
174 */
175 if (pdev->device == 0x4396) {
176 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
177 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
178 NULL);
179 if (!p_smbus)
180 break;
181 rev = p_smbus->revision;
182 if ((rev == 0x3a) || (rev == 0x3b)) {
183 u8 tmp;
184 pci_read_config_byte(pdev, 0x53, &tmp);
185 pci_write_config_byte(pdev, 0x53, tmp | (1<<3));
186 }
187 pci_dev_put(p_smbus);
188 }
189 break;
169 } 190 }
170 191
171 ehci_reset(ehci); 192 ehci_reset(ehci);
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 0eba894bcb01..9c9da35abc6c 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -205,6 +205,7 @@ static int ps3_ehci_remove(struct ps3_system_bus_device *dev)
205 205
206 tmp = hcd->irq; 206 tmp = hcd->irq;
207 207
208 ehci_shutdown(hcd);
208 usb_remove_hcd(hcd); 209 usb_remove_hcd(hcd);
209 210
210 ps3_system_bus_set_driver_data(dev, NULL); 211 ps3_system_bus_set_driver_data(dev, NULL);
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 4a0c5a78b2ed..a081ee65bde6 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -918,7 +918,7 @@ iso_stream_init (
918 */ 918 */
919 stream->usecs = HS_USECS_ISO (maxp); 919 stream->usecs = HS_USECS_ISO (maxp);
920 bandwidth = stream->usecs * 8; 920 bandwidth = stream->usecs * 8;
921 bandwidth /= 1 << (interval - 1); 921 bandwidth /= interval;
922 922
923 } else { 923 } else {
924 u32 addr; 924 u32 addr;
@@ -951,7 +951,7 @@ iso_stream_init (
951 } else 951 } else
952 stream->raw_mask = smask_out [hs_transfers - 1]; 952 stream->raw_mask = smask_out [hs_transfers - 1];
953 bandwidth = stream->usecs + stream->c_usecs; 953 bandwidth = stream->usecs + stream->c_usecs;
954 bandwidth /= 1 << (interval + 2); 954 bandwidth /= interval << 3;
955 955
956 /* stream->splits gets created from raw_mask later */ 956 /* stream->splits gets created from raw_mask later */
957 stream->address = cpu_to_hc32(ehci, addr); 957 stream->address = cpu_to_hc32(ehci, addr);
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index af849f596135..b87ca7cf4b37 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -14,16 +14,16 @@
14#include "../core/hcd.h" 14#include "../core/hcd.h"
15#include "isp1760-hcd.h" 15#include "isp1760-hcd.h"
16 16
17#ifdef CONFIG_USB_ISP1760_OF 17#ifdef CONFIG_PPC_OF
18#include <linux/of.h> 18#include <linux/of.h>
19#include <linux/of_platform.h> 19#include <linux/of_platform.h>
20#endif 20#endif
21 21
22#ifdef CONFIG_USB_ISP1760_PCI 22#ifdef CONFIG_PCI
23#include <linux/pci.h> 23#include <linux/pci.h>
24#endif 24#endif
25 25
26#ifdef CONFIG_USB_ISP1760_OF 26#ifdef CONFIG_PPC_OF
27static int of_isp1760_probe(struct of_device *dev, 27static int of_isp1760_probe(struct of_device *dev,
28 const struct of_device_id *match) 28 const struct of_device_id *match)
29{ 29{
@@ -128,7 +128,7 @@ static struct of_platform_driver isp1760_of_driver = {
128}; 128};
129#endif 129#endif
130 130
131#ifdef CONFIG_USB_ISP1760_PCI 131#ifdef CONFIG_PCI
132static u32 nxp_pci_io_base; 132static u32 nxp_pci_io_base;
133static u32 iolength; 133static u32 iolength;
134static u32 pci_mem_phy0; 134static u32 pci_mem_phy0;
@@ -288,28 +288,28 @@ static struct pci_driver isp1761_pci_driver = {
288 288
289static int __init isp1760_init(void) 289static int __init isp1760_init(void)
290{ 290{
291 int ret = -ENODEV; 291 int ret;
292 292
293 init_kmem_once(); 293 init_kmem_once();
294 294
295#ifdef CONFIG_USB_ISP1760_OF 295#ifdef CONFIG_PPC_OF
296 ret = of_register_platform_driver(&isp1760_of_driver); 296 ret = of_register_platform_driver(&isp1760_of_driver);
297 if (ret) { 297 if (ret) {
298 deinit_kmem_cache(); 298 deinit_kmem_cache();
299 return ret; 299 return ret;
300 } 300 }
301#endif 301#endif
302#ifdef CONFIG_USB_ISP1760_PCI 302#ifdef CONFIG_PCI
303 ret = pci_register_driver(&isp1761_pci_driver); 303 ret = pci_register_driver(&isp1761_pci_driver);
304 if (ret) 304 if (ret)
305 goto unreg_of; 305 goto unreg_of;
306#endif 306#endif
307 return ret; 307 return ret;
308 308
309#ifdef CONFIG_USB_ISP1760_PCI 309#ifdef CONFIG_PCI
310unreg_of: 310unreg_of:
311#endif 311#endif
312#ifdef CONFIG_USB_ISP1760_OF 312#ifdef CONFIG_PPC_OF
313 of_unregister_platform_driver(&isp1760_of_driver); 313 of_unregister_platform_driver(&isp1760_of_driver);
314#endif 314#endif
315 deinit_kmem_cache(); 315 deinit_kmem_cache();
@@ -319,10 +319,10 @@ module_init(isp1760_init);
319 319
320static void __exit isp1760_exit(void) 320static void __exit isp1760_exit(void)
321{ 321{
322#ifdef CONFIG_USB_ISP1760_OF 322#ifdef CONFIG_PPC_OF
323 of_unregister_platform_driver(&isp1760_of_driver); 323 of_unregister_platform_driver(&isp1760_of_driver);
324#endif 324#endif
325#ifdef CONFIG_USB_ISP1760_PCI 325#ifdef CONFIG_PCI
326 pci_unregister_driver(&isp1761_pci_driver); 326 pci_unregister_driver(&isp1761_pci_driver);
327#endif 327#endif
328 deinit_kmem_cache(); 328 deinit_kmem_cache();
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
index 2089d8a46c4b..3c1a3b5f89f1 100644
--- a/drivers/usb/host/ohci-ps3.c
+++ b/drivers/usb/host/ohci-ps3.c
@@ -192,7 +192,7 @@ fail_start:
192 return result; 192 return result;
193} 193}
194 194
195static int ps3_ohci_remove (struct ps3_system_bus_device *dev) 195static int ps3_ohci_remove(struct ps3_system_bus_device *dev)
196{ 196{
197 unsigned int tmp; 197 unsigned int tmp;
198 struct usb_hcd *hcd = 198 struct usb_hcd *hcd =
@@ -205,6 +205,7 @@ static int ps3_ohci_remove (struct ps3_system_bus_device *dev)
205 205
206 tmp = hcd->irq; 206 tmp = hcd->irq;
207 207
208 ohci_shutdown(hcd);
208 usb_remove_hcd(hcd); 209 usb_remove_hcd(hcd);
209 210
210 ps3_system_bus_set_driver_data(dev, NULL); 211 ps3_system_bus_set_driver_data(dev, NULL);
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index c18d8790c410..2376f24f3c83 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1763,11 +1763,12 @@ static void r8a66597_timer(unsigned long _r8a66597)
1763{ 1763{
1764 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; 1764 struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597;
1765 unsigned long flags; 1765 unsigned long flags;
1766 int port;
1766 1767
1767 spin_lock_irqsave(&r8a66597->lock, flags); 1768 spin_lock_irqsave(&r8a66597->lock, flags);
1768 1769
1769 r8a66597_root_hub_control(r8a66597, 0); 1770 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++)
1770 r8a66597_root_hub_control(r8a66597, 1); 1771 r8a66597_root_hub_control(r8a66597, port);
1771 1772
1772 spin_unlock_irqrestore(&r8a66597->lock, flags); 1773 spin_unlock_irqrestore(&r8a66597->lock, flags);
1773} 1774}
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 69c34a58e205..b4ec716de7da 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3270,6 +3270,7 @@ static struct usb_device_id sisusb_table [] = {
3270 { USB_DEVICE(0x0711, 0x0900) }, 3270 { USB_DEVICE(0x0711, 0x0900) },
3271 { USB_DEVICE(0x0711, 0x0901) }, 3271 { USB_DEVICE(0x0711, 0x0901) },
3272 { USB_DEVICE(0x0711, 0x0902) }, 3272 { USB_DEVICE(0x0711, 0x0902) },
3273 { USB_DEVICE(0x0711, 0x0903) },
3273 { USB_DEVICE(0x0711, 0x0918) }, 3274 { USB_DEVICE(0x0711, 0x0918) },
3274 { USB_DEVICE(0x182d, 0x021c) }, 3275 { USB_DEVICE(0x182d, 0x021c) },
3275 { USB_DEVICE(0x182d, 0x0269) }, 3276 { USB_DEVICE(0x182d, 0x0269) },
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c
index 8648470c81ca..63dff9ba73c5 100644
--- a/drivers/usb/misc/vstusb.c
+++ b/drivers/usb/misc/vstusb.c
@@ -620,7 +620,7 @@ static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
620 __func__); 620 __func__);
621 retval = -EFAULT; 621 retval = -EFAULT;
622 } else { 622 } else {
623 dev_dbg(&dev->dev, "%s: recv %d bytes from pipe %d\n", 623 dev_dbg(&dev->dev, "%s: recv %zd bytes from pipe %d\n",
624 __func__, usb_data.count, usb_data.pipe); 624 __func__, usb_data.count, usb_data.pipe);
625 } 625 }
626 626
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index c9de3f027aab..e06810aef2df 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -687,7 +687,10 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
687 } 687 }
688 688
689 if (rp->b_read >= sizeof(struct mon_bin_hdr)) { 689 if (rp->b_read >= sizeof(struct mon_bin_hdr)) {
690 step_len = min(nbytes, (size_t)ep->len_cap); 690 step_len = ep->len_cap;
691 step_len -= rp->b_read - sizeof(struct mon_bin_hdr);
692 if (step_len > nbytes)
693 step_len = nbytes;
691 offset = rp->b_out + PKT_SIZE; 694 offset = rp->b_out + PKT_SIZE;
692 offset += rp->b_read - sizeof(struct mon_bin_hdr); 695 offset += rp->b_read - sizeof(struct mon_bin_hdr);
693 if (offset >= rp->b_size) 696 if (offset >= rp->b_size)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 4a35745b30be..5280dba9b1fb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -114,8 +114,8 @@
114 114
115 115
116 116
117unsigned debug; 117unsigned musb_debug;
118module_param(debug, uint, S_IRUGO | S_IWUSR); 118module_param(musb_debug, uint, S_IRUGO | S_IWUSR);
119MODULE_PARM_DESC(debug, "Debug message level. Default = 0"); 119MODULE_PARM_DESC(debug, "Debug message level. Default = 0");
120 120
121#define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia" 121#define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"
@@ -2248,7 +2248,7 @@ static int __init musb_init(void)
2248 "host" 2248 "host"
2249#endif 2249#endif
2250 ", debug=%d\n", 2250 ", debug=%d\n",
2251 musb_driver_name, debug); 2251 musb_driver_name, musb_debug);
2252 return platform_driver_probe(&musb_driver, musb_probe); 2252 return platform_driver_probe(&musb_driver, musb_probe);
2253} 2253}
2254 2254
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index 4d2794441b15..9fc1db44c72c 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -48,11 +48,11 @@
48 __func__, __LINE__ , ## args); \ 48 __func__, __LINE__ , ## args); \
49 } } while (0) 49 } } while (0)
50 50
51extern unsigned debug; 51extern unsigned musb_debug;
52 52
53static inline int _dbg_level(unsigned l) 53static inline int _dbg_level(unsigned l)
54{ 54{
55 return debug >= l; 55 return musb_debug >= l;
56} 56}
57 57
58#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args) 58#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 3133990f04ec..cc64462d4c4e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -378,6 +378,19 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
378 378
379 switch (qh->type) { 379 switch (qh->type) {
380 380
381 case USB_ENDPOINT_XFER_CONTROL:
382 case USB_ENDPOINT_XFER_BULK:
383 /* fifo policy for these lists, except that NAKing
384 * should rotate a qh to the end (for fairness).
385 */
386 if (qh->mux == 1) {
387 head = qh->ring.prev;
388 list_del(&qh->ring);
389 kfree(qh);
390 qh = first_qh(head);
391 break;
392 }
393
381 case USB_ENDPOINT_XFER_ISOC: 394 case USB_ENDPOINT_XFER_ISOC:
382 case USB_ENDPOINT_XFER_INT: 395 case USB_ENDPOINT_XFER_INT:
383 /* this is where periodic bandwidth should be 396 /* this is where periodic bandwidth should be
@@ -388,17 +401,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
388 kfree(qh); 401 kfree(qh);
389 qh = NULL; 402 qh = NULL;
390 break; 403 break;
391
392 case USB_ENDPOINT_XFER_CONTROL:
393 case USB_ENDPOINT_XFER_BULK:
394 /* fifo policy for these lists, except that NAKing
395 * should rotate a qh to the end (for fairness).
396 */
397 head = qh->ring.prev;
398 list_del(&qh->ring);
399 kfree(qh);
400 qh = first_qh(head);
401 break;
402 } 404 }
403 } 405 }
404 return qh; 406 return qh;
@@ -1507,10 +1509,29 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1507 musb_writew(hw_ep->regs, MUSB_RXCSR, val); 1509 musb_writew(hw_ep->regs, MUSB_RXCSR, val);
1508 1510
1509#ifdef CONFIG_USB_INVENTRA_DMA 1511#ifdef CONFIG_USB_INVENTRA_DMA
1512 if (usb_pipeisoc(pipe)) {
1513 struct usb_iso_packet_descriptor *d;
1514
1515 d = urb->iso_frame_desc + qh->iso_idx;
1516 d->actual_length = xfer_len;
1517
1518 /* even if there was an error, we did the dma
1519 * for iso_frame_desc->length
1520 */
1521 if (d->status != EILSEQ && d->status != -EOVERFLOW)
1522 d->status = 0;
1523
1524 if (++qh->iso_idx >= urb->number_of_packets)
1525 done = true;
1526 else
1527 done = false;
1528
1529 } else {
1510 /* done if urb buffer is full or short packet is recd */ 1530 /* done if urb buffer is full or short packet is recd */
1511 done = (urb->actual_length + xfer_len >= 1531 done = (urb->actual_length + xfer_len >=
1512 urb->transfer_buffer_length 1532 urb->transfer_buffer_length
1513 || dma->actual_len < qh->maxpacket); 1533 || dma->actual_len < qh->maxpacket);
1534 }
1514 1535
1515 /* send IN token for next packet, without AUTOREQ */ 1536 /* send IN token for next packet, without AUTOREQ */
1516 if (!done) { 1537 if (!done) {
@@ -1547,7 +1568,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1547 if (dma) { 1568 if (dma) {
1548 struct dma_controller *c; 1569 struct dma_controller *c;
1549 u16 rx_count; 1570 u16 rx_count;
1550 int ret; 1571 int ret, length;
1572 dma_addr_t buf;
1551 1573
1552 rx_count = musb_readw(epio, MUSB_RXCOUNT); 1574 rx_count = musb_readw(epio, MUSB_RXCOUNT);
1553 1575
@@ -1560,6 +1582,35 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1560 1582
1561 c = musb->dma_controller; 1583 c = musb->dma_controller;
1562 1584
1585 if (usb_pipeisoc(pipe)) {
1586 int status = 0;
1587 struct usb_iso_packet_descriptor *d;
1588
1589 d = urb->iso_frame_desc + qh->iso_idx;
1590
1591 if (iso_err) {
1592 status = -EILSEQ;
1593 urb->error_count++;
1594 }
1595 if (rx_count > d->length) {
1596 if (status == 0) {
1597 status = -EOVERFLOW;
1598 urb->error_count++;
1599 }
1600 DBG(2, "** OVERFLOW %d into %d\n",\
1601 rx_count, d->length);
1602
1603 length = d->length;
1604 } else
1605 length = rx_count;
1606 d->status = status;
1607 buf = urb->transfer_dma + d->offset;
1608 } else {
1609 length = rx_count;
1610 buf = urb->transfer_dma +
1611 urb->actual_length;
1612 }
1613
1563 dma->desired_mode = 0; 1614 dma->desired_mode = 0;
1564#ifdef USE_MODE1 1615#ifdef USE_MODE1
1565 /* because of the issue below, mode 1 will 1616 /* because of the issue below, mode 1 will
@@ -1571,6 +1622,12 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1571 urb->actual_length) 1622 urb->actual_length)
1572 > qh->maxpacket) 1623 > qh->maxpacket)
1573 dma->desired_mode = 1; 1624 dma->desired_mode = 1;
1625 if (rx_count < hw_ep->max_packet_sz_rx) {
1626 length = rx_count;
1627 dma->bDesiredMode = 0;
1628 } else {
1629 length = urb->transfer_buffer_length;
1630 }
1574#endif 1631#endif
1575 1632
1576/* Disadvantage of using mode 1: 1633/* Disadvantage of using mode 1:
@@ -1608,12 +1665,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1608 */ 1665 */
1609 ret = c->channel_program( 1666 ret = c->channel_program(
1610 dma, qh->maxpacket, 1667 dma, qh->maxpacket,
1611 dma->desired_mode, 1668 dma->desired_mode, buf, length);
1612 urb->transfer_dma
1613 + urb->actual_length,
1614 (dma->desired_mode == 0)
1615 ? rx_count
1616 : urb->transfer_buffer_length);
1617 1669
1618 if (!ret) { 1670 if (!ret) {
1619 c->channel_release(dma); 1671 c->channel_release(dma);
@@ -1631,19 +1683,6 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1631 } 1683 }
1632 } 1684 }
1633 1685
1634 if (dma && usb_pipeisoc(pipe)) {
1635 struct usb_iso_packet_descriptor *d;
1636 int iso_stat = status;
1637
1638 d = urb->iso_frame_desc + qh->iso_idx;
1639 d->actual_length += xfer_len;
1640 if (iso_err) {
1641 iso_stat = -EILSEQ;
1642 urb->error_count++;
1643 }
1644 d->status = iso_stat;
1645 }
1646
1647finish: 1686finish:
1648 urb->actual_length += xfer_len; 1687 urb->actual_length += xfer_len;
1649 qh->offset += xfer_len; 1688 qh->offset += xfer_len;
@@ -1671,22 +1710,9 @@ static int musb_schedule(
1671 struct list_head *head = NULL; 1710 struct list_head *head = NULL;
1672 1711
1673 /* use fixed hardware for control and bulk */ 1712 /* use fixed hardware for control and bulk */
1674 switch (qh->type) { 1713 if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
1675 case USB_ENDPOINT_XFER_CONTROL:
1676 head = &musb->control; 1714 head = &musb->control;
1677 hw_ep = musb->control_ep; 1715 hw_ep = musb->control_ep;
1678 break;
1679 case USB_ENDPOINT_XFER_BULK:
1680 hw_ep = musb->bulk_ep;
1681 if (is_in)
1682 head = &musb->in_bulk;
1683 else
1684 head = &musb->out_bulk;
1685 break;
1686 }
1687 if (head) {
1688 idle = list_empty(head);
1689 list_add_tail(&qh->ring, head);
1690 goto success; 1716 goto success;
1691 } 1717 }
1692 1718
@@ -1725,19 +1751,34 @@ static int musb_schedule(
1725 else 1751 else
1726 diff = hw_ep->max_packet_sz_tx - qh->maxpacket; 1752 diff = hw_ep->max_packet_sz_tx - qh->maxpacket;
1727 1753
1728 if (diff > 0 && best_diff > diff) { 1754 if (diff >= 0 && best_diff > diff) {
1729 best_diff = diff; 1755 best_diff = diff;
1730 best_end = epnum; 1756 best_end = epnum;
1731 } 1757 }
1732 } 1758 }
1733 if (best_end < 0) 1759 /* use bulk reserved ep1 if no other ep is free */
1760 if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) {
1761 hw_ep = musb->bulk_ep;
1762 if (is_in)
1763 head = &musb->in_bulk;
1764 else
1765 head = &musb->out_bulk;
1766 goto success;
1767 } else if (best_end < 0) {
1734 return -ENOSPC; 1768 return -ENOSPC;
1769 }
1735 1770
1736 idle = 1; 1771 idle = 1;
1772 qh->mux = 0;
1737 hw_ep = musb->endpoints + best_end; 1773 hw_ep = musb->endpoints + best_end;
1738 musb->periodic[best_end] = qh; 1774 musb->periodic[best_end] = qh;
1739 DBG(4, "qh %p periodic slot %d\n", qh, best_end); 1775 DBG(4, "qh %p periodic slot %d\n", qh, best_end);
1740success: 1776success:
1777 if (head) {
1778 idle = list_empty(head);
1779 list_add_tail(&qh->ring, head);
1780 qh->mux = 1;
1781 }
1741 qh->hw_ep = hw_ep; 1782 qh->hw_ep = hw_ep;
1742 qh->hep->hcpriv = qh; 1783 qh->hep->hcpriv = qh;
1743 if (idle) 1784 if (idle)
@@ -2015,11 +2056,13 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
2015 sched = &musb->control; 2056 sched = &musb->control;
2016 break; 2057 break;
2017 case USB_ENDPOINT_XFER_BULK: 2058 case USB_ENDPOINT_XFER_BULK:
2018 if (usb_pipein(urb->pipe)) 2059 if (qh->mux == 1) {
2019 sched = &musb->in_bulk; 2060 if (usb_pipein(urb->pipe))
2020 else 2061 sched = &musb->in_bulk;
2021 sched = &musb->out_bulk; 2062 else
2022 break; 2063 sched = &musb->out_bulk;
2064 break;
2065 }
2023 default: 2066 default:
2024 /* REVISIT when we get a schedule tree, periodic 2067 /* REVISIT when we get a schedule tree, periodic
2025 * transfers won't always be at the head of a 2068 * transfers won't always be at the head of a
@@ -2067,11 +2110,13 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
2067 sched = &musb->control; 2110 sched = &musb->control;
2068 break; 2111 break;
2069 case USB_ENDPOINT_XFER_BULK: 2112 case USB_ENDPOINT_XFER_BULK:
2070 if (is_in) 2113 if (qh->mux == 1) {
2071 sched = &musb->in_bulk; 2114 if (is_in)
2072 else 2115 sched = &musb->in_bulk;
2073 sched = &musb->out_bulk; 2116 else
2074 break; 2117 sched = &musb->out_bulk;
2118 break;
2119 }
2075 default: 2120 default:
2076 /* REVISIT when we get a schedule tree, periodic transfers 2121 /* REVISIT when we get a schedule tree, periodic transfers
2077 * won't always be at the head of a singleton queue... 2122 * won't always be at the head of a singleton queue...
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 77bcdb9d5b32..0b7fbcd21963 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -53,6 +53,7 @@ struct musb_qh {
53 53
54 struct list_head ring; /* of musb_qh */ 54 struct list_head ring; /* of musb_qh */
55 /* struct musb_qh *next; */ /* for periodic tree */ 55 /* struct musb_qh *next; */ /* for periodic tree */
56 u8 mux; /* qh multiplexed to hw_ep */
56 57
57 unsigned offset; /* in urb->transfer_buffer */ 58 unsigned offset; /* in urb->transfer_buffer */
58 unsigned segsize; /* current xfer fragment */ 59 unsigned segsize; /* current xfer fragment */
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 9d2dcb121c5e..ce6c162920f7 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -53,7 +53,9 @@ static void musb_do_idle(unsigned long _musb)
53{ 53{
54 struct musb *musb = (void *)_musb; 54 struct musb *musb = (void *)_musb;
55 unsigned long flags; 55 unsigned long flags;
56#ifdef CONFIG_USB_MUSB_HDRC_HCD
56 u8 power; 57 u8 power;
58#endif
57 u8 devctl; 59 u8 devctl;
58 60
59 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 61 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index b73b036f3d77..ee8fca92a4ac 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -605,7 +605,7 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
605 605
606 if (musb->board_mode != MUSB_OTG) { 606 if (musb->board_mode != MUSB_OTG) {
607 ERR("Changing mode currently only supported in OTG mode\n"); 607 ERR("Changing mode currently only supported in OTG mode\n");
608 return; 608 return -EINVAL;
609 } 609 }
610 610
611 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); 611 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 8008d0bc80ad..cfaf1f085535 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -56,6 +56,7 @@ static void cp2101_shutdown(struct usb_serial *);
56static int debug; 56static int debug;
57 57
58static struct usb_device_id id_table [] = { 58static struct usb_device_id id_table [] = {
59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
59 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
60 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 61 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
61 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 62 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
@@ -67,6 +68,7 @@ static struct usb_device_id id_table [] = {
67 { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ 68 { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */
68 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ 69 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */
69 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ 70 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */
71 { USB_DEVICE(0x10C4, 0x8054) }, /* Enfora GSM2228 */
70 { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ 72 { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */
71 { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ 73 { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */
72 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ 74 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
@@ -85,6 +87,7 @@ static struct usb_device_id id_table [] = {
85 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 87 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
86 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 88 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
87 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 89 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
90 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
88 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 91 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
89 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 92 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
90 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 93 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index bd07eaa300b9..6fa1ec441b61 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -160,6 +160,11 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
160 160
161#define NOVATELWIRELESS_VENDOR_ID 0x1410 161#define NOVATELWIRELESS_VENDOR_ID 0x1410
162 162
163/* YISO PRODUCTS */
164
165#define YISO_VENDOR_ID 0x0EAB
166#define YISO_PRODUCT_U893 0xC893
167
163/* MERLIN EVDO PRODUCTS */ 168/* MERLIN EVDO PRODUCTS */
164#define NOVATELWIRELESS_PRODUCT_V640 0x1100 169#define NOVATELWIRELESS_PRODUCT_V640 0x1100
165#define NOVATELWIRELESS_PRODUCT_V620 0x1110 170#define NOVATELWIRELESS_PRODUCT_V620 0x1110
@@ -408,6 +413,7 @@ static struct usb_device_id option_ids[] = {
408 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 413 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
409 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, 414 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) },
410 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, 415 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) },
416 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) },
411 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 417 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
412 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 418 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
413 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, 419 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) },
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 3d9249632ae1..c68b738900bd 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -2,8 +2,8 @@
2# USB Storage driver configuration 2# USB Storage driver configuration
3# 3#
4 4
5comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'" 5comment "NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;"
6comment "may also be needed; see USB_STORAGE Help for more information" 6comment "see USB_STORAGE Help for more information"
7 depends on USB 7 depends on USB
8 8
9config USB_STORAGE 9config USB_STORAGE
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index fb9e20e624c1..6da9a7a962a8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -167,6 +167,13 @@ UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
167 US_SC_DEVICE, US_PR_DEVICE, NULL, 167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ), 168 US_FL_FIX_CAPACITY ),
169 169
170/* Patch for Nokia 5310 capacity */
171UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
172 "Nokia",
173 "5310",
174 US_SC_DEVICE, US_PR_DEVICE, NULL,
175 US_FL_FIX_CAPACITY ),
176
170/* Reported by Mario Rettig <mariorettig@web.de> */ 177/* Reported by Mario Rettig <mariorettig@web.de> */
171UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 178UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
172 "Nokia", 179 "Nokia",
@@ -233,14 +240,14 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
233 US_FL_MAX_SECTORS_64 ), 240 US_FL_MAX_SECTORS_64 ),
234 241
235/* Reported by Cedric Godin <cedric@belbone.be> */ 242/* Reported by Cedric Godin <cedric@belbone.be> */
236UNUSUAL_DEV( 0x0421, 0x04b9, 0x0551, 0x0551, 243UNUSUAL_DEV( 0x0421, 0x04b9, 0x0500, 0x0551,
237 "Nokia", 244 "Nokia",
238 "5300", 245 "5300",
239 US_SC_DEVICE, US_PR_DEVICE, NULL, 246 US_SC_DEVICE, US_PR_DEVICE, NULL,
240 US_FL_FIX_CAPACITY ), 247 US_FL_FIX_CAPACITY ),
241 248
242/* Reported by Richard Nauber <RichardNauber@web.de> */ 249/* Reported by Richard Nauber <RichardNauber@web.de> */
243UNUSUAL_DEV( 0x0421, 0x04fa, 0x0601, 0x0601, 250UNUSUAL_DEV( 0x0421, 0x04fa, 0x0550, 0x0660,
244 "Nokia", 251 "Nokia",
245 "6300", 252 "6300",
246 US_SC_DEVICE, US_PR_DEVICE, NULL, 253 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -253,6 +260,14 @@ UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
253 US_SC_DEVICE, US_PR_DEVICE, NULL, 260 US_SC_DEVICE, US_PR_DEVICE, NULL,
254 US_FL_FIX_CAPACITY ), 261 US_FL_FIX_CAPACITY ),
255 262
263/* Submitted by Ricky Wong Yung Fei <evilbladewarrior@gmail.com> */
264/* Nokia 7610 Supernova - Too many sectors reported in usb storage mode */
265UNUSUAL_DEV( 0x0421, 0x00f5, 0x0000, 0x0470,
266 "Nokia",
267 "7610 Supernova",
268 US_SC_DEVICE, US_PR_DEVICE, NULL,
269 US_FL_FIX_CAPACITY ),
270
256/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 271/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
257UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 272UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
258 "SMSC", 273 "SMSC",
@@ -418,6 +433,13 @@ UNUSUAL_DEV( 0x04b0, 0x0417, 0x0100, 0x0100,
418 US_SC_DEVICE, US_PR_DEVICE, NULL, 433 US_SC_DEVICE, US_PR_DEVICE, NULL,
419 US_FL_FIX_CAPACITY), 434 US_FL_FIX_CAPACITY),
420 435
436/* Reported by paul ready <lxtwin@homecall.co.uk> */
437UNUSUAL_DEV( 0x04b0, 0x0419, 0x0100, 0x0200,
438 "NIKON",
439 "NIKON DSC D300",
440 US_SC_DEVICE, US_PR_DEVICE, NULL,
441 US_FL_FIX_CAPACITY),
442
421/* Reported by Doug Maxey (dwm@austin.ibm.com) */ 443/* Reported by Doug Maxey (dwm@austin.ibm.com) */
422UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, 444UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
423 "IBM", 445 "IBM",
@@ -1258,6 +1280,13 @@ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
1258 US_SC_DEVICE, US_PR_DEVICE, NULL, 1280 US_SC_DEVICE, US_PR_DEVICE, NULL,
1259 US_FL_FIX_INQUIRY), 1281 US_FL_FIX_INQUIRY),
1260 1282
1283/* Reported by Luciano Rocha <luciano@eurotux.com> */
1284UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001,
1285 "Argosy",
1286 "Storage",
1287 US_SC_DEVICE, US_PR_DEVICE, NULL,
1288 US_FL_FIX_CAPACITY),
1289
1261/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 1290/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
1262 * Flag will support Bulk devices which use a standards-violating 32-byte 1291 * Flag will support Bulk devices which use a standards-violating 32-byte
1263 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with 1292 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index f8d0a57a07cb..9a577a800db5 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -132,7 +132,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
132 132
133 bl = backlight_device_register("backlight", &sinfo->pdev->dev, 133 bl = backlight_device_register("backlight", &sinfo->pdev->dev,
134 sinfo, &atmel_lcdc_bl_ops); 134 sinfo, &atmel_lcdc_bl_ops);
135 if (IS_ERR(sinfo->backlight)) { 135 if (IS_ERR(bl)) {
136 dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n", 136 dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
137 PTR_ERR(bl)); 137 PTR_ERR(bl));
138 return; 138 return;
diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x.c
index 242c38250166..93bb4340cc64 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x.c
@@ -119,6 +119,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
119 default: 119 default:
120 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", 120 dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
121 pdev->id); 121 pdev->id);
122 kfree(data);
122 return -EINVAL; 123 return -EINVAL;
123 } 124 }
124 125
@@ -130,6 +131,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
130 data, &da903x_backlight_ops); 131 data, &da903x_backlight_ops);
131 if (IS_ERR(bl)) { 132 if (IS_ERR(bl)) {
132 dev_err(&pdev->dev, "failed to register backlight\n"); 133 dev_err(&pdev->dev, "failed to register backlight\n");
134 kfree(data);
133 return PTR_ERR(bl); 135 return PTR_ERR(bl);
134 } 136 }
135 137
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 8e1731d3b228..680e57b616cd 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -42,10 +42,13 @@ static int fb_notifier_callback(struct notifier_block *self,
42 42
43 mutex_lock(&ld->ops_lock); 43 mutex_lock(&ld->ops_lock);
44 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { 44 if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
45 if (event == FB_EVENT_BLANK) 45 if (event == FB_EVENT_BLANK) {
46 ld->ops->set_power(ld, *(int *)evdata->data); 46 if (ld->ops->set_power)
47 else 47 ld->ops->set_power(ld, *(int *)evdata->data);
48 ld->ops->set_mode(ld, evdata->data); 48 } else {
49 if (ld->ops->set_mode)
50 ld->ops->set_mode(ld, evdata->data);
51 }
49 } 52 }
50 mutex_unlock(&ld->ops_lock); 53 mutex_unlock(&ld->ops_lock);
51 return 0; 54 return 0;
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 8a8760230bc7..a2aa6ddffbe2 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -2462,8 +2462,7 @@ static int __init cirrusfb_init(void)
2462 2462
2463#ifndef MODULE 2463#ifndef MODULE
2464static int __init cirrusfb_setup(char *options) { 2464static int __init cirrusfb_setup(char *options) {
2465 char *this_opt, s[32]; 2465 char *this_opt;
2466 int i;
2467 2466
2468 DPRINTK("ENTER\n"); 2467 DPRINTK("ENTER\n");
2469 2468
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 1d5ae39cb271..3c65b0d67617 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -230,7 +230,7 @@ static void fb_set_logo_directpalette(struct fb_info *info,
230 greenshift = info->var.green.offset; 230 greenshift = info->var.green.offset;
231 blueshift = info->var.blue.offset; 231 blueshift = info->var.blue.offset;
232 232
233 for (i = 32; i < logo->clutsize; i++) 233 for (i = 32; i < 32 + logo->clutsize; i++)
234 palette[i] = i << redshift | i << greenshift | i << blueshift; 234 palette[i] = i << redshift | i << greenshift | i << blueshift;
235} 235}
236 236
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 97204497d9f7..cc59c52e1103 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -804,6 +804,9 @@ static int pxafb_smart_thread(void *arg)
804 804
805static int pxafb_smart_init(struct pxafb_info *fbi) 805static int pxafb_smart_init(struct pxafb_info *fbi)
806{ 806{
807 if (!(fbi->lccr0 | LCCR0_LCDT))
808 return 0;
809
807 fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi, 810 fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi,
808 "lcd_refresh"); 811 "lcd_refresh");
809 if (IS_ERR(fbi->smart_thread)) { 812 if (IS_ERR(fbi->smart_thread)) {
@@ -1372,7 +1375,7 @@ static void pxafb_decode_mach_info(struct pxafb_info *fbi,
1372 fbi->cmap_inverse = inf->cmap_inverse; 1375 fbi->cmap_inverse = inf->cmap_inverse;
1373 fbi->cmap_static = inf->cmap_static; 1376 fbi->cmap_static = inf->cmap_static;
1374 1377
1375 switch (lcd_conn & 0xf) { 1378 switch (lcd_conn & LCD_TYPE_MASK) {
1376 case LCD_TYPE_MONO_STN: 1379 case LCD_TYPE_MONO_STN:
1377 fbi->lccr0 = LCCR0_CMS; 1380 fbi->lccr0 = LCCR0_CMS;
1378 break; 1381 break;
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 2a380011e9ba..7baf2dd12d50 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -222,6 +222,9 @@ static irqreturn_t tmiofb_irq(int irq, void *__info)
222 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC); 222 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC);
223 223
224 224
225 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC);
226
227#ifdef CONFIG_FB_TMIO_ACCELL
225 /* 228 /*
226 * We were in polling mode and now we got correct irq. 229 * We were in polling mode and now we got correct irq.
227 * Switch back to IRQ-based sync of command FIFO 230 * Switch back to IRQ-based sync of command FIFO
@@ -231,9 +234,6 @@ static irqreturn_t tmiofb_irq(int irq, void *__info)
231 par->use_polling = false; 234 par->use_polling = false;
232 } 235 }
233 236
234 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC);
235
236#ifdef CONFIG_FB_TMIO_ACCELL
237 if (bbisc & 1) 237 if (bbisc & 1)
238 wake_up(&par->wait_acc); 238 wake_up(&par->wait_acc);
239#endif 239#endif
@@ -938,7 +938,9 @@ static void tmiofb_dump_regs(struct platform_device *dev)
938static int tmiofb_suspend(struct platform_device *dev, pm_message_t state) 938static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
939{ 939{
940 struct fb_info *info = platform_get_drvdata(dev); 940 struct fb_info *info = platform_get_drvdata(dev);
941#ifdef CONFIG_FB_TMIO_ACCELL
941 struct tmiofb_par *par = info->par; 942 struct tmiofb_par *par = info->par;
943#endif
942 struct mfd_cell *cell = dev->dev.platform_data; 944 struct mfd_cell *cell = dev->dev.platform_data;
943 int retval = 0; 945 int retval = 0;
944 946
@@ -950,12 +952,14 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
950 info->fbops->fb_sync(info); 952 info->fbops->fb_sync(info);
951 953
952 954
955#ifdef CONFIG_FB_TMIO_ACCELL
953 /* 956 /*
954 * The fb should be usable even if interrupts are disabled (and they are 957 * The fb should be usable even if interrupts are disabled (and they are
955 * during suspend/resume). Switch temporary to forced polling. 958 * during suspend/resume). Switch temporary to forced polling.
956 */ 959 */
957 printk(KERN_INFO "tmiofb: switching to polling\n"); 960 printk(KERN_INFO "tmiofb: switching to polling\n");
958 par->use_polling = true; 961 par->use_polling = true;
962#endif
959 tmiofb_hw_stop(dev); 963 tmiofb_hw_stop(dev);
960 964
961 if (cell->suspend) 965 if (cell->suspend)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 0132eae06f55..73ac754ad801 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -2036,30 +2036,30 @@ static int viafb_vt1636_proc_write(struct file *file,
2036 return count; 2036 return count;
2037} 2037}
2038 2038
2039static void viafb_init_proc(struct proc_dir_entry *viafb_entry) 2039static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
2040{ 2040{
2041 struct proc_dir_entry *entry; 2041 struct proc_dir_entry *entry;
2042 viafb_entry = proc_mkdir("viafb", NULL); 2042 *viafb_entry = proc_mkdir("viafb", NULL);
2043 if (viafb_entry) { 2043 if (viafb_entry) {
2044 entry = create_proc_entry("dvp0", 0, viafb_entry); 2044 entry = create_proc_entry("dvp0", 0, *viafb_entry);
2045 if (entry) { 2045 if (entry) {
2046 entry->owner = THIS_MODULE; 2046 entry->owner = THIS_MODULE;
2047 entry->read_proc = viafb_dvp0_proc_read; 2047 entry->read_proc = viafb_dvp0_proc_read;
2048 entry->write_proc = viafb_dvp0_proc_write; 2048 entry->write_proc = viafb_dvp0_proc_write;
2049 } 2049 }
2050 entry = create_proc_entry("dvp1", 0, viafb_entry); 2050 entry = create_proc_entry("dvp1", 0, *viafb_entry);
2051 if (entry) { 2051 if (entry) {
2052 entry->owner = THIS_MODULE; 2052 entry->owner = THIS_MODULE;
2053 entry->read_proc = viafb_dvp1_proc_read; 2053 entry->read_proc = viafb_dvp1_proc_read;
2054 entry->write_proc = viafb_dvp1_proc_write; 2054 entry->write_proc = viafb_dvp1_proc_write;
2055 } 2055 }
2056 entry = create_proc_entry("dfph", 0, viafb_entry); 2056 entry = create_proc_entry("dfph", 0, *viafb_entry);
2057 if (entry) { 2057 if (entry) {
2058 entry->owner = THIS_MODULE; 2058 entry->owner = THIS_MODULE;
2059 entry->read_proc = viafb_dfph_proc_read; 2059 entry->read_proc = viafb_dfph_proc_read;
2060 entry->write_proc = viafb_dfph_proc_write; 2060 entry->write_proc = viafb_dfph_proc_write;
2061 } 2061 }
2062 entry = create_proc_entry("dfpl", 0, viafb_entry); 2062 entry = create_proc_entry("dfpl", 0, *viafb_entry);
2063 if (entry) { 2063 if (entry) {
2064 entry->owner = THIS_MODULE; 2064 entry->owner = THIS_MODULE;
2065 entry->read_proc = viafb_dfpl_proc_read; 2065 entry->read_proc = viafb_dfpl_proc_read;
@@ -2068,7 +2068,7 @@ static void viafb_init_proc(struct proc_dir_entry *viafb_entry)
2068 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info. 2068 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
2069 lvds_chip_name || VT1636_LVDS == 2069 lvds_chip_name || VT1636_LVDS ==
2070 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { 2070 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2071 entry = create_proc_entry("vt1636", 0, viafb_entry); 2071 entry = create_proc_entry("vt1636", 0, *viafb_entry);
2072 if (entry) { 2072 if (entry) {
2073 entry->owner = THIS_MODULE; 2073 entry->owner = THIS_MODULE;
2074 entry->read_proc = viafb_vt1636_proc_read; 2074 entry->read_proc = viafb_vt1636_proc_read;
@@ -2087,6 +2087,7 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
2087 remove_proc_entry("dfpl", viafb_entry); 2087 remove_proc_entry("dfpl", viafb_entry);
2088 remove_proc_entry("vt1636", viafb_entry); 2088 remove_proc_entry("vt1636", viafb_entry);
2089 remove_proc_entry("vt1625", viafb_entry); 2089 remove_proc_entry("vt1625", viafb_entry);
2090 remove_proc_entry("viafb", NULL);
2090} 2091}
2091 2092
2092static int __devinit via_pci_probe(void) 2093static int __devinit via_pci_probe(void)
@@ -2348,7 +2349,7 @@ static int __devinit via_pci_probe(void)
2348 viafbinfo->node, viafbinfo->fix.id, default_var.xres, 2349 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2349 default_var.yres, default_var.bits_per_pixel); 2350 default_var.yres, default_var.bits_per_pixel);
2350 2351
2351 viafb_init_proc(viaparinfo->proc_entry); 2352 viafb_init_proc(&viaparinfo->proc_entry);
2352 viafb_init_dac(IGA2); 2353 viafb_init_dac(IGA2);
2353 return 0; 2354 return 0;
2354} 2355}
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 1295625c4825..c973889110c8 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -86,8 +86,8 @@ static struct platform_driver omap_hdq_driver = {
86static u8 omap_w1_read_byte(void *_hdq); 86static u8 omap_w1_read_byte(void *_hdq);
87static void omap_w1_write_byte(void *_hdq, u8 byte); 87static void omap_w1_write_byte(void *_hdq, u8 byte);
88static u8 omap_w1_reset_bus(void *_hdq); 88static u8 omap_w1_reset_bus(void *_hdq);
89static void omap_w1_search_bus(void *_hdq, u8 search_type, 89static void omap_w1_search_bus(void *_hdq, struct w1_master *master_dev,
90 w1_slave_found_callback slave_found); 90 u8 search_type, w1_slave_found_callback slave_found);
91 91
92 92
93static struct w1_bus_master omap_w1_master = { 93static struct w1_bus_master omap_w1_master = {
@@ -231,8 +231,8 @@ static u8 omap_w1_reset_bus(void *_hdq)
231} 231}
232 232
233/* W1 search callback function */ 233/* W1 search callback function */
234static void omap_w1_search_bus(void *_hdq, u8 search_type, 234static void omap_w1_search_bus(void *_hdq, struct w1_master *master_dev,
235 w1_slave_found_callback slave_found) 235 u8 search_type, w1_slave_found_callback slave_found)
236{ 236{
237 u64 module_id, rn_le, cs, id; 237 u64 module_id, rn_le, cs, id;
238 238
@@ -249,7 +249,7 @@ static void omap_w1_search_bus(void *_hdq, u8 search_type,
249 cs = w1_calc_crc8((u8 *)&rn_le, 7); 249 cs = w1_calc_crc8((u8 *)&rn_le, 7);
250 id = (cs << 56) | module_id; 250 id = (cs << 56) | module_id;
251 251
252 slave_found(_hdq, id); 252 slave_found(master_dev, id);
253} 253}
254 254
255static int _omap_hdq_reset(struct hdq_data *hdq_data) 255static int _omap_hdq_reset(struct hdq_data *hdq_data)
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a0fb5eac407c..526c191e84ea 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -122,14 +122,7 @@ static struct timer_list balloon_timer;
122static void scrub_page(struct page *page) 122static void scrub_page(struct page *page)
123{ 123{
124#ifdef CONFIG_XEN_SCRUB_PAGES 124#ifdef CONFIG_XEN_SCRUB_PAGES
125 if (PageHighMem(page)) { 125 clear_highpage(page);
126 void *v = kmap(page);
127 clear_page(v);
128 kunmap(v);
129 } else {
130 void *v = page_address(page);
131 clear_page(v);
132 }
133#endif 126#endif
134} 127}
135 128
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 8855331b2fba..e078b7aea143 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -8,7 +8,11 @@ handling fcntl(F_SETLEASE). Convert cifs to using blocking tcp
8sends, and also let tcp autotune the socket send and receive buffers. 8sends, and also let tcp autotune the socket send and receive buffers.
9This reduces the number of EAGAIN errors returned by TCP/IP in 9This reduces the number of EAGAIN errors returned by TCP/IP in
10high stress workloads (and the number of retries on socket writes 10high stress workloads (and the number of retries on socket writes
11when sending large SMBWriteX requests). 11when sending large SMBWriteX requests). Fix case in which a portion of
12data can in some cases not get written to the file on the server before the
13file is closed. Fix DFS parsing to properly handle path consumed field,
14and to handle certain codepage conversions better. Fix mount and
15umount race that can cause oops in mount or umount or reconnect.
12 16
13Version 1.54 17Version 1.54
14------------ 18------------
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 69a12aae91d3..490e34bbf27a 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -107,12 +107,13 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
107#ifdef CONFIG_PROC_FS 107#ifdef CONFIG_PROC_FS
108static int cifs_debug_data_proc_show(struct seq_file *m, void *v) 108static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
109{ 109{
110 struct list_head *tmp; 110 struct list_head *tmp1, *tmp2, *tmp3;
111 struct list_head *tmp1;
112 struct mid_q_entry *mid_entry; 111 struct mid_q_entry *mid_entry;
112 struct TCP_Server_Info *server;
113 struct cifsSesInfo *ses; 113 struct cifsSesInfo *ses;
114 struct cifsTconInfo *tcon; 114 struct cifsTconInfo *tcon;
115 int i; 115 int i, j;
116 __u32 dev_type;
116 117
117 seq_puts(m, 118 seq_puts(m,
118 "Display Internal CIFS Data Structures for Debugging\n" 119 "Display Internal CIFS Data Structures for Debugging\n"
@@ -122,46 +123,78 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
122 seq_printf(m, "Servers:"); 123 seq_printf(m, "Servers:");
123 124
124 i = 0; 125 i = 0;
125 read_lock(&GlobalSMBSeslock); 126 read_lock(&cifs_tcp_ses_lock);
126 list_for_each(tmp, &GlobalSMBSessionList) { 127 list_for_each(tmp1, &cifs_tcp_ses_list) {
128 server = list_entry(tmp1, struct TCP_Server_Info,
129 tcp_ses_list);
127 i++; 130 i++;
128 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 131 list_for_each(tmp2, &server->smb_ses_list) {
129 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || 132 ses = list_entry(tmp2, struct cifsSesInfo,
130 (ses->serverNOS == NULL)) { 133 smb_ses_list);
131 seq_printf(m, "\nentry for %s not fully " 134 if ((ses->serverDomain == NULL) ||
132 "displayed\n\t", ses->serverName); 135 (ses->serverOS == NULL) ||
133 } else { 136 (ses->serverNOS == NULL)) {
134 seq_printf(m, 137 seq_printf(m, "\n%d) entry for %s not fully "
135 "\n%d) Name: %s Domain: %s Mounts: %d OS:" 138 "displayed\n\t", i, ses->serverName);
136 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" 139 } else {
140 seq_printf(m,
141 "\n%d) Name: %s Domain: %s Uses: %d OS:"
142 " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB"
137 " session status: %d\t", 143 " session status: %d\t",
138 i, ses->serverName, ses->serverDomain, 144 i, ses->serverName, ses->serverDomain,
139 atomic_read(&ses->inUse), 145 ses->ses_count, ses->serverOS, ses->serverNOS,
140 ses->serverOS, ses->serverNOS,
141 ses->capabilities, ses->status); 146 ses->capabilities, ses->status);
142 } 147 }
143 if (ses->server) {
144 seq_printf(m, "TCP status: %d\n\tLocal Users To " 148 seq_printf(m, "TCP status: %d\n\tLocal Users To "
145 "Server: %d SecMode: 0x%x Req On Wire: %d", 149 "Server: %d SecMode: 0x%x Req On Wire: %d",
146 ses->server->tcpStatus, 150 server->tcpStatus, server->srv_count,
147 atomic_read(&ses->server->socketUseCount), 151 server->secMode,
148 ses->server->secMode, 152 atomic_read(&server->inFlight));
149 atomic_read(&ses->server->inFlight));
150 153
151#ifdef CONFIG_CIFS_STATS2 154#ifdef CONFIG_CIFS_STATS2
152 seq_printf(m, " In Send: %d In MaxReq Wait: %d", 155 seq_printf(m, " In Send: %d In MaxReq Wait: %d",
153 atomic_read(&ses->server->inSend), 156 atomic_read(&server->inSend),
154 atomic_read(&ses->server->num_waiters)); 157 atomic_read(&server->num_waiters));
155#endif 158#endif
156 159
157 seq_puts(m, "\nMIDs:\n"); 160 seq_puts(m, "\n\tShares:");
161 j = 0;
162 list_for_each(tmp3, &ses->tcon_list) {
163 tcon = list_entry(tmp3, struct cifsTconInfo,
164 tcon_list);
165 ++j;
166 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
167 seq_printf(m, "\n\t%d) %s Mounts: %d ", j,
168 tcon->treeName, tcon->tc_count);
169 if (tcon->nativeFileSystem) {
170 seq_printf(m, "Type: %s ",
171 tcon->nativeFileSystem);
172 }
173 seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
174 "\nPathComponentMax: %d Status: 0x%d",
175 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
176 le32_to_cpu(tcon->fsAttrInfo.Attributes),
177 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
178 tcon->tidStatus);
179 if (dev_type == FILE_DEVICE_DISK)
180 seq_puts(m, " type: DISK ");
181 else if (dev_type == FILE_DEVICE_CD_ROM)
182 seq_puts(m, " type: CDROM ");
183 else
184 seq_printf(m, " type: %d ", dev_type);
185
186 if (tcon->need_reconnect)
187 seq_puts(m, "\tDISCONNECTED ");
188 seq_putc(m, '\n');
189 }
190
191 seq_puts(m, "\n\tMIDs:\n");
158 192
159 spin_lock(&GlobalMid_Lock); 193 spin_lock(&GlobalMid_Lock);
160 list_for_each(tmp1, &ses->server->pending_mid_q) { 194 list_for_each(tmp3, &server->pending_mid_q) {
161 mid_entry = list_entry(tmp1, struct 195 mid_entry = list_entry(tmp3, struct mid_q_entry,
162 mid_q_entry,
163 qhead); 196 qhead);
164 seq_printf(m, "State: %d com: %d pid:" 197 seq_printf(m, "\tState: %d com: %d pid:"
165 " %d tsk: %p mid %d\n", 198 " %d tsk: %p mid %d\n",
166 mid_entry->midState, 199 mid_entry->midState,
167 (int)mid_entry->command, 200 (int)mid_entry->command,
@@ -171,44 +204,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
171 } 204 }
172 spin_unlock(&GlobalMid_Lock); 205 spin_unlock(&GlobalMid_Lock);
173 } 206 }
174
175 }
176 read_unlock(&GlobalSMBSeslock);
177 seq_putc(m, '\n');
178
179 seq_puts(m, "Shares:");
180
181 i = 0;
182 read_lock(&GlobalSMBSeslock);
183 list_for_each(tmp, &GlobalTreeConnectionList) {
184 __u32 dev_type;
185 i++;
186 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
187 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
188 seq_printf(m, "\n%d) %s Uses: %d ", i,
189 tcon->treeName, atomic_read(&tcon->useCount));
190 if (tcon->nativeFileSystem) {
191 seq_printf(m, "Type: %s ",
192 tcon->nativeFileSystem);
193 }
194 seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
195 "\nPathComponentMax: %d Status: %d",
196 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
197 le32_to_cpu(tcon->fsAttrInfo.Attributes),
198 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
199 tcon->tidStatus);
200 if (dev_type == FILE_DEVICE_DISK)
201 seq_puts(m, " type: DISK ");
202 else if (dev_type == FILE_DEVICE_CD_ROM)
203 seq_puts(m, " type: CDROM ");
204 else
205 seq_printf(m, " type: %d ", dev_type);
206
207 if (tcon->tidStatus == CifsNeedReconnect)
208 seq_puts(m, "\tDISCONNECTED ");
209 } 207 }
210 read_unlock(&GlobalSMBSeslock); 208 read_unlock(&cifs_tcp_ses_lock);
211
212 seq_putc(m, '\n'); 209 seq_putc(m, '\n');
213 210
214 /* BB add code to dump additional info such as TCP session info now */ 211 /* BB add code to dump additional info such as TCP session info now */
@@ -234,7 +231,9 @@ static ssize_t cifs_stats_proc_write(struct file *file,
234{ 231{
235 char c; 232 char c;
236 int rc; 233 int rc;
237 struct list_head *tmp; 234 struct list_head *tmp1, *tmp2, *tmp3;
235 struct TCP_Server_Info *server;
236 struct cifsSesInfo *ses;
238 struct cifsTconInfo *tcon; 237 struct cifsTconInfo *tcon;
239 238
240 rc = get_user(c, buffer); 239 rc = get_user(c, buffer);
@@ -242,33 +241,42 @@ static ssize_t cifs_stats_proc_write(struct file *file,
242 return rc; 241 return rc;
243 242
244 if (c == '1' || c == 'y' || c == 'Y' || c == '0') { 243 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
245 read_lock(&GlobalSMBSeslock);
246#ifdef CONFIG_CIFS_STATS2 244#ifdef CONFIG_CIFS_STATS2
247 atomic_set(&totBufAllocCount, 0); 245 atomic_set(&totBufAllocCount, 0);
248 atomic_set(&totSmBufAllocCount, 0); 246 atomic_set(&totSmBufAllocCount, 0);
249#endif /* CONFIG_CIFS_STATS2 */ 247#endif /* CONFIG_CIFS_STATS2 */
250 list_for_each(tmp, &GlobalTreeConnectionList) { 248 read_lock(&cifs_tcp_ses_lock);
251 tcon = list_entry(tmp, struct cifsTconInfo, 249 list_for_each(tmp1, &cifs_tcp_ses_list) {
252 cifsConnectionList); 250 server = list_entry(tmp1, struct TCP_Server_Info,
253 atomic_set(&tcon->num_smbs_sent, 0); 251 tcp_ses_list);
254 atomic_set(&tcon->num_writes, 0); 252 list_for_each(tmp2, &server->smb_ses_list) {
255 atomic_set(&tcon->num_reads, 0); 253 ses = list_entry(tmp2, struct cifsSesInfo,
256 atomic_set(&tcon->num_oplock_brks, 0); 254 smb_ses_list);
257 atomic_set(&tcon->num_opens, 0); 255 list_for_each(tmp3, &ses->tcon_list) {
258 atomic_set(&tcon->num_closes, 0); 256 tcon = list_entry(tmp3,
259 atomic_set(&tcon->num_deletes, 0); 257 struct cifsTconInfo,
260 atomic_set(&tcon->num_mkdirs, 0); 258 tcon_list);
261 atomic_set(&tcon->num_rmdirs, 0); 259 atomic_set(&tcon->num_smbs_sent, 0);
262 atomic_set(&tcon->num_renames, 0); 260 atomic_set(&tcon->num_writes, 0);
263 atomic_set(&tcon->num_t2renames, 0); 261 atomic_set(&tcon->num_reads, 0);
264 atomic_set(&tcon->num_ffirst, 0); 262 atomic_set(&tcon->num_oplock_brks, 0);
265 atomic_set(&tcon->num_fnext, 0); 263 atomic_set(&tcon->num_opens, 0);
266 atomic_set(&tcon->num_fclose, 0); 264 atomic_set(&tcon->num_closes, 0);
267 atomic_set(&tcon->num_hardlinks, 0); 265 atomic_set(&tcon->num_deletes, 0);
268 atomic_set(&tcon->num_symlinks, 0); 266 atomic_set(&tcon->num_mkdirs, 0);
269 atomic_set(&tcon->num_locks, 0); 267 atomic_set(&tcon->num_rmdirs, 0);
268 atomic_set(&tcon->num_renames, 0);
269 atomic_set(&tcon->num_t2renames, 0);
270 atomic_set(&tcon->num_ffirst, 0);
271 atomic_set(&tcon->num_fnext, 0);
272 atomic_set(&tcon->num_fclose, 0);
273 atomic_set(&tcon->num_hardlinks, 0);
274 atomic_set(&tcon->num_symlinks, 0);
275 atomic_set(&tcon->num_locks, 0);
276 }
277 }
270 } 278 }
271 read_unlock(&GlobalSMBSeslock); 279 read_unlock(&cifs_tcp_ses_lock);
272 } 280 }
273 281
274 return count; 282 return count;
@@ -277,7 +285,9 @@ static ssize_t cifs_stats_proc_write(struct file *file,
277static int cifs_stats_proc_show(struct seq_file *m, void *v) 285static int cifs_stats_proc_show(struct seq_file *m, void *v)
278{ 286{
279 int i; 287 int i;
280 struct list_head *tmp; 288 struct list_head *tmp1, *tmp2, *tmp3;
289 struct TCP_Server_Info *server;
290 struct cifsSesInfo *ses;
281 struct cifsTconInfo *tcon; 291 struct cifsTconInfo *tcon;
282 292
283 seq_printf(m, 293 seq_printf(m,
@@ -306,44 +316,55 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
306 GlobalCurrentXid, GlobalMaxActiveXid); 316 GlobalCurrentXid, GlobalMaxActiveXid);
307 317
308 i = 0; 318 i = 0;
309 read_lock(&GlobalSMBSeslock); 319 read_lock(&cifs_tcp_ses_lock);
310 list_for_each(tmp, &GlobalTreeConnectionList) { 320 list_for_each(tmp1, &cifs_tcp_ses_list) {
311 i++; 321 server = list_entry(tmp1, struct TCP_Server_Info,
312 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 322 tcp_ses_list);
313 seq_printf(m, "\n%d) %s", i, tcon->treeName); 323 list_for_each(tmp2, &server->smb_ses_list) {
314 if (tcon->tidStatus == CifsNeedReconnect) 324 ses = list_entry(tmp2, struct cifsSesInfo,
315 seq_puts(m, "\tDISCONNECTED "); 325 smb_ses_list);
316 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d", 326 list_for_each(tmp3, &ses->tcon_list) {
317 atomic_read(&tcon->num_smbs_sent), 327 tcon = list_entry(tmp3,
318 atomic_read(&tcon->num_oplock_brks)); 328 struct cifsTconInfo,
319 seq_printf(m, "\nReads: %d Bytes: %lld", 329 tcon_list);
320 atomic_read(&tcon->num_reads), 330 i++;
321 (long long)(tcon->bytes_read)); 331 seq_printf(m, "\n%d) %s", i, tcon->treeName);
322 seq_printf(m, "\nWrites: %d Bytes: %lld", 332 if (tcon->need_reconnect)
323 atomic_read(&tcon->num_writes), 333 seq_puts(m, "\tDISCONNECTED ");
324 (long long)(tcon->bytes_written)); 334 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
325 seq_printf(m, 335 atomic_read(&tcon->num_smbs_sent),
326 "\nLocks: %d HardLinks: %d Symlinks: %d", 336 atomic_read(&tcon->num_oplock_brks));
327 atomic_read(&tcon->num_locks), 337 seq_printf(m, "\nReads: %d Bytes: %lld",
328 atomic_read(&tcon->num_hardlinks), 338 atomic_read(&tcon->num_reads),
329 atomic_read(&tcon->num_symlinks)); 339 (long long)(tcon->bytes_read));
330 340 seq_printf(m, "\nWrites: %d Bytes: %lld",
331 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d", 341 atomic_read(&tcon->num_writes),
332 atomic_read(&tcon->num_opens), 342 (long long)(tcon->bytes_written));
333 atomic_read(&tcon->num_closes), 343 seq_printf(m, "\nLocks: %d HardLinks: %d "
334 atomic_read(&tcon->num_deletes)); 344 "Symlinks: %d",
335 seq_printf(m, "\nMkdirs: %d Rmdirs: %d", 345 atomic_read(&tcon->num_locks),
336 atomic_read(&tcon->num_mkdirs), 346 atomic_read(&tcon->num_hardlinks),
337 atomic_read(&tcon->num_rmdirs)); 347 atomic_read(&tcon->num_symlinks));
338 seq_printf(m, "\nRenames: %d T2 Renames %d", 348 seq_printf(m, "\nOpens: %d Closes: %d"
339 atomic_read(&tcon->num_renames), 349 "Deletes: %d",
340 atomic_read(&tcon->num_t2renames)); 350 atomic_read(&tcon->num_opens),
341 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d", 351 atomic_read(&tcon->num_closes),
342 atomic_read(&tcon->num_ffirst), 352 atomic_read(&tcon->num_deletes));
343 atomic_read(&tcon->num_fnext), 353 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
344 atomic_read(&tcon->num_fclose)); 354 atomic_read(&tcon->num_mkdirs),
355 atomic_read(&tcon->num_rmdirs));
356 seq_printf(m, "\nRenames: %d T2 Renames %d",
357 atomic_read(&tcon->num_renames),
358 atomic_read(&tcon->num_t2renames));
359 seq_printf(m, "\nFindFirst: %d FNext %d "
360 "FClose %d",
361 atomic_read(&tcon->num_ffirst),
362 atomic_read(&tcon->num_fnext),
363 atomic_read(&tcon->num_fclose));
364 }
365 }
345 } 366 }
346 read_unlock(&GlobalSMBSeslock); 367 read_unlock(&cifs_tcp_ses_lock);
347 368
348 seq_putc(m, '\n'); 369 seq_putc(m, '\n');
349 return 0; 370 return 0;
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index d2c8eef84f3c..e1c18362ba46 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -106,7 +106,8 @@ static char *cifs_get_share_name(const char *node_name)
106/** 106/**
107 * compose_mount_options - creates mount options for refferral 107 * compose_mount_options - creates mount options for refferral
108 * @sb_mountdata: parent/root DFS mount options (template) 108 * @sb_mountdata: parent/root DFS mount options (template)
109 * @ref_unc: refferral server UNC 109 * @dentry: point where we are going to mount
110 * @ref: server's referral
110 * @devname: pointer for saving device name 111 * @devname: pointer for saving device name
111 * 112 *
112 * creates mount options for submount based on template options sb_mountdata 113 * creates mount options for submount based on template options sb_mountdata
@@ -116,7 +117,8 @@ static char *cifs_get_share_name(const char *node_name)
116 * Caller is responcible for freeing retunrned value if it is not error. 117 * Caller is responcible for freeing retunrned value if it is not error.
117 */ 118 */
118static char *compose_mount_options(const char *sb_mountdata, 119static char *compose_mount_options(const char *sb_mountdata,
119 const char *ref_unc, 120 struct dentry *dentry,
121 const struct dfs_info3_param *ref,
120 char **devname) 122 char **devname)
121{ 123{
122 int rc; 124 int rc;
@@ -126,11 +128,12 @@ static char *compose_mount_options(const char *sb_mountdata,
126 char *srvIP = NULL; 128 char *srvIP = NULL;
127 char sep = ','; 129 char sep = ',';
128 int off, noff; 130 int off, noff;
131 char *fullpath;
129 132
130 if (sb_mountdata == NULL) 133 if (sb_mountdata == NULL)
131 return ERR_PTR(-EINVAL); 134 return ERR_PTR(-EINVAL);
132 135
133 *devname = cifs_get_share_name(ref_unc); 136 *devname = cifs_get_share_name(ref->node_name);
134 rc = dns_resolve_server_name_to_ip(*devname, &srvIP); 137 rc = dns_resolve_server_name_to_ip(*devname, &srvIP);
135 if (rc != 0) { 138 if (rc != 0) {
136 cERROR(1, ("%s: Failed to resolve server part of %s to IP", 139 cERROR(1, ("%s: Failed to resolve server part of %s to IP",
@@ -138,7 +141,12 @@ static char *compose_mount_options(const char *sb_mountdata,
138 mountdata = ERR_PTR(rc); 141 mountdata = ERR_PTR(rc);
139 goto compose_mount_options_out; 142 goto compose_mount_options_out;
140 } 143 }
141 md_len = strlen(sb_mountdata) + strlen(srvIP) + strlen(ref_unc) + 3; 144 /* md_len = strlen(...) + 12 for 'sep+prefixpath='
145 * assuming that we have 'unc=' and 'ip=' in
146 * the original sb_mountdata
147 */
148 md_len = strlen(sb_mountdata) + strlen(srvIP) +
149 strlen(ref->node_name) + 12;
142 mountdata = kzalloc(md_len+1, GFP_KERNEL); 150 mountdata = kzalloc(md_len+1, GFP_KERNEL);
143 if (mountdata == NULL) { 151 if (mountdata == NULL) {
144 mountdata = ERR_PTR(-ENOMEM); 152 mountdata = ERR_PTR(-ENOMEM);
@@ -152,41 +160,56 @@ static char *compose_mount_options(const char *sb_mountdata,
152 strncpy(mountdata, sb_mountdata, 5); 160 strncpy(mountdata, sb_mountdata, 5);
153 off += 5; 161 off += 5;
154 } 162 }
155 while ((tkn_e = strchr(sb_mountdata+off, sep))) { 163
156 noff = (tkn_e - (sb_mountdata+off)) + 1; 164 do {
157 if (strnicmp(sb_mountdata+off, "unc=", 4) == 0) { 165 tkn_e = strchr(sb_mountdata + off, sep);
166 if (tkn_e == NULL)
167 noff = strlen(sb_mountdata + off);
168 else
169 noff = tkn_e - (sb_mountdata + off) + 1;
170
171 if (strnicmp(sb_mountdata + off, "unc=", 4) == 0) {
158 off += noff; 172 off += noff;
159 continue; 173 continue;
160 } 174 }
161 if (strnicmp(sb_mountdata+off, "ip=", 3) == 0) { 175 if (strnicmp(sb_mountdata + off, "ip=", 3) == 0) {
162 off += noff; 176 off += noff;
163 continue; 177 continue;
164 } 178 }
165 if (strnicmp(sb_mountdata+off, "prefixpath=", 3) == 0) { 179 if (strnicmp(sb_mountdata + off, "prefixpath=", 11) == 0) {
166 off += noff; 180 off += noff;
167 continue; 181 continue;
168 } 182 }
169 strncat(mountdata, sb_mountdata+off, noff); 183 strncat(mountdata, sb_mountdata + off, noff);
170 off += noff; 184 off += noff;
171 } 185 } while (tkn_e);
172 strcat(mountdata, sb_mountdata+off); 186 strcat(mountdata, sb_mountdata + off);
173 mountdata[md_len] = '\0'; 187 mountdata[md_len] = '\0';
174 188
175 /* copy new IP and ref share name */ 189 /* copy new IP and ref share name */
176 strcat(mountdata, ",ip="); 190 if (mountdata[strlen(mountdata) - 1] != sep)
191 strncat(mountdata, &sep, 1);
192 strcat(mountdata, "ip=");
177 strcat(mountdata, srvIP); 193 strcat(mountdata, srvIP);
178 strcat(mountdata, ",unc="); 194 strncat(mountdata, &sep, 1);
195 strcat(mountdata, "unc=");
179 strcat(mountdata, *devname); 196 strcat(mountdata, *devname);
180 197
181 /* find & copy prefixpath */ 198 /* find & copy prefixpath */
182 tkn_e = strchr(ref_unc+2, '\\'); 199 tkn_e = strchr(ref->node_name + 2, '\\');
183 if (tkn_e) { 200 if (tkn_e == NULL) /* invalid unc, missing share name*/
184 tkn_e = strchr(tkn_e+1, '\\'); 201 goto compose_mount_options_out;
185 if (tkn_e) { 202
186 strcat(mountdata, ",prefixpath="); 203 fullpath = build_path_from_dentry(dentry);
187 strcat(mountdata, tkn_e+1); 204 tkn_e = strchr(tkn_e + 1, '\\');
188 } 205 if (tkn_e || strlen(fullpath) - (ref->path_consumed)) {
206 strncat(mountdata, &sep, 1);
207 strcat(mountdata, "prefixpath=");
208 if (tkn_e)
209 strcat(mountdata, tkn_e + 1);
210 strcat(mountdata, fullpath + (ref->path_consumed));
189 } 211 }
212 kfree(fullpath);
190 213
191 /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/ 214 /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/
192 /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/ 215 /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/
@@ -198,7 +221,7 @@ compose_mount_options_out:
198 221
199 222
200static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, 223static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent,
201 struct dentry *dentry, char *ref_unc) 224 struct dentry *dentry, const struct dfs_info3_param *ref)
202{ 225{
203 struct cifs_sb_info *cifs_sb; 226 struct cifs_sb_info *cifs_sb;
204 struct vfsmount *mnt; 227 struct vfsmount *mnt;
@@ -207,7 +230,7 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent,
207 230
208 cifs_sb = CIFS_SB(dentry->d_inode->i_sb); 231 cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
209 mountdata = compose_mount_options(cifs_sb->mountdata, 232 mountdata = compose_mount_options(cifs_sb->mountdata,
210 ref_unc, &devname); 233 dentry, ref, &devname);
211 234
212 if (IS_ERR(mountdata)) 235 if (IS_ERR(mountdata))
213 return (struct vfsmount *)mountdata; 236 return (struct vfsmount *)mountdata;
@@ -310,7 +333,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
310 } 333 }
311 mnt = cifs_dfs_do_refmount(nd->path.mnt, 334 mnt = cifs_dfs_do_refmount(nd->path.mnt,
312 nd->path.dentry, 335 nd->path.dentry,
313 referrals[i].node_name); 336 referrals + i);
314 cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p", 337 cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p",
315 __func__, 338 __func__,
316 referrals[i].node_name, mnt)); 339 referrals[i].node_name, mnt));
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index fcee9298b620..0ab2fb5afef1 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -73,8 +73,8 @@ struct key_type cifs_spnego_key_type = {
73 * strlen(";sec=ntlmsspi") */ 73 * strlen(";sec=ntlmsspi") */
74#define MAX_MECH_STR_LEN 13 74#define MAX_MECH_STR_LEN 13
75 75
76/* max possible addr len eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60 */ 76/* max possible addr len eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/128 */
77#define MAX_IPV6_ADDR_LEN 42 77#define MAX_IPV6_ADDR_LEN 43
78 78
79/* strlen of "host=" */ 79/* strlen of "host=" */
80#define HOST_KEY_LEN 5 80#define HOST_KEY_LEN 5
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index ac5915d61dca..d9cf467309e8 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -514,10 +514,11 @@ static void cifs_umount_begin(struct super_block *sb)
514 tcon = cifs_sb->tcon; 514 tcon = cifs_sb->tcon;
515 if (tcon == NULL) 515 if (tcon == NULL)
516 return; 516 return;
517 down(&tcon->tconSem); 517
518 if (atomic_read(&tcon->useCount) == 1) 518 read_lock(&cifs_tcp_ses_lock);
519 if (tcon->tc_count == 1)
519 tcon->tidStatus = CifsExiting; 520 tcon->tidStatus = CifsExiting;
520 up(&tcon->tconSem); 521 read_unlock(&cifs_tcp_ses_lock);
521 522
522 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ 523 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
523 /* cancel_notify_requests(tcon); */ 524 /* cancel_notify_requests(tcon); */
@@ -1013,7 +1014,7 @@ static int cifs_oplock_thread(void *dummyarg)
1013 not bother sending an oplock release if session 1014 not bother sending an oplock release if session
1014 to server still is disconnected since oplock 1015 to server still is disconnected since oplock
1015 already released by the server in that case */ 1016 already released by the server in that case */
1016 if (pTcon->tidStatus != CifsNeedReconnect) { 1017 if (!pTcon->need_reconnect) {
1017 rc = CIFSSMBLock(0, pTcon, netfid, 1018 rc = CIFSSMBLock(0, pTcon, netfid,
1018 0 /* len */ , 0 /* offset */, 0, 1019 0 /* len */ , 0 /* offset */, 0,
1019 0, LOCKING_ANDX_OPLOCK_RELEASE, 1020 0, LOCKING_ANDX_OPLOCK_RELEASE,
@@ -1031,24 +1032,24 @@ static int cifs_oplock_thread(void *dummyarg)
1031static int cifs_dnotify_thread(void *dummyarg) 1032static int cifs_dnotify_thread(void *dummyarg)
1032{ 1033{
1033 struct list_head *tmp; 1034 struct list_head *tmp;
1034 struct cifsSesInfo *ses; 1035 struct TCP_Server_Info *server;
1035 1036
1036 do { 1037 do {
1037 if (try_to_freeze()) 1038 if (try_to_freeze())
1038 continue; 1039 continue;
1039 set_current_state(TASK_INTERRUPTIBLE); 1040 set_current_state(TASK_INTERRUPTIBLE);
1040 schedule_timeout(15*HZ); 1041 schedule_timeout(15*HZ);
1041 read_lock(&GlobalSMBSeslock);
1042 /* check if any stuck requests that need 1042 /* check if any stuck requests that need
1043 to be woken up and wakeq so the 1043 to be woken up and wakeq so the
1044 thread can wake up and error out */ 1044 thread can wake up and error out */
1045 list_for_each(tmp, &GlobalSMBSessionList) { 1045 read_lock(&cifs_tcp_ses_lock);
1046 ses = list_entry(tmp, struct cifsSesInfo, 1046 list_for_each(tmp, &cifs_tcp_ses_list) {
1047 cifsSessionList); 1047 server = list_entry(tmp, struct TCP_Server_Info,
1048 if (ses->server && atomic_read(&ses->server->inFlight)) 1048 tcp_ses_list);
1049 wake_up_all(&ses->server->response_q); 1049 if (atomic_read(&server->inFlight))
1050 wake_up_all(&server->response_q);
1050 } 1051 }
1051 read_unlock(&GlobalSMBSeslock); 1052 read_unlock(&cifs_tcp_ses_lock);
1052 } while (!kthread_should_stop()); 1053 } while (!kthread_should_stop());
1053 1054
1054 return 0; 1055 return 0;
@@ -1059,9 +1060,7 @@ init_cifs(void)
1059{ 1060{
1060 int rc = 0; 1061 int rc = 0;
1061 cifs_proc_init(); 1062 cifs_proc_init();
1062/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */ 1063 INIT_LIST_HEAD(&cifs_tcp_ses_list);
1063 INIT_LIST_HEAD(&GlobalSMBSessionList);
1064 INIT_LIST_HEAD(&GlobalTreeConnectionList);
1065 INIT_LIST_HEAD(&GlobalOplock_Q); 1064 INIT_LIST_HEAD(&GlobalOplock_Q);
1066#ifdef CONFIG_CIFS_EXPERIMENTAL 1065#ifdef CONFIG_CIFS_EXPERIMENTAL
1067 INIT_LIST_HEAD(&GlobalDnotifyReqList); 1066 INIT_LIST_HEAD(&GlobalDnotifyReqList);
@@ -1089,6 +1088,7 @@ init_cifs(void)
1089 GlobalMaxActiveXid = 0; 1088 GlobalMaxActiveXid = 0;
1090 memset(Local_System_Name, 0, 15); 1089 memset(Local_System_Name, 0, 15);
1091 rwlock_init(&GlobalSMBSeslock); 1090 rwlock_init(&GlobalSMBSeslock);
1091 rwlock_init(&cifs_tcp_ses_lock);
1092 spin_lock_init(&GlobalMid_Lock); 1092 spin_lock_init(&GlobalMid_Lock);
1093 1093
1094 if (cifs_max_pending < 2) { 1094 if (cifs_max_pending < 2) {
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 1cb1189f24e0..c57c0565547f 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -85,8 +85,7 @@ enum securityEnum {
85}; 85};
86 86
87enum protocolEnum { 87enum protocolEnum {
88 IPV4 = 0, 88 TCP = 0,
89 IPV6,
90 SCTP 89 SCTP
91 /* Netbios frames protocol not supported at this time */ 90 /* Netbios frames protocol not supported at this time */
92}; 91};
@@ -122,6 +121,9 @@ struct cifs_cred {
122 */ 121 */
123 122
124struct TCP_Server_Info { 123struct TCP_Server_Info {
124 struct list_head tcp_ses_list;
125 struct list_head smb_ses_list;
126 int srv_count; /* reference counter */
125 /* 15 character server name + 0x20 16th byte indicating type = srv */ 127 /* 15 character server name + 0x20 16th byte indicating type = srv */
126 char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; 128 char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
127 char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; 129 char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2];
@@ -143,7 +145,6 @@ struct TCP_Server_Info {
143 bool svlocal:1; /* local server or remote */ 145 bool svlocal:1; /* local server or remote */
144 bool noblocksnd; /* use blocking sendmsg */ 146 bool noblocksnd; /* use blocking sendmsg */
145 bool noautotune; /* do not autotune send buf sizes */ 147 bool noautotune; /* do not autotune send buf sizes */
146 atomic_t socketUseCount; /* number of open cifs sessions on socket */
147 atomic_t inFlight; /* number of requests on the wire to server */ 148 atomic_t inFlight; /* number of requests on the wire to server */
148#ifdef CONFIG_CIFS_STATS2 149#ifdef CONFIG_CIFS_STATS2
149 atomic_t inSend; /* requests trying to send */ 150 atomic_t inSend; /* requests trying to send */
@@ -194,13 +195,14 @@ struct cifsUidInfo {
194 * Session structure. One of these for each uid session with a particular host 195 * Session structure. One of these for each uid session with a particular host
195 */ 196 */
196struct cifsSesInfo { 197struct cifsSesInfo {
197 struct list_head cifsSessionList; 198 struct list_head smb_ses_list;
199 struct list_head tcon_list;
198 struct semaphore sesSem; 200 struct semaphore sesSem;
199#if 0 201#if 0
200 struct cifsUidInfo *uidInfo; /* pointer to user info */ 202 struct cifsUidInfo *uidInfo; /* pointer to user info */
201#endif 203#endif
202 struct TCP_Server_Info *server; /* pointer to server info */ 204 struct TCP_Server_Info *server; /* pointer to server info */
203 atomic_t inUse; /* # of mounts (tree connections) on this ses */ 205 int ses_count; /* reference counter */
204 enum statusEnum status; 206 enum statusEnum status;
205 unsigned overrideSecFlg; /* if non-zero override global sec flags */ 207 unsigned overrideSecFlg; /* if non-zero override global sec flags */
206 __u16 ipc_tid; /* special tid for connection to IPC share */ 208 __u16 ipc_tid; /* special tid for connection to IPC share */
@@ -216,6 +218,7 @@ struct cifsSesInfo {
216 char userName[MAX_USERNAME_SIZE + 1]; 218 char userName[MAX_USERNAME_SIZE + 1];
217 char *domainName; 219 char *domainName;
218 char *password; 220 char *password;
221 bool need_reconnect:1; /* connection reset, uid now invalid */
219}; 222};
220/* no more than one of the following three session flags may be set */ 223/* no more than one of the following three session flags may be set */
221#define CIFS_SES_NT4 1 224#define CIFS_SES_NT4 1
@@ -230,16 +233,15 @@ struct cifsSesInfo {
230 * session 233 * session
231 */ 234 */
232struct cifsTconInfo { 235struct cifsTconInfo {
233 struct list_head cifsConnectionList; 236 struct list_head tcon_list;
237 int tc_count;
234 struct list_head openFileList; 238 struct list_head openFileList;
235 struct semaphore tconSem;
236 struct cifsSesInfo *ses; /* pointer to session associated with */ 239 struct cifsSesInfo *ses; /* pointer to session associated with */
237 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ 240 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
238 char *nativeFileSystem; 241 char *nativeFileSystem;
239 __u16 tid; /* The 2 byte tree id */ 242 __u16 tid; /* The 2 byte tree id */
240 __u16 Flags; /* optional support bits */ 243 __u16 Flags; /* optional support bits */
241 enum statusEnum tidStatus; 244 enum statusEnum tidStatus;
242 atomic_t useCount; /* how many explicit/implicit mounts to share */
243#ifdef CONFIG_CIFS_STATS 245#ifdef CONFIG_CIFS_STATS
244 atomic_t num_smbs_sent; 246 atomic_t num_smbs_sent;
245 atomic_t num_writes; 247 atomic_t num_writes;
@@ -288,6 +290,7 @@ struct cifsTconInfo {
288 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol 290 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
289 for this mount even if server would support */ 291 for this mount even if server would support */
290 bool local_lease:1; /* check leases (only) on local system not remote */ 292 bool local_lease:1; /* check leases (only) on local system not remote */
293 bool need_reconnect:1; /* connection reset, tid now invalid */
291 /* BB add field for back pointer to sb struct(s)? */ 294 /* BB add field for back pointer to sb struct(s)? */
292}; 295};
293 296
@@ -588,22 +591,30 @@ require use of the stronger protocol */
588#endif 591#endif
589 592
590/* 593/*
591 * The list of servers that did not respond with NT LM 0.12. 594 * the list of TCP_Server_Info structures, ie each of the sockets
592 * This list helps improve performance and eliminate the messages indicating 595 * connecting our client to a distinct server (ip address), is
593 * that we had a communications error talking to the server in this list. 596 * chained together by cifs_tcp_ses_list. The list of all our SMB
597 * sessions (and from that the tree connections) can be found
598 * by iterating over cifs_tcp_ses_list
594 */ 599 */
595/* Feature not supported */ 600GLOBAL_EXTERN struct list_head cifs_tcp_ses_list;
596/* GLOBAL_EXTERN struct servers_not_supported *NotSuppList; */
597 601
598/* 602/*
599 * The following is a hash table of all the users we know about. 603 * This lock protects the cifs_tcp_ses_list, the list of smb sessions per
604 * tcp session, and the list of tcon's per smb session. It also protects
605 * the reference counters for the server, smb session, and tcon. Finally,
606 * changes to the tcon->tidStatus should be done while holding this lock.
600 */ 607 */
601GLOBAL_EXTERN struct smbUidInfo *GlobalUidList[UID_HASH]; 608GLOBAL_EXTERN rwlock_t cifs_tcp_ses_lock;
602 609
603/* GLOBAL_EXTERN struct list_head GlobalServerList; BB not implemented yet */ 610/*
604GLOBAL_EXTERN struct list_head GlobalSMBSessionList; 611 * This lock protects the cifs_file->llist and cifs_file->flist
605GLOBAL_EXTERN struct list_head GlobalTreeConnectionList; 612 * list operations, and updates to some flags (cifs_file->invalidHandle)
606GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */ 613 * It will be moved to either use the tcon->stat_lock or equivalent later.
614 * If cifs_tcp_ses_lock and the lock below are both needed to be held, then
615 * the cifs_tcp_ses_lock must be grabbed first and released last.
616 */
617GLOBAL_EXTERN rwlock_t GlobalSMBSeslock;
607 618
608GLOBAL_EXTERN struct list_head GlobalOplock_Q; 619GLOBAL_EXTERN struct list_head GlobalOplock_Q;
609 620
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index d5eac48fc415..2af8626ced43 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -190,10 +190,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
190 /* need to prevent multiple threads trying to 190 /* need to prevent multiple threads trying to
191 simultaneously reconnect the same SMB session */ 191 simultaneously reconnect the same SMB session */
192 down(&tcon->ses->sesSem); 192 down(&tcon->ses->sesSem);
193 if (tcon->ses->status == CifsNeedReconnect) 193 if (tcon->ses->need_reconnect)
194 rc = cifs_setup_session(0, tcon->ses, 194 rc = cifs_setup_session(0, tcon->ses,
195 nls_codepage); 195 nls_codepage);
196 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { 196 if (!rc && (tcon->need_reconnect)) {
197 mark_open_files_invalid(tcon); 197 mark_open_files_invalid(tcon);
198 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 198 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
199 tcon, nls_codepage); 199 tcon, nls_codepage);
@@ -337,10 +337,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
337 /* need to prevent multiple threads trying to 337 /* need to prevent multiple threads trying to
338 simultaneously reconnect the same SMB session */ 338 simultaneously reconnect the same SMB session */
339 down(&tcon->ses->sesSem); 339 down(&tcon->ses->sesSem);
340 if (tcon->ses->status == CifsNeedReconnect) 340 if (tcon->ses->need_reconnect)
341 rc = cifs_setup_session(0, tcon->ses, 341 rc = cifs_setup_session(0, tcon->ses,
342 nls_codepage); 342 nls_codepage);
343 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { 343 if (!rc && (tcon->need_reconnect)) {
344 mark_open_files_invalid(tcon); 344 mark_open_files_invalid(tcon);
345 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 345 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
346 tcon, nls_codepage); 346 tcon, nls_codepage);
@@ -664,8 +664,9 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
664 rc = -EIO; 664 rc = -EIO;
665 goto neg_err_exit; 665 goto neg_err_exit;
666 } 666 }
667 667 read_lock(&cifs_tcp_ses_lock);
668 if (server->socketUseCount.counter > 1) { 668 if (server->srv_count > 1) {
669 read_unlock(&cifs_tcp_ses_lock);
669 if (memcmp(server->server_GUID, 670 if (memcmp(server->server_GUID,
670 pSMBr->u.extended_response. 671 pSMBr->u.extended_response.
671 GUID, 16) != 0) { 672 GUID, 16) != 0) {
@@ -674,9 +675,11 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
674 pSMBr->u.extended_response.GUID, 675 pSMBr->u.extended_response.GUID,
675 16); 676 16);
676 } 677 }
677 } else 678 } else {
679 read_unlock(&cifs_tcp_ses_lock);
678 memcpy(server->server_GUID, 680 memcpy(server->server_GUID,
679 pSMBr->u.extended_response.GUID, 16); 681 pSMBr->u.extended_response.GUID, 16);
682 }
680 683
681 if (count == 16) { 684 if (count == 16) {
682 server->secType = RawNTLMSSP; 685 server->secType = RawNTLMSSP;
@@ -739,50 +742,31 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
739 int rc = 0; 742 int rc = 0;
740 743
741 cFYI(1, ("In tree disconnect")); 744 cFYI(1, ("In tree disconnect"));
742 /*
743 * If last user of the connection and
744 * connection alive - disconnect it
745 * If this is the last connection on the server session disconnect it
746 * (and inside session disconnect we should check if tcp socket needs
747 * to be freed and kernel thread woken up).
748 */
749 if (tcon)
750 down(&tcon->tconSem);
751 else
752 return -EIO;
753 745
754 atomic_dec(&tcon->useCount); 746 /* BB: do we need to check this? These should never be NULL. */
755 if (atomic_read(&tcon->useCount) > 0) { 747 if ((tcon->ses == NULL) || (tcon->ses->server == NULL))
756 up(&tcon->tconSem); 748 return -EIO;
757 return -EBUSY;
758 }
759 749
760 /* No need to return error on this operation if tid invalidated and 750 /*
761 closed on server already e.g. due to tcp session crashing */ 751 * No need to return error on this operation if tid invalidated and
762 if (tcon->tidStatus == CifsNeedReconnect) { 752 * closed on server already e.g. due to tcp session crashing. Also,
763 up(&tcon->tconSem); 753 * the tcon is no longer on the list, so no need to take lock before
754 * checking this.
755 */
756 if (tcon->need_reconnect)
764 return 0; 757 return 0;
765 }
766 758
767 if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) {
768 up(&tcon->tconSem);
769 return -EIO;
770 }
771 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, 759 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon,
772 (void **)&smb_buffer); 760 (void **)&smb_buffer);
773 if (rc) { 761 if (rc)
774 up(&tcon->tconSem);
775 return rc; 762 return rc;
776 }
777 763
778 rc = SendReceiveNoRsp(xid, tcon->ses, smb_buffer, 0); 764 rc = SendReceiveNoRsp(xid, tcon->ses, smb_buffer, 0);
779 if (rc) 765 if (rc)
780 cFYI(1, ("Tree disconnect failed %d", rc)); 766 cFYI(1, ("Tree disconnect failed %d", rc));
781 767
782 up(&tcon->tconSem);
783
784 /* No need to return error on this operation if tid invalidated and 768 /* No need to return error on this operation if tid invalidated and
785 closed on server already e.g. due to tcp session crashing */ 769 closed on server already e.g. due to tcp session crashing */
786 if (rc == -EAGAIN) 770 if (rc == -EAGAIN)
787 rc = 0; 771 rc = 0;
788 772
@@ -796,43 +780,36 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
796 int rc = 0; 780 int rc = 0;
797 781
798 cFYI(1, ("In SMBLogoff for session disconnect")); 782 cFYI(1, ("In SMBLogoff for session disconnect"));
799 if (ses) 783
800 down(&ses->sesSem); 784 /*
801 else 785 * BB: do we need to check validity of ses and server? They should
786 * always be valid since we have an active reference. If not, that
787 * should probably be a BUG()
788 */
789 if (!ses || !ses->server)
802 return -EIO; 790 return -EIO;
803 791
804 atomic_dec(&ses->inUse); 792 down(&ses->sesSem);
805 if (atomic_read(&ses->inUse) > 0) { 793 if (ses->need_reconnect)
806 up(&ses->sesSem); 794 goto session_already_dead; /* no need to send SMBlogoff if uid
807 return -EBUSY; 795 already closed due to reconnect */
808 }
809 rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); 796 rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB);
810 if (rc) { 797 if (rc) {
811 up(&ses->sesSem); 798 up(&ses->sesSem);
812 return rc; 799 return rc;
813 } 800 }
814 801
815 if (ses->server) { 802 pSMB->hdr.Mid = GetNextMid(ses->server);
816 pSMB->hdr.Mid = GetNextMid(ses->server);
817 803
818 if (ses->server->secMode & 804 if (ses->server->secMode &
819 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 805 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
820 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 806 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
821 }
822 807
823 pSMB->hdr.Uid = ses->Suid; 808 pSMB->hdr.Uid = ses->Suid;
824 809
825 pSMB->AndXCommand = 0xFF; 810 pSMB->AndXCommand = 0xFF;
826 rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); 811 rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0);
827 if (ses->server) { 812session_already_dead:
828 atomic_dec(&ses->server->socketUseCount);
829 if (atomic_read(&ses->server->socketUseCount) == 0) {
830 spin_lock(&GlobalMid_Lock);
831 ses->server->tcpStatus = CifsExiting;
832 spin_unlock(&GlobalMid_Lock);
833 rc = -ESHUTDOWN;
834 }
835 }
836 up(&ses->sesSem); 813 up(&ses->sesSem);
837 814
838 /* if session dead then we do not need to do ulogoff, 815 /* if session dead then we do not need to do ulogoff,
@@ -3922,6 +3899,27 @@ GetInodeNumOut:
3922 return rc; 3899 return rc;
3923} 3900}
3924 3901
3902/* computes length of UCS string converted to host codepage
3903 * @src: UCS string
3904 * @maxlen: length of the input string in UCS characters
3905 * (not in bytes)
3906 *
3907 * return: size of input string in host codepage
3908 */
3909static int hostlen_fromUCS(const __le16 *src, const int maxlen,
3910 const struct nls_table *nls_codepage) {
3911 int i;
3912 int hostlen = 0;
3913 char to[4];
3914 int charlen;
3915 for (i = 0; (i < maxlen) && src[i]; ++i) {
3916 charlen = nls_codepage->uni2char(le16_to_cpu(src[i]),
3917 to, NLS_MAX_CHARSET_SIZE);
3918 hostlen += charlen > 0 ? charlen : 1;
3919 }
3920 return hostlen;
3921}
3922
3925/* parses DFS refferal V3 structure 3923/* parses DFS refferal V3 structure
3926 * caller is responsible for freeing target_nodes 3924 * caller is responsible for freeing target_nodes
3927 * returns: 3925 * returns:
@@ -3932,7 +3930,8 @@ static int
3932parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, 3930parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3933 unsigned int *num_of_nodes, 3931 unsigned int *num_of_nodes,
3934 struct dfs_info3_param **target_nodes, 3932 struct dfs_info3_param **target_nodes,
3935 const struct nls_table *nls_codepage) 3933 const struct nls_table *nls_codepage, int remap,
3934 const char *searchName)
3936{ 3935{
3937 int i, rc = 0; 3936 int i, rc = 0;
3938 char *data_end; 3937 char *data_end;
@@ -3983,7 +3982,17 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3983 struct dfs_info3_param *node = (*target_nodes)+i; 3982 struct dfs_info3_param *node = (*target_nodes)+i;
3984 3983
3985 node->flags = le16_to_cpu(pSMBr->DFSFlags); 3984 node->flags = le16_to_cpu(pSMBr->DFSFlags);
3986 node->path_consumed = le16_to_cpu(pSMBr->PathConsumed); 3985 if (is_unicode) {
3986 __le16 *tmp = kmalloc(strlen(searchName)*2, GFP_KERNEL);
3987 cifsConvertToUCS((__le16 *) tmp, searchName,
3988 PATH_MAX, nls_codepage, remap);
3989 node->path_consumed = hostlen_fromUCS(tmp,
3990 le16_to_cpu(pSMBr->PathConsumed)/2,
3991 nls_codepage);
3992 kfree(tmp);
3993 } else
3994 node->path_consumed = le16_to_cpu(pSMBr->PathConsumed);
3995
3987 node->server_type = le16_to_cpu(ref->ServerType); 3996 node->server_type = le16_to_cpu(ref->ServerType);
3988 node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags); 3997 node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags);
3989 3998
@@ -4116,7 +4125,8 @@ getDFSRetry:
4116 4125
4117 /* parse returned result into more usable form */ 4126 /* parse returned result into more usable form */
4118 rc = parse_DFS_referrals(pSMBr, num_of_nodes, 4127 rc = parse_DFS_referrals(pSMBr, num_of_nodes,
4119 target_nodes, nls_codepage); 4128 target_nodes, nls_codepage, remap,
4129 searchName);
4120 4130
4121GetDFSRefExit: 4131GetDFSRefExit:
4122 cifs_buf_release(pSMB); 4132 cifs_buf_release(pSMB);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e9f9248cb3fe..c7d341714586 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -124,7 +124,7 @@ static int
124cifs_reconnect(struct TCP_Server_Info *server) 124cifs_reconnect(struct TCP_Server_Info *server)
125{ 125{
126 int rc = 0; 126 int rc = 0;
127 struct list_head *tmp; 127 struct list_head *tmp, *tmp2;
128 struct cifsSesInfo *ses; 128 struct cifsSesInfo *ses;
129 struct cifsTconInfo *tcon; 129 struct cifsTconInfo *tcon;
130 struct mid_q_entry *mid_entry; 130 struct mid_q_entry *mid_entry;
@@ -144,23 +144,17 @@ cifs_reconnect(struct TCP_Server_Info *server)
144 144
145 /* before reconnecting the tcp session, mark the smb session (uid) 145 /* before reconnecting the tcp session, mark the smb session (uid)
146 and the tid bad so they are not used until reconnected */ 146 and the tid bad so they are not used until reconnected */
147 read_lock(&GlobalSMBSeslock); 147 read_lock(&cifs_tcp_ses_lock);
148 list_for_each(tmp, &GlobalSMBSessionList) { 148 list_for_each(tmp, &server->smb_ses_list) {
149 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 149 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
150 if (ses->server) { 150 ses->need_reconnect = true;
151 if (ses->server == server) { 151 ses->ipc_tid = 0;
152 ses->status = CifsNeedReconnect; 152 list_for_each(tmp2, &ses->tcon_list) {
153 ses->ipc_tid = 0; 153 tcon = list_entry(tmp2, struct cifsTconInfo, tcon_list);
154 } 154 tcon->need_reconnect = true;
155 } 155 }
156 /* else tcp and smb sessions need reconnection */
157 }
158 list_for_each(tmp, &GlobalTreeConnectionList) {
159 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
160 if ((tcon->ses) && (tcon->ses->server == server))
161 tcon->tidStatus = CifsNeedReconnect;
162 } 156 }
163 read_unlock(&GlobalSMBSeslock); 157 read_unlock(&cifs_tcp_ses_lock);
164 /* do not want to be sending data on a socket we are freeing */ 158 /* do not want to be sending data on a socket we are freeing */
165 down(&server->tcpSem); 159 down(&server->tcpSem);
166 if (server->ssocket) { 160 if (server->ssocket) {
@@ -193,7 +187,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
193 while ((server->tcpStatus != CifsExiting) && 187 while ((server->tcpStatus != CifsExiting) &&
194 (server->tcpStatus != CifsGood)) { 188 (server->tcpStatus != CifsGood)) {
195 try_to_freeze(); 189 try_to_freeze();
196 if (server->protocolType == IPV6) { 190 if (server->addr.sockAddr6.sin6_family == AF_INET6) {
197 rc = ipv6_connect(&server->addr.sockAddr6, 191 rc = ipv6_connect(&server->addr.sockAddr6,
198 &server->ssocket, server->noautotune); 192 &server->ssocket, server->noautotune);
199 } else { 193 } else {
@@ -417,9 +411,14 @@ incomplete_rcv:
417 msleep(1); /* minimum sleep to prevent looping 411 msleep(1); /* minimum sleep to prevent looping
418 allowing socket to clear and app threads to set 412 allowing socket to clear and app threads to set
419 tcpStatus CifsNeedReconnect if server hung */ 413 tcpStatus CifsNeedReconnect if server hung */
420 if (pdu_length < 4) 414 if (pdu_length < 4) {
415 iov.iov_base = (4 - pdu_length) +
416 (char *)smb_buffer;
417 iov.iov_len = pdu_length;
418 smb_msg.msg_control = NULL;
419 smb_msg.msg_controllen = 0;
421 goto incomplete_rcv; 420 goto incomplete_rcv;
422 else 421 } else
423 continue; 422 continue;
424 } else if (length <= 0) { 423 } else if (length <= 0) {
425 if (server->tcpStatus == CifsNew) { 424 if (server->tcpStatus == CifsNew) {
@@ -654,6 +653,11 @@ multi_t2_fnd:
654 } 653 }
655 } /* end while !EXITING */ 654 } /* end while !EXITING */
656 655
656 /* take it off the list, if it's not already */
657 write_lock(&cifs_tcp_ses_lock);
658 list_del_init(&server->tcp_ses_list);
659 write_unlock(&cifs_tcp_ses_lock);
660
657 spin_lock(&GlobalMid_Lock); 661 spin_lock(&GlobalMid_Lock);
658 server->tcpStatus = CifsExiting; 662 server->tcpStatus = CifsExiting;
659 spin_unlock(&GlobalMid_Lock); 663 spin_unlock(&GlobalMid_Lock);
@@ -686,29 +690,29 @@ multi_t2_fnd:
686 if (smallbuf) /* no sense logging a debug message if NULL */ 690 if (smallbuf) /* no sense logging a debug message if NULL */
687 cifs_small_buf_release(smallbuf); 691 cifs_small_buf_release(smallbuf);
688 692
689 read_lock(&GlobalSMBSeslock); 693 /*
694 * BB: we shouldn't have to do any of this. It shouldn't be
695 * possible to exit from the thread with active SMB sessions
696 */
697 read_lock(&cifs_tcp_ses_lock);
690 if (list_empty(&server->pending_mid_q)) { 698 if (list_empty(&server->pending_mid_q)) {
691 /* loop through server session structures attached to this and 699 /* loop through server session structures attached to this and
692 mark them dead */ 700 mark them dead */
693 list_for_each(tmp, &GlobalSMBSessionList) { 701 list_for_each(tmp, &server->smb_ses_list) {
694 ses = 702 ses = list_entry(tmp, struct cifsSesInfo,
695 list_entry(tmp, struct cifsSesInfo, 703 smb_ses_list);
696 cifsSessionList); 704 ses->status = CifsExiting;
697 if (ses->server == server) { 705 ses->server = NULL;
698 ses->status = CifsExiting;
699 ses->server = NULL;
700 }
701 } 706 }
702 read_unlock(&GlobalSMBSeslock); 707 read_unlock(&cifs_tcp_ses_lock);
703 } else { 708 } else {
704 /* although we can not zero the server struct pointer yet, 709 /* although we can not zero the server struct pointer yet,
705 since there are active requests which may depnd on them, 710 since there are active requests which may depnd on them,
706 mark the corresponding SMB sessions as exiting too */ 711 mark the corresponding SMB sessions as exiting too */
707 list_for_each(tmp, &GlobalSMBSessionList) { 712 list_for_each(tmp, &server->smb_ses_list) {
708 ses = list_entry(tmp, struct cifsSesInfo, 713 ses = list_entry(tmp, struct cifsSesInfo,
709 cifsSessionList); 714 smb_ses_list);
710 if (ses->server == server) 715 ses->status = CifsExiting;
711 ses->status = CifsExiting;
712 } 716 }
713 717
714 spin_lock(&GlobalMid_Lock); 718 spin_lock(&GlobalMid_Lock);
@@ -723,7 +727,7 @@ multi_t2_fnd:
723 } 727 }
724 } 728 }
725 spin_unlock(&GlobalMid_Lock); 729 spin_unlock(&GlobalMid_Lock);
726 read_unlock(&GlobalSMBSeslock); 730 read_unlock(&cifs_tcp_ses_lock);
727 /* 1/8th of sec is more than enough time for them to exit */ 731 /* 1/8th of sec is more than enough time for them to exit */
728 msleep(125); 732 msleep(125);
729 } 733 }
@@ -745,14 +749,13 @@ multi_t2_fnd:
745 if there are any pointing to this (e.g 749 if there are any pointing to this (e.g
746 if a crazy root user tried to kill cifsd 750 if a crazy root user tried to kill cifsd
747 kernel thread explicitly this might happen) */ 751 kernel thread explicitly this might happen) */
748 write_lock(&GlobalSMBSeslock); 752 /* BB: This shouldn't be necessary, see above */
749 list_for_each(tmp, &GlobalSMBSessionList) { 753 read_lock(&cifs_tcp_ses_lock);
750 ses = list_entry(tmp, struct cifsSesInfo, 754 list_for_each(tmp, &server->smb_ses_list) {
751 cifsSessionList); 755 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
752 if (ses->server == server) 756 ses->server = NULL;
753 ses->server = NULL;
754 } 757 }
755 write_unlock(&GlobalSMBSeslock); 758 read_unlock(&cifs_tcp_ses_lock);
756 759
757 kfree(server->hostname); 760 kfree(server->hostname);
758 task_to_wake = xchg(&server->tsk, NULL); 761 task_to_wake = xchg(&server->tsk, NULL);
@@ -1352,94 +1355,158 @@ cifs_parse_mount_options(char *options, const char *devname,
1352 return 0; 1355 return 0;
1353} 1356}
1354 1357
1355static struct cifsSesInfo * 1358static struct TCP_Server_Info *
1356cifs_find_tcp_session(struct in_addr *target_ip_addr, 1359cifs_find_tcp_session(struct sockaddr *addr)
1357 struct in6_addr *target_ip6_addr,
1358 char *userName, struct TCP_Server_Info **psrvTcp)
1359{ 1360{
1360 struct list_head *tmp; 1361 struct list_head *tmp;
1361 struct cifsSesInfo *ses; 1362 struct TCP_Server_Info *server;
1362 1363 struct sockaddr_in *addr4 = (struct sockaddr_in *) addr;
1363 *psrvTcp = NULL; 1364 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
1365
1366 write_lock(&cifs_tcp_ses_lock);
1367 list_for_each(tmp, &cifs_tcp_ses_list) {
1368 server = list_entry(tmp, struct TCP_Server_Info,
1369 tcp_ses_list);
1370 /*
1371 * the demux thread can exit on its own while still in CifsNew
1372 * so don't accept any sockets in that state. Since the
1373 * tcpStatus never changes back to CifsNew it's safe to check
1374 * for this without a lock.
1375 */
1376 if (server->tcpStatus == CifsNew)
1377 continue;
1364 1378
1365 read_lock(&GlobalSMBSeslock); 1379 if (addr->sa_family == AF_INET &&
1366 list_for_each(tmp, &GlobalSMBSessionList) { 1380 (addr4->sin_addr.s_addr !=
1367 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1381 server->addr.sockAddr.sin_addr.s_addr))
1368 if (!ses->server) 1382 continue;
1383 else if (addr->sa_family == AF_INET6 &&
1384 memcmp(&server->addr.sockAddr6.sin6_addr,
1385 &addr6->sin6_addr, sizeof(addr6->sin6_addr)))
1369 continue; 1386 continue;
1370 1387
1371 if (target_ip_addr && 1388 ++server->srv_count;
1372 ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr) 1389 write_unlock(&cifs_tcp_ses_lock);
1373 continue; 1390 cFYI(1, ("Existing tcp session with server found"));
1374 else if (target_ip6_addr && 1391 return server;
1375 memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1392 }
1376 target_ip6_addr, sizeof(*target_ip6_addr))) 1393 write_unlock(&cifs_tcp_ses_lock);
1377 continue; 1394 return NULL;
1378 /* BB lock server and tcp session; increment use count here?? */ 1395}
1379 1396
1380 /* found a match on the TCP session */ 1397static void
1381 *psrvTcp = ses->server; 1398cifs_put_tcp_session(struct TCP_Server_Info *server)
1399{
1400 struct task_struct *task;
1382 1401
1383 /* BB check if reconnection needed */ 1402 write_lock(&cifs_tcp_ses_lock);
1384 if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) { 1403 if (--server->srv_count > 0) {
1385 read_unlock(&GlobalSMBSeslock); 1404 write_unlock(&cifs_tcp_ses_lock);
1386 /* Found exact match on both TCP and 1405 return;
1387 SMB sessions */
1388 return ses;
1389 }
1390 /* else tcp and smb sessions need reconnection */
1391 } 1406 }
1392 read_unlock(&GlobalSMBSeslock);
1393 1407
1394 return NULL; 1408 list_del_init(&server->tcp_ses_list);
1409 write_unlock(&cifs_tcp_ses_lock);
1410
1411 spin_lock(&GlobalMid_Lock);
1412 server->tcpStatus = CifsExiting;
1413 spin_unlock(&GlobalMid_Lock);
1414
1415 task = xchg(&server->tsk, NULL);
1416 if (task)
1417 force_sig(SIGKILL, task);
1395} 1418}
1396 1419
1397static struct cifsTconInfo * 1420static struct cifsSesInfo *
1398find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) 1421cifs_find_smb_ses(struct TCP_Server_Info *server, char *username)
1399{ 1422{
1400 struct list_head *tmp; 1423 struct list_head *tmp;
1401 struct cifsTconInfo *tcon; 1424 struct cifsSesInfo *ses;
1402 __be32 old_ip;
1403
1404 read_lock(&GlobalSMBSeslock);
1405 1425
1406 list_for_each(tmp, &GlobalTreeConnectionList) { 1426 write_lock(&cifs_tcp_ses_lock);
1407 cFYI(1, ("Next tcon")); 1427 list_for_each(tmp, &server->smb_ses_list) {
1408 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 1428 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
1409 if (!tcon->ses || !tcon->ses->server) 1429 if (strncmp(ses->userName, username, MAX_USERNAME_SIZE))
1410 continue; 1430 continue;
1411 1431
1412 old_ip = tcon->ses->server->addr.sockAddr.sin_addr.s_addr; 1432 ++ses->ses_count;
1413 cFYI(1, ("old ip addr: %x == new ip %x ?", 1433 write_unlock(&cifs_tcp_ses_lock);
1414 old_ip, new_target_ip_addr)); 1434 return ses;
1435 }
1436 write_unlock(&cifs_tcp_ses_lock);
1437 return NULL;
1438}
1415 1439
1416 if (old_ip != new_target_ip_addr) 1440static void
1417 continue; 1441cifs_put_smb_ses(struct cifsSesInfo *ses)
1442{
1443 int xid;
1444 struct TCP_Server_Info *server = ses->server;
1418 1445
1419 /* BB lock tcon, server, tcp session and increment use count? */ 1446 write_lock(&cifs_tcp_ses_lock);
1420 /* found a match on the TCP session */ 1447 if (--ses->ses_count > 0) {
1421 /* BB check if reconnection needed */ 1448 write_unlock(&cifs_tcp_ses_lock);
1422 cFYI(1, ("IP match, old UNC: %s new: %s", 1449 return;
1423 tcon->treeName, uncName)); 1450 }
1424 1451
1425 if (strncmp(tcon->treeName, uncName, MAX_TREE_SIZE)) 1452 list_del_init(&ses->smb_ses_list);
1426 continue; 1453 write_unlock(&cifs_tcp_ses_lock);
1427 1454
1428 cFYI(1, ("and old usr: %s new: %s", 1455 if (ses->status == CifsGood) {
1429 tcon->treeName, uncName)); 1456 xid = GetXid();
1457 CIFSSMBLogoff(xid, ses);
1458 _FreeXid(xid);
1459 }
1460 sesInfoFree(ses);
1461 cifs_put_tcp_session(server);
1462}
1430 1463
1431 if (strncmp(tcon->ses->userName, userName, MAX_USERNAME_SIZE)) 1464static struct cifsTconInfo *
1465cifs_find_tcon(struct cifsSesInfo *ses, const char *unc)
1466{
1467 struct list_head *tmp;
1468 struct cifsTconInfo *tcon;
1469
1470 write_lock(&cifs_tcp_ses_lock);
1471 list_for_each(tmp, &ses->tcon_list) {
1472 tcon = list_entry(tmp, struct cifsTconInfo, tcon_list);
1473 if (tcon->tidStatus == CifsExiting)
1474 continue;
1475 if (strncmp(tcon->treeName, unc, MAX_TREE_SIZE))
1432 continue; 1476 continue;
1433 1477
1434 /* matched smb session (user name) */ 1478 ++tcon->tc_count;
1435 read_unlock(&GlobalSMBSeslock); 1479 write_unlock(&cifs_tcp_ses_lock);
1436 return tcon; 1480 return tcon;
1437 } 1481 }
1438 1482 write_unlock(&cifs_tcp_ses_lock);
1439 read_unlock(&GlobalSMBSeslock);
1440 return NULL; 1483 return NULL;
1441} 1484}
1442 1485
1486static void
1487cifs_put_tcon(struct cifsTconInfo *tcon)
1488{
1489 int xid;
1490 struct cifsSesInfo *ses = tcon->ses;
1491
1492 write_lock(&cifs_tcp_ses_lock);
1493 if (--tcon->tc_count > 0) {
1494 write_unlock(&cifs_tcp_ses_lock);
1495 return;
1496 }
1497
1498 list_del_init(&tcon->tcon_list);
1499 write_unlock(&cifs_tcp_ses_lock);
1500
1501 xid = GetXid();
1502 CIFSSMBTDis(xid, tcon);
1503 _FreeXid(xid);
1504
1505 DeleteTconOplockQEntries(tcon);
1506 tconInfoFree(tcon);
1507 cifs_put_smb_ses(ses);
1508}
1509
1443int 1510int
1444get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, 1511get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
1445 const struct nls_table *nls_codepage, unsigned int *pnum_referrals, 1512 const struct nls_table *nls_codepage, unsigned int *pnum_referrals,
@@ -1876,14 +1943,90 @@ convert_delimiter(char *path, char delim)
1876 } 1943 }
1877} 1944}
1878 1945
1879static void 1946static void setup_cifs_sb(struct smb_vol *pvolume_info,
1880kill_cifsd(struct TCP_Server_Info *server) 1947 struct cifs_sb_info *cifs_sb)
1881{ 1948{
1882 struct task_struct *task; 1949 if (pvolume_info->rsize > CIFSMaxBufSize) {
1883 1950 cERROR(1, ("rsize %d too large, using MaxBufSize",
1884 task = xchg(&server->tsk, NULL); 1951 pvolume_info->rsize));
1885 if (task) 1952 cifs_sb->rsize = CIFSMaxBufSize;
1886 force_sig(SIGKILL, task); 1953 } else if ((pvolume_info->rsize) &&
1954 (pvolume_info->rsize <= CIFSMaxBufSize))
1955 cifs_sb->rsize = pvolume_info->rsize;
1956 else /* default */
1957 cifs_sb->rsize = CIFSMaxBufSize;
1958
1959 if (pvolume_info->wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) {
1960 cERROR(1, ("wsize %d too large, using 4096 instead",
1961 pvolume_info->wsize));
1962 cifs_sb->wsize = 4096;
1963 } else if (pvolume_info->wsize)
1964 cifs_sb->wsize = pvolume_info->wsize;
1965 else
1966 cifs_sb->wsize = min_t(const int,
1967 PAGEVEC_SIZE * PAGE_CACHE_SIZE,
1968 127*1024);
1969 /* old default of CIFSMaxBufSize was too small now
1970 that SMB Write2 can send multiple pages in kvec.
1971 RFC1001 does not describe what happens when frame
1972 bigger than 128K is sent so use that as max in
1973 conjunction with 52K kvec constraint on arch with 4K
1974 page size */
1975
1976 if (cifs_sb->rsize < 2048) {
1977 cifs_sb->rsize = 2048;
1978 /* Windows ME may prefer this */
1979 cFYI(1, ("readsize set to minimum: 2048"));
1980 }
1981 /* calculate prepath */
1982 cifs_sb->prepath = pvolume_info->prepath;
1983 if (cifs_sb->prepath) {
1984 cifs_sb->prepathlen = strlen(cifs_sb->prepath);
1985 /* we can not convert the / to \ in the path
1986 separators in the prefixpath yet because we do not
1987 know (until reset_cifs_unix_caps is called later)
1988 whether POSIX PATH CAP is available. We normalize
1989 the / to \ after reset_cifs_unix_caps is called */
1990 pvolume_info->prepath = NULL;
1991 } else
1992 cifs_sb->prepathlen = 0;
1993 cifs_sb->mnt_uid = pvolume_info->linux_uid;
1994 cifs_sb->mnt_gid = pvolume_info->linux_gid;
1995 cifs_sb->mnt_file_mode = pvolume_info->file_mode;
1996 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
1997 cFYI(1, ("file mode: 0x%x dir mode: 0x%x",
1998 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode));
1999
2000 if (pvolume_info->noperm)
2001 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
2002 if (pvolume_info->setuids)
2003 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
2004 if (pvolume_info->server_ino)
2005 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
2006 if (pvolume_info->remap)
2007 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
2008 if (pvolume_info->no_xattr)
2009 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
2010 if (pvolume_info->sfu_emul)
2011 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
2012 if (pvolume_info->nobrl)
2013 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
2014 if (pvolume_info->cifs_acl)
2015 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
2016 if (pvolume_info->override_uid)
2017 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
2018 if (pvolume_info->override_gid)
2019 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
2020 if (pvolume_info->dynperm)
2021 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
2022 if (pvolume_info->direct_io) {
2023 cFYI(1, ("mounting share using direct i/o"));
2024 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
2025 }
2026
2027 if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm))
2028 cERROR(1, ("mount option dynperm ignored if cifsacl "
2029 "mount option supported"));
1887} 2030}
1888 2031
1889int 2032int
@@ -1892,13 +2035,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1892{ 2035{
1893 int rc = 0; 2036 int rc = 0;
1894 int xid; 2037 int xid;
1895 int address_type = AF_INET;
1896 struct socket *csocket = NULL; 2038 struct socket *csocket = NULL;
1897 struct sockaddr_in sin_server; 2039 struct sockaddr addr;
1898 struct sockaddr_in6 sin_server6; 2040 struct sockaddr_in *sin_server = (struct sockaddr_in *) &addr;
2041 struct sockaddr_in6 *sin_server6 = (struct sockaddr_in6 *) &addr;
1899 struct smb_vol volume_info; 2042 struct smb_vol volume_info;
1900 struct cifsSesInfo *pSesInfo = NULL; 2043 struct cifsSesInfo *pSesInfo = NULL;
1901 struct cifsSesInfo *existingCifsSes = NULL;
1902 struct cifsTconInfo *tcon = NULL; 2044 struct cifsTconInfo *tcon = NULL;
1903 struct TCP_Server_Info *srvTcp = NULL; 2045 struct TCP_Server_Info *srvTcp = NULL;
1904 2046
@@ -1906,6 +2048,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1906 2048
1907/* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ 2049/* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */
1908 2050
2051 memset(&addr, 0, sizeof(struct sockaddr));
1909 memset(&volume_info, 0, sizeof(struct smb_vol)); 2052 memset(&volume_info, 0, sizeof(struct smb_vol));
1910 if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { 2053 if (cifs_parse_mount_options(mount_data, devname, &volume_info)) {
1911 rc = -EINVAL; 2054 rc = -EINVAL;
@@ -1928,16 +2071,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1928 2071
1929 if (volume_info.UNCip && volume_info.UNC) { 2072 if (volume_info.UNCip && volume_info.UNC) {
1930 rc = cifs_inet_pton(AF_INET, volume_info.UNCip, 2073 rc = cifs_inet_pton(AF_INET, volume_info.UNCip,
1931 &sin_server.sin_addr.s_addr); 2074 &sin_server->sin_addr.s_addr);
1932 2075
1933 if (rc <= 0) { 2076 if (rc <= 0) {
1934 /* not ipv4 address, try ipv6 */ 2077 /* not ipv4 address, try ipv6 */
1935 rc = cifs_inet_pton(AF_INET6, volume_info.UNCip, 2078 rc = cifs_inet_pton(AF_INET6, volume_info.UNCip,
1936 &sin_server6.sin6_addr.in6_u); 2079 &sin_server6->sin6_addr.in6_u);
1937 if (rc > 0) 2080 if (rc > 0)
1938 address_type = AF_INET6; 2081 addr.sa_family = AF_INET6;
1939 } else { 2082 } else {
1940 address_type = AF_INET; 2083 addr.sa_family = AF_INET;
1941 } 2084 }
1942 2085
1943 if (rc <= 0) { 2086 if (rc <= 0) {
@@ -1977,41 +2120,25 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1977 } 2120 }
1978 } 2121 }
1979 2122
1980 if (address_type == AF_INET) 2123 srvTcp = cifs_find_tcp_session(&addr);
1981 existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, 2124 if (!srvTcp) { /* create socket */
1982 NULL /* no ipv6 addr */, 2125 if (addr.sa_family == AF_INET6) {
1983 volume_info.username, &srvTcp);
1984 else if (address_type == AF_INET6) {
1985 cFYI(1, ("looking for ipv6 address"));
1986 existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */,
1987 &sin_server6.sin6_addr,
1988 volume_info.username, &srvTcp);
1989 } else {
1990 rc = -EINVAL;
1991 goto out;
1992 }
1993
1994 if (srvTcp) {
1995 cFYI(1, ("Existing tcp session with server found"));
1996 } else { /* create socket */
1997 if (volume_info.port)
1998 sin_server.sin_port = htons(volume_info.port);
1999 else
2000 sin_server.sin_port = 0;
2001 if (address_type == AF_INET6) {
2002 cFYI(1, ("attempting ipv6 connect")); 2126 cFYI(1, ("attempting ipv6 connect"));
2003 /* BB should we allow ipv6 on port 139? */ 2127 /* BB should we allow ipv6 on port 139? */
2004 /* other OS never observed in Wild doing 139 with v6 */ 2128 /* other OS never observed in Wild doing 139 with v6 */
2005 rc = ipv6_connect(&sin_server6, &csocket, 2129 sin_server6->sin6_port = htons(volume_info.port);
2130 rc = ipv6_connect(sin_server6, &csocket,
2006 volume_info.noblocksnd); 2131 volume_info.noblocksnd);
2007 } else 2132 } else {
2008 rc = ipv4_connect(&sin_server, &csocket, 2133 sin_server->sin_port = htons(volume_info.port);
2134 rc = ipv4_connect(sin_server, &csocket,
2009 volume_info.source_rfc1001_name, 2135 volume_info.source_rfc1001_name,
2010 volume_info.target_rfc1001_name, 2136 volume_info.target_rfc1001_name,
2011 volume_info.noblocksnd, 2137 volume_info.noblocksnd,
2012 volume_info.noautotune); 2138 volume_info.noautotune);
2139 }
2013 if (rc < 0) { 2140 if (rc < 0) {
2014 cERROR(1, ("Error connecting to IPv4 socket. " 2141 cERROR(1, ("Error connecting to socket. "
2015 "Aborting operation")); 2142 "Aborting operation"));
2016 if (csocket != NULL) 2143 if (csocket != NULL)
2017 sock_release(csocket); 2144 sock_release(csocket);
@@ -2026,12 +2153,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2026 } else { 2153 } else {
2027 srvTcp->noblocksnd = volume_info.noblocksnd; 2154 srvTcp->noblocksnd = volume_info.noblocksnd;
2028 srvTcp->noautotune = volume_info.noautotune; 2155 srvTcp->noautotune = volume_info.noautotune;
2029 memcpy(&srvTcp->addr.sockAddr, &sin_server, 2156 if (addr.sa_family == AF_INET6)
2030 sizeof(struct sockaddr_in)); 2157 memcpy(&srvTcp->addr.sockAddr6, sin_server6,
2158 sizeof(struct sockaddr_in6));
2159 else
2160 memcpy(&srvTcp->addr.sockAddr, sin_server,
2161 sizeof(struct sockaddr_in));
2031 atomic_set(&srvTcp->inFlight, 0); 2162 atomic_set(&srvTcp->inFlight, 0);
2032 /* BB Add code for ipv6 case too */ 2163 /* BB Add code for ipv6 case too */
2033 srvTcp->ssocket = csocket; 2164 srvTcp->ssocket = csocket;
2034 srvTcp->protocolType = IPV4;
2035 srvTcp->hostname = extract_hostname(volume_info.UNC); 2165 srvTcp->hostname = extract_hostname(volume_info.UNC);
2036 if (IS_ERR(srvTcp->hostname)) { 2166 if (IS_ERR(srvTcp->hostname)) {
2037 rc = PTR_ERR(srvTcp->hostname); 2167 rc = PTR_ERR(srvTcp->hostname);
@@ -2061,15 +2191,28 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2061 memcpy(srvTcp->server_RFC1001_name, 2191 memcpy(srvTcp->server_RFC1001_name,
2062 volume_info.target_rfc1001_name, 16); 2192 volume_info.target_rfc1001_name, 16);
2063 srvTcp->sequence_number = 0; 2193 srvTcp->sequence_number = 0;
2194 INIT_LIST_HEAD(&srvTcp->tcp_ses_list);
2195 INIT_LIST_HEAD(&srvTcp->smb_ses_list);
2196 ++srvTcp->srv_count;
2197 write_lock(&cifs_tcp_ses_lock);
2198 list_add(&srvTcp->tcp_ses_list,
2199 &cifs_tcp_ses_list);
2200 write_unlock(&cifs_tcp_ses_lock);
2064 } 2201 }
2065 } 2202 }
2066 2203
2067 if (existingCifsSes) { 2204 pSesInfo = cifs_find_smb_ses(srvTcp, volume_info.username);
2068 pSesInfo = existingCifsSes; 2205 if (pSesInfo) {
2069 cFYI(1, ("Existing smb sess found (status=%d)", 2206 cFYI(1, ("Existing smb sess found (status=%d)",
2070 pSesInfo->status)); 2207 pSesInfo->status));
2208 /*
2209 * The existing SMB session already has a reference to srvTcp,
2210 * so we can put back the extra one we got before
2211 */
2212 cifs_put_tcp_session(srvTcp);
2213
2071 down(&pSesInfo->sesSem); 2214 down(&pSesInfo->sesSem);
2072 if (pSesInfo->status == CifsNeedReconnect) { 2215 if (pSesInfo->need_reconnect) {
2073 cFYI(1, ("Session needs reconnect")); 2216 cFYI(1, ("Session needs reconnect"));
2074 rc = cifs_setup_session(xid, pSesInfo, 2217 rc = cifs_setup_session(xid, pSesInfo,
2075 cifs_sb->local_nls); 2218 cifs_sb->local_nls);
@@ -2078,187 +2221,101 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2078 } else if (!rc) { 2221 } else if (!rc) {
2079 cFYI(1, ("Existing smb sess not found")); 2222 cFYI(1, ("Existing smb sess not found"));
2080 pSesInfo = sesInfoAlloc(); 2223 pSesInfo = sesInfoAlloc();
2081 if (pSesInfo == NULL) 2224 if (pSesInfo == NULL) {
2082 rc = -ENOMEM; 2225 rc = -ENOMEM;
2083 else { 2226 goto mount_fail_check;
2084 pSesInfo->server = srvTcp; 2227 }
2085 sprintf(pSesInfo->serverName, "%u.%u.%u.%u", 2228
2086 NIPQUAD(sin_server.sin_addr.s_addr)); 2229 /* new SMB session uses our srvTcp ref */
2087 } 2230 pSesInfo->server = srvTcp;
2231 sprintf(pSesInfo->serverName, "%u.%u.%u.%u",
2232 NIPQUAD(sin_server->sin_addr.s_addr));
2233
2234 write_lock(&cifs_tcp_ses_lock);
2235 list_add(&pSesInfo->smb_ses_list, &srvTcp->smb_ses_list);
2236 write_unlock(&cifs_tcp_ses_lock);
2237
2238 /* volume_info.password freed at unmount */
2239 if (volume_info.password) {
2240 pSesInfo->password = volume_info.password;
2241 /* set to NULL to prevent freeing on exit */
2242 volume_info.password = NULL;
2243 }
2244 if (volume_info.username)
2245 strncpy(pSesInfo->userName, volume_info.username,
2246 MAX_USERNAME_SIZE);
2247 if (volume_info.domainname) {
2248 int len = strlen(volume_info.domainname);
2249 pSesInfo->domainName = kmalloc(len + 1, GFP_KERNEL);
2250 if (pSesInfo->domainName)
2251 strcpy(pSesInfo->domainName,
2252 volume_info.domainname);
2253 }
2254 pSesInfo->linux_uid = volume_info.linux_uid;
2255 pSesInfo->overrideSecFlg = volume_info.secFlg;
2256 down(&pSesInfo->sesSem);
2088 2257
2089 if (!rc) { 2258 /* BB FIXME need to pass vol->secFlgs BB */
2090 /* volume_info.password freed at unmount */ 2259 rc = cifs_setup_session(xid, pSesInfo,
2091 if (volume_info.password) { 2260 cifs_sb->local_nls);
2092 pSesInfo->password = volume_info.password; 2261 up(&pSesInfo->sesSem);
2093 /* set to NULL to prevent freeing on exit */
2094 volume_info.password = NULL;
2095 }
2096 if (volume_info.username)
2097 strncpy(pSesInfo->userName,
2098 volume_info.username,
2099 MAX_USERNAME_SIZE);
2100 if (volume_info.domainname) {
2101 int len = strlen(volume_info.domainname);
2102 pSesInfo->domainName =
2103 kmalloc(len + 1, GFP_KERNEL);
2104 if (pSesInfo->domainName)
2105 strcpy(pSesInfo->domainName,
2106 volume_info.domainname);
2107 }
2108 pSesInfo->linux_uid = volume_info.linux_uid;
2109 pSesInfo->overrideSecFlg = volume_info.secFlg;
2110 down(&pSesInfo->sesSem);
2111 /* BB FIXME need to pass vol->secFlgs BB */
2112 rc = cifs_setup_session(xid, pSesInfo,
2113 cifs_sb->local_nls);
2114 up(&pSesInfo->sesSem);
2115 if (!rc)
2116 atomic_inc(&srvTcp->socketUseCount);
2117 }
2118 } 2262 }
2119 2263
2120 /* search for existing tcon to this server share */ 2264 /* search for existing tcon to this server share */
2121 if (!rc) { 2265 if (!rc) {
2122 if (volume_info.rsize > CIFSMaxBufSize) { 2266 setup_cifs_sb(&volume_info, cifs_sb);
2123 cERROR(1, ("rsize %d too large, using MaxBufSize",
2124 volume_info.rsize));
2125 cifs_sb->rsize = CIFSMaxBufSize;
2126 } else if ((volume_info.rsize) &&
2127 (volume_info.rsize <= CIFSMaxBufSize))
2128 cifs_sb->rsize = volume_info.rsize;
2129 else /* default */
2130 cifs_sb->rsize = CIFSMaxBufSize;
2131
2132 if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) {
2133 cERROR(1, ("wsize %d too large, using 4096 instead",
2134 volume_info.wsize));
2135 cifs_sb->wsize = 4096;
2136 } else if (volume_info.wsize)
2137 cifs_sb->wsize = volume_info.wsize;
2138 else
2139 cifs_sb->wsize =
2140 min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE,
2141 127*1024);
2142 /* old default of CIFSMaxBufSize was too small now
2143 that SMB Write2 can send multiple pages in kvec.
2144 RFC1001 does not describe what happens when frame
2145 bigger than 128K is sent so use that as max in
2146 conjunction with 52K kvec constraint on arch with 4K
2147 page size */
2148
2149 if (cifs_sb->rsize < 2048) {
2150 cifs_sb->rsize = 2048;
2151 /* Windows ME may prefer this */
2152 cFYI(1, ("readsize set to minimum: 2048"));
2153 }
2154 /* calculate prepath */
2155 cifs_sb->prepath = volume_info.prepath;
2156 if (cifs_sb->prepath) {
2157 cifs_sb->prepathlen = strlen(cifs_sb->prepath);
2158 /* we can not convert the / to \ in the path
2159 separators in the prefixpath yet because we do not
2160 know (until reset_cifs_unix_caps is called later)
2161 whether POSIX PATH CAP is available. We normalize
2162 the / to \ after reset_cifs_unix_caps is called */
2163 volume_info.prepath = NULL;
2164 } else
2165 cifs_sb->prepathlen = 0;
2166 cifs_sb->mnt_uid = volume_info.linux_uid;
2167 cifs_sb->mnt_gid = volume_info.linux_gid;
2168 cifs_sb->mnt_file_mode = volume_info.file_mode;
2169 cifs_sb->mnt_dir_mode = volume_info.dir_mode;
2170 cFYI(1, ("file mode: 0x%x dir mode: 0x%x",
2171 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode));
2172
2173 if (volume_info.noperm)
2174 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
2175 if (volume_info.setuids)
2176 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
2177 if (volume_info.server_ino)
2178 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
2179 if (volume_info.remap)
2180 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
2181 if (volume_info.no_xattr)
2182 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
2183 if (volume_info.sfu_emul)
2184 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
2185 if (volume_info.nobrl)
2186 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
2187 if (volume_info.cifs_acl)
2188 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
2189 if (volume_info.override_uid)
2190 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
2191 if (volume_info.override_gid)
2192 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
2193 if (volume_info.dynperm)
2194 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
2195 if (volume_info.direct_io) {
2196 cFYI(1, ("mounting share using direct i/o"));
2197 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
2198 }
2199 2267
2200 if ((volume_info.cifs_acl) && (volume_info.dynperm)) 2268 tcon = cifs_find_tcon(pSesInfo, volume_info.UNC);
2201 cERROR(1, ("mount option dynperm ignored if cifsacl "
2202 "mount option supported"));
2203
2204 tcon =
2205 find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,
2206 volume_info.username);
2207 if (tcon) { 2269 if (tcon) {
2208 cFYI(1, ("Found match on UNC path")); 2270 cFYI(1, ("Found match on UNC path"));
2209 /* we can have only one retry value for a connection 2271 /* existing tcon already has a reference */
2210 to a share so for resources mounted more than once 2272 cifs_put_smb_ses(pSesInfo);
2211 to the same server share the last value passed in
2212 for the retry flag is used */
2213 tcon->retry = volume_info.retry;
2214 tcon->nocase = volume_info.nocase;
2215 tcon->local_lease = volume_info.local_lease;
2216 if (tcon->seal != volume_info.seal) 2273 if (tcon->seal != volume_info.seal)
2217 cERROR(1, ("transport encryption setting " 2274 cERROR(1, ("transport encryption setting "
2218 "conflicts with existing tid")); 2275 "conflicts with existing tid"));
2219 } else { 2276 } else {
2220 tcon = tconInfoAlloc(); 2277 tcon = tconInfoAlloc();
2221 if (tcon == NULL) 2278 if (tcon == NULL) {
2222 rc = -ENOMEM; 2279 rc = -ENOMEM;
2223 else { 2280 goto mount_fail_check;
2224 /* check for null share name ie connecting to 2281 }
2225 * dfs root */ 2282 tcon->ses = pSesInfo;
2226 2283
2227 /* BB check if this works for exactly length 2284 /* check for null share name ie connect to dfs root */
2228 * three strings */ 2285 if ((strchr(volume_info.UNC + 3, '\\') == NULL)
2229 if ((strchr(volume_info.UNC + 3, '\\') == NULL) 2286 && (strchr(volume_info.UNC + 3, '/') == NULL)) {
2230 && (strchr(volume_info.UNC + 3, '/') == 2287 /* rc = connect_to_dfs_path(...) */
2231 NULL)) { 2288 cFYI(1, ("DFS root not supported"));
2232/* rc = connect_to_dfs_path(xid, pSesInfo, 2289 rc = -ENODEV;
2233 "", cifs_sb->local_nls, 2290 goto mount_fail_check;
2234 cifs_sb->mnt_cifs_flags & 2291 } else {
2235 CIFS_MOUNT_MAP_SPECIAL_CHR);*/ 2292 /* BB Do we need to wrap sesSem around
2236 cFYI(1, ("DFS root not supported")); 2293 * this TCon call and Unix SetFS as
2237 rc = -ENODEV; 2294 * we do on SessSetup and reconnect? */
2238 goto out; 2295 rc = CIFSTCon(xid, pSesInfo, volume_info.UNC,
2239 } else { 2296 tcon, cifs_sb->local_nls);
2240 /* BB Do we need to wrap sesSem around 2297 cFYI(1, ("CIFS Tcon rc = %d", rc));
2241 * this TCon call and Unix SetFS as 2298 if (volume_info.nodfs) {
2242 * we do on SessSetup and reconnect? */ 2299 tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
2243 rc = CIFSTCon(xid, pSesInfo, 2300 cFYI(1, ("DFS disabled (%d)",
2244 volume_info.UNC, 2301 tcon->Flags));
2245 tcon, cifs_sb->local_nls);
2246 cFYI(1, ("CIFS Tcon rc = %d", rc));
2247 if (volume_info.nodfs) {
2248 tcon->Flags &=
2249 ~SMB_SHARE_IS_IN_DFS;
2250 cFYI(1, ("DFS disabled (%d)",
2251 tcon->Flags));
2252 }
2253 }
2254 if (!rc) {
2255 atomic_inc(&pSesInfo->inUse);
2256 tcon->retry = volume_info.retry;
2257 tcon->nocase = volume_info.nocase;
2258 tcon->seal = volume_info.seal;
2259 } 2302 }
2260 } 2303 }
2261 } 2304 if (rc)
2305 goto mount_fail_check;
2306 tcon->seal = volume_info.seal;
2307 write_lock(&cifs_tcp_ses_lock);
2308 list_add(&tcon->tcon_list, &pSesInfo->tcon_list);
2309 write_unlock(&cifs_tcp_ses_lock);
2310 }
2311
2312 /* we can have only one retry value for a connection
2313 to a share so for resources mounted more than once
2314 to the same server share the last value passed in
2315 for the retry flag is used */
2316 tcon->retry = volume_info.retry;
2317 tcon->nocase = volume_info.nocase;
2318 tcon->local_lease = volume_info.local_lease;
2262 } 2319 }
2263 if (pSesInfo) { 2320 if (pSesInfo) {
2264 if (pSesInfo->capabilities & CAP_LARGE_FILES) { 2321 if (pSesInfo->capabilities & CAP_LARGE_FILES) {
@@ -2270,80 +2327,49 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2270 /* BB FIXME fix time_gran to be larger for LANMAN sessions */ 2327 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
2271 sb->s_time_gran = 100; 2328 sb->s_time_gran = 100;
2272 2329
2273/* on error free sesinfo and tcon struct if needed */ 2330mount_fail_check:
2331 /* on error free sesinfo and tcon struct if needed */
2274 if (rc) { 2332 if (rc) {
2275 /* if session setup failed, use count is zero but 2333 /* If find_unc succeeded then rc == 0 so we can not end */
2276 we still need to free cifsd thread */ 2334 /* up accidently freeing someone elses tcon struct */
2277 if (atomic_read(&srvTcp->socketUseCount) == 0) { 2335 if (tcon)
2278 spin_lock(&GlobalMid_Lock); 2336 cifs_put_tcon(tcon);
2279 srvTcp->tcpStatus = CifsExiting; 2337 else if (pSesInfo)
2280 spin_unlock(&GlobalMid_Lock); 2338 cifs_put_smb_ses(pSesInfo);
2281 kill_cifsd(srvTcp);
2282 }
2283 /* If find_unc succeeded then rc == 0 so we can not end */
2284 if (tcon) /* up accidently freeing someone elses tcon struct */
2285 tconInfoFree(tcon);
2286 if (existingCifsSes == NULL) {
2287 if (pSesInfo) {
2288 if ((pSesInfo->server) &&
2289 (pSesInfo->status == CifsGood)) {
2290 int temp_rc;
2291 temp_rc = CIFSSMBLogoff(xid, pSesInfo);
2292 /* if the socketUseCount is now zero */
2293 if ((temp_rc == -ESHUTDOWN) &&
2294 (pSesInfo->server))
2295 kill_cifsd(pSesInfo->server);
2296 } else {
2297 cFYI(1, ("No session or bad tcon"));
2298 if (pSesInfo->server) {
2299 spin_lock(&GlobalMid_Lock);
2300 srvTcp->tcpStatus = CifsExiting;
2301 spin_unlock(&GlobalMid_Lock);
2302 kill_cifsd(pSesInfo->server);
2303 }
2304 }
2305 sesInfoFree(pSesInfo);
2306 /* pSesInfo = NULL; */
2307 }
2308 }
2309 } else {
2310 atomic_inc(&tcon->useCount);
2311 cifs_sb->tcon = tcon;
2312 tcon->ses = pSesInfo;
2313
2314 /* do not care if following two calls succeed - informational */
2315 if (!tcon->ipc) {
2316 CIFSSMBQFSDeviceInfo(xid, tcon);
2317 CIFSSMBQFSAttributeInfo(xid, tcon);
2318 }
2319
2320 /* tell server which Unix caps we support */
2321 if (tcon->ses->capabilities & CAP_UNIX)
2322 /* reset of caps checks mount to see if unix extensions
2323 disabled for just this mount */
2324 reset_cifs_unix_caps(xid, tcon, sb, &volume_info);
2325 else 2339 else
2326 tcon->unix_ext = 0; /* server does not support them */ 2340 cifs_put_tcp_session(srvTcp);
2341 goto out;
2342 }
2343 cifs_sb->tcon = tcon;
2327 2344
2328 /* convert forward to back slashes in prepath here if needed */ 2345 /* do not care if following two calls succeed - informational */
2329 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0) 2346 if (!tcon->ipc) {
2330 convert_delimiter(cifs_sb->prepath, 2347 CIFSSMBQFSDeviceInfo(xid, tcon);
2331 CIFS_DIR_SEP(cifs_sb)); 2348 CIFSSMBQFSAttributeInfo(xid, tcon);
2349 }
2332 2350
2333 if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { 2351 /* tell server which Unix caps we support */
2334 cifs_sb->rsize = 1024 * 127; 2352 if (tcon->ses->capabilities & CAP_UNIX)
2335 cFYI(DBG2, 2353 /* reset of caps checks mount to see if unix extensions
2336 ("no very large read support, rsize now 127K")); 2354 disabled for just this mount */
2337 } 2355 reset_cifs_unix_caps(xid, tcon, sb, &volume_info);
2338 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) 2356 else
2339 cifs_sb->wsize = min(cifs_sb->wsize, 2357 tcon->unix_ext = 0; /* server does not support them */
2340 (tcon->ses->server->maxBuf - 2358
2341 MAX_CIFS_HDR_SIZE)); 2359 /* convert forward to back slashes in prepath here if needed */
2342 if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) 2360 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0)
2343 cifs_sb->rsize = min(cifs_sb->rsize, 2361 convert_delimiter(cifs_sb->prepath, CIFS_DIR_SEP(cifs_sb));
2344 (tcon->ses->server->maxBuf - 2362
2345 MAX_CIFS_HDR_SIZE)); 2363 if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) {
2364 cifs_sb->rsize = 1024 * 127;
2365 cFYI(DBG2, ("no very large read support, rsize now 127K"));
2346 } 2366 }
2367 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X))
2368 cifs_sb->wsize = min(cifs_sb->wsize,
2369 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE));
2370 if (!(tcon->ses->capabilities & CAP_LARGE_READ_X))
2371 cifs_sb->rsize = min(cifs_sb->rsize,
2372 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE));
2347 2373
2348 /* volume_info.password is freed above when existing session found 2374 /* volume_info.password is freed above when existing session found
2349 (in which case it is not needed anymore) but when new sesion is created 2375 (in which case it is not needed anymore) but when new sesion is created
@@ -3513,6 +3539,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3513 /* above now done in SendReceive */ 3539 /* above now done in SendReceive */
3514 if ((rc == 0) && (tcon != NULL)) { 3540 if ((rc == 0) && (tcon != NULL)) {
3515 tcon->tidStatus = CifsGood; 3541 tcon->tidStatus = CifsGood;
3542 tcon->need_reconnect = false;
3516 tcon->tid = smb_buffer_response->Tid; 3543 tcon->tid = smb_buffer_response->Tid;
3517 bcc_ptr = pByteArea(smb_buffer_response); 3544 bcc_ptr = pByteArea(smb_buffer_response);
3518 length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); 3545 length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2);
@@ -3584,48 +3611,17 @@ int
3584cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) 3611cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3585{ 3612{
3586 int rc = 0; 3613 int rc = 0;
3587 int xid;
3588 struct cifsSesInfo *ses = NULL;
3589 char *tmp; 3614 char *tmp;
3590 3615
3591 xid = GetXid(); 3616 if (cifs_sb->tcon)
3592 3617 cifs_put_tcon(cifs_sb->tcon);
3593 if (cifs_sb->tcon) {
3594 ses = cifs_sb->tcon->ses; /* save ptr to ses before delete tcon!*/
3595 rc = CIFSSMBTDis(xid, cifs_sb->tcon);
3596 if (rc == -EBUSY) {
3597 FreeXid(xid);
3598 return 0;
3599 }
3600 DeleteTconOplockQEntries(cifs_sb->tcon);
3601 tconInfoFree(cifs_sb->tcon);
3602 if ((ses) && (ses->server)) {
3603 /* save off task so we do not refer to ses later */
3604 cFYI(1, ("About to do SMBLogoff "));
3605 rc = CIFSSMBLogoff(xid, ses);
3606 if (rc == -EBUSY) {
3607 FreeXid(xid);
3608 return 0;
3609 } else if (rc == -ESHUTDOWN) {
3610 cFYI(1, ("Waking up socket by sending signal"));
3611 if (ses->server)
3612 kill_cifsd(ses->server);
3613 rc = 0;
3614 } /* else - we have an smb session
3615 left on this socket do not kill cifsd */
3616 } else
3617 cFYI(1, ("No session or bad tcon"));
3618 }
3619 3618
3620 cifs_sb->tcon = NULL; 3619 cifs_sb->tcon = NULL;
3621 tmp = cifs_sb->prepath; 3620 tmp = cifs_sb->prepath;
3622 cifs_sb->prepathlen = 0; 3621 cifs_sb->prepathlen = 0;
3623 cifs_sb->prepath = NULL; 3622 cifs_sb->prepath = NULL;
3624 kfree(tmp); 3623 kfree(tmp);
3625 if (ses)
3626 sesInfoFree(ses);
3627 3624
3628 FreeXid(xid);
3629 return rc; 3625 return rc;
3630} 3626}
3631 3627
@@ -3741,6 +3737,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3741 cFYI(1, ("CIFS Session Established successfully")); 3737 cFYI(1, ("CIFS Session Established successfully"));
3742 spin_lock(&GlobalMid_Lock); 3738 spin_lock(&GlobalMid_Lock);
3743 pSesInfo->status = CifsGood; 3739 pSesInfo->status = CifsGood;
3740 pSesInfo->need_reconnect = false;
3744 spin_unlock(&GlobalMid_Lock); 3741 spin_unlock(&GlobalMid_Lock);
3745 } 3742 }
3746 3743
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index ead1a3bb0256..b691b893a848 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -488,12 +488,13 @@ int cifs_close(struct inode *inode, struct file *file)
488 pTcon = cifs_sb->tcon; 488 pTcon = cifs_sb->tcon;
489 if (pSMBFile) { 489 if (pSMBFile) {
490 struct cifsLockInfo *li, *tmp; 490 struct cifsLockInfo *li, *tmp;
491 491 write_lock(&GlobalSMBSeslock);
492 pSMBFile->closePend = true; 492 pSMBFile->closePend = true;
493 if (pTcon) { 493 if (pTcon) {
494 /* no sense reconnecting to close a file that is 494 /* no sense reconnecting to close a file that is
495 already closed */ 495 already closed */
496 if (pTcon->tidStatus != CifsNeedReconnect) { 496 if (!pTcon->need_reconnect) {
497 write_unlock(&GlobalSMBSeslock);
497 timeout = 2; 498 timeout = 2;
498 while ((atomic_read(&pSMBFile->wrtPending) != 0) 499 while ((atomic_read(&pSMBFile->wrtPending) != 0)
499 && (timeout <= 2048)) { 500 && (timeout <= 2048)) {
@@ -510,12 +511,15 @@ int cifs_close(struct inode *inode, struct file *file)
510 timeout *= 4; 511 timeout *= 4;
511 } 512 }
512 if (atomic_read(&pSMBFile->wrtPending)) 513 if (atomic_read(&pSMBFile->wrtPending))
513 cERROR(1, 514 cERROR(1, ("close with pending write"));
514 ("close with pending writes")); 515 if (!pTcon->need_reconnect &&
515 rc = CIFSSMBClose(xid, pTcon, 516 !pSMBFile->invalidHandle)
517 rc = CIFSSMBClose(xid, pTcon,
516 pSMBFile->netfid); 518 pSMBFile->netfid);
517 } 519 } else
518 } 520 write_unlock(&GlobalSMBSeslock);
521 } else
522 write_unlock(&GlobalSMBSeslock);
519 523
520 /* Delete any outstanding lock records. 524 /* Delete any outstanding lock records.
521 We'll lose them when the file is closed anyway. */ 525 We'll lose them when the file is closed anyway. */
@@ -587,15 +591,18 @@ int cifs_closedir(struct inode *inode, struct file *file)
587 pTcon = cifs_sb->tcon; 591 pTcon = cifs_sb->tcon;
588 592
589 cFYI(1, ("Freeing private data in close dir")); 593 cFYI(1, ("Freeing private data in close dir"));
594 write_lock(&GlobalSMBSeslock);
590 if (!pCFileStruct->srch_inf.endOfSearch && 595 if (!pCFileStruct->srch_inf.endOfSearch &&
591 !pCFileStruct->invalidHandle) { 596 !pCFileStruct->invalidHandle) {
592 pCFileStruct->invalidHandle = true; 597 pCFileStruct->invalidHandle = true;
598 write_unlock(&GlobalSMBSeslock);
593 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 599 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
594 cFYI(1, ("Closing uncompleted readdir with rc %d", 600 cFYI(1, ("Closing uncompleted readdir with rc %d",
595 rc)); 601 rc));
596 /* not much we can do if it fails anyway, ignore rc */ 602 /* not much we can do if it fails anyway, ignore rc */
597 rc = 0; 603 rc = 0;
598 } 604 } else
605 write_unlock(&GlobalSMBSeslock);
599 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start; 606 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
600 if (ptmp) { 607 if (ptmp) {
601 cFYI(1, ("closedir free smb buf in srch struct")); 608 cFYI(1, ("closedir free smb buf in srch struct"));
@@ -1404,7 +1411,10 @@ retry:
1404 if ((wbc->nr_to_write -= n_iov) <= 0) 1411 if ((wbc->nr_to_write -= n_iov) <= 0)
1405 done = 1; 1412 done = 1;
1406 index = next; 1413 index = next;
1407 } 1414 } else
1415 /* Need to re-find the pages we skipped */
1416 index = pvec.pages[0]->index + 1;
1417
1408 pagevec_release(&pvec); 1418 pagevec_release(&pvec);
1409 } 1419 }
1410 if (!scanned && !done) { 1420 if (!scanned && !done) {
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 88786ba02d27..9ee3f689c2b0 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -75,12 +75,12 @@ sesInfoAlloc(void)
75 75
76 ret_buf = kzalloc(sizeof(struct cifsSesInfo), GFP_KERNEL); 76 ret_buf = kzalloc(sizeof(struct cifsSesInfo), GFP_KERNEL);
77 if (ret_buf) { 77 if (ret_buf) {
78 write_lock(&GlobalSMBSeslock);
79 atomic_inc(&sesInfoAllocCount); 78 atomic_inc(&sesInfoAllocCount);
80 ret_buf->status = CifsNew; 79 ret_buf->status = CifsNew;
81 list_add(&ret_buf->cifsSessionList, &GlobalSMBSessionList); 80 ++ret_buf->ses_count;
81 INIT_LIST_HEAD(&ret_buf->smb_ses_list);
82 INIT_LIST_HEAD(&ret_buf->tcon_list);
82 init_MUTEX(&ret_buf->sesSem); 83 init_MUTEX(&ret_buf->sesSem);
83 write_unlock(&GlobalSMBSeslock);
84 } 84 }
85 return ret_buf; 85 return ret_buf;
86} 86}
@@ -93,10 +93,7 @@ sesInfoFree(struct cifsSesInfo *buf_to_free)
93 return; 93 return;
94 } 94 }
95 95
96 write_lock(&GlobalSMBSeslock);
97 atomic_dec(&sesInfoAllocCount); 96 atomic_dec(&sesInfoAllocCount);
98 list_del(&buf_to_free->cifsSessionList);
99 write_unlock(&GlobalSMBSeslock);
100 kfree(buf_to_free->serverOS); 97 kfree(buf_to_free->serverOS);
101 kfree(buf_to_free->serverDomain); 98 kfree(buf_to_free->serverDomain);
102 kfree(buf_to_free->serverNOS); 99 kfree(buf_to_free->serverNOS);
@@ -111,17 +108,14 @@ tconInfoAlloc(void)
111 struct cifsTconInfo *ret_buf; 108 struct cifsTconInfo *ret_buf;
112 ret_buf = kzalloc(sizeof(struct cifsTconInfo), GFP_KERNEL); 109 ret_buf = kzalloc(sizeof(struct cifsTconInfo), GFP_KERNEL);
113 if (ret_buf) { 110 if (ret_buf) {
114 write_lock(&GlobalSMBSeslock);
115 atomic_inc(&tconInfoAllocCount); 111 atomic_inc(&tconInfoAllocCount);
116 list_add(&ret_buf->cifsConnectionList,
117 &GlobalTreeConnectionList);
118 ret_buf->tidStatus = CifsNew; 112 ret_buf->tidStatus = CifsNew;
113 ++ret_buf->tc_count;
119 INIT_LIST_HEAD(&ret_buf->openFileList); 114 INIT_LIST_HEAD(&ret_buf->openFileList);
120 init_MUTEX(&ret_buf->tconSem); 115 INIT_LIST_HEAD(&ret_buf->tcon_list);
121#ifdef CONFIG_CIFS_STATS 116#ifdef CONFIG_CIFS_STATS
122 spin_lock_init(&ret_buf->stat_lock); 117 spin_lock_init(&ret_buf->stat_lock);
123#endif 118#endif
124 write_unlock(&GlobalSMBSeslock);
125 } 119 }
126 return ret_buf; 120 return ret_buf;
127} 121}
@@ -133,10 +127,7 @@ tconInfoFree(struct cifsTconInfo *buf_to_free)
133 cFYI(1, ("Null buffer passed to tconInfoFree")); 127 cFYI(1, ("Null buffer passed to tconInfoFree"));
134 return; 128 return;
135 } 129 }
136 write_lock(&GlobalSMBSeslock);
137 atomic_dec(&tconInfoAllocCount); 130 atomic_dec(&tconInfoAllocCount);
138 list_del(&buf_to_free->cifsConnectionList);
139 write_unlock(&GlobalSMBSeslock);
140 kfree(buf_to_free->nativeFileSystem); 131 kfree(buf_to_free->nativeFileSystem);
141 kfree(buf_to_free); 132 kfree(buf_to_free);
142} 133}
@@ -350,9 +341,9 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
350 if (current->fsuid != treeCon->ses->linux_uid) { 341 if (current->fsuid != treeCon->ses->linux_uid) {
351 cFYI(1, ("Multiuser mode and UID " 342 cFYI(1, ("Multiuser mode and UID "
352 "did not match tcon uid")); 343 "did not match tcon uid"));
353 read_lock(&GlobalSMBSeslock); 344 read_lock(&cifs_tcp_ses_lock);
354 list_for_each(temp_item, &GlobalSMBSessionList) { 345 list_for_each(temp_item, &treeCon->ses->server->smb_ses_list) {
355 ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); 346 ses = list_entry(temp_item, struct cifsSesInfo, smb_ses_list);
356 if (ses->linux_uid == current->fsuid) { 347 if (ses->linux_uid == current->fsuid) {
357 if (ses->server == treeCon->ses->server) { 348 if (ses->server == treeCon->ses->server) {
358 cFYI(1, ("found matching uid substitute right smb_uid")); 349 cFYI(1, ("found matching uid substitute right smb_uid"));
@@ -364,7 +355,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
364 } 355 }
365 } 356 }
366 } 357 }
367 read_unlock(&GlobalSMBSeslock); 358 read_unlock(&cifs_tcp_ses_lock);
368 } 359 }
369 } 360 }
370 } 361 }
@@ -497,9 +488,10 @@ bool
497is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) 488is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
498{ 489{
499 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; 490 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
500 struct list_head *tmp; 491 struct list_head *tmp, *tmp1, *tmp2;
501 struct list_head *tmp1; 492 struct cifsSesInfo *ses;
502 struct cifsTconInfo *tcon; 493 struct cifsTconInfo *tcon;
494 struct cifsInodeInfo *pCifsInode;
503 struct cifsFileInfo *netfile; 495 struct cifsFileInfo *netfile;
504 496
505 cFYI(1, ("Checking for oplock break or dnotify response")); 497 cFYI(1, ("Checking for oplock break or dnotify response"));
@@ -554,42 +546,45 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
554 return false; 546 return false;
555 547
556 /* look up tcon based on tid & uid */ 548 /* look up tcon based on tid & uid */
557 read_lock(&GlobalSMBSeslock); 549 read_lock(&cifs_tcp_ses_lock);
558 list_for_each(tmp, &GlobalTreeConnectionList) { 550 list_for_each(tmp, &srv->smb_ses_list) {
559 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 551 ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list);
560 if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { 552 list_for_each(tmp1, &ses->tcon_list) {
553 tcon = list_entry(tmp1, struct cifsTconInfo, tcon_list);
554 if (tcon->tid != buf->Tid)
555 continue;
556
561 cifs_stats_inc(&tcon->num_oplock_brks); 557 cifs_stats_inc(&tcon->num_oplock_brks);
562 list_for_each(tmp1, &tcon->openFileList) { 558 write_lock(&GlobalSMBSeslock);
563 netfile = list_entry(tmp1, struct cifsFileInfo, 559 list_for_each(tmp2, &tcon->openFileList) {
560 netfile = list_entry(tmp2, struct cifsFileInfo,
564 tlist); 561 tlist);
565 if (pSMB->Fid == netfile->netfid) { 562 if (pSMB->Fid != netfile->netfid)
566 struct cifsInodeInfo *pCifsInode; 563 continue;
567 read_unlock(&GlobalSMBSeslock); 564
568 cFYI(1, 565 write_unlock(&GlobalSMBSeslock);
569 ("file id match, oplock break")); 566 read_unlock(&cifs_tcp_ses_lock);
570 pCifsInode = 567 cFYI(1, ("file id match, oplock break"));
571 CIFS_I(netfile->pInode); 568 pCifsInode = CIFS_I(netfile->pInode);
572 pCifsInode->clientCanCacheAll = false; 569 pCifsInode->clientCanCacheAll = false;
573 if (pSMB->OplockLevel == 0) 570 if (pSMB->OplockLevel == 0)
574 pCifsInode->clientCanCacheRead 571 pCifsInode->clientCanCacheRead = false;
575 = false; 572 pCifsInode->oplockPending = true;
576 pCifsInode->oplockPending = true; 573 AllocOplockQEntry(netfile->pInode,
577 AllocOplockQEntry(netfile->pInode, 574 netfile->netfid, tcon);
578 netfile->netfid, 575 cFYI(1, ("about to wake up oplock thread"));
579 tcon); 576 if (oplockThread)
580 cFYI(1, 577 wake_up_process(oplockThread);
581 ("about to wake up oplock thread")); 578
582 if (oplockThread) 579 return true;
583 wake_up_process(oplockThread);
584 return true;
585 }
586 } 580 }
587 read_unlock(&GlobalSMBSeslock); 581 write_unlock(&GlobalSMBSeslock);
582 read_unlock(&cifs_tcp_ses_lock);
588 cFYI(1, ("No matching file for oplock break")); 583 cFYI(1, ("No matching file for oplock break"));
589 return true; 584 return true;
590 } 585 }
591 } 586 }
592 read_unlock(&GlobalSMBSeslock); 587 read_unlock(&cifs_tcp_ses_lock);
593 cFYI(1, ("Can not process oplock break for non-existent connection")); 588 cFYI(1, ("Can not process oplock break for non-existent connection"));
594 return true; 589 return true;
595} 590}
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 58d57299f2a0..9f51f9bf0292 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -741,11 +741,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
741 (index_to_find < first_entry_in_buffer)) { 741 (index_to_find < first_entry_in_buffer)) {
742 /* close and restart search */ 742 /* close and restart search */
743 cFYI(1, ("search backing up - close and restart search")); 743 cFYI(1, ("search backing up - close and restart search"));
744 write_lock(&GlobalSMBSeslock);
744 if (!cifsFile->srch_inf.endOfSearch && 745 if (!cifsFile->srch_inf.endOfSearch &&
745 !cifsFile->invalidHandle) { 746 !cifsFile->invalidHandle) {
746 cifsFile->invalidHandle = true; 747 cifsFile->invalidHandle = true;
748 write_unlock(&GlobalSMBSeslock);
747 CIFSFindClose(xid, pTcon, cifsFile->netfid); 749 CIFSFindClose(xid, pTcon, cifsFile->netfid);
748 } 750 } else
751 write_unlock(&GlobalSMBSeslock);
749 if (cifsFile->srch_inf.ntwrk_buf_start) { 752 if (cifsFile->srch_inf.ntwrk_buf_start) {
750 cFYI(1, ("freeing SMB ff cache buf on search rewind")); 753 cFYI(1, ("freeing SMB ff cache buf on search rewind"));
751 if (cifsFile->srch_inf.smallBuf) 754 if (cifsFile->srch_inf.smallBuf)
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index d910501de6d2..8d86b7960f0d 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -812,7 +812,7 @@ int dlm_release_lockspace(void *lockspace, int force)
812 error = release_lockspace(ls, force); 812 error = release_lockspace(ls, force);
813 if (!error) 813 if (!error)
814 ls_count--; 814 ls_count--;
815 else if (!ls_count) 815 if (!ls_count)
816 threads_stop(); 816 threads_stop();
817 mutex_unlock(&ls_lock); 817 mutex_unlock(&ls_lock);
818 818
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index e22bc3961345..0d713b691941 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1037,17 +1037,14 @@ static int
1037decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, 1037decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1038 struct ecryptfs_crypt_stat *crypt_stat) 1038 struct ecryptfs_crypt_stat *crypt_stat)
1039{ 1039{
1040 struct scatterlist dst_sg; 1040 struct scatterlist dst_sg[2];
1041 struct scatterlist src_sg; 1041 struct scatterlist src_sg[2];
1042 struct mutex *tfm_mutex; 1042 struct mutex *tfm_mutex;
1043 struct blkcipher_desc desc = { 1043 struct blkcipher_desc desc = {
1044 .flags = CRYPTO_TFM_REQ_MAY_SLEEP 1044 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
1045 }; 1045 };
1046 int rc = 0; 1046 int rc = 0;
1047 1047
1048 sg_init_table(&dst_sg, 1);
1049 sg_init_table(&src_sg, 1);
1050
1051 if (unlikely(ecryptfs_verbosity > 0)) { 1048 if (unlikely(ecryptfs_verbosity > 0)) {
1052 ecryptfs_printk( 1049 ecryptfs_printk(
1053 KERN_DEBUG, "Session key encryption key (size [%d]):\n", 1050 KERN_DEBUG, "Session key encryption key (size [%d]):\n",
@@ -1066,8 +1063,8 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1066 } 1063 }
1067 rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key, 1064 rc = virt_to_scatterlist(auth_tok->session_key.encrypted_key,
1068 auth_tok->session_key.encrypted_key_size, 1065 auth_tok->session_key.encrypted_key_size,
1069 &src_sg, 1); 1066 src_sg, 2);
1070 if (rc != 1) { 1067 if (rc < 1 || rc > 2) {
1071 printk(KERN_ERR "Internal error whilst attempting to convert " 1068 printk(KERN_ERR "Internal error whilst attempting to convert "
1072 "auth_tok->session_key.encrypted_key to scatterlist; " 1069 "auth_tok->session_key.encrypted_key to scatterlist; "
1073 "expected rc = 1; got rc = [%d]. " 1070 "expected rc = 1; got rc = [%d]. "
@@ -1079,8 +1076,8 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1079 auth_tok->session_key.encrypted_key_size; 1076 auth_tok->session_key.encrypted_key_size;
1080 rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key, 1077 rc = virt_to_scatterlist(auth_tok->session_key.decrypted_key,
1081 auth_tok->session_key.decrypted_key_size, 1078 auth_tok->session_key.decrypted_key_size,
1082 &dst_sg, 1); 1079 dst_sg, 2);
1083 if (rc != 1) { 1080 if (rc < 1 || rc > 2) {
1084 printk(KERN_ERR "Internal error whilst attempting to convert " 1081 printk(KERN_ERR "Internal error whilst attempting to convert "
1085 "auth_tok->session_key.decrypted_key to scatterlist; " 1082 "auth_tok->session_key.decrypted_key to scatterlist; "
1086 "expected rc = 1; got rc = [%d]\n", rc); 1083 "expected rc = 1; got rc = [%d]\n", rc);
@@ -1096,7 +1093,7 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
1096 rc = -EINVAL; 1093 rc = -EINVAL;
1097 goto out; 1094 goto out;
1098 } 1095 }
1099 rc = crypto_blkcipher_decrypt(&desc, &dst_sg, &src_sg, 1096 rc = crypto_blkcipher_decrypt(&desc, dst_sg, src_sg,
1100 auth_tok->session_key.encrypted_key_size); 1097 auth_tok->session_key.encrypted_key_size);
1101 mutex_unlock(tfm_mutex); 1098 mutex_unlock(tfm_mutex);
1102 if (unlikely(rc)) { 1099 if (unlikely(rc)) {
@@ -1539,8 +1536,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1539 size_t i; 1536 size_t i;
1540 size_t encrypted_session_key_valid = 0; 1537 size_t encrypted_session_key_valid = 0;
1541 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES]; 1538 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES];
1542 struct scatterlist dst_sg; 1539 struct scatterlist dst_sg[2];
1543 struct scatterlist src_sg; 1540 struct scatterlist src_sg[2];
1544 struct mutex *tfm_mutex = NULL; 1541 struct mutex *tfm_mutex = NULL;
1545 u8 cipher_code; 1542 u8 cipher_code;
1546 size_t packet_size_length; 1543 size_t packet_size_length;
@@ -1619,8 +1616,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1619 ecryptfs_dump_hex(session_key_encryption_key, 16); 1616 ecryptfs_dump_hex(session_key_encryption_key, 16);
1620 } 1617 }
1621 rc = virt_to_scatterlist(crypt_stat->key, key_rec->enc_key_size, 1618 rc = virt_to_scatterlist(crypt_stat->key, key_rec->enc_key_size,
1622 &src_sg, 1); 1619 src_sg, 2);
1623 if (rc != 1) { 1620 if (rc < 1 || rc > 2) {
1624 ecryptfs_printk(KERN_ERR, "Error generating scatterlist " 1621 ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
1625 "for crypt_stat session key; expected rc = 1; " 1622 "for crypt_stat session key; expected rc = 1; "
1626 "got rc = [%d]. key_rec->enc_key_size = [%d]\n", 1623 "got rc = [%d]. key_rec->enc_key_size = [%d]\n",
@@ -1629,8 +1626,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1629 goto out; 1626 goto out;
1630 } 1627 }
1631 rc = virt_to_scatterlist(key_rec->enc_key, key_rec->enc_key_size, 1628 rc = virt_to_scatterlist(key_rec->enc_key, key_rec->enc_key_size,
1632 &dst_sg, 1); 1629 dst_sg, 2);
1633 if (rc != 1) { 1630 if (rc < 1 || rc > 2) {
1634 ecryptfs_printk(KERN_ERR, "Error generating scatterlist " 1631 ecryptfs_printk(KERN_ERR, "Error generating scatterlist "
1635 "for crypt_stat encrypted session key; " 1632 "for crypt_stat encrypted session key; "
1636 "expected rc = 1; got rc = [%d]. " 1633 "expected rc = 1; got rc = [%d]. "
@@ -1651,7 +1648,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
1651 rc = 0; 1648 rc = 0;
1652 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n", 1649 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n",
1653 crypt_stat->key_size); 1650 crypt_stat->key_size);
1654 rc = crypto_blkcipher_encrypt(&desc, &dst_sg, &src_sg, 1651 rc = crypto_blkcipher_encrypt(&desc, dst_sg, src_sg,
1655 (*key_rec).enc_key_size); 1652 (*key_rec).enc_key_size);
1656 mutex_unlock(tfm_mutex); 1653 mutex_unlock(tfm_mutex);
1657 if (rc) { 1654 if (rc) {
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index 6ae9011b95eb..2f34f8f2134b 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -81,7 +81,7 @@ extern int do_rmdir(const char *file);
81extern int do_mknod(const char *file, int mode, unsigned int major, 81extern int do_mknod(const char *file, int mode, unsigned int major,
82 unsigned int minor); 82 unsigned int minor);
83extern int link_file(const char *from, const char *to); 83extern int link_file(const char *from, const char *to);
84extern int do_readlink(char *file, char *buf, int size); 84extern int hostfs_do_readlink(char *file, char *buf, int size);
85extern int rename_file(char *from, char *to); 85extern int rename_file(char *from, char *to);
86extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, 86extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
87 long long *bfree_out, long long *bavail_out, 87 long long *bfree_out, long long *bavail_out,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 7f34f4385de0..3a31451ac170 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -168,7 +168,7 @@ static char *follow_link(char *link)
168 if (name == NULL) 168 if (name == NULL)
169 goto out; 169 goto out;
170 170
171 n = do_readlink(link, name, len); 171 n = hostfs_do_readlink(link, name, len);
172 if (n < len) 172 if (n < len)
173 break; 173 break;
174 len *= 2; 174 len *= 2;
@@ -943,7 +943,7 @@ int hostfs_link_readpage(struct file *file, struct page *page)
943 name = inode_name(page->mapping->host, 0); 943 name = inode_name(page->mapping->host, 0);
944 if (name == NULL) 944 if (name == NULL)
945 return -ENOMEM; 945 return -ENOMEM;
946 err = do_readlink(name, buffer, PAGE_CACHE_SIZE); 946 err = hostfs_do_readlink(name, buffer, PAGE_CACHE_SIZE);
947 kfree(name); 947 kfree(name);
948 if (err == PAGE_CACHE_SIZE) 948 if (err == PAGE_CACHE_SIZE)
949 err = -E2BIG; 949 err = -E2BIG;
diff --git a/fs/hostfs/hostfs_user.c b/fs/hostfs/hostfs_user.c
index 53fd0a67c11a..b79424f93282 100644
--- a/fs/hostfs/hostfs_user.c
+++ b/fs/hostfs/hostfs_user.c
@@ -377,7 +377,7 @@ int link_file(const char *to, const char *from)
377 return 0; 377 return 0;
378} 378}
379 379
380int do_readlink(char *file, char *buf, int size) 380int hostfs_do_readlink(char *file, char *buf, int size)
381{ 381{
382 int n; 382 int n;
383 383
diff --git a/fs/inotify.c b/fs/inotify.c
index 690e72595e6e..7bbed1b89825 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -106,6 +106,20 @@ void get_inotify_watch(struct inotify_watch *watch)
106} 106}
107EXPORT_SYMBOL_GPL(get_inotify_watch); 107EXPORT_SYMBOL_GPL(get_inotify_watch);
108 108
109int pin_inotify_watch(struct inotify_watch *watch)
110{
111 struct super_block *sb = watch->inode->i_sb;
112 spin_lock(&sb_lock);
113 if (sb->s_count >= S_BIAS) {
114 atomic_inc(&sb->s_active);
115 spin_unlock(&sb_lock);
116 atomic_inc(&watch->count);
117 return 1;
118 }
119 spin_unlock(&sb_lock);
120 return 0;
121}
122
109/** 123/**
110 * put_inotify_watch - decrements the ref count on a given watch. cleans up 124 * put_inotify_watch - decrements the ref count on a given watch. cleans up
111 * watch references if the count reaches zero. inotify_watch is freed by 125 * watch references if the count reaches zero. inotify_watch is freed by
@@ -124,6 +138,13 @@ void put_inotify_watch(struct inotify_watch *watch)
124} 138}
125EXPORT_SYMBOL_GPL(put_inotify_watch); 139EXPORT_SYMBOL_GPL(put_inotify_watch);
126 140
141void unpin_inotify_watch(struct inotify_watch *watch)
142{
143 struct super_block *sb = watch->inode->i_sb;
144 put_inotify_watch(watch);
145 deactivate_super(sb);
146}
147
127/* 148/*
128 * inotify_handle_get_wd - returns the next WD for use by the given handle 149 * inotify_handle_get_wd - returns the next WD for use by the given handle
129 * 150 *
@@ -479,6 +500,112 @@ void inotify_init_watch(struct inotify_watch *watch)
479} 500}
480EXPORT_SYMBOL_GPL(inotify_init_watch); 501EXPORT_SYMBOL_GPL(inotify_init_watch);
481 502
503/*
504 * Watch removals suck violently. To kick the watch out we need (in this
505 * order) inode->inotify_mutex and ih->mutex. That's fine if we have
506 * a hold on inode; however, for all other cases we need to make damn sure
507 * we don't race with umount. We can *NOT* just grab a reference to a
508 * watch - inotify_unmount_inodes() will happily sail past it and we'll end
509 * with reference to inode potentially outliving its superblock. Ideally
510 * we just want to grab an active reference to superblock if we can; that
511 * will make sure we won't go into inotify_umount_inodes() until we are
512 * done. Cleanup is just deactivate_super(). However, that leaves a messy
513 * case - what if we *are* racing with umount() and active references to
514 * superblock can't be acquired anymore? We can bump ->s_count, grab
515 * ->s_umount, which will almost certainly wait until the superblock is shut
516 * down and the watch in question is pining for fjords. That's fine, but
517 * there is a problem - we might have hit the window between ->s_active
518 * getting to 0 / ->s_count - below S_BIAS (i.e. the moment when superblock
519 * is past the point of no return and is heading for shutdown) and the
520 * moment when deactivate_super() acquires ->s_umount. We could just do
521 * drop_super() yield() and retry, but that's rather antisocial and this
522 * stuff is luser-triggerable. OTOH, having grabbed ->s_umount and having
523 * found that we'd got there first (i.e. that ->s_root is non-NULL) we know
524 * that we won't race with inotify_umount_inodes(). So we could grab a
525 * reference to watch and do the rest as above, just with drop_super() instead
526 * of deactivate_super(), right? Wrong. We had to drop ih->mutex before we
527 * could grab ->s_umount. So the watch could've been gone already.
528 *
529 * That still can be dealt with - we need to save watch->wd, do idr_find()
530 * and compare its result with our pointer. If they match, we either have
531 * the damn thing still alive or we'd lost not one but two races at once,
532 * the watch had been killed and a new one got created with the same ->wd
533 * at the same address. That couldn't have happened in inotify_destroy(),
534 * but inotify_rm_wd() could run into that. Still, "new one got created"
535 * is not a problem - we have every right to kill it or leave it alone,
536 * whatever's more convenient.
537 *
538 * So we can use idr_find(...) == watch && watch->inode->i_sb == sb as
539 * "grab it and kill it" check. If it's been our original watch, we are
540 * fine, if it's a newcomer - nevermind, just pretend that we'd won the
541 * race and kill the fscker anyway; we are safe since we know that its
542 * superblock won't be going away.
543 *
544 * And yes, this is far beyond mere "not very pretty"; so's the entire
545 * concept of inotify to start with.
546 */
547
548/**
549 * pin_to_kill - pin the watch down for removal
550 * @ih: inotify handle
551 * @watch: watch to kill
552 *
553 * Called with ih->mutex held, drops it. Possible return values:
554 * 0 - nothing to do, it has died
555 * 1 - remove it, drop the reference and deactivate_super()
556 * 2 - remove it, drop the reference and drop_super(); we tried hard to avoid
557 * that variant, since it involved a lot of PITA, but that's the best that
558 * could've been done.
559 */
560static int pin_to_kill(struct inotify_handle *ih, struct inotify_watch *watch)
561{
562 struct super_block *sb = watch->inode->i_sb;
563 s32 wd = watch->wd;
564
565 spin_lock(&sb_lock);
566 if (sb->s_count >= S_BIAS) {
567 atomic_inc(&sb->s_active);
568 spin_unlock(&sb_lock);
569 get_inotify_watch(watch);
570 mutex_unlock(&ih->mutex);
571 return 1; /* the best outcome */
572 }
573 sb->s_count++;
574 spin_unlock(&sb_lock);
575 mutex_unlock(&ih->mutex); /* can't grab ->s_umount under it */
576 down_read(&sb->s_umount);
577 if (likely(!sb->s_root)) {
578 /* fs is already shut down; the watch is dead */
579 drop_super(sb);
580 return 0;
581 }
582 /* raced with the final deactivate_super() */
583 mutex_lock(&ih->mutex);
584 if (idr_find(&ih->idr, wd) != watch || watch->inode->i_sb != sb) {
585 /* the watch is dead */
586 mutex_unlock(&ih->mutex);
587 drop_super(sb);
588 return 0;
589 }
590 /* still alive or freed and reused with the same sb and wd; kill */
591 get_inotify_watch(watch);
592 mutex_unlock(&ih->mutex);
593 return 2;
594}
595
596static void unpin_and_kill(struct inotify_watch *watch, int how)
597{
598 struct super_block *sb = watch->inode->i_sb;
599 put_inotify_watch(watch);
600 switch (how) {
601 case 1:
602 deactivate_super(sb);
603 break;
604 case 2:
605 drop_super(sb);
606 }
607}
608
482/** 609/**
483 * inotify_destroy - clean up and destroy an inotify instance 610 * inotify_destroy - clean up and destroy an inotify instance
484 * @ih: inotify handle 611 * @ih: inotify handle
@@ -490,11 +617,15 @@ void inotify_destroy(struct inotify_handle *ih)
490 * pretty. We cannot do a simple iteration over the list, because we 617 * pretty. We cannot do a simple iteration over the list, because we
491 * do not know the inode until we iterate to the watch. But we need to 618 * do not know the inode until we iterate to the watch. But we need to
492 * hold inode->inotify_mutex before ih->mutex. The following works. 619 * hold inode->inotify_mutex before ih->mutex. The following works.
620 *
621 * AV: it had to become even uglier to start working ;-/
493 */ 622 */
494 while (1) { 623 while (1) {
495 struct inotify_watch *watch; 624 struct inotify_watch *watch;
496 struct list_head *watches; 625 struct list_head *watches;
626 struct super_block *sb;
497 struct inode *inode; 627 struct inode *inode;
628 int how;
498 629
499 mutex_lock(&ih->mutex); 630 mutex_lock(&ih->mutex);
500 watches = &ih->watches; 631 watches = &ih->watches;
@@ -503,8 +634,10 @@ void inotify_destroy(struct inotify_handle *ih)
503 break; 634 break;
504 } 635 }
505 watch = list_first_entry(watches, struct inotify_watch, h_list); 636 watch = list_first_entry(watches, struct inotify_watch, h_list);
506 get_inotify_watch(watch); 637 sb = watch->inode->i_sb;
507 mutex_unlock(&ih->mutex); 638 how = pin_to_kill(ih, watch);
639 if (!how)
640 continue;
508 641
509 inode = watch->inode; 642 inode = watch->inode;
510 mutex_lock(&inode->inotify_mutex); 643 mutex_lock(&inode->inotify_mutex);
@@ -518,7 +651,7 @@ void inotify_destroy(struct inotify_handle *ih)
518 651
519 mutex_unlock(&ih->mutex); 652 mutex_unlock(&ih->mutex);
520 mutex_unlock(&inode->inotify_mutex); 653 mutex_unlock(&inode->inotify_mutex);
521 put_inotify_watch(watch); 654 unpin_and_kill(watch, how);
522 } 655 }
523 656
524 /* free this handle: the put matching the get in inotify_init() */ 657 /* free this handle: the put matching the get in inotify_init() */
@@ -719,7 +852,9 @@ void inotify_evict_watch(struct inotify_watch *watch)
719int inotify_rm_wd(struct inotify_handle *ih, u32 wd) 852int inotify_rm_wd(struct inotify_handle *ih, u32 wd)
720{ 853{
721 struct inotify_watch *watch; 854 struct inotify_watch *watch;
855 struct super_block *sb;
722 struct inode *inode; 856 struct inode *inode;
857 int how;
723 858
724 mutex_lock(&ih->mutex); 859 mutex_lock(&ih->mutex);
725 watch = idr_find(&ih->idr, wd); 860 watch = idr_find(&ih->idr, wd);
@@ -727,9 +862,12 @@ int inotify_rm_wd(struct inotify_handle *ih, u32 wd)
727 mutex_unlock(&ih->mutex); 862 mutex_unlock(&ih->mutex);
728 return -EINVAL; 863 return -EINVAL;
729 } 864 }
730 get_inotify_watch(watch); 865 sb = watch->inode->i_sb;
866 how = pin_to_kill(ih, watch);
867 if (!how)
868 return 0;
869
731 inode = watch->inode; 870 inode = watch->inode;
732 mutex_unlock(&ih->mutex);
733 871
734 mutex_lock(&inode->inotify_mutex); 872 mutex_lock(&inode->inotify_mutex);
735 mutex_lock(&ih->mutex); 873 mutex_lock(&ih->mutex);
@@ -740,7 +878,7 @@ int inotify_rm_wd(struct inotify_handle *ih, u32 wd)
740 878
741 mutex_unlock(&ih->mutex); 879 mutex_unlock(&ih->mutex);
742 mutex_unlock(&inode->inotify_mutex); 880 mutex_unlock(&inode->inotify_mutex);
743 put_inotify_watch(watch); 881 unpin_and_kill(watch, how);
744 882
745 return 0; 883 return 0;
746} 884}
diff --git a/fs/namei.c b/fs/namei.c
index 09ce58e49e72..d34e0f9681c6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1378,7 +1378,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
1378 if (IS_APPEND(dir)) 1378 if (IS_APPEND(dir))
1379 return -EPERM; 1379 return -EPERM;
1380 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)|| 1380 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
1381 IS_IMMUTABLE(victim->d_inode)) 1381 IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
1382 return -EPERM; 1382 return -EPERM;
1383 if (isdir) { 1383 if (isdir) {
1384 if (!S_ISDIR(victim->d_inode->i_mode)) 1384 if (!S_ISDIR(victim->d_inode->i_mode))
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 633f7a0ebb2c..6d5b213b8a9b 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -348,8 +348,8 @@ static ssize_t whole_disk_show(struct device *dev,
348static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, 348static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
349 whole_disk_show, NULL); 349 whole_disk_show, NULL);
350 350
351int add_partition(struct gendisk *disk, int partno, 351struct hd_struct *add_partition(struct gendisk *disk, int partno,
352 sector_t start, sector_t len, int flags) 352 sector_t start, sector_t len, int flags)
353{ 353{
354 struct hd_struct *p; 354 struct hd_struct *p;
355 dev_t devt = MKDEV(0, 0); 355 dev_t devt = MKDEV(0, 0);
@@ -361,15 +361,15 @@ int add_partition(struct gendisk *disk, int partno,
361 361
362 err = disk_expand_part_tbl(disk, partno); 362 err = disk_expand_part_tbl(disk, partno);
363 if (err) 363 if (err)
364 return err; 364 return ERR_PTR(err);
365 ptbl = disk->part_tbl; 365 ptbl = disk->part_tbl;
366 366
367 if (ptbl->part[partno]) 367 if (ptbl->part[partno])
368 return -EBUSY; 368 return ERR_PTR(-EBUSY);
369 369
370 p = kzalloc(sizeof(*p), GFP_KERNEL); 370 p = kzalloc(sizeof(*p), GFP_KERNEL);
371 if (!p) 371 if (!p)
372 return -ENOMEM; 372 return ERR_PTR(-EBUSY);
373 373
374 if (!init_part_stats(p)) { 374 if (!init_part_stats(p)) {
375 err = -ENOMEM; 375 err = -ENOMEM;
@@ -395,7 +395,7 @@ int add_partition(struct gendisk *disk, int partno,
395 395
396 err = blk_alloc_devt(p, &devt); 396 err = blk_alloc_devt(p, &devt);
397 if (err) 397 if (err)
398 goto out_free; 398 goto out_free_stats;
399 pdev->devt = devt; 399 pdev->devt = devt;
400 400
401 /* delay uevent until 'holders' subdir is created */ 401 /* delay uevent until 'holders' subdir is created */
@@ -424,18 +424,20 @@ int add_partition(struct gendisk *disk, int partno,
424 if (!ddev->uevent_suppress) 424 if (!ddev->uevent_suppress)
425 kobject_uevent(&pdev->kobj, KOBJ_ADD); 425 kobject_uevent(&pdev->kobj, KOBJ_ADD);
426 426
427 return 0; 427 return p;
428 428
429out_free_stats:
430 free_part_stats(p);
429out_free: 431out_free:
430 kfree(p); 432 kfree(p);
431 return err; 433 return ERR_PTR(err);
432out_del: 434out_del:
433 kobject_put(p->holder_dir); 435 kobject_put(p->holder_dir);
434 device_del(pdev); 436 device_del(pdev);
435out_put: 437out_put:
436 put_device(pdev); 438 put_device(pdev);
437 blk_free_devt(devt); 439 blk_free_devt(devt);
438 return err; 440 return ERR_PTR(err);
439} 441}
440 442
441/* Not exported, helper to add_disk(). */ 443/* Not exported, helper to add_disk(). */
@@ -566,15 +568,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
566 disk->disk_name, p, (unsigned long long) size); 568 disk->disk_name, p, (unsigned long long) size);
567 size = get_capacity(disk) - from; 569 size = get_capacity(disk) - from;
568 } 570 }
569 res = add_partition(disk, p, from, size, state->parts[p].flags); 571 part = add_partition(disk, p, from, size,
570 if (res) { 572 state->parts[p].flags);
571 printk(KERN_ERR " %s: p%d could not be added: %d\n", 573 if (IS_ERR(part)) {
572 disk->disk_name, p, -res); 574 printk(KERN_ERR " %s: p%d could not be added: %ld\n",
575 disk->disk_name, p, -PTR_ERR(part));
573 continue; 576 continue;
574 } 577 }
575#ifdef CONFIG_BLK_DEV_MD 578#ifdef CONFIG_BLK_DEV_MD
576 if (state->parts[p].flags & ADDPART_FLAG_RAID) 579 if (state->parts[p].flags & ADDPART_FLAG_RAID)
577 md_autodetect_dev(bdev->bd_dev+p); 580 md_autodetect_dev(part_to_dev(part)->devt);
578#endif 581#endif
579 } 582 }
580 kfree(state); 583 kfree(state);
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 94fcfff6863a..06ed10b7da9e 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -31,6 +31,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
31 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 31 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
32 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ 32 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */
33 inode->i_mode = table->mode; 33 inode->i_mode = table->mode;
34 inode->i_uid = inode->i_gid = 0;
34 if (!table->child) { 35 if (!table->child) {
35 inode->i_mode |= S_IFREG; 36 inode->i_mode |= S_IFREG;
36 inode->i_op = &proc_sys_inode_operations; 37 inode->i_op = &proc_sys_inode_operations;
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 2691926fb506..8e540d32c9fe 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -74,8 +74,6 @@ static inline int cpuset_do_slab_mem_spread(void)
74 return current->flags & PF_SPREAD_SLAB; 74 return current->flags & PF_SPREAD_SLAB;
75} 75}
76 76
77extern void cpuset_track_online_nodes(void);
78
79extern int current_cpuset_is_being_rebound(void); 77extern int current_cpuset_is_being_rebound(void);
80 78
81extern void rebuild_sched_domains(void); 79extern void rebuild_sched_domains(void);
@@ -151,8 +149,6 @@ static inline int cpuset_do_slab_mem_spread(void)
151 return 0; 149 return 0;
152} 150}
153 151
154static inline void cpuset_track_online_nodes(void) {}
155
156static inline int current_cpuset_is_being_rebound(void) 152static inline int current_cpuset_is_being_rebound(void)
157{ 153{
158 return 0; 154 return 0;
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 4aaa4afb1cb9..096476f1fb35 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -17,7 +17,7 @@ extern int debug_locks_off(void);
17({ \ 17({ \
18 int __ret = 0; \ 18 int __ret = 0; \
19 \ 19 \
20 if (unlikely(c)) { \ 20 if (!oops_in_progress && unlikely(c)) { \
21 if (debug_locks_off() && !debug_locks_silent) \ 21 if (debug_locks_off() && !debug_locks_silent) \
22 WARN_ON(1); \ 22 WARN_ON(1); \
23 __ret = 1; \ 23 __ret = 1; \
diff --git a/include/linux/futex.h b/include/linux/futex.h
index 586ab56a3ec3..8f627b9ae2b1 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -164,6 +164,8 @@ union futex_key {
164 } both; 164 } both;
165}; 165};
166 166
167#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
168
167#ifdef CONFIG_FUTEX 169#ifdef CONFIG_FUTEX
168extern void exit_robust_list(struct task_struct *curr); 170extern void exit_robust_list(struct task_struct *curr);
169extern void exit_pi_state_list(struct task_struct *curr); 171extern void exit_pi_state_list(struct task_struct *curr);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e439e6aed832..3df7742ce246 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -522,7 +522,9 @@ extern char *disk_name (struct gendisk *hd, int partno, char *buf);
522 522
523extern int disk_expand_part_tbl(struct gendisk *disk, int target); 523extern int disk_expand_part_tbl(struct gendisk *disk, int target);
524extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 524extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
525extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); 525extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
526 int partno, sector_t start,
527 sector_t len, int flags);
526extern void delete_partition(struct gendisk *, int); 528extern void delete_partition(struct gendisk *, int);
527extern void printk_all_partitions(void); 529extern void printk_all_partitions(void);
528 530
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index bd578578a8b9..37ea2894b3c0 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -134,6 +134,8 @@ extern void inotify_remove_watch_locked(struct inotify_handle *,
134 struct inotify_watch *); 134 struct inotify_watch *);
135extern void get_inotify_watch(struct inotify_watch *); 135extern void get_inotify_watch(struct inotify_watch *);
136extern void put_inotify_watch(struct inotify_watch *); 136extern void put_inotify_watch(struct inotify_watch *);
137extern int pin_inotify_watch(struct inotify_watch *);
138extern void unpin_inotify_watch(struct inotify_watch *);
137 139
138#else 140#else
139 141
@@ -228,6 +230,15 @@ static inline void put_inotify_watch(struct inotify_watch *watch)
228{ 230{
229} 231}
230 232
233extern inline int pin_inotify_watch(struct inotify_watch *watch)
234{
235 return 0;
236}
237
238extern inline void unpin_inotify_watch(struct inotify_watch *watch)
239{
240}
241
231#endif /* CONFIG_INOTIFY */ 242#endif /* CONFIG_INOTIFY */
232 243
233#endif /* __KERNEL __ */ 244#endif /* __KERNEL __ */
diff --git a/include/linux/input.h b/include/linux/input.h
index b86fb5581ce6..5341e8251f8c 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -238,6 +238,7 @@ struct input_absinfo {
238#define KEY_KPEQUAL 117 238#define KEY_KPEQUAL 117
239#define KEY_KPPLUSMINUS 118 239#define KEY_KPPLUSMINUS 118
240#define KEY_PAUSE 119 240#define KEY_PAUSE 119
241#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */
241 242
242#define KEY_KPCOMMA 121 243#define KEY_KPCOMMA 121
243#define KEY_HANGEUL 122 244#define KEY_HANGEUL 122
@@ -322,6 +323,7 @@ struct input_absinfo {
322#define KEY_PAUSECD 201 323#define KEY_PAUSECD 201
323#define KEY_PROG3 202 324#define KEY_PROG3 202
324#define KEY_PROG4 203 325#define KEY_PROG4 203
326#define KEY_DASHBOARD 204 /* AL Dashboard */
325#define KEY_SUSPEND 205 327#define KEY_SUSPEND 205
326#define KEY_CLOSE 206 /* AC Close */ 328#define KEY_CLOSE 206 /* AC Close */
327#define KEY_PLAY 207 329#define KEY_PLAY 207
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fba141d3ca07..269df5a17b30 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -141,6 +141,15 @@ extern int _cond_resched(void);
141 (__x < 0) ? -__x : __x; \ 141 (__x < 0) ? -__x : __x; \
142 }) 142 })
143 143
144#ifdef CONFIG_PROVE_LOCKING
145void might_fault(void);
146#else
147static inline void might_fault(void)
148{
149 might_sleep();
150}
151#endif
152
144extern struct atomic_notifier_head panic_notifier_list; 153extern struct atomic_notifier_head panic_notifier_list;
145extern long (*panic_blink)(long time); 154extern long (*panic_blink)(long time);
146NORET_TYPE void panic(const char * fmt, ...) 155NORET_TYPE void panic(const char * fmt, ...)
@@ -188,6 +197,8 @@ extern unsigned long long memparse(const char *ptr, char **retptr);
188extern int core_kernel_text(unsigned long addr); 197extern int core_kernel_text(unsigned long addr);
189extern int __kernel_text_address(unsigned long addr); 198extern int __kernel_text_address(unsigned long addr);
190extern int kernel_text_address(unsigned long addr); 199extern int kernel_text_address(unsigned long addr);
200extern int func_ptr_is_kernel_text(void *ptr);
201
191struct pid; 202struct pid;
192extern struct pid *session_of_pgrp(struct pid *pgrp); 203extern struct pid *session_of_pgrp(struct pid *pgrp);
193 204
@@ -318,32 +329,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
318 return buf; 329 return buf;
319} 330}
320 331
321#define pr_emerg(fmt, arg...) \ 332#ifndef pr_fmt
322 printk(KERN_EMERG fmt, ##arg) 333#define pr_fmt(fmt) fmt
323#define pr_alert(fmt, arg...) \ 334#endif
324 printk(KERN_ALERT fmt, ##arg) 335
325#define pr_crit(fmt, arg...) \ 336#define pr_emerg(fmt, ...) \
326 printk(KERN_CRIT fmt, ##arg) 337 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
327#define pr_err(fmt, arg...) \ 338#define pr_alert(fmt, ...) \
328 printk(KERN_ERR fmt, ##arg) 339 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
329#define pr_warning(fmt, arg...) \ 340#define pr_crit(fmt, ...) \
330 printk(KERN_WARNING fmt, ##arg) 341 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
331#define pr_notice(fmt, arg...) \ 342#define pr_err(fmt, ...) \
332 printk(KERN_NOTICE fmt, ##arg) 343 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
333#define pr_info(fmt, arg...) \ 344#define pr_warning(fmt, ...) \
334 printk(KERN_INFO fmt, ##arg) 345 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
346#define pr_notice(fmt, ...) \
347 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
348#define pr_info(fmt, ...) \
349 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
335 350
336/* If you are writing a driver, please use dev_dbg instead */ 351/* If you are writing a driver, please use dev_dbg instead */
337#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 352#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
338#define pr_debug(fmt, ...) do { \ 353#define pr_debug(fmt, ...) do { \
339 dynamic_pr_debug(fmt, ##__VA_ARGS__); \ 354 dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \
340 } while (0) 355 } while (0)
341#elif defined(DEBUG) 356#elif defined(DEBUG)
342#define pr_debug(fmt, arg...) \ 357#define pr_debug(fmt, ...) \
343 printk(KERN_DEBUG fmt, ##arg) 358 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
344#else 359#else
345#define pr_debug(fmt, arg...) \ 360#define pr_debug(fmt, ...) \
346 ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) 361 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
347#endif 362#endif
348 363
349/* 364/*
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 331e5f1c2d8e..8956daf64abd 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -73,6 +73,8 @@ struct lock_class_key {
73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; 73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
74}; 74};
75 75
76#define LOCKSTAT_POINTS 4
77
76/* 78/*
77 * The lock-class itself: 79 * The lock-class itself:
78 */ 80 */
@@ -119,7 +121,8 @@ struct lock_class {
119 int name_version; 121 int name_version;
120 122
121#ifdef CONFIG_LOCK_STAT 123#ifdef CONFIG_LOCK_STAT
122 unsigned long contention_point[4]; 124 unsigned long contention_point[LOCKSTAT_POINTS];
125 unsigned long contending_point[LOCKSTAT_POINTS];
123#endif 126#endif
124}; 127};
125 128
@@ -144,6 +147,7 @@ enum bounce_type {
144 147
145struct lock_class_stats { 148struct lock_class_stats {
146 unsigned long contention_point[4]; 149 unsigned long contention_point[4];
150 unsigned long contending_point[4];
147 struct lock_time read_waittime; 151 struct lock_time read_waittime;
148 struct lock_time write_waittime; 152 struct lock_time write_waittime;
149 struct lock_time read_holdtime; 153 struct lock_time read_holdtime;
@@ -165,6 +169,7 @@ struct lockdep_map {
165 const char *name; 169 const char *name;
166#ifdef CONFIG_LOCK_STAT 170#ifdef CONFIG_LOCK_STAT
167 int cpu; 171 int cpu;
172 unsigned long ip;
168#endif 173#endif
169}; 174};
170 175
@@ -331,10 +336,11 @@ static inline void lockdep_on(void)
331# define lock_set_subclass(l, s, i) do { } while (0) 336# define lock_set_subclass(l, s, i) do { } while (0)
332# define lockdep_init() do { } while (0) 337# define lockdep_init() do { } while (0)
333# define lockdep_info() do { } while (0) 338# define lockdep_info() do { } while (0)
334# define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0) 339# define lockdep_init_map(lock, name, key, sub) \
340 do { (void)(name); (void)(key); } while (0)
335# define lockdep_set_class(lock, key) do { (void)(key); } while (0) 341# define lockdep_set_class(lock, key) do { (void)(key); } while (0)
336# define lockdep_set_class_and_name(lock, key, name) \ 342# define lockdep_set_class_and_name(lock, key, name) \
337 do { (void)(key); } while (0) 343 do { (void)(key); (void)(name); } while (0)
338#define lockdep_set_class_and_subclass(lock, key, sub) \ 344#define lockdep_set_class_and_subclass(lock, key, sub) \
339 do { (void)(key); } while (0) 345 do { (void)(key); } while (0)
340#define lockdep_set_subclass(lock, sub) do { } while (0) 346#define lockdep_set_subclass(lock, sub) do { } while (0)
@@ -355,7 +361,7 @@ struct lock_class_key { };
355#ifdef CONFIG_LOCK_STAT 361#ifdef CONFIG_LOCK_STAT
356 362
357extern void lock_contended(struct lockdep_map *lock, unsigned long ip); 363extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
358extern void lock_acquired(struct lockdep_map *lock); 364extern void lock_acquired(struct lockdep_map *lock, unsigned long ip);
359 365
360#define LOCK_CONTENDED(_lock, try, lock) \ 366#define LOCK_CONTENDED(_lock, try, lock) \
361do { \ 367do { \
@@ -363,13 +369,13 @@ do { \
363 lock_contended(&(_lock)->dep_map, _RET_IP_); \ 369 lock_contended(&(_lock)->dep_map, _RET_IP_); \
364 lock(_lock); \ 370 lock(_lock); \
365 } \ 371 } \
366 lock_acquired(&(_lock)->dep_map); \ 372 lock_acquired(&(_lock)->dep_map, _RET_IP_); \
367} while (0) 373} while (0)
368 374
369#else /* CONFIG_LOCK_STAT */ 375#else /* CONFIG_LOCK_STAT */
370 376
371#define lock_contended(lockdep_map, ip) do {} while (0) 377#define lock_contended(lockdep_map, ip) do {} while (0)
372#define lock_acquired(lockdep_map) do {} while (0) 378#define lock_acquired(lockdep_map, ip) do {} while (0)
373 379
374#define LOCK_CONTENDED(_lock, try, lock) \ 380#define LOCK_CONTENDED(_lock, try, lock) \
375 lock(_lock) 381 lock(_lock)
@@ -480,4 +486,22 @@ static inline void print_irqtrace_events(struct task_struct *curr)
480# define lock_map_release(l) do { } while (0) 486# define lock_map_release(l) do { } while (0)
481#endif 487#endif
482 488
489#ifdef CONFIG_PROVE_LOCKING
490# define might_lock(lock) \
491do { \
492 typecheck(struct lockdep_map *, &(lock)->dep_map); \
493 lock_acquire(&(lock)->dep_map, 0, 0, 0, 2, NULL, _THIS_IP_); \
494 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
495} while (0)
496# define might_lock_read(lock) \
497do { \
498 typecheck(struct lockdep_map *, &(lock)->dep_map); \
499 lock_acquire(&(lock)->dep_map, 0, 0, 1, 2, NULL, _THIS_IP_); \
500 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
501} while (0)
502#else
503# define might_lock(lock) do { } while (0)
504# define might_lock_read(lock) do { } while (0)
505#endif
506
483#endif /* __LINUX_LOCKDEP_H */ 507#endif /* __LINUX_LOCKDEP_H */
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index bc6da10ceee0..7a0e5c4f8072 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -144,6 +144,8 @@ extern int __must_check mutex_lock_killable(struct mutex *lock);
144/* 144/*
145 * NOTE: mutex_trylock() follows the spin_trylock() convention, 145 * NOTE: mutex_trylock() follows the spin_trylock() convention,
146 * not the down_trylock() convention! 146 * not the down_trylock() convention!
147 *
148 * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
147 */ 149 */
148extern int mutex_trylock(struct mutex *lock); 150extern int mutex_trylock(struct mutex *lock);
149extern void mutex_unlock(struct mutex *lock); 151extern void mutex_unlock(struct mutex *lock);
diff --git a/include/linux/net.h b/include/linux/net.h
index 6dc14a240042..4515efae4c39 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -40,7 +40,7 @@
40#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ 40#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
41#define SYS_SENDMSG 16 /* sys_sendmsg(2) */ 41#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
43#define SYS_PACCEPT 18 /* sys_paccept(2) */ 43#define SYS_ACCEPT4 18 /* sys_accept4(2) */
44 44
45typedef enum { 45typedef enum {
46 SS_FREE = 0, /* not allocated */ 46 SS_FREE = 0, /* not allocated */
@@ -100,7 +100,7 @@ enum sock_type {
100 * remaining bits are used as flags. */ 100 * remaining bits are used as flags. */
101#define SOCK_TYPE_MASK 0xf 101#define SOCK_TYPE_MASK 0xf
102 102
103/* Flags for socket, socketpair, paccept */ 103/* Flags for socket, socketpair, accept4 */
104#define SOCK_CLOEXEC O_CLOEXEC 104#define SOCK_CLOEXEC O_CLOEXEC
105#ifndef SOCK_NONBLOCK 105#ifndef SOCK_NONBLOCK
106#define SOCK_NONBLOCK O_NONBLOCK 106#define SOCK_NONBLOCK O_NONBLOCK
@@ -223,8 +223,6 @@ extern int sock_map_fd(struct socket *sock, int flags);
223extern struct socket *sockfd_lookup(int fd, int *err); 223extern struct socket *sockfd_lookup(int fd, int *err);
224#define sockfd_put(sock) fput(sock->file) 224#define sockfd_put(sock) fput(sock->file)
225extern int net_ratelimit(void); 225extern int net_ratelimit(void);
226extern long do_accept(int fd, struct sockaddr __user *upeer_sockaddr,
227 int __user *upeer_addrlen, int flags);
228 226
229#define net_random() random32() 227#define net_random() random32()
230#define net_srandom(seed) srandom32((__force u32)seed) 228#define net_srandom(seed) srandom32((__force u32)seed)
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index 5f89b62e6983..301dda829e37 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -41,7 +41,7 @@
41#include <linux/seqlock.h> 41#include <linux/seqlock.h>
42 42
43#ifdef CONFIG_RCU_CPU_STALL_DETECTOR 43#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
44#define RCU_SECONDS_TILL_STALL_CHECK ( 3 * HZ) /* for rcp->jiffies_stall */ 44#define RCU_SECONDS_TILL_STALL_CHECK (10 * HZ) /* for rcp->jiffies_stall */
45#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */ 45#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */
46#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ 46#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
47 47
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 536b0ca46a03..e097c2e6b6dc 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -120,6 +120,9 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
120u64 ring_buffer_time_stamp(int cpu); 120u64 ring_buffer_time_stamp(int cpu);
121void ring_buffer_normalize_time_stamp(int cpu, u64 *ts); 121void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);
122 122
123void tracing_on(void);
124void tracing_off(void);
125
123enum ring_buffer_flags { 126enum ring_buffer_flags {
124 RB_FL_OVERWRITE = 1 << 0, 127 RB_FL_OVERWRITE = 1 << 0,
125}; 128};
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index e27f216361fc..4e4f1277f3bf 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -155,6 +155,9 @@
155 155
156#define PORT_SC26XX 82 156#define PORT_SC26XX 82
157 157
158/* SH-SCI */
159#define PORT_SCIFA 83
160
158#ifdef __KERNEL__ 161#ifdef __KERNEL__
159 162
160#include <linux/compiler.h> 163#include <linux/compiler.h>
diff --git a/include/linux/slab.h b/include/linux/slab.h
index ba965c84ae06..000da12b5cf0 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -23,6 +23,34 @@
23#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ 23#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
24#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ 24#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
25#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ 25#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */
26/*
27 * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS!
28 *
29 * This delays freeing the SLAB page by a grace period, it does _NOT_
30 * delay object freeing. This means that if you do kmem_cache_free()
31 * that memory location is free to be reused at any time. Thus it may
32 * be possible to see another object there in the same RCU grace period.
33 *
34 * This feature only ensures the memory location backing the object
35 * stays valid, the trick to using this is relying on an independent
36 * object validation pass. Something like:
37 *
38 * rcu_read_lock()
39 * again:
40 * obj = lockless_lookup(key);
41 * if (obj) {
42 * if (!try_get_ref(obj)) // might fail for free objects
43 * goto again;
44 *
45 * if (obj->key != key) { // not the object we expected
46 * put_ref(obj);
47 * goto again;
48 * }
49 * }
50 * rcu_read_unlock();
51 *
52 * See also the comment on struct slab_rcu in mm/slab.c.
53 */
26#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ 54#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
27#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 55#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
28#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 56#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index d6ff145919ca..04fb47bfb920 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -410,8 +410,7 @@ asmlinkage long sys_getsockopt(int fd, int level, int optname,
410asmlinkage long sys_bind(int, struct sockaddr __user *, int); 410asmlinkage long sys_bind(int, struct sockaddr __user *, int);
411asmlinkage long sys_connect(int, struct sockaddr __user *, int); 411asmlinkage long sys_connect(int, struct sockaddr __user *, int);
412asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *); 412asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *);
413asmlinkage long sys_paccept(int, struct sockaddr __user *, int __user *, 413asmlinkage long sys_accept4(int, struct sockaddr __user *, int __user *, int);
414 const __user sigset_t *, size_t, int);
415asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *); 414asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
416asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *); 415asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
417asmlinkage long sys_send(int, void __user *, size_t, unsigned); 416asmlinkage long sys_send(int, void __user *, size_t, unsigned);
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index fec6decfb983..6b58367d145e 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -78,7 +78,7 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78 \ 78 \
79 set_fs(KERNEL_DS); \ 79 set_fs(KERNEL_DS); \
80 pagefault_disable(); \ 80 pagefault_disable(); \
81 ret = __get_user(retval, (__force typeof(retval) __user *)(addr)); \ 81 ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
82 pagefault_enable(); \ 82 pagefault_enable(); \
83 set_fs(old_fs); \ 83 set_fs(old_fs); \
84 ret; \ 84 ret; \
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 8fa973bede5e..f72aa51f7bcd 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -108,6 +108,7 @@ enum usb_interface_condition {
108 * (in probe()), bound to a driver, or unbinding (in disconnect()) 108 * (in probe()), bound to a driver, or unbinding (in disconnect())
109 * @is_active: flag set when the interface is bound and not suspended. 109 * @is_active: flag set when the interface is bound and not suspended.
110 * @sysfs_files_created: sysfs attributes exist 110 * @sysfs_files_created: sysfs attributes exist
111 * @unregistering: flag set when the interface is being unregistered
111 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup 112 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
112 * capability during autosuspend. 113 * capability during autosuspend.
113 * @needs_altsetting0: flag set when a set-interface request for altsetting 0 114 * @needs_altsetting0: flag set when a set-interface request for altsetting 0
@@ -163,6 +164,7 @@ struct usb_interface {
163 enum usb_interface_condition condition; /* state of binding */ 164 enum usb_interface_condition condition; /* state of binding */
164 unsigned is_active:1; /* the interface is not suspended */ 165 unsigned is_active:1; /* the interface is not suspended */
165 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 166 unsigned sysfs_files_created:1; /* the sysfs attributes exist */
167 unsigned unregistering:1; /* unregistration is in progress */
166 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 168 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
167 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ 169 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
168 unsigned needs_binding:1; /* needs delayed unbind/rebind */ 170 unsigned needs_binding:1; /* needs delayed unbind/rebind */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 8856e2d60e9f..73d81bc6aa75 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -74,14 +74,6 @@
74 */ 74 */
75 75
76/** 76/**
77 * enum ieee80211_notification_type - Low level driver notification
78 * @IEEE80211_NOTIFY_RE_ASSOC: start the re-association sequence
79 */
80enum ieee80211_notification_types {
81 IEEE80211_NOTIFY_RE_ASSOC,
82};
83
84/**
85 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics 77 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics
86 * 78 *
87 * This structure describes most essential parameters needed 79 * This structure describes most essential parameters needed
@@ -1798,18 +1790,6 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
1798 u16 tid); 1790 u16 tid);
1799 1791
1800/** 1792/**
1801 * ieee80211_notify_mac - low level driver notification
1802 * @hw: pointer as obtained from ieee80211_alloc_hw().
1803 * @notif_type: enum ieee80211_notification_types
1804 *
1805 * This function must be called by low level driver to inform mac80211 of
1806 * low level driver status change or force mac80211 to re-assoc for low
1807 * level driver internal error that require re-assoc.
1808 */
1809void ieee80211_notify_mac(struct ieee80211_hw *hw,
1810 enum ieee80211_notification_types notif_type);
1811
1812/**
1813 * ieee80211_find_sta - find a station 1793 * ieee80211_find_sta - find a station
1814 * 1794 *
1815 * @hw: pointer as obtained from ieee80211_alloc_hw() 1795 * @hw: pointer as obtained from ieee80211_alloc_hw()
diff --git a/include/net/sock.h b/include/net/sock.h
index c04f9e18ea22..2f47107f6d0f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -815,7 +815,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
815 */ 815 */
816#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ 816#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \
817do { \ 817do { \
818 sk->sk_lock.owned = 0; \ 818 sk->sk_lock.owned = 0; \
819 init_waitqueue_head(&sk->sk_lock.wq); \ 819 init_waitqueue_head(&sk->sk_lock.wq); \
820 spin_lock_init(&(sk)->sk_lock.slock); \ 820 spin_lock_init(&(sk)->sk_lock.slock); \
821 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ 821 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \
diff --git a/init/Kconfig b/init/Kconfig
index 2f850d800d94..f763762d544a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -771,8 +771,7 @@ config SLAB
771 help 771 help
772 The regular slab allocator that is established and known to work 772 The regular slab allocator that is established and known to work
773 well in all environments. It organizes cache hot objects in 773 well in all environments. It organizes cache hot objects in
774 per cpu and per node queues. SLAB is the default choice for 774 per cpu and per node queues.
775 a slab allocator.
776 775
777config SLUB 776config SLUB
778 bool "SLUB (Unqueued Allocator)" 777 bool "SLUB (Unqueued Allocator)"
@@ -781,7 +780,8 @@ config SLUB
781 instead of managing queues of cached objects (SLAB approach). 780 instead of managing queues of cached objects (SLAB approach).
782 Per cpu caching is realized using slabs of objects instead 781 Per cpu caching is realized using slabs of objects instead
783 of queues of objects. SLUB can use memory efficiently 782 of queues of objects. SLUB can use memory efficiently
784 and has enhanced diagnostics. 783 and has enhanced diagnostics. SLUB is the default choice for
784 a slab allocator.
785 785
786config SLOB 786config SLOB
787 depends on EMBEDDED 787 depends on EMBEDDED
diff --git a/ipc/util.c b/ipc/util.c
index 49b3ea615dc5..361fd1c96fcf 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -266,9 +266,17 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
266 if (ids->in_use >= size) 266 if (ids->in_use >= size)
267 return -ENOSPC; 267 return -ENOSPC;
268 268
269 spin_lock_init(&new->lock);
270 new->deleted = 0;
271 rcu_read_lock();
272 spin_lock(&new->lock);
273
269 err = idr_get_new(&ids->ipcs_idr, new, &id); 274 err = idr_get_new(&ids->ipcs_idr, new, &id);
270 if (err) 275 if (err) {
276 spin_unlock(&new->lock);
277 rcu_read_unlock();
271 return err; 278 return err;
279 }
272 280
273 ids->in_use++; 281 ids->in_use++;
274 282
@@ -280,10 +288,6 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
280 ids->seq = 0; 288 ids->seq = 0;
281 289
282 new->id = ipc_buildid(id, new->seq); 290 new->id = ipc_buildid(id, new->seq);
283 spin_lock_init(&new->lock);
284 new->deleted = 0;
285 rcu_read_lock();
286 spin_lock(&new->lock);
287 return id; 291 return id;
288} 292}
289 293
diff --git a/kernel/Makefile b/kernel/Makefile
index 9a3ec66a9d84..19fad003b19d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -11,8 +11,6 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ 11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
12 notifier.o ksysfs.o pm_qos_params.o sched_clock.o 12 notifier.o ksysfs.o pm_qos_params.o sched_clock.o
13 13
14CFLAGS_REMOVE_sched.o = -mno-spe
15
16ifdef CONFIG_FUNCTION_TRACER 14ifdef CONFIG_FUNCTION_TRACER
17# Do not trace debug files and internal ftrace files 15# Do not trace debug files and internal ftrace files
18CFLAGS_REMOVE_lockdep.o = -pg 16CFLAGS_REMOVE_lockdep.o = -pg
@@ -21,7 +19,7 @@ CFLAGS_REMOVE_mutex-debug.o = -pg
21CFLAGS_REMOVE_rtmutex-debug.o = -pg 19CFLAGS_REMOVE_rtmutex-debug.o = -pg
22CFLAGS_REMOVE_cgroup-debug.o = -pg 20CFLAGS_REMOVE_cgroup-debug.o = -pg
23CFLAGS_REMOVE_sched_clock.o = -pg 21CFLAGS_REMOVE_sched_clock.o = -pg
24CFLAGS_REMOVE_sched.o = -mno-spe -pg 22CFLAGS_REMOVE_sched.o = -pg
25endif 23endif
26 24
27obj-$(CONFIG_FREEZER) += freezer.o 25obj-$(CONFIG_FREEZER) += freezer.o
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 8ba0e0d934f2..8b509441f49a 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -24,6 +24,7 @@ struct audit_chunk {
24 struct list_head trees; /* with root here */ 24 struct list_head trees; /* with root here */
25 int dead; 25 int dead;
26 int count; 26 int count;
27 atomic_long_t refs;
27 struct rcu_head head; 28 struct rcu_head head;
28 struct node { 29 struct node {
29 struct list_head list; 30 struct list_head list;
@@ -56,7 +57,8 @@ static LIST_HEAD(prune_list);
56 * tree is refcounted; one reference for "some rules on rules_list refer to 57 * tree is refcounted; one reference for "some rules on rules_list refer to
57 * it", one for each chunk with pointer to it. 58 * it", one for each chunk with pointer to it.
58 * 59 *
59 * chunk is refcounted by embedded inotify_watch. 60 * chunk is refcounted by embedded inotify_watch + .refs (non-zero refcount
61 * of watch contributes 1 to .refs).
60 * 62 *
61 * node.index allows to get from node.list to containing chunk. 63 * node.index allows to get from node.list to containing chunk.
62 * MSB of that sucker is stolen to mark taggings that we might have to 64 * MSB of that sucker is stolen to mark taggings that we might have to
@@ -121,6 +123,7 @@ static struct audit_chunk *alloc_chunk(int count)
121 INIT_LIST_HEAD(&chunk->hash); 123 INIT_LIST_HEAD(&chunk->hash);
122 INIT_LIST_HEAD(&chunk->trees); 124 INIT_LIST_HEAD(&chunk->trees);
123 chunk->count = count; 125 chunk->count = count;
126 atomic_long_set(&chunk->refs, 1);
124 for (i = 0; i < count; i++) { 127 for (i = 0; i < count; i++) {
125 INIT_LIST_HEAD(&chunk->owners[i].list); 128 INIT_LIST_HEAD(&chunk->owners[i].list);
126 chunk->owners[i].index = i; 129 chunk->owners[i].index = i;
@@ -129,9 +132,8 @@ static struct audit_chunk *alloc_chunk(int count)
129 return chunk; 132 return chunk;
130} 133}
131 134
132static void __free_chunk(struct rcu_head *rcu) 135static void free_chunk(struct audit_chunk *chunk)
133{ 136{
134 struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head);
135 int i; 137 int i;
136 138
137 for (i = 0; i < chunk->count; i++) { 139 for (i = 0; i < chunk->count; i++) {
@@ -141,14 +143,16 @@ static void __free_chunk(struct rcu_head *rcu)
141 kfree(chunk); 143 kfree(chunk);
142} 144}
143 145
144static inline void free_chunk(struct audit_chunk *chunk) 146void audit_put_chunk(struct audit_chunk *chunk)
145{ 147{
146 call_rcu(&chunk->head, __free_chunk); 148 if (atomic_long_dec_and_test(&chunk->refs))
149 free_chunk(chunk);
147} 150}
148 151
149void audit_put_chunk(struct audit_chunk *chunk) 152static void __put_chunk(struct rcu_head *rcu)
150{ 153{
151 put_inotify_watch(&chunk->watch); 154 struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head);
155 audit_put_chunk(chunk);
152} 156}
153 157
154enum {HASH_SIZE = 128}; 158enum {HASH_SIZE = 128};
@@ -176,7 +180,7 @@ struct audit_chunk *audit_tree_lookup(const struct inode *inode)
176 180
177 list_for_each_entry_rcu(p, list, hash) { 181 list_for_each_entry_rcu(p, list, hash) {
178 if (p->watch.inode == inode) { 182 if (p->watch.inode == inode) {
179 get_inotify_watch(&p->watch); 183 atomic_long_inc(&p->refs);
180 return p; 184 return p;
181 } 185 }
182 } 186 }
@@ -194,17 +198,49 @@ int audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree)
194 198
195/* tagging and untagging inodes with trees */ 199/* tagging and untagging inodes with trees */
196 200
197static void untag_chunk(struct audit_chunk *chunk, struct node *p) 201static struct audit_chunk *find_chunk(struct node *p)
202{
203 int index = p->index & ~(1U<<31);
204 p -= index;
205 return container_of(p, struct audit_chunk, owners[0]);
206}
207
208static void untag_chunk(struct node *p)
198{ 209{
210 struct audit_chunk *chunk = find_chunk(p);
199 struct audit_chunk *new; 211 struct audit_chunk *new;
200 struct audit_tree *owner; 212 struct audit_tree *owner;
201 int size = chunk->count - 1; 213 int size = chunk->count - 1;
202 int i, j; 214 int i, j;
203 215
216 if (!pin_inotify_watch(&chunk->watch)) {
217 /*
218 * Filesystem is shutting down; all watches are getting
219 * evicted, just take it off the node list for this
220 * tree and let the eviction logics take care of the
221 * rest.
222 */
223 owner = p->owner;
224 if (owner->root == chunk) {
225 list_del_init(&owner->same_root);
226 owner->root = NULL;
227 }
228 list_del_init(&p->list);
229 p->owner = NULL;
230 put_tree(owner);
231 return;
232 }
233
234 spin_unlock(&hash_lock);
235
236 /*
237 * pin_inotify_watch() succeeded, so the watch won't go away
238 * from under us.
239 */
204 mutex_lock(&chunk->watch.inode->inotify_mutex); 240 mutex_lock(&chunk->watch.inode->inotify_mutex);
205 if (chunk->dead) { 241 if (chunk->dead) {
206 mutex_unlock(&chunk->watch.inode->inotify_mutex); 242 mutex_unlock(&chunk->watch.inode->inotify_mutex);
207 return; 243 goto out;
208 } 244 }
209 245
210 owner = p->owner; 246 owner = p->owner;
@@ -221,7 +257,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct node *p)
221 inotify_evict_watch(&chunk->watch); 257 inotify_evict_watch(&chunk->watch);
222 mutex_unlock(&chunk->watch.inode->inotify_mutex); 258 mutex_unlock(&chunk->watch.inode->inotify_mutex);
223 put_inotify_watch(&chunk->watch); 259 put_inotify_watch(&chunk->watch);
224 return; 260 goto out;
225 } 261 }
226 262
227 new = alloc_chunk(size); 263 new = alloc_chunk(size);
@@ -263,7 +299,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct node *p)
263 inotify_evict_watch(&chunk->watch); 299 inotify_evict_watch(&chunk->watch);
264 mutex_unlock(&chunk->watch.inode->inotify_mutex); 300 mutex_unlock(&chunk->watch.inode->inotify_mutex);
265 put_inotify_watch(&chunk->watch); 301 put_inotify_watch(&chunk->watch);
266 return; 302 goto out;
267 303
268Fallback: 304Fallback:
269 // do the best we can 305 // do the best we can
@@ -277,6 +313,9 @@ Fallback:
277 put_tree(owner); 313 put_tree(owner);
278 spin_unlock(&hash_lock); 314 spin_unlock(&hash_lock);
279 mutex_unlock(&chunk->watch.inode->inotify_mutex); 315 mutex_unlock(&chunk->watch.inode->inotify_mutex);
316out:
317 unpin_inotify_watch(&chunk->watch);
318 spin_lock(&hash_lock);
280} 319}
281 320
282static int create_chunk(struct inode *inode, struct audit_tree *tree) 321static int create_chunk(struct inode *inode, struct audit_tree *tree)
@@ -387,13 +426,6 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
387 return 0; 426 return 0;
388} 427}
389 428
390static struct audit_chunk *find_chunk(struct node *p)
391{
392 int index = p->index & ~(1U<<31);
393 p -= index;
394 return container_of(p, struct audit_chunk, owners[0]);
395}
396
397static void kill_rules(struct audit_tree *tree) 429static void kill_rules(struct audit_tree *tree)
398{ 430{
399 struct audit_krule *rule, *next; 431 struct audit_krule *rule, *next;
@@ -431,17 +463,10 @@ static void prune_one(struct audit_tree *victim)
431 spin_lock(&hash_lock); 463 spin_lock(&hash_lock);
432 while (!list_empty(&victim->chunks)) { 464 while (!list_empty(&victim->chunks)) {
433 struct node *p; 465 struct node *p;
434 struct audit_chunk *chunk;
435 466
436 p = list_entry(victim->chunks.next, struct node, list); 467 p = list_entry(victim->chunks.next, struct node, list);
437 chunk = find_chunk(p);
438 get_inotify_watch(&chunk->watch);
439 spin_unlock(&hash_lock);
440
441 untag_chunk(chunk, p);
442 468
443 put_inotify_watch(&chunk->watch); 469 untag_chunk(p);
444 spin_lock(&hash_lock);
445 } 470 }
446 spin_unlock(&hash_lock); 471 spin_unlock(&hash_lock);
447 put_tree(victim); 472 put_tree(victim);
@@ -469,7 +494,6 @@ static void trim_marked(struct audit_tree *tree)
469 494
470 while (!list_empty(&tree->chunks)) { 495 while (!list_empty(&tree->chunks)) {
471 struct node *node; 496 struct node *node;
472 struct audit_chunk *chunk;
473 497
474 node = list_entry(tree->chunks.next, struct node, list); 498 node = list_entry(tree->chunks.next, struct node, list);
475 499
@@ -477,14 +501,7 @@ static void trim_marked(struct audit_tree *tree)
477 if (!(node->index & (1U<<31))) 501 if (!(node->index & (1U<<31)))
478 break; 502 break;
479 503
480 chunk = find_chunk(node); 504 untag_chunk(node);
481 get_inotify_watch(&chunk->watch);
482 spin_unlock(&hash_lock);
483
484 untag_chunk(chunk, node);
485
486 put_inotify_watch(&chunk->watch);
487 spin_lock(&hash_lock);
488 } 505 }
489 if (!tree->root && !tree->goner) { 506 if (!tree->root && !tree->goner) {
490 tree->goner = 1; 507 tree->goner = 1;
@@ -878,7 +895,7 @@ static void handle_event(struct inotify_watch *watch, u32 wd, u32 mask,
878static void destroy_watch(struct inotify_watch *watch) 895static void destroy_watch(struct inotify_watch *watch)
879{ 896{
880 struct audit_chunk *chunk = container_of(watch, struct audit_chunk, watch); 897 struct audit_chunk *chunk = container_of(watch, struct audit_chunk, watch);
881 free_chunk(chunk); 898 call_rcu(&chunk->head, __put_chunk);
882} 899}
883 900
884static const struct inotify_operations rtree_inotify_ops = { 901static const struct inotify_operations rtree_inotify_ops = {
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index b7d354e2b0ef..9fd85a4640a0 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1094,8 +1094,8 @@ static void audit_inotify_unregister(struct list_head *in_list)
1094 list_for_each_entry_safe(p, n, in_list, ilist) { 1094 list_for_each_entry_safe(p, n, in_list, ilist) {
1095 list_del(&p->ilist); 1095 list_del(&p->ilist);
1096 inotify_rm_watch(audit_ih, &p->wdata); 1096 inotify_rm_watch(audit_ih, &p->wdata);
1097 /* the put matching the get in audit_do_del_rule() */ 1097 /* the unpin matching the pin in audit_do_del_rule() */
1098 put_inotify_watch(&p->wdata); 1098 unpin_inotify_watch(&p->wdata);
1099 } 1099 }
1100} 1100}
1101 1101
@@ -1389,9 +1389,13 @@ static inline int audit_del_rule(struct audit_entry *entry,
1389 /* Put parent on the inotify un-registration 1389 /* Put parent on the inotify un-registration
1390 * list. Grab a reference before releasing 1390 * list. Grab a reference before releasing
1391 * audit_filter_mutex, to be released in 1391 * audit_filter_mutex, to be released in
1392 * audit_inotify_unregister(). */ 1392 * audit_inotify_unregister().
1393 list_add(&parent->ilist, &inotify_list); 1393 * If filesystem is going away, just leave
1394 get_inotify_watch(&parent->wdata); 1394 * the sucker alone, eviction will take
1395 * care of it.
1396 */
1397 if (pin_inotify_watch(&parent->wdata))
1398 list_add(&parent->ilist, &inotify_list);
1395 } 1399 }
1396 } 1400 }
1397 } 1401 }
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e77564e6f..fe00b3b983a8 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2039,10 +2039,13 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
2039 struct cgroup *cgrp; 2039 struct cgroup *cgrp;
2040 struct cgroup_iter it; 2040 struct cgroup_iter it;
2041 struct task_struct *tsk; 2041 struct task_struct *tsk;
2042
2042 /* 2043 /*
2043 * Validate dentry by checking the superblock operations 2044 * Validate dentry by checking the superblock operations,
2045 * and make sure it's a directory.
2044 */ 2046 */
2045 if (dentry->d_sb->s_op != &cgroup_ops) 2047 if (dentry->d_sb->s_op != &cgroup_ops ||
2048 !S_ISDIR(dentry->d_inode->i_mode))
2046 goto err; 2049 goto err;
2047 2050
2048 ret = 0; 2051 ret = 0;
@@ -2472,10 +2475,7 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2472 mutex_unlock(&cgroup_mutex); 2475 mutex_unlock(&cgroup_mutex);
2473 return -EBUSY; 2476 return -EBUSY;
2474 } 2477 }
2475 2478 mutex_unlock(&cgroup_mutex);
2476 parent = cgrp->parent;
2477 root = cgrp->root;
2478 sb = root->sb;
2479 2479
2480 /* 2480 /*
2481 * Call pre_destroy handlers of subsys. Notify subsystems 2481 * Call pre_destroy handlers of subsys. Notify subsystems
@@ -2483,7 +2483,14 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2483 */ 2483 */
2484 cgroup_call_pre_destroy(cgrp); 2484 cgroup_call_pre_destroy(cgrp);
2485 2485
2486 if (cgroup_has_css_refs(cgrp)) { 2486 mutex_lock(&cgroup_mutex);
2487 parent = cgrp->parent;
2488 root = cgrp->root;
2489 sb = root->sb;
2490
2491 if (atomic_read(&cgrp->count)
2492 || !list_empty(&cgrp->children)
2493 || cgroup_has_css_refs(cgrp)) {
2487 mutex_unlock(&cgroup_mutex); 2494 mutex_unlock(&cgroup_mutex);
2488 return -EBUSY; 2495 return -EBUSY;
2489 } 2496 }
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 3e00526f52ec..da7ff6137f37 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -36,6 +36,7 @@
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/mempolicy.h> 37#include <linux/mempolicy.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/memory.h>
39#include <linux/module.h> 40#include <linux/module.h>
40#include <linux/mount.h> 41#include <linux/mount.h>
41#include <linux/namei.h> 42#include <linux/namei.h>
@@ -587,7 +588,6 @@ static int generate_sched_domains(cpumask_t **domains,
587 int ndoms; /* number of sched domains in result */ 588 int ndoms; /* number of sched domains in result */
588 int nslot; /* next empty doms[] cpumask_t slot */ 589 int nslot; /* next empty doms[] cpumask_t slot */
589 590
590 ndoms = 0;
591 doms = NULL; 591 doms = NULL;
592 dattr = NULL; 592 dattr = NULL;
593 csa = NULL; 593 csa = NULL;
@@ -674,10 +674,8 @@ restart:
674 * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. 674 * Convert <csn, csa> to <ndoms, doms> and populate cpu masks.
675 */ 675 */
676 doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); 676 doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL);
677 if (!doms) { 677 if (!doms)
678 ndoms = 0;
679 goto done; 678 goto done;
680 }
681 679
682 /* 680 /*
683 * The rest of the code, including the scheduler, can deal with 681 * The rest of the code, including the scheduler, can deal with
@@ -732,6 +730,13 @@ restart:
732done: 730done:
733 kfree(csa); 731 kfree(csa);
734 732
733 /*
734 * Fallback to the default domain if kmalloc() failed.
735 * See comments in partition_sched_domains().
736 */
737 if (doms == NULL)
738 ndoms = 1;
739
735 *domains = doms; 740 *domains = doms;
736 *attributes = dattr; 741 *attributes = dattr;
737 return ndoms; 742 return ndoms;
@@ -2011,12 +2016,23 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
2011 * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. 2016 * Call this routine anytime after node_states[N_HIGH_MEMORY] changes.
2012 * See also the previous routine cpuset_track_online_cpus(). 2017 * See also the previous routine cpuset_track_online_cpus().
2013 */ 2018 */
2014void cpuset_track_online_nodes(void) 2019static int cpuset_track_online_nodes(struct notifier_block *self,
2020 unsigned long action, void *arg)
2015{ 2021{
2016 cgroup_lock(); 2022 cgroup_lock();
2017 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; 2023 switch (action) {
2018 scan_for_empty_cpusets(&top_cpuset); 2024 case MEM_ONLINE:
2025 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2026 break;
2027 case MEM_OFFLINE:
2028 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2029 scan_for_empty_cpusets(&top_cpuset);
2030 break;
2031 default:
2032 break;
2033 }
2019 cgroup_unlock(); 2034 cgroup_unlock();
2035 return NOTIFY_OK;
2020} 2036}
2021#endif 2037#endif
2022 2038
@@ -2032,6 +2048,7 @@ void __init cpuset_init_smp(void)
2032 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; 2048 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2033 2049
2034 hotcpu_notifier(cpuset_track_online_cpus, 0); 2050 hotcpu_notifier(cpuset_track_online_cpus, 0);
2051 hotplug_memory_notifier(cpuset_track_online_nodes, 10);
2035} 2052}
2036 2053
2037/** 2054/**
diff --git a/kernel/exit.c b/kernel/exit.c
index b9c4d8bb72e5..30fcdf16737a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -40,7 +40,6 @@
40#include <linux/cn_proc.h> 40#include <linux/cn_proc.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/futex.h> 42#include <linux/futex.h>
43#include <linux/compat.h>
44#include <linux/pipe_fs_i.h> 43#include <linux/pipe_fs_i.h>
45#include <linux/audit.h> /* for audit_free() */ 44#include <linux/audit.h> /* for audit_free() */
46#include <linux/resource.h> 45#include <linux/resource.h>
@@ -1059,14 +1058,6 @@ NORET_TYPE void do_exit(long code)
1059 exit_itimers(tsk->signal); 1058 exit_itimers(tsk->signal);
1060 } 1059 }
1061 acct_collect(code, group_dead); 1060 acct_collect(code, group_dead);
1062#ifdef CONFIG_FUTEX
1063 if (unlikely(tsk->robust_list))
1064 exit_robust_list(tsk);
1065#ifdef CONFIG_COMPAT
1066 if (unlikely(tsk->compat_robust_list))
1067 compat_exit_robust_list(tsk);
1068#endif
1069#endif
1070 if (group_dead) 1061 if (group_dead)
1071 tty_audit_exit(); 1062 tty_audit_exit();
1072 if (unlikely(tsk->audit_context)) 1063 if (unlikely(tsk->audit_context))
diff --git a/kernel/extable.c b/kernel/extable.c
index a26cb2e17023..adf0cc9c02d6 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -66,3 +66,19 @@ int kernel_text_address(unsigned long addr)
66 return 1; 66 return 1;
67 return module_text_address(addr) != NULL; 67 return module_text_address(addr) != NULL;
68} 68}
69
70/*
71 * On some architectures (PPC64, IA64) function pointers
72 * are actually only tokens to some data that then holds the
73 * real function address. As a result, to find if a function
74 * pointer is part of the kernel text, we need to do some
75 * special dereferencing first.
76 */
77int func_ptr_is_kernel_text(void *ptr)
78{
79 unsigned long addr;
80 addr = (unsigned long) dereference_function_descriptor(ptr);
81 if (core_kernel_text(addr))
82 return 1;
83 return module_text_address(addr) != NULL;
84}
diff --git a/kernel/fork.c b/kernel/fork.c
index f6083561dfe0..2a372a0e206f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -40,6 +40,7 @@
40#include <linux/jiffies.h> 40#include <linux/jiffies.h>
41#include <linux/tracehook.h> 41#include <linux/tracehook.h>
42#include <linux/futex.h> 42#include <linux/futex.h>
43#include <linux/compat.h>
43#include <linux/task_io_accounting_ops.h> 44#include <linux/task_io_accounting_ops.h>
44#include <linux/rcupdate.h> 45#include <linux/rcupdate.h>
45#include <linux/ptrace.h> 46#include <linux/ptrace.h>
@@ -519,6 +520,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
519{ 520{
520 struct completion *vfork_done = tsk->vfork_done; 521 struct completion *vfork_done = tsk->vfork_done;
521 522
523 /* Get rid of any futexes when releasing the mm */
524#ifdef CONFIG_FUTEX
525 if (unlikely(tsk->robust_list))
526 exit_robust_list(tsk);
527#ifdef CONFIG_COMPAT
528 if (unlikely(tsk->compat_robust_list))
529 compat_exit_robust_list(tsk);
530#endif
531#endif
532
522 /* Get rid of any cached register state */ 533 /* Get rid of any cached register state */
523 deactivate_mm(tsk, mm); 534 deactivate_mm(tsk, mm);
524 535
diff --git a/kernel/futex.c b/kernel/futex.c
index 8af10027514b..e10c5c8786a6 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -123,24 +123,6 @@ struct futex_hash_bucket {
123static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; 123static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS];
124 124
125/* 125/*
126 * Take mm->mmap_sem, when futex is shared
127 */
128static inline void futex_lock_mm(struct rw_semaphore *fshared)
129{
130 if (fshared)
131 down_read(fshared);
132}
133
134/*
135 * Release mm->mmap_sem, when the futex is shared
136 */
137static inline void futex_unlock_mm(struct rw_semaphore *fshared)
138{
139 if (fshared)
140 up_read(fshared);
141}
142
143/*
144 * We hash on the keys returned from get_futex_key (see below). 126 * We hash on the keys returned from get_futex_key (see below).
145 */ 127 */
146static struct futex_hash_bucket *hash_futex(union futex_key *key) 128static struct futex_hash_bucket *hash_futex(union futex_key *key)
@@ -161,6 +143,45 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2)
161 && key1->both.offset == key2->both.offset); 143 && key1->both.offset == key2->both.offset);
162} 144}
163 145
146/*
147 * Take a reference to the resource addressed by a key.
148 * Can be called while holding spinlocks.
149 *
150 */
151static void get_futex_key_refs(union futex_key *key)
152{
153 if (!key->both.ptr)
154 return;
155
156 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
157 case FUT_OFF_INODE:
158 atomic_inc(&key->shared.inode->i_count);
159 break;
160 case FUT_OFF_MMSHARED:
161 atomic_inc(&key->private.mm->mm_count);
162 break;
163 }
164}
165
166/*
167 * Drop a reference to the resource addressed by a key.
168 * The hash bucket spinlock must not be held.
169 */
170static void drop_futex_key_refs(union futex_key *key)
171{
172 if (!key->both.ptr)
173 return;
174
175 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
176 case FUT_OFF_INODE:
177 iput(key->shared.inode);
178 break;
179 case FUT_OFF_MMSHARED:
180 mmdrop(key->private.mm);
181 break;
182 }
183}
184
164/** 185/**
165 * get_futex_key - Get parameters which are the keys for a futex. 186 * get_futex_key - Get parameters which are the keys for a futex.
166 * @uaddr: virtual address of the futex 187 * @uaddr: virtual address of the futex
@@ -179,12 +200,10 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2)
179 * For other futexes, it points to &current->mm->mmap_sem and 200 * For other futexes, it points to &current->mm->mmap_sem and
180 * caller must have taken the reader lock. but NOT any spinlocks. 201 * caller must have taken the reader lock. but NOT any spinlocks.
181 */ 202 */
182static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, 203static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key)
183 union futex_key *key)
184{ 204{
185 unsigned long address = (unsigned long)uaddr; 205 unsigned long address = (unsigned long)uaddr;
186 struct mm_struct *mm = current->mm; 206 struct mm_struct *mm = current->mm;
187 struct vm_area_struct *vma;
188 struct page *page; 207 struct page *page;
189 int err; 208 int err;
190 209
@@ -208,100 +227,50 @@ static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared,
208 return -EFAULT; 227 return -EFAULT;
209 key->private.mm = mm; 228 key->private.mm = mm;
210 key->private.address = address; 229 key->private.address = address;
230 get_futex_key_refs(key);
211 return 0; 231 return 0;
212 } 232 }
213 /*
214 * The futex is hashed differently depending on whether
215 * it's in a shared or private mapping. So check vma first.
216 */
217 vma = find_extend_vma(mm, address);
218 if (unlikely(!vma))
219 return -EFAULT;
220 233
221 /* 234again:
222 * Permissions. 235 err = get_user_pages_fast(address, 1, 0, &page);
223 */ 236 if (err < 0)
224 if (unlikely((vma->vm_flags & (VM_IO|VM_READ)) != VM_READ)) 237 return err;
225 return (vma->vm_flags & VM_IO) ? -EPERM : -EACCES; 238
239 lock_page(page);
240 if (!page->mapping) {
241 unlock_page(page);
242 put_page(page);
243 goto again;
244 }
226 245
227 /* 246 /*
228 * Private mappings are handled in a simple way. 247 * Private mappings are handled in a simple way.
229 * 248 *
230 * NOTE: When userspace waits on a MAP_SHARED mapping, even if 249 * NOTE: When userspace waits on a MAP_SHARED mapping, even if
231 * it's a read-only handle, it's expected that futexes attach to 250 * it's a read-only handle, it's expected that futexes attach to
232 * the object not the particular process. Therefore we use 251 * the object not the particular process.
233 * VM_MAYSHARE here, not VM_SHARED which is restricted to shared
234 * mappings of _writable_ handles.
235 */ 252 */
236 if (likely(!(vma->vm_flags & VM_MAYSHARE))) { 253 if (PageAnon(page)) {
237 key->both.offset |= FUT_OFF_MMSHARED; /* reference taken on mm */ 254 key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */
238 key->private.mm = mm; 255 key->private.mm = mm;
239 key->private.address = address; 256 key->private.address = address;
240 return 0; 257 } else {
258 key->both.offset |= FUT_OFF_INODE; /* inode-based key */
259 key->shared.inode = page->mapping->host;
260 key->shared.pgoff = page->index;
241 } 261 }
242 262
243 /* 263 get_futex_key_refs(key);
244 * Linear file mappings are also simple.
245 */
246 key->shared.inode = vma->vm_file->f_path.dentry->d_inode;
247 key->both.offset |= FUT_OFF_INODE; /* inode-based key. */
248 if (likely(!(vma->vm_flags & VM_NONLINEAR))) {
249 key->shared.pgoff = (((address - vma->vm_start) >> PAGE_SHIFT)
250 + vma->vm_pgoff);
251 return 0;
252 }
253 264
254 /* 265 unlock_page(page);
255 * We could walk the page table to read the non-linear 266 put_page(page);
256 * pte, and get the page index without fetching the page 267 return 0;
257 * from swap. But that's a lot of code to duplicate here
258 * for a rare case, so we simply fetch the page.
259 */
260 err = get_user_pages(current, mm, address, 1, 0, 0, &page, NULL);
261 if (err >= 0) {
262 key->shared.pgoff =
263 page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
264 put_page(page);
265 return 0;
266 }
267 return err;
268}
269
270/*
271 * Take a reference to the resource addressed by a key.
272 * Can be called while holding spinlocks.
273 *
274 */
275static void get_futex_key_refs(union futex_key *key)
276{
277 if (key->both.ptr == NULL)
278 return;
279 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
280 case FUT_OFF_INODE:
281 atomic_inc(&key->shared.inode->i_count);
282 break;
283 case FUT_OFF_MMSHARED:
284 atomic_inc(&key->private.mm->mm_count);
285 break;
286 }
287} 268}
288 269
289/* 270static inline
290 * Drop a reference to the resource addressed by a key. 271void put_futex_key(int fshared, union futex_key *key)
291 * The hash bucket spinlock must not be held.
292 */
293static void drop_futex_key_refs(union futex_key *key)
294{ 272{
295 if (!key->both.ptr) 273 drop_futex_key_refs(key);
296 return;
297 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
298 case FUT_OFF_INODE:
299 iput(key->shared.inode);
300 break;
301 case FUT_OFF_MMSHARED:
302 mmdrop(key->private.mm);
303 break;
304 }
305} 274}
306 275
307static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval) 276static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval)
@@ -328,10 +297,8 @@ static int get_futex_value_locked(u32 *dest, u32 __user *from)
328 297
329/* 298/*
330 * Fault handling. 299 * Fault handling.
331 * if fshared is non NULL, current->mm->mmap_sem is already held
332 */ 300 */
333static int futex_handle_fault(unsigned long address, 301static int futex_handle_fault(unsigned long address, int attempt)
334 struct rw_semaphore *fshared, int attempt)
335{ 302{
336 struct vm_area_struct * vma; 303 struct vm_area_struct * vma;
337 struct mm_struct *mm = current->mm; 304 struct mm_struct *mm = current->mm;
@@ -340,8 +307,7 @@ static int futex_handle_fault(unsigned long address,
340 if (attempt > 2) 307 if (attempt > 2)
341 return ret; 308 return ret;
342 309
343 if (!fshared) 310 down_read(&mm->mmap_sem);
344 down_read(&mm->mmap_sem);
345 vma = find_vma(mm, address); 311 vma = find_vma(mm, address);
346 if (vma && address >= vma->vm_start && 312 if (vma && address >= vma->vm_start &&
347 (vma->vm_flags & VM_WRITE)) { 313 (vma->vm_flags & VM_WRITE)) {
@@ -361,8 +327,7 @@ static int futex_handle_fault(unsigned long address,
361 current->min_flt++; 327 current->min_flt++;
362 } 328 }
363 } 329 }
364 if (!fshared) 330 up_read(&mm->mmap_sem);
365 up_read(&mm->mmap_sem);
366 return ret; 331 return ret;
367} 332}
368 333
@@ -385,6 +350,7 @@ static int refill_pi_state_cache(void)
385 /* pi_mutex gets initialized later */ 350 /* pi_mutex gets initialized later */
386 pi_state->owner = NULL; 351 pi_state->owner = NULL;
387 atomic_set(&pi_state->refcount, 1); 352 atomic_set(&pi_state->refcount, 1);
353 pi_state->key = FUTEX_KEY_INIT;
388 354
389 current->pi_state_cache = pi_state; 355 current->pi_state_cache = pi_state;
390 356
@@ -462,7 +428,7 @@ void exit_pi_state_list(struct task_struct *curr)
462 struct list_head *next, *head = &curr->pi_state_list; 428 struct list_head *next, *head = &curr->pi_state_list;
463 struct futex_pi_state *pi_state; 429 struct futex_pi_state *pi_state;
464 struct futex_hash_bucket *hb; 430 struct futex_hash_bucket *hb;
465 union futex_key key; 431 union futex_key key = FUTEX_KEY_INIT;
466 432
467 if (!futex_cmpxchg_enabled) 433 if (!futex_cmpxchg_enabled)
468 return; 434 return;
@@ -719,20 +685,17 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
719 * Wake up all waiters hashed on the physical page that is mapped 685 * Wake up all waiters hashed on the physical page that is mapped
720 * to this virtual address: 686 * to this virtual address:
721 */ 687 */
722static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared, 688static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset)
723 int nr_wake, u32 bitset)
724{ 689{
725 struct futex_hash_bucket *hb; 690 struct futex_hash_bucket *hb;
726 struct futex_q *this, *next; 691 struct futex_q *this, *next;
727 struct plist_head *head; 692 struct plist_head *head;
728 union futex_key key; 693 union futex_key key = FUTEX_KEY_INIT;
729 int ret; 694 int ret;
730 695
731 if (!bitset) 696 if (!bitset)
732 return -EINVAL; 697 return -EINVAL;
733 698
734 futex_lock_mm(fshared);
735
736 ret = get_futex_key(uaddr, fshared, &key); 699 ret = get_futex_key(uaddr, fshared, &key);
737 if (unlikely(ret != 0)) 700 if (unlikely(ret != 0))
738 goto out; 701 goto out;
@@ -760,7 +723,7 @@ static int futex_wake(u32 __user *uaddr, struct rw_semaphore *fshared,
760 723
761 spin_unlock(&hb->lock); 724 spin_unlock(&hb->lock);
762out: 725out:
763 futex_unlock_mm(fshared); 726 put_futex_key(fshared, &key);
764 return ret; 727 return ret;
765} 728}
766 729
@@ -769,19 +732,16 @@ out:
769 * to this virtual address: 732 * to this virtual address:
770 */ 733 */
771static int 734static int
772futex_wake_op(u32 __user *uaddr1, struct rw_semaphore *fshared, 735futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
773 u32 __user *uaddr2,
774 int nr_wake, int nr_wake2, int op) 736 int nr_wake, int nr_wake2, int op)
775{ 737{
776 union futex_key key1, key2; 738 union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT;
777 struct futex_hash_bucket *hb1, *hb2; 739 struct futex_hash_bucket *hb1, *hb2;
778 struct plist_head *head; 740 struct plist_head *head;
779 struct futex_q *this, *next; 741 struct futex_q *this, *next;
780 int ret, op_ret, attempt = 0; 742 int ret, op_ret, attempt = 0;
781 743
782retryfull: 744retryfull:
783 futex_lock_mm(fshared);
784
785 ret = get_futex_key(uaddr1, fshared, &key1); 745 ret = get_futex_key(uaddr1, fshared, &key1);
786 if (unlikely(ret != 0)) 746 if (unlikely(ret != 0))
787 goto out; 747 goto out;
@@ -826,18 +786,12 @@ retry:
826 */ 786 */
827 if (attempt++) { 787 if (attempt++) {
828 ret = futex_handle_fault((unsigned long)uaddr2, 788 ret = futex_handle_fault((unsigned long)uaddr2,
829 fshared, attempt); 789 attempt);
830 if (ret) 790 if (ret)
831 goto out; 791 goto out;
832 goto retry; 792 goto retry;
833 } 793 }
834 794
835 /*
836 * If we would have faulted, release mmap_sem,
837 * fault it in and start all over again.
838 */
839 futex_unlock_mm(fshared);
840
841 ret = get_user(dummy, uaddr2); 795 ret = get_user(dummy, uaddr2);
842 if (ret) 796 if (ret)
843 return ret; 797 return ret;
@@ -873,7 +827,8 @@ retry:
873 if (hb1 != hb2) 827 if (hb1 != hb2)
874 spin_unlock(&hb2->lock); 828 spin_unlock(&hb2->lock);
875out: 829out:
876 futex_unlock_mm(fshared); 830 put_futex_key(fshared, &key2);
831 put_futex_key(fshared, &key1);
877 832
878 return ret; 833 return ret;
879} 834}
@@ -882,19 +837,16 @@ out:
882 * Requeue all waiters hashed on one physical page to another 837 * Requeue all waiters hashed on one physical page to another
883 * physical page. 838 * physical page.
884 */ 839 */
885static int futex_requeue(u32 __user *uaddr1, struct rw_semaphore *fshared, 840static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2,
886 u32 __user *uaddr2,
887 int nr_wake, int nr_requeue, u32 *cmpval) 841 int nr_wake, int nr_requeue, u32 *cmpval)
888{ 842{
889 union futex_key key1, key2; 843 union futex_key key1 = FUTEX_KEY_INIT, key2 = FUTEX_KEY_INIT;
890 struct futex_hash_bucket *hb1, *hb2; 844 struct futex_hash_bucket *hb1, *hb2;
891 struct plist_head *head1; 845 struct plist_head *head1;
892 struct futex_q *this, *next; 846 struct futex_q *this, *next;
893 int ret, drop_count = 0; 847 int ret, drop_count = 0;
894 848
895 retry: 849 retry:
896 futex_lock_mm(fshared);
897
898 ret = get_futex_key(uaddr1, fshared, &key1); 850 ret = get_futex_key(uaddr1, fshared, &key1);
899 if (unlikely(ret != 0)) 851 if (unlikely(ret != 0))
900 goto out; 852 goto out;
@@ -917,12 +869,6 @@ static int futex_requeue(u32 __user *uaddr1, struct rw_semaphore *fshared,
917 if (hb1 != hb2) 869 if (hb1 != hb2)
918 spin_unlock(&hb2->lock); 870 spin_unlock(&hb2->lock);
919 871
920 /*
921 * If we would have faulted, release mmap_sem, fault
922 * it in and start all over again.
923 */
924 futex_unlock_mm(fshared);
925
926 ret = get_user(curval, uaddr1); 872 ret = get_user(curval, uaddr1);
927 873
928 if (!ret) 874 if (!ret)
@@ -974,7 +920,8 @@ out_unlock:
974 drop_futex_key_refs(&key1); 920 drop_futex_key_refs(&key1);
975 921
976out: 922out:
977 futex_unlock_mm(fshared); 923 put_futex_key(fshared, &key2);
924 put_futex_key(fshared, &key1);
978 return ret; 925 return ret;
979} 926}
980 927
@@ -1096,8 +1043,7 @@ static void unqueue_me_pi(struct futex_q *q)
1096 * private futexes. 1043 * private futexes.
1097 */ 1044 */
1098static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q, 1045static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
1099 struct task_struct *newowner, 1046 struct task_struct *newowner, int fshared)
1100 struct rw_semaphore *fshared)
1101{ 1047{
1102 u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS; 1048 u32 newtid = task_pid_vnr(newowner) | FUTEX_WAITERS;
1103 struct futex_pi_state *pi_state = q->pi_state; 1049 struct futex_pi_state *pi_state = q->pi_state;
@@ -1176,7 +1122,7 @@ retry:
1176handle_fault: 1122handle_fault:
1177 spin_unlock(q->lock_ptr); 1123 spin_unlock(q->lock_ptr);
1178 1124
1179 ret = futex_handle_fault((unsigned long)uaddr, fshared, attempt++); 1125 ret = futex_handle_fault((unsigned long)uaddr, attempt++);
1180 1126
1181 spin_lock(q->lock_ptr); 1127 spin_lock(q->lock_ptr);
1182 1128
@@ -1200,7 +1146,7 @@ handle_fault:
1200 1146
1201static long futex_wait_restart(struct restart_block *restart); 1147static long futex_wait_restart(struct restart_block *restart);
1202 1148
1203static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared, 1149static int futex_wait(u32 __user *uaddr, int fshared,
1204 u32 val, ktime_t *abs_time, u32 bitset) 1150 u32 val, ktime_t *abs_time, u32 bitset)
1205{ 1151{
1206 struct task_struct *curr = current; 1152 struct task_struct *curr = current;
@@ -1218,8 +1164,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1218 q.pi_state = NULL; 1164 q.pi_state = NULL;
1219 q.bitset = bitset; 1165 q.bitset = bitset;
1220 retry: 1166 retry:
1221 futex_lock_mm(fshared); 1167 q.key = FUTEX_KEY_INIT;
1222
1223 ret = get_futex_key(uaddr, fshared, &q.key); 1168 ret = get_futex_key(uaddr, fshared, &q.key);
1224 if (unlikely(ret != 0)) 1169 if (unlikely(ret != 0))
1225 goto out_release_sem; 1170 goto out_release_sem;
@@ -1251,12 +1196,6 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1251 if (unlikely(ret)) { 1196 if (unlikely(ret)) {
1252 queue_unlock(&q, hb); 1197 queue_unlock(&q, hb);
1253 1198
1254 /*
1255 * If we would have faulted, release mmap_sem, fault it in and
1256 * start all over again.
1257 */
1258 futex_unlock_mm(fshared);
1259
1260 ret = get_user(uval, uaddr); 1199 ret = get_user(uval, uaddr);
1261 1200
1262 if (!ret) 1201 if (!ret)
@@ -1271,12 +1210,6 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1271 queue_me(&q, hb); 1210 queue_me(&q, hb);
1272 1211
1273 /* 1212 /*
1274 * Now the futex is queued and we have checked the data, we
1275 * don't want to hold mmap_sem while we sleep.
1276 */
1277 futex_unlock_mm(fshared);
1278
1279 /*
1280 * There might have been scheduling since the queue_me(), as we 1213 * There might have been scheduling since the queue_me(), as we
1281 * cannot hold a spinlock across the get_user() in case it 1214 * cannot hold a spinlock across the get_user() in case it
1282 * faults, and we cannot just set TASK_INTERRUPTIBLE state when 1215 * faults, and we cannot just set TASK_INTERRUPTIBLE state when
@@ -1363,7 +1296,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1363 queue_unlock(&q, hb); 1296 queue_unlock(&q, hb);
1364 1297
1365 out_release_sem: 1298 out_release_sem:
1366 futex_unlock_mm(fshared); 1299 put_futex_key(fshared, &q.key);
1367 return ret; 1300 return ret;
1368} 1301}
1369 1302
@@ -1371,13 +1304,13 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1371static long futex_wait_restart(struct restart_block *restart) 1304static long futex_wait_restart(struct restart_block *restart)
1372{ 1305{
1373 u32 __user *uaddr = (u32 __user *)restart->futex.uaddr; 1306 u32 __user *uaddr = (u32 __user *)restart->futex.uaddr;
1374 struct rw_semaphore *fshared = NULL; 1307 int fshared = 0;
1375 ktime_t t; 1308 ktime_t t;
1376 1309
1377 t.tv64 = restart->futex.time; 1310 t.tv64 = restart->futex.time;
1378 restart->fn = do_no_restart_syscall; 1311 restart->fn = do_no_restart_syscall;
1379 if (restart->futex.flags & FLAGS_SHARED) 1312 if (restart->futex.flags & FLAGS_SHARED)
1380 fshared = &current->mm->mmap_sem; 1313 fshared = 1;
1381 return (long)futex_wait(uaddr, fshared, restart->futex.val, &t, 1314 return (long)futex_wait(uaddr, fshared, restart->futex.val, &t,
1382 restart->futex.bitset); 1315 restart->futex.bitset);
1383} 1316}
@@ -1389,7 +1322,7 @@ static long futex_wait_restart(struct restart_block *restart)
1389 * if there are waiters then it will block, it does PI, etc. (Due to 1322 * if there are waiters then it will block, it does PI, etc. (Due to
1390 * races the kernel might see a 0 value of the futex too.) 1323 * races the kernel might see a 0 value of the futex too.)
1391 */ 1324 */
1392static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared, 1325static int futex_lock_pi(u32 __user *uaddr, int fshared,
1393 int detect, ktime_t *time, int trylock) 1326 int detect, ktime_t *time, int trylock)
1394{ 1327{
1395 struct hrtimer_sleeper timeout, *to = NULL; 1328 struct hrtimer_sleeper timeout, *to = NULL;
@@ -1412,8 +1345,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1412 1345
1413 q.pi_state = NULL; 1346 q.pi_state = NULL;
1414 retry: 1347 retry:
1415 futex_lock_mm(fshared); 1348 q.key = FUTEX_KEY_INIT;
1416
1417 ret = get_futex_key(uaddr, fshared, &q.key); 1349 ret = get_futex_key(uaddr, fshared, &q.key);
1418 if (unlikely(ret != 0)) 1350 if (unlikely(ret != 0))
1419 goto out_release_sem; 1351 goto out_release_sem;
@@ -1502,7 +1434,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1502 * exit to complete. 1434 * exit to complete.
1503 */ 1435 */
1504 queue_unlock(&q, hb); 1436 queue_unlock(&q, hb);
1505 futex_unlock_mm(fshared);
1506 cond_resched(); 1437 cond_resched();
1507 goto retry; 1438 goto retry;
1508 1439
@@ -1534,12 +1465,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1534 */ 1465 */
1535 queue_me(&q, hb); 1466 queue_me(&q, hb);
1536 1467
1537 /*
1538 * Now the futex is queued and we have checked the data, we
1539 * don't want to hold mmap_sem while we sleep.
1540 */
1541 futex_unlock_mm(fshared);
1542
1543 WARN_ON(!q.pi_state); 1468 WARN_ON(!q.pi_state);
1544 /* 1469 /*
1545 * Block on the PI mutex: 1470 * Block on the PI mutex:
@@ -1552,7 +1477,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1552 ret = ret ? 0 : -EWOULDBLOCK; 1477 ret = ret ? 0 : -EWOULDBLOCK;
1553 } 1478 }
1554 1479
1555 futex_lock_mm(fshared);
1556 spin_lock(q.lock_ptr); 1480 spin_lock(q.lock_ptr);
1557 1481
1558 if (!ret) { 1482 if (!ret) {
@@ -1618,7 +1542,6 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1618 1542
1619 /* Unqueue and drop the lock */ 1543 /* Unqueue and drop the lock */
1620 unqueue_me_pi(&q); 1544 unqueue_me_pi(&q);
1621 futex_unlock_mm(fshared);
1622 1545
1623 if (to) 1546 if (to)
1624 destroy_hrtimer_on_stack(&to->timer); 1547 destroy_hrtimer_on_stack(&to->timer);
@@ -1628,7 +1551,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1628 queue_unlock(&q, hb); 1551 queue_unlock(&q, hb);
1629 1552
1630 out_release_sem: 1553 out_release_sem:
1631 futex_unlock_mm(fshared); 1554 put_futex_key(fshared, &q.key);
1632 if (to) 1555 if (to)
1633 destroy_hrtimer_on_stack(&to->timer); 1556 destroy_hrtimer_on_stack(&to->timer);
1634 return ret; 1557 return ret;
@@ -1645,15 +1568,12 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1645 queue_unlock(&q, hb); 1568 queue_unlock(&q, hb);
1646 1569
1647 if (attempt++) { 1570 if (attempt++) {
1648 ret = futex_handle_fault((unsigned long)uaddr, fshared, 1571 ret = futex_handle_fault((unsigned long)uaddr, attempt);
1649 attempt);
1650 if (ret) 1572 if (ret)
1651 goto out_release_sem; 1573 goto out_release_sem;
1652 goto retry_unlocked; 1574 goto retry_unlocked;
1653 } 1575 }
1654 1576
1655 futex_unlock_mm(fshared);
1656
1657 ret = get_user(uval, uaddr); 1577 ret = get_user(uval, uaddr);
1658 if (!ret && (uval != -EFAULT)) 1578 if (!ret && (uval != -EFAULT))
1659 goto retry; 1579 goto retry;
@@ -1668,13 +1588,13 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1668 * This is the in-kernel slowpath: we look up the PI state (if any), 1588 * This is the in-kernel slowpath: we look up the PI state (if any),
1669 * and do the rt-mutex unlock. 1589 * and do the rt-mutex unlock.
1670 */ 1590 */
1671static int futex_unlock_pi(u32 __user *uaddr, struct rw_semaphore *fshared) 1591static int futex_unlock_pi(u32 __user *uaddr, int fshared)
1672{ 1592{
1673 struct futex_hash_bucket *hb; 1593 struct futex_hash_bucket *hb;
1674 struct futex_q *this, *next; 1594 struct futex_q *this, *next;
1675 u32 uval; 1595 u32 uval;
1676 struct plist_head *head; 1596 struct plist_head *head;
1677 union futex_key key; 1597 union futex_key key = FUTEX_KEY_INIT;
1678 int ret, attempt = 0; 1598 int ret, attempt = 0;
1679 1599
1680retry: 1600retry:
@@ -1685,10 +1605,6 @@ retry:
1685 */ 1605 */
1686 if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) 1606 if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current))
1687 return -EPERM; 1607 return -EPERM;
1688 /*
1689 * First take all the futex related locks:
1690 */
1691 futex_lock_mm(fshared);
1692 1608
1693 ret = get_futex_key(uaddr, fshared, &key); 1609 ret = get_futex_key(uaddr, fshared, &key);
1694 if (unlikely(ret != 0)) 1610 if (unlikely(ret != 0))
@@ -1747,7 +1663,7 @@ retry_unlocked:
1747out_unlock: 1663out_unlock:
1748 spin_unlock(&hb->lock); 1664 spin_unlock(&hb->lock);
1749out: 1665out:
1750 futex_unlock_mm(fshared); 1666 put_futex_key(fshared, &key);
1751 1667
1752 return ret; 1668 return ret;
1753 1669
@@ -1763,16 +1679,13 @@ pi_faulted:
1763 spin_unlock(&hb->lock); 1679 spin_unlock(&hb->lock);
1764 1680
1765 if (attempt++) { 1681 if (attempt++) {
1766 ret = futex_handle_fault((unsigned long)uaddr, fshared, 1682 ret = futex_handle_fault((unsigned long)uaddr, attempt);
1767 attempt);
1768 if (ret) 1683 if (ret)
1769 goto out; 1684 goto out;
1770 uval = 0; 1685 uval = 0;
1771 goto retry_unlocked; 1686 goto retry_unlocked;
1772 } 1687 }
1773 1688
1774 futex_unlock_mm(fshared);
1775
1776 ret = get_user(uval, uaddr); 1689 ret = get_user(uval, uaddr);
1777 if (!ret && (uval != -EFAULT)) 1690 if (!ret && (uval != -EFAULT))
1778 goto retry; 1691 goto retry;
@@ -1898,8 +1811,7 @@ retry:
1898 * PI futexes happens in exit_pi_state(): 1811 * PI futexes happens in exit_pi_state():
1899 */ 1812 */
1900 if (!pi && (uval & FUTEX_WAITERS)) 1813 if (!pi && (uval & FUTEX_WAITERS))
1901 futex_wake(uaddr, &curr->mm->mmap_sem, 1, 1814 futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
1902 FUTEX_BITSET_MATCH_ANY);
1903 } 1815 }
1904 return 0; 1816 return 0;
1905} 1817}
@@ -1995,10 +1907,10 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
1995{ 1907{
1996 int ret = -ENOSYS; 1908 int ret = -ENOSYS;
1997 int cmd = op & FUTEX_CMD_MASK; 1909 int cmd = op & FUTEX_CMD_MASK;
1998 struct rw_semaphore *fshared = NULL; 1910 int fshared = 0;
1999 1911
2000 if (!(op & FUTEX_PRIVATE_FLAG)) 1912 if (!(op & FUTEX_PRIVATE_FLAG))
2001 fshared = &current->mm->mmap_sem; 1913 fshared = 1;
2002 1914
2003 switch (cmd) { 1915 switch (cmd) {
2004 case FUTEX_WAIT: 1916 case FUTEX_WAIT:
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 5072cf1685a2..7b8b0f21a5b1 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -304,17 +304,24 @@ int sprint_symbol(char *buffer, unsigned long address)
304 char *modname; 304 char *modname;
305 const char *name; 305 const char *name;
306 unsigned long offset, size; 306 unsigned long offset, size;
307 char namebuf[KSYM_NAME_LEN]; 307 int len;
308 308
309 name = kallsyms_lookup(address, &size, &offset, &modname, namebuf); 309 name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
310 if (!name) 310 if (!name)
311 return sprintf(buffer, "0x%lx", address); 311 return sprintf(buffer, "0x%lx", address);
312 312
313 if (name != buffer)
314 strcpy(buffer, name);
315 len = strlen(buffer);
316 buffer += len;
317
313 if (modname) 318 if (modname)
314 return sprintf(buffer, "%s+%#lx/%#lx [%s]", name, offset, 319 len += sprintf(buffer, "+%#lx/%#lx [%s]",
315 size, modname); 320 offset, size, modname);
316 else 321 else
317 return sprintf(buffer, "%s+%#lx/%#lx", name, offset, size); 322 len += sprintf(buffer, "+%#lx/%#lx", offset, size);
323
324 return len;
318} 325}
319 326
320/* Look up a kernel symbol and print it to the kernel messages. */ 327/* Look up a kernel symbol and print it to the kernel messages. */
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 06e157119d2b..e4bdda8dcf04 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -136,16 +136,16 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock)
136#ifdef CONFIG_LOCK_STAT 136#ifdef CONFIG_LOCK_STAT
137static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); 137static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats);
138 138
139static int lock_contention_point(struct lock_class *class, unsigned long ip) 139static int lock_point(unsigned long points[], unsigned long ip)
140{ 140{
141 int i; 141 int i;
142 142
143 for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) { 143 for (i = 0; i < LOCKSTAT_POINTS; i++) {
144 if (class->contention_point[i] == 0) { 144 if (points[i] == 0) {
145 class->contention_point[i] = ip; 145 points[i] = ip;
146 break; 146 break;
147 } 147 }
148 if (class->contention_point[i] == ip) 148 if (points[i] == ip)
149 break; 149 break;
150 } 150 }
151 151
@@ -185,6 +185,9 @@ struct lock_class_stats lock_stats(struct lock_class *class)
185 for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++) 185 for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++)
186 stats.contention_point[i] += pcs->contention_point[i]; 186 stats.contention_point[i] += pcs->contention_point[i];
187 187
188 for (i = 0; i < ARRAY_SIZE(stats.contending_point); i++)
189 stats.contending_point[i] += pcs->contending_point[i];
190
188 lock_time_add(&pcs->read_waittime, &stats.read_waittime); 191 lock_time_add(&pcs->read_waittime, &stats.read_waittime);
189 lock_time_add(&pcs->write_waittime, &stats.write_waittime); 192 lock_time_add(&pcs->write_waittime, &stats.write_waittime);
190 193
@@ -209,6 +212,7 @@ void clear_lock_stats(struct lock_class *class)
209 memset(cpu_stats, 0, sizeof(struct lock_class_stats)); 212 memset(cpu_stats, 0, sizeof(struct lock_class_stats));
210 } 213 }
211 memset(class->contention_point, 0, sizeof(class->contention_point)); 214 memset(class->contention_point, 0, sizeof(class->contention_point));
215 memset(class->contending_point, 0, sizeof(class->contending_point));
212} 216}
213 217
214static struct lock_class_stats *get_lock_stats(struct lock_class *class) 218static struct lock_class_stats *get_lock_stats(struct lock_class *class)
@@ -2999,7 +3003,7 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip)
2999 struct held_lock *hlock, *prev_hlock; 3003 struct held_lock *hlock, *prev_hlock;
3000 struct lock_class_stats *stats; 3004 struct lock_class_stats *stats;
3001 unsigned int depth; 3005 unsigned int depth;
3002 int i, point; 3006 int i, contention_point, contending_point;
3003 3007
3004 depth = curr->lockdep_depth; 3008 depth = curr->lockdep_depth;
3005 if (DEBUG_LOCKS_WARN_ON(!depth)) 3009 if (DEBUG_LOCKS_WARN_ON(!depth))
@@ -3023,18 +3027,22 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip)
3023found_it: 3027found_it:
3024 hlock->waittime_stamp = sched_clock(); 3028 hlock->waittime_stamp = sched_clock();
3025 3029
3026 point = lock_contention_point(hlock_class(hlock), ip); 3030 contention_point = lock_point(hlock_class(hlock)->contention_point, ip);
3031 contending_point = lock_point(hlock_class(hlock)->contending_point,
3032 lock->ip);
3027 3033
3028 stats = get_lock_stats(hlock_class(hlock)); 3034 stats = get_lock_stats(hlock_class(hlock));
3029 if (point < ARRAY_SIZE(stats->contention_point)) 3035 if (contention_point < LOCKSTAT_POINTS)
3030 stats->contention_point[point]++; 3036 stats->contention_point[contention_point]++;
3037 if (contending_point < LOCKSTAT_POINTS)
3038 stats->contending_point[contending_point]++;
3031 if (lock->cpu != smp_processor_id()) 3039 if (lock->cpu != smp_processor_id())
3032 stats->bounces[bounce_contended + !!hlock->read]++; 3040 stats->bounces[bounce_contended + !!hlock->read]++;
3033 put_lock_stats(stats); 3041 put_lock_stats(stats);
3034} 3042}
3035 3043
3036static void 3044static void
3037__lock_acquired(struct lockdep_map *lock) 3045__lock_acquired(struct lockdep_map *lock, unsigned long ip)
3038{ 3046{
3039 struct task_struct *curr = current; 3047 struct task_struct *curr = current;
3040 struct held_lock *hlock, *prev_hlock; 3048 struct held_lock *hlock, *prev_hlock;
@@ -3083,6 +3091,7 @@ found_it:
3083 put_lock_stats(stats); 3091 put_lock_stats(stats);
3084 3092
3085 lock->cpu = cpu; 3093 lock->cpu = cpu;
3094 lock->ip = ip;
3086} 3095}
3087 3096
3088void lock_contended(struct lockdep_map *lock, unsigned long ip) 3097void lock_contended(struct lockdep_map *lock, unsigned long ip)
@@ -3104,7 +3113,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
3104} 3113}
3105EXPORT_SYMBOL_GPL(lock_contended); 3114EXPORT_SYMBOL_GPL(lock_contended);
3106 3115
3107void lock_acquired(struct lockdep_map *lock) 3116void lock_acquired(struct lockdep_map *lock, unsigned long ip)
3108{ 3117{
3109 unsigned long flags; 3118 unsigned long flags;
3110 3119
@@ -3117,7 +3126,7 @@ void lock_acquired(struct lockdep_map *lock)
3117 raw_local_irq_save(flags); 3126 raw_local_irq_save(flags);
3118 check_flags(flags); 3127 check_flags(flags);
3119 current->lockdep_recursion = 1; 3128 current->lockdep_recursion = 1;
3120 __lock_acquired(lock); 3129 __lock_acquired(lock, ip);
3121 current->lockdep_recursion = 0; 3130 current->lockdep_recursion = 0;
3122 raw_local_irq_restore(flags); 3131 raw_local_irq_restore(flags);
3123} 3132}
@@ -3276,10 +3285,10 @@ void __init lockdep_info(void)
3276{ 3285{
3277 printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); 3286 printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n");
3278 3287
3279 printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); 3288 printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES);
3280 printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); 3289 printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH);
3281 printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS); 3290 printk("... MAX_LOCKDEP_KEYS: %lu\n", MAX_LOCKDEP_KEYS);
3282 printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); 3291 printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE);
3283 printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); 3292 printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES);
3284 printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); 3293 printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS);
3285 printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); 3294 printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE);
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 20dbcbf9c7dd..13716b813896 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -470,11 +470,12 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)
470 470
471static void snprint_time(char *buf, size_t bufsiz, s64 nr) 471static void snprint_time(char *buf, size_t bufsiz, s64 nr)
472{ 472{
473 unsigned long rem; 473 s64 div;
474 s32 rem;
474 475
475 nr += 5; /* for display rounding */ 476 nr += 5; /* for display rounding */
476 rem = do_div(nr, 1000); /* XXX: do_div_signed */ 477 div = div_s64_rem(nr, 1000, &rem);
477 snprintf(buf, bufsiz, "%lld.%02d", (long long)nr, (int)rem/10); 478 snprintf(buf, bufsiz, "%lld.%02d", (long long)div, (int)rem/10);
478} 479}
479 480
480static void seq_time(struct seq_file *m, s64 time) 481static void seq_time(struct seq_file *m, s64 time)
@@ -556,7 +557,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
556 if (stats->read_holdtime.nr) 557 if (stats->read_holdtime.nr)
557 namelen += 2; 558 namelen += 2;
558 559
559 for (i = 0; i < ARRAY_SIZE(class->contention_point); i++) { 560 for (i = 0; i < LOCKSTAT_POINTS; i++) {
560 char sym[KSYM_SYMBOL_LEN]; 561 char sym[KSYM_SYMBOL_LEN];
561 char ip[32]; 562 char ip[32];
562 563
@@ -573,6 +574,23 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
573 stats->contention_point[i], 574 stats->contention_point[i],
574 ip, sym); 575 ip, sym);
575 } 576 }
577 for (i = 0; i < LOCKSTAT_POINTS; i++) {
578 char sym[KSYM_SYMBOL_LEN];
579 char ip[32];
580
581 if (class->contending_point[i] == 0)
582 break;
583
584 if (!i)
585 seq_line(m, '-', 40-namelen, namelen);
586
587 sprint_symbol(sym, class->contending_point[i]);
588 snprintf(ip, sizeof(ip), "[<%p>]",
589 (void *)class->contending_point[i]);
590 seq_printf(m, "%40s %14lu %29s %s\n", name,
591 stats->contending_point[i],
592 ip, sym);
593 }
576 if (i) { 594 if (i) {
577 seq_puts(m, "\n"); 595 seq_puts(m, "\n");
578 seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1)); 596 seq_line(m, '.', 0, 40 + 1 + 10 * (14 + 1));
@@ -582,7 +600,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
582 600
583static void seq_header(struct seq_file *m) 601static void seq_header(struct seq_file *m)
584{ 602{
585 seq_printf(m, "lock_stat version 0.2\n"); 603 seq_printf(m, "lock_stat version 0.3\n");
586 seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1)); 604 seq_line(m, '-', 0, 40 + 1 + 10 * (14 + 1));
587 seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s " 605 seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s "
588 "%14s %14s\n", 606 "%14s %14s\n",
diff --git a/kernel/mutex.c b/kernel/mutex.c
index 12c779dc65d4..4f45d4b658ef 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -59,7 +59,7 @@ EXPORT_SYMBOL(__mutex_init);
59 * We also put the fastpath first in the kernel image, to make sure the 59 * We also put the fastpath first in the kernel image, to make sure the
60 * branch is predicted by the CPU as default-untaken. 60 * branch is predicted by the CPU as default-untaken.
61 */ 61 */
62static void noinline __sched 62static __used noinline void __sched
63__mutex_lock_slowpath(atomic_t *lock_count); 63__mutex_lock_slowpath(atomic_t *lock_count);
64 64
65/*** 65/***
@@ -96,7 +96,7 @@ void inline __sched mutex_lock(struct mutex *lock)
96EXPORT_SYMBOL(mutex_lock); 96EXPORT_SYMBOL(mutex_lock);
97#endif 97#endif
98 98
99static noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count); 99static __used noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
100 100
101/*** 101/***
102 * mutex_unlock - release the mutex 102 * mutex_unlock - release the mutex
@@ -184,7 +184,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
184 } 184 }
185 185
186done: 186done:
187 lock_acquired(&lock->dep_map); 187 lock_acquired(&lock->dep_map, ip);
188 /* got the lock - rejoice! */ 188 /* got the lock - rejoice! */
189 mutex_remove_waiter(lock, &waiter, task_thread_info(task)); 189 mutex_remove_waiter(lock, &waiter, task_thread_info(task));
190 debug_mutex_set_owner(lock, task_thread_info(task)); 190 debug_mutex_set_owner(lock, task_thread_info(task));
@@ -268,7 +268,7 @@ __mutex_unlock_common_slowpath(atomic_t *lock_count, int nested)
268/* 268/*
269 * Release the lock, slowpath: 269 * Release the lock, slowpath:
270 */ 270 */
271static noinline void 271static __used noinline void
272__mutex_unlock_slowpath(atomic_t *lock_count) 272__mutex_unlock_slowpath(atomic_t *lock_count)
273{ 273{
274 __mutex_unlock_common_slowpath(lock_count, 1); 274 __mutex_unlock_common_slowpath(lock_count, 1);
@@ -313,7 +313,7 @@ int __sched mutex_lock_killable(struct mutex *lock)
313} 313}
314EXPORT_SYMBOL(mutex_lock_killable); 314EXPORT_SYMBOL(mutex_lock_killable);
315 315
316static noinline void __sched 316static __used noinline void __sched
317__mutex_lock_slowpath(atomic_t *lock_count) 317__mutex_lock_slowpath(atomic_t *lock_count)
318{ 318{
319 struct mutex *lock = container_of(lock_count, struct mutex, count); 319 struct mutex *lock = container_of(lock_count, struct mutex, count);
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 4282c0a40a57..61d5aa5eced3 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -82,6 +82,14 @@ static int __kprobes notifier_call_chain(struct notifier_block **nl,
82 82
83 while (nb && nr_to_call) { 83 while (nb && nr_to_call) {
84 next_nb = rcu_dereference(nb->next); 84 next_nb = rcu_dereference(nb->next);
85
86#ifdef CONFIG_DEBUG_NOTIFIERS
87 if (unlikely(!func_ptr_is_kernel_text(nb->notifier_call))) {
88 WARN(1, "Invalid notifier called!");
89 nb = next_nb;
90 continue;
91 }
92#endif
85 ret = nb->notifier_call(nb, val, v); 93 ret = nb->notifier_call(nb, val, v);
86 94
87 if (nr_calls) 95 if (nr_calls)
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 19122cf6d827..b8f7ce9473e8 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -174,7 +174,7 @@ static void suspend_test_finish(const char *label)
174 * has some performance issues. The stack dump of a WARN_ON 174 * has some performance issues. The stack dump of a WARN_ON
175 * is more likely to get the right attention than a printk... 175 * is more likely to get the right attention than a printk...
176 */ 176 */
177 WARN_ON(msec > (TEST_SUSPEND_SECONDS * 1000)); 177 WARN(msec > (TEST_SUSPEND_SECONDS * 1000), "Component: %s\n", label);
178} 178}
179 179
180#else 180#else
diff --git a/kernel/profile.c b/kernel/profile.c
index 9830a037d8db..5b7d1ac7124c 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -544,7 +544,7 @@ static const struct file_operations proc_profile_operations = {
544}; 544};
545 545
546#ifdef CONFIG_SMP 546#ifdef CONFIG_SMP
547static void __init profile_nop(void *unused) 547static inline void profile_nop(void *unused)
548{ 548{
549} 549}
550 550
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
index 37f72e551542..e503a002f330 100644
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@ -191,7 +191,7 @@ static void print_other_cpu_stall(struct rcu_ctrlblk *rcp)
191 191
192 /* OK, time to rat on our buddy... */ 192 /* OK, time to rat on our buddy... */
193 193
194 printk(KERN_ERR "RCU detected CPU stalls:"); 194 printk(KERN_ERR "INFO: RCU detected CPU stalls:");
195 for_each_possible_cpu(cpu) { 195 for_each_possible_cpu(cpu) {
196 if (cpu_isset(cpu, rcp->cpumask)) 196 if (cpu_isset(cpu, rcp->cpumask))
197 printk(" %d", cpu); 197 printk(" %d", cpu);
@@ -204,7 +204,7 @@ static void print_cpu_stall(struct rcu_ctrlblk *rcp)
204{ 204{
205 unsigned long flags; 205 unsigned long flags;
206 206
207 printk(KERN_ERR "RCU detected CPU %d stall (t=%lu/%lu jiffies)\n", 207 printk(KERN_ERR "INFO: RCU detected CPU %d stall (t=%lu/%lu jiffies)\n",
208 smp_processor_id(), jiffies, 208 smp_processor_id(), jiffies,
209 jiffies - rcp->gp_start); 209 jiffies - rcp->gp_start);
210 dump_stack(); 210 dump_stack();
diff --git a/kernel/relay.c b/kernel/relay.c
index 8d13a7855c08..32b0befdcb6a 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -400,7 +400,7 @@ void relay_reset(struct rchan *chan)
400 } 400 }
401 401
402 mutex_lock(&relay_channels_mutex); 402 mutex_lock(&relay_channels_mutex);
403 for_each_online_cpu(i) 403 for_each_possible_cpu(i)
404 if (chan->buf[i]) 404 if (chan->buf[i])
405 __relay_reset(chan->buf[i], 0); 405 __relay_reset(chan->buf[i], 0);
406 mutex_unlock(&relay_channels_mutex); 406 mutex_unlock(&relay_channels_mutex);
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *base_filename,
611 return chan; 611 return chan;
612 612
613free_bufs: 613free_bufs:
614 for_each_online_cpu(i) { 614 for_each_possible_cpu(i) {
615 if (!chan->buf[i]) 615 if (chan->buf[i])
616 break; 616 relay_close_buf(chan->buf[i]);
617 relay_close_buf(chan->buf[i]);
618 } 617 }
619 618
620 kref_put(&chan->kref, relay_destroy_channel); 619 kref_put(&chan->kref, relay_destroy_channel);
diff --git a/kernel/sched.c b/kernel/sched.c
index b388c9b243e9..558e5f284269 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4337,7 +4337,7 @@ void __kprobes sub_preempt_count(int val)
4337 /* 4337 /*
4338 * Underflow? 4338 * Underflow?
4339 */ 4339 */
4340 if (DEBUG_LOCKS_WARN_ON(val > preempt_count())) 4340 if (DEBUG_LOCKS_WARN_ON(val > preempt_count() - (!!kernel_locked())))
4341 return; 4341 return;
4342 /* 4342 /*
4343 * Is the spinlock portion underflowing? 4343 * Is the spinlock portion underflowing?
@@ -7788,13 +7788,14 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur,
7788 * 7788 *
7789 * The passed in 'doms_new' should be kmalloc'd. This routine takes 7789 * The passed in 'doms_new' should be kmalloc'd. This routine takes
7790 * ownership of it and will kfree it when done with it. If the caller 7790 * ownership of it and will kfree it when done with it. If the caller
7791 * failed the kmalloc call, then it can pass in doms_new == NULL, 7791 * failed the kmalloc call, then it can pass in doms_new == NULL &&
7792 * and partition_sched_domains() will fallback to the single partition 7792 * ndoms_new == 1, and partition_sched_domains() will fallback to
7793 * 'fallback_doms', it also forces the domains to be rebuilt. 7793 * the single partition 'fallback_doms', it also forces the domains
7794 * to be rebuilt.
7794 * 7795 *
7795 * If doms_new==NULL it will be replaced with cpu_online_map. 7796 * If doms_new == NULL it will be replaced with cpu_online_map.
7796 * ndoms_new==0 is a special case for destroying existing domains. 7797 * ndoms_new == 0 is a special case for destroying existing domains,
7797 * It will not create the default domain. 7798 * and it will not create the default domain.
7798 * 7799 *
7799 * Call with hotplug lock held 7800 * Call with hotplug lock held
7800 */ 7801 */
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 3953e4aed733..884e6cd2769c 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -164,7 +164,7 @@ unsigned long __read_mostly sysctl_hung_task_check_count = 1024;
164/* 164/*
165 * Zero means infinite timeout - no checking done: 165 * Zero means infinite timeout - no checking done:
166 */ 166 */
167unsigned long __read_mostly sysctl_hung_task_timeout_secs = 120; 167unsigned long __read_mostly sysctl_hung_task_timeout_secs = 480;
168 168
169unsigned long __read_mostly sysctl_hung_task_warnings = 10; 169unsigned long __read_mostly sysctl_hung_task_warnings = 10;
170 170
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 9bc4c00872c9..24e8ceacc388 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -112,7 +112,7 @@ static int chill(void *unused)
112int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) 112int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
113{ 113{
114 struct work_struct *sm_work; 114 struct work_struct *sm_work;
115 int i; 115 int i, ret;
116 116
117 /* Set up initial state. */ 117 /* Set up initial state. */
118 mutex_lock(&lock); 118 mutex_lock(&lock);
@@ -137,8 +137,9 @@ int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
137 /* This will release the thread on our CPU. */ 137 /* This will release the thread on our CPU. */
138 put_cpu(); 138 put_cpu();
139 flush_workqueue(stop_machine_wq); 139 flush_workqueue(stop_machine_wq);
140 ret = active.fnret;
140 mutex_unlock(&lock); 141 mutex_unlock(&lock);
141 return active.fnret; 142 return ret;
142} 143}
143 144
144int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) 145int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index a77b27b11b04..e14a23281707 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -31,7 +31,7 @@ cond_syscall(sys_socketpair);
31cond_syscall(sys_bind); 31cond_syscall(sys_bind);
32cond_syscall(sys_listen); 32cond_syscall(sys_listen);
33cond_syscall(sys_accept); 33cond_syscall(sys_accept);
34cond_syscall(sys_paccept); 34cond_syscall(sys_accept4);
35cond_syscall(sys_connect); 35cond_syscall(sys_connect);
36cond_syscall(sys_getsockname); 36cond_syscall(sys_getsockname);
37cond_syscall(sys_getpeername); 37cond_syscall(sys_getpeername);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4a39d24568c8..78db083390f0 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -185,7 +185,6 @@ enum {
185}; 185};
186 186
187static int ftrace_filtered; 187static int ftrace_filtered;
188static int tracing_on;
189 188
190static LIST_HEAD(ftrace_new_addrs); 189static LIST_HEAD(ftrace_new_addrs);
191 190
@@ -327,96 +326,89 @@ ftrace_record_ip(unsigned long ip)
327 326
328static int 327static int
329__ftrace_replace_code(struct dyn_ftrace *rec, 328__ftrace_replace_code(struct dyn_ftrace *rec,
330 unsigned char *old, unsigned char *new, int enable) 329 unsigned char *nop, int enable)
331{ 330{
332 unsigned long ip, fl; 331 unsigned long ip, fl;
332 unsigned char *call, *old, *new;
333 333
334 ip = rec->ip; 334 ip = rec->ip;
335 335
336 if (ftrace_filtered && enable) { 336 /*
337 * If this record is not to be traced and
338 * it is not enabled then do nothing.
339 *
340 * If this record is not to be traced and
341 * it is enabled then disabled it.
342 *
343 */
344 if (rec->flags & FTRACE_FL_NOTRACE) {
345 if (rec->flags & FTRACE_FL_ENABLED)
346 rec->flags &= ~FTRACE_FL_ENABLED;
347 else
348 return 0;
349
350 } else if (ftrace_filtered && enable) {
337 /* 351 /*
338 * If filtering is on: 352 * Filtering is on:
339 *
340 * If this record is set to be filtered and
341 * is enabled then do nothing.
342 *
343 * If this record is set to be filtered and
344 * it is not enabled, enable it.
345 *
346 * If this record is not set to be filtered
347 * and it is not enabled do nothing.
348 *
349 * If this record is set not to trace then
350 * do nothing.
351 *
352 * If this record is set not to trace and
353 * it is enabled then disable it.
354 *
355 * If this record is not set to be filtered and
356 * it is enabled, disable it.
357 */ 353 */
358 354
359 fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE | 355 fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED);
360 FTRACE_FL_ENABLED);
361 356
362 if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) || 357 /* Record is filtered and enabled, do nothing */
363 (fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) || 358 if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED))
364 !fl || (fl == FTRACE_FL_NOTRACE))
365 return 0; 359 return 0;
366 360
367 /* 361 /* Record is not filtered and is not enabled do nothing */
368 * If it is enabled disable it, 362 if (!fl)
369 * otherwise enable it! 363 return 0;
370 */ 364
371 if (fl & FTRACE_FL_ENABLED) { 365 /* Record is not filtered but enabled, disable it */
372 /* swap new and old */ 366 if (fl == FTRACE_FL_ENABLED)
373 new = old;
374 old = ftrace_call_replace(ip, FTRACE_ADDR);
375 rec->flags &= ~FTRACE_FL_ENABLED; 367 rec->flags &= ~FTRACE_FL_ENABLED;
376 } else { 368 else
377 new = ftrace_call_replace(ip, FTRACE_ADDR); 369 /* Otherwise record is filtered but not enabled, enable it */
378 rec->flags |= FTRACE_FL_ENABLED; 370 rec->flags |= FTRACE_FL_ENABLED;
379 }
380 } else { 371 } else {
372 /* Disable or not filtered */
381 373
382 if (enable) { 374 if (enable) {
383 /* 375 /* if record is enabled, do nothing */
384 * If this record is set not to trace and is
385 * not enabled, do nothing.
386 */
387 fl = rec->flags & (FTRACE_FL_NOTRACE | FTRACE_FL_ENABLED);
388 if (fl == FTRACE_FL_NOTRACE)
389 return 0;
390
391 new = ftrace_call_replace(ip, FTRACE_ADDR);
392 } else
393 old = ftrace_call_replace(ip, FTRACE_ADDR);
394
395 if (enable) {
396 if (rec->flags & FTRACE_FL_ENABLED) 376 if (rec->flags & FTRACE_FL_ENABLED)
397 return 0; 377 return 0;
378
398 rec->flags |= FTRACE_FL_ENABLED; 379 rec->flags |= FTRACE_FL_ENABLED;
380
399 } else { 381 } else {
382
383 /* if record is not enabled do nothing */
400 if (!(rec->flags & FTRACE_FL_ENABLED)) 384 if (!(rec->flags & FTRACE_FL_ENABLED))
401 return 0; 385 return 0;
386
402 rec->flags &= ~FTRACE_FL_ENABLED; 387 rec->flags &= ~FTRACE_FL_ENABLED;
403 } 388 }
404 } 389 }
405 390
391 call = ftrace_call_replace(ip, FTRACE_ADDR);
392
393 if (rec->flags & FTRACE_FL_ENABLED) {
394 old = nop;
395 new = call;
396 } else {
397 old = call;
398 new = nop;
399 }
400
406 return ftrace_modify_code(ip, old, new); 401 return ftrace_modify_code(ip, old, new);
407} 402}
408 403
409static void ftrace_replace_code(int enable) 404static void ftrace_replace_code(int enable)
410{ 405{
411 int i, failed; 406 int i, failed;
412 unsigned char *new = NULL, *old = NULL; 407 unsigned char *nop = NULL;
413 struct dyn_ftrace *rec; 408 struct dyn_ftrace *rec;
414 struct ftrace_page *pg; 409 struct ftrace_page *pg;
415 410
416 if (enable) 411 nop = ftrace_nop_replace();
417 old = ftrace_nop_replace();
418 else
419 new = ftrace_nop_replace();
420 412
421 for (pg = ftrace_pages_start; pg; pg = pg->next) { 413 for (pg = ftrace_pages_start; pg; pg = pg->next) {
422 for (i = 0; i < pg->index; i++) { 414 for (i = 0; i < pg->index; i++) {
@@ -434,7 +426,7 @@ static void ftrace_replace_code(int enable)
434 unfreeze_record(rec); 426 unfreeze_record(rec);
435 } 427 }
436 428
437 failed = __ftrace_replace_code(rec, old, new, enable); 429 failed = __ftrace_replace_code(rec, nop, enable);
438 if (failed && (rec->flags & FTRACE_FL_CONVERTED)) { 430 if (failed && (rec->flags & FTRACE_FL_CONVERTED)) {
439 rec->flags |= FTRACE_FL_FAILED; 431 rec->flags |= FTRACE_FL_FAILED;
440 if ((system_state == SYSTEM_BOOTING) || 432 if ((system_state == SYSTEM_BOOTING) ||
@@ -506,13 +498,10 @@ static int __ftrace_modify_code(void *data)
506{ 498{
507 int *command = data; 499 int *command = data;
508 500
509 if (*command & FTRACE_ENABLE_CALLS) { 501 if (*command & FTRACE_ENABLE_CALLS)
510 ftrace_replace_code(1); 502 ftrace_replace_code(1);
511 tracing_on = 1; 503 else if (*command & FTRACE_DISABLE_CALLS)
512 } else if (*command & FTRACE_DISABLE_CALLS) {
513 ftrace_replace_code(0); 504 ftrace_replace_code(0);
514 tracing_on = 0;
515 }
516 505
517 if (*command & FTRACE_UPDATE_TRACE_FUNC) 506 if (*command & FTRACE_UPDATE_TRACE_FUNC)
518 ftrace_update_ftrace_func(ftrace_trace_function); 507 ftrace_update_ftrace_func(ftrace_trace_function);
@@ -538,8 +527,7 @@ static void ftrace_startup(void)
538 527
539 mutex_lock(&ftrace_start_lock); 528 mutex_lock(&ftrace_start_lock);
540 ftrace_start++; 529 ftrace_start++;
541 if (ftrace_start == 1) 530 command |= FTRACE_ENABLE_CALLS;
542 command |= FTRACE_ENABLE_CALLS;
543 531
544 if (saved_ftrace_func != ftrace_trace_function) { 532 if (saved_ftrace_func != ftrace_trace_function) {
545 saved_ftrace_func = ftrace_trace_function; 533 saved_ftrace_func = ftrace_trace_function;
@@ -677,7 +665,7 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
677 665
678 cnt = num_to_init / ENTRIES_PER_PAGE; 666 cnt = num_to_init / ENTRIES_PER_PAGE;
679 pr_info("ftrace: allocating %ld entries in %d pages\n", 667 pr_info("ftrace: allocating %ld entries in %d pages\n",
680 num_to_init, cnt); 668 num_to_init, cnt + 1);
681 669
682 for (i = 0; i < cnt; i++) { 670 for (i = 0; i < cnt; i++) {
683 pg->next = (void *)get_zeroed_page(GFP_KERNEL); 671 pg->next = (void *)get_zeroed_page(GFP_KERNEL);
@@ -738,6 +726,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
738 ((iter->flags & FTRACE_ITER_FAILURES) && 726 ((iter->flags & FTRACE_ITER_FAILURES) &&
739 !(rec->flags & FTRACE_FL_FAILED)) || 727 !(rec->flags & FTRACE_FL_FAILED)) ||
740 728
729 ((iter->flags & FTRACE_ITER_FILTER) &&
730 !(rec->flags & FTRACE_FL_FILTER)) ||
731
741 ((iter->flags & FTRACE_ITER_NOTRACE) && 732 ((iter->flags & FTRACE_ITER_NOTRACE) &&
742 !(rec->flags & FTRACE_FL_NOTRACE))) { 733 !(rec->flags & FTRACE_FL_NOTRACE))) {
743 rec = NULL; 734 rec = NULL;
@@ -757,13 +748,11 @@ static void *t_start(struct seq_file *m, loff_t *pos)
757 void *p = NULL; 748 void *p = NULL;
758 loff_t l = -1; 749 loff_t l = -1;
759 750
760 if (*pos != iter->pos) { 751 if (*pos > iter->pos)
761 for (p = t_next(m, p, &l); p && l < *pos; p = t_next(m, p, &l)) 752 *pos = iter->pos;
762 ; 753
763 } else { 754 l = *pos;
764 l = *pos; 755 p = t_next(m, p, &l);
765 p = t_next(m, p, &l);
766 }
767 756
768 return p; 757 return p;
769} 758}
@@ -774,15 +763,21 @@ static void t_stop(struct seq_file *m, void *p)
774 763
775static int t_show(struct seq_file *m, void *v) 764static int t_show(struct seq_file *m, void *v)
776{ 765{
766 struct ftrace_iterator *iter = m->private;
777 struct dyn_ftrace *rec = v; 767 struct dyn_ftrace *rec = v;
778 char str[KSYM_SYMBOL_LEN]; 768 char str[KSYM_SYMBOL_LEN];
769 int ret = 0;
779 770
780 if (!rec) 771 if (!rec)
781 return 0; 772 return 0;
782 773
783 kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); 774 kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
784 775
785 seq_printf(m, "%s\n", str); 776 ret = seq_printf(m, "%s\n", str);
777 if (ret < 0) {
778 iter->pos--;
779 iter->idx--;
780 }
786 781
787 return 0; 782 return 0;
788} 783}
@@ -808,7 +803,7 @@ ftrace_avail_open(struct inode *inode, struct file *file)
808 return -ENOMEM; 803 return -ENOMEM;
809 804
810 iter->pg = ftrace_pages_start; 805 iter->pg = ftrace_pages_start;
811 iter->pos = -1; 806 iter->pos = 0;
812 807
813 ret = seq_open(file, &show_ftrace_seq_ops); 808 ret = seq_open(file, &show_ftrace_seq_ops);
814 if (!ret) { 809 if (!ret) {
@@ -895,7 +890,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
895 890
896 if (file->f_mode & FMODE_READ) { 891 if (file->f_mode & FMODE_READ) {
897 iter->pg = ftrace_pages_start; 892 iter->pg = ftrace_pages_start;
898 iter->pos = -1; 893 iter->pos = 0;
899 iter->flags = enable ? FTRACE_ITER_FILTER : 894 iter->flags = enable ? FTRACE_ITER_FILTER :
900 FTRACE_ITER_NOTRACE; 895 FTRACE_ITER_NOTRACE;
901 896
@@ -1186,7 +1181,7 @@ ftrace_regex_release(struct inode *inode, struct file *file, int enable)
1186 1181
1187 mutex_lock(&ftrace_sysctl_lock); 1182 mutex_lock(&ftrace_sysctl_lock);
1188 mutex_lock(&ftrace_start_lock); 1183 mutex_lock(&ftrace_start_lock);
1189 if (iter->filtered && ftrace_start && ftrace_enabled) 1184 if (ftrace_start && ftrace_enabled)
1190 ftrace_run_update_code(FTRACE_ENABLE_CALLS); 1185 ftrace_run_update_code(FTRACE_ENABLE_CALLS);
1191 mutex_unlock(&ftrace_start_lock); 1186 mutex_unlock(&ftrace_start_lock);
1192 mutex_unlock(&ftrace_sysctl_lock); 1187 mutex_unlock(&ftrace_sysctl_lock);
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2f76193c3489..f780e9552f91 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -16,14 +16,49 @@
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18 18
19#include "trace.h"
20
21/* Global flag to disable all recording to ring buffers */
22static int ring_buffers_off __read_mostly;
23
24/**
25 * tracing_on - enable all tracing buffers
26 *
27 * This function enables all tracing buffers that may have been
28 * disabled with tracing_off.
29 */
30void tracing_on(void)
31{
32 ring_buffers_off = 0;
33}
34
35/**
36 * tracing_off - turn off all tracing buffers
37 *
38 * This function stops all tracing buffers from recording data.
39 * It does not disable any overhead the tracers themselves may
40 * be causing. This function simply causes all recording to
41 * the ring buffers to fail.
42 */
43void tracing_off(void)
44{
45 ring_buffers_off = 1;
46}
47
19/* Up this if you want to test the TIME_EXTENTS and normalization */ 48/* Up this if you want to test the TIME_EXTENTS and normalization */
20#define DEBUG_SHIFT 0 49#define DEBUG_SHIFT 0
21 50
22/* FIXME!!! */ 51/* FIXME!!! */
23u64 ring_buffer_time_stamp(int cpu) 52u64 ring_buffer_time_stamp(int cpu)
24{ 53{
54 u64 time;
55
56 preempt_disable_notrace();
25 /* shift to debug/test normalization and TIME_EXTENTS */ 57 /* shift to debug/test normalization and TIME_EXTENTS */
26 return sched_clock() << DEBUG_SHIFT; 58 time = sched_clock() << DEBUG_SHIFT;
59 preempt_enable_notrace();
60
61 return time;
27} 62}
28 63
29void ring_buffer_normalize_time_stamp(int cpu, u64 *ts) 64void ring_buffer_normalize_time_stamp(int cpu, u64 *ts)
@@ -503,6 +538,12 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
503 LIST_HEAD(pages); 538 LIST_HEAD(pages);
504 int i, cpu; 539 int i, cpu;
505 540
541 /*
542 * Always succeed at resizing a non-existent buffer:
543 */
544 if (!buffer)
545 return size;
546
506 size = DIV_ROUND_UP(size, BUF_PAGE_SIZE); 547 size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
507 size *= BUF_PAGE_SIZE; 548 size *= BUF_PAGE_SIZE;
508 buffer_size = buffer->pages * BUF_PAGE_SIZE; 549 buffer_size = buffer->pages * BUF_PAGE_SIZE;
@@ -576,6 +617,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
576 list_del_init(&page->list); 617 list_del_init(&page->list);
577 free_buffer_page(page); 618 free_buffer_page(page);
578 } 619 }
620 mutex_unlock(&buffer->mutex);
579 return -ENOMEM; 621 return -ENOMEM;
580} 622}
581 623
@@ -1133,6 +1175,9 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1133 struct ring_buffer_event *event; 1175 struct ring_buffer_event *event;
1134 int cpu, resched; 1176 int cpu, resched;
1135 1177
1178 if (ring_buffers_off)
1179 return NULL;
1180
1136 if (atomic_read(&buffer->record_disabled)) 1181 if (atomic_read(&buffer->record_disabled))
1137 return NULL; 1182 return NULL;
1138 1183
@@ -1249,6 +1294,9 @@ int ring_buffer_write(struct ring_buffer *buffer,
1249 int ret = -EBUSY; 1294 int ret = -EBUSY;
1250 int cpu, resched; 1295 int cpu, resched;
1251 1296
1297 if (ring_buffers_off)
1298 return -EBUSY;
1299
1252 if (atomic_read(&buffer->record_disabled)) 1300 if (atomic_read(&buffer->record_disabled))
1253 return -EBUSY; 1301 return -EBUSY;
1254 1302
@@ -2070,3 +2118,69 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
2070 return 0; 2118 return 0;
2071} 2119}
2072 2120
2121static ssize_t
2122rb_simple_read(struct file *filp, char __user *ubuf,
2123 size_t cnt, loff_t *ppos)
2124{
2125 int *p = filp->private_data;
2126 char buf[64];
2127 int r;
2128
2129 /* !ring_buffers_off == tracing_on */
2130 r = sprintf(buf, "%d\n", !*p);
2131
2132 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2133}
2134
2135static ssize_t
2136rb_simple_write(struct file *filp, const char __user *ubuf,
2137 size_t cnt, loff_t *ppos)
2138{
2139 int *p = filp->private_data;
2140 char buf[64];
2141 long val;
2142 int ret;
2143
2144 if (cnt >= sizeof(buf))
2145 return -EINVAL;
2146
2147 if (copy_from_user(&buf, ubuf, cnt))
2148 return -EFAULT;
2149
2150 buf[cnt] = 0;
2151
2152 ret = strict_strtoul(buf, 10, &val);
2153 if (ret < 0)
2154 return ret;
2155
2156 /* !ring_buffers_off == tracing_on */
2157 *p = !val;
2158
2159 (*ppos)++;
2160
2161 return cnt;
2162}
2163
2164static struct file_operations rb_simple_fops = {
2165 .open = tracing_open_generic,
2166 .read = rb_simple_read,
2167 .write = rb_simple_write,
2168};
2169
2170
2171static __init int rb_init_debugfs(void)
2172{
2173 struct dentry *d_tracer;
2174 struct dentry *entry;
2175
2176 d_tracer = tracing_init_dentry();
2177
2178 entry = debugfs_create_file("tracing_on", 0644, d_tracer,
2179 &ring_buffers_off, &rb_simple_fops);
2180 if (!entry)
2181 pr_warning("Could not create debugfs 'tracing_on' entry\n");
2182
2183 return 0;
2184}
2185
2186fs_initcall(rb_init_debugfs);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 697eda36b86a..d86e3252f300 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1936,6 +1936,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
1936 ring_buffer_read_finish(iter->buffer_iter[cpu]); 1936 ring_buffer_read_finish(iter->buffer_iter[cpu]);
1937 } 1937 }
1938 mutex_unlock(&trace_types_lock); 1938 mutex_unlock(&trace_types_lock);
1939 kfree(iter);
1939 1940
1940 return ERR_PTR(-ENOMEM); 1941 return ERR_PTR(-ENOMEM);
1941} 1942}
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b0f239e443bc..1e3fd3e3436a 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -545,6 +545,16 @@ config DEBUG_SG
545 545
546 If unsure, say N. 546 If unsure, say N.
547 547
548config DEBUG_NOTIFIERS
549 bool "Debug notifier call chains"
550 depends on DEBUG_KERNEL
551 help
552 Enable this to turn on sanity checking for notifier call chains.
553 This is most useful for kernel developers to make sure that
554 modules properly unregister themselves from notifier chains.
555 This is a relatively cheap check but if you care about maximum
556 performance, say N.
557
548config FRAME_POINTER 558config FRAME_POINTER
549 bool "Compile the kernel with frame pointers" 559 bool "Compile the kernel with frame pointers"
550 depends on DEBUG_KERNEL && \ 560 depends on DEBUG_KERNEL && \
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 8d2688ff1352..b7b449dafbe5 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -395,7 +395,7 @@ void sg_miter_stop(struct sg_mapping_iter *miter)
395 WARN_ON(!irqs_disabled()); 395 WARN_ON(!irqs_disabled());
396 kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ); 396 kunmap_atomic(miter->addr, KM_BIO_SRC_IRQ);
397 } else 397 } else
398 kunmap(miter->addr); 398 kunmap(miter->page);
399 399
400 miter->page = NULL; 400 miter->page = NULL;
401 miter->addr = NULL; 401 miter->addr = NULL;
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 78330c37a61b..5f6c629a924d 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -467,9 +467,13 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
467 dma_addr_t dev_addr; 467 dma_addr_t dev_addr;
468 void *ret; 468 void *ret;
469 int order = get_order(size); 469 int order = get_order(size);
470 u64 dma_mask = DMA_32BIT_MASK;
471
472 if (hwdev && hwdev->coherent_dma_mask)
473 dma_mask = hwdev->coherent_dma_mask;
470 474
471 ret = (void *)__get_free_pages(flags, order); 475 ret = (void *)__get_free_pages(flags, order);
472 if (ret && address_needs_mapping(hwdev, virt_to_bus(ret), size)) { 476 if (ret && !is_buffer_dma_capable(dma_mask, virt_to_bus(ret), size)) {
473 /* 477 /*
474 * The allocated memory isn't reachable by the device. 478 * The allocated memory isn't reachable by the device.
475 * Fall back on swiotlb_map_single(). 479 * Fall back on swiotlb_map_single().
@@ -493,9 +497,9 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
493 dev_addr = virt_to_bus(ret); 497 dev_addr = virt_to_bus(ret);
494 498
495 /* Confirm address can be DMA'd by device */ 499 /* Confirm address can be DMA'd by device */
496 if (address_needs_mapping(hwdev, dev_addr, size)) { 500 if (!is_buffer_dma_capable(dma_mask, dev_addr, size)) {
497 printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n", 501 printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n",
498 (unsigned long long)*hwdev->dma_mask, 502 (unsigned long long)dma_mask,
499 (unsigned long long)dev_addr); 503 (unsigned long long)dev_addr);
500 504
501 /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ 505 /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
diff --git a/mm/memory.c b/mm/memory.c
index 164951c47305..fc031d68327e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3049,3 +3049,18 @@ void print_vma_addr(char *prefix, unsigned long ip)
3049 } 3049 }
3050 up_read(&current->mm->mmap_sem); 3050 up_read(&current->mm->mmap_sem);
3051} 3051}
3052
3053#ifdef CONFIG_PROVE_LOCKING
3054void might_fault(void)
3055{
3056 might_sleep();
3057 /*
3058 * it would be nicer only to annotate paths which are not under
3059 * pagefault_disable, however that requires a larger audit and
3060 * providing helpers like get_user_atomic.
3061 */
3062 if (!in_atomic() && current->mm)
3063 might_lock_read(&current->mm->mmap_sem);
3064}
3065EXPORT_SYMBOL(might_fault);
3066#endif
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 6837a1014372..b5b2b15085a8 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -22,7 +22,6 @@
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/cpuset.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/migrate.h> 26#include <linux/migrate.h>
28#include <linux/page-isolation.h> 27#include <linux/page-isolation.h>
@@ -498,8 +497,6 @@ int add_memory(int nid, u64 start, u64 size)
498 /* we online node here. we can't roll back from here. */ 497 /* we online node here. we can't roll back from here. */
499 node_set_online(nid); 498 node_set_online(nid);
500 499
501 cpuset_track_online_nodes();
502
503 if (new_pgdat) { 500 if (new_pgdat) {
504 ret = register_one_node(nid); 501 ret = register_one_node(nid);
505 /* 502 /*
diff --git a/mm/migrate.c b/mm/migrate.c
index 385db89f0c33..1e0d6b237f44 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -522,15 +522,12 @@ static int writeout(struct address_space *mapping, struct page *page)
522 remove_migration_ptes(page, page); 522 remove_migration_ptes(page, page);
523 523
524 rc = mapping->a_ops->writepage(page, &wbc); 524 rc = mapping->a_ops->writepage(page, &wbc);
525 if (rc < 0)
526 /* I/O Error writing */
527 return -EIO;
528 525
529 if (rc != AOP_WRITEPAGE_ACTIVATE) 526 if (rc != AOP_WRITEPAGE_ACTIVATE)
530 /* unlocked. Relock */ 527 /* unlocked. Relock */
531 lock_page(page); 528 lock_page(page);
532 529
533 return -EAGAIN; 530 return (rc < 0) ? -EIO : -EAGAIN;
534} 531}
535 532
536/* 533/*
diff --git a/mm/mlock.c b/mm/mlock.c
index a6da2aee940a..1ada366570cb 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -162,7 +162,7 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma,
162 unsigned long addr = start; 162 unsigned long addr = start;
163 struct page *pages[16]; /* 16 gives a reasonable batch */ 163 struct page *pages[16]; /* 16 gives a reasonable batch */
164 int nr_pages = (end - start) / PAGE_SIZE; 164 int nr_pages = (end - start) / PAGE_SIZE;
165 int ret; 165 int ret = 0;
166 int gup_flags = 0; 166 int gup_flags = 0;
167 167
168 VM_BUG_ON(start & ~PAGE_MASK); 168 VM_BUG_ON(start & ~PAGE_MASK);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ba6b0f5f7fac..30f826d484f0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -324,14 +324,14 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
324 324
325 BUG_ON(size & ~PAGE_MASK); 325 BUG_ON(size & ~PAGE_MASK);
326 326
327 addr = ALIGN(vstart, align);
328
329 va = kmalloc_node(sizeof(struct vmap_area), 327 va = kmalloc_node(sizeof(struct vmap_area),
330 gfp_mask & GFP_RECLAIM_MASK, node); 328 gfp_mask & GFP_RECLAIM_MASK, node);
331 if (unlikely(!va)) 329 if (unlikely(!va))
332 return ERR_PTR(-ENOMEM); 330 return ERR_PTR(-ENOMEM);
333 331
334retry: 332retry:
333 addr = ALIGN(vstart, align);
334
335 spin_lock(&vmap_area_lock); 335 spin_lock(&vmap_area_lock);
336 /* XXX: could have a last_hole cache */ 336 /* XXX: could have a last_hole cache */
337 n = vmap_area_root.rb_node; 337 n = vmap_area_root.rb_node;
@@ -362,7 +362,7 @@ retry:
362 goto found; 362 goto found;
363 } 363 }
364 364
365 while (addr + size >= first->va_start && addr + size <= vend) { 365 while (addr + size > first->va_start && addr + size <= vend) {
366 addr = ALIGN(first->va_end + PAGE_SIZE, align); 366 addr = ALIGN(first->va_end + PAGE_SIZE, align);
367 367
368 n = rb_next(&first->rb_node); 368 n = rb_next(&first->rb_node);
@@ -522,13 +522,24 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
522} 522}
523 523
524/* 524/*
525 * Kick off a purge of the outstanding lazy areas. Don't bother if somebody
526 * is already purging.
527 */
528static void try_purge_vmap_area_lazy(void)
529{
530 unsigned long start = ULONG_MAX, end = 0;
531
532 __purge_vmap_area_lazy(&start, &end, 0, 0);
533}
534
535/*
525 * Kick off a purge of the outstanding lazy areas. 536 * Kick off a purge of the outstanding lazy areas.
526 */ 537 */
527static void purge_vmap_area_lazy(void) 538static void purge_vmap_area_lazy(void)
528{ 539{
529 unsigned long start = ULONG_MAX, end = 0; 540 unsigned long start = ULONG_MAX, end = 0;
530 541
531 __purge_vmap_area_lazy(&start, &end, 0, 0); 542 __purge_vmap_area_lazy(&start, &end, 1, 0);
532} 543}
533 544
534/* 545/*
@@ -539,7 +550,7 @@ static void free_unmap_vmap_area(struct vmap_area *va)
539 va->flags |= VM_LAZY_FREE; 550 va->flags |= VM_LAZY_FREE;
540 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr); 551 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
541 if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages())) 552 if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages()))
542 purge_vmap_area_lazy(); 553 try_purge_vmap_area_lazy();
543} 554}
544 555
545static struct vmap_area *find_vmap_area(unsigned long addr) 556static struct vmap_area *find_vmap_area(unsigned long addr)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3b5860294bb6..7ea1440b53db 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -623,6 +623,8 @@ static unsigned long shrink_page_list(struct list_head *page_list,
623 * Try to allocate it some swap space here. 623 * Try to allocate it some swap space here.
624 */ 624 */
625 if (PageAnon(page) && !PageSwapCache(page)) { 625 if (PageAnon(page) && !PageSwapCache(page)) {
626 if (!(sc->gfp_mask & __GFP_IO))
627 goto keep_locked;
626 switch (try_to_munlock(page)) { 628 switch (try_to_munlock(page)) {
627 case SWAP_FAIL: /* shouldn't happen */ 629 case SWAP_FAIL: /* shouldn't happen */
628 case SWAP_AGAIN: 630 case SWAP_AGAIN:
@@ -634,6 +636,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
634 } 636 }
635 if (!add_to_swap(page, GFP_ATOMIC)) 637 if (!add_to_swap(page, GFP_ATOMIC))
636 goto activate_locked; 638 goto activate_locked;
639 may_enter_fs = 1;
637 } 640 }
638#endif /* CONFIG_SWAP */ 641#endif /* CONFIG_SWAP */
639 642
@@ -1386,9 +1389,9 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
1386 file_prio = 200 - sc->swappiness; 1389 file_prio = 200 - sc->swappiness;
1387 1390
1388 /* 1391 /*
1389 * anon recent_rotated[0] 1392 * The amount of pressure on anon vs file pages is inversely
1390 * %anon = 100 * ----------- / ----------------- * IO cost 1393 * proportional to the fraction of recently scanned pages on
1391 * anon + file rotate_sum 1394 * each list that were recently referenced and in active use.
1392 */ 1395 */
1393 ap = (anon_prio + 1) * (zone->recent_scanned[0] + 1); 1396 ap = (anon_prio + 1) * (zone->recent_scanned[0] + 1);
1394 ap /= zone->recent_rotated[0] + 1; 1397 ap /= zone->recent_rotated[0] + 1;
@@ -2368,39 +2371,6 @@ int page_evictable(struct page *page, struct vm_area_struct *vma)
2368 return 1; 2371 return 1;
2369} 2372}
2370 2373
2371static void show_page_path(struct page *page)
2372{
2373 char buf[256];
2374 if (page_is_file_cache(page)) {
2375 struct address_space *mapping = page->mapping;
2376 struct dentry *dentry;
2377 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
2378
2379 spin_lock(&mapping->i_mmap_lock);
2380 dentry = d_find_alias(mapping->host);
2381 printk(KERN_INFO "rescued: %s %lu\n",
2382 dentry_path(dentry, buf, 256), pgoff);
2383 spin_unlock(&mapping->i_mmap_lock);
2384 } else {
2385#if defined(CONFIG_MM_OWNER) && defined(CONFIG_MMU)
2386 struct anon_vma *anon_vma;
2387 struct vm_area_struct *vma;
2388
2389 anon_vma = page_lock_anon_vma(page);
2390 if (!anon_vma)
2391 return;
2392
2393 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
2394 printk(KERN_INFO "rescued: anon %s\n",
2395 vma->vm_mm->owner->comm);
2396 break;
2397 }
2398 page_unlock_anon_vma(anon_vma);
2399#endif
2400 }
2401}
2402
2403
2404/** 2374/**
2405 * check_move_unevictable_page - check page for evictability and move to appropriate zone lru list 2375 * check_move_unevictable_page - check page for evictability and move to appropriate zone lru list
2406 * @page: page to check evictability and move to appropriate lru list 2376 * @page: page to check evictability and move to appropriate lru list
@@ -2421,8 +2391,6 @@ retry:
2421 if (page_evictable(page, NULL)) { 2391 if (page_evictable(page, NULL)) {
2422 enum lru_list l = LRU_INACTIVE_ANON + page_is_file_cache(page); 2392 enum lru_list l = LRU_INACTIVE_ANON + page_is_file_cache(page);
2423 2393
2424 show_page_path(page);
2425
2426 __dec_zone_state(zone, NR_UNEVICTABLE); 2394 __dec_zone_state(zone, NR_UNEVICTABLE);
2427 list_move(&page->lru, &zone->lru[l].list); 2395 list_move(&page->lru, &zone->lru[l].list);
2428 __inc_zone_state(zone, NR_INACTIVE_ANON + l); 2396 __inc_zone_state(zone, NR_INACTIVE_ANON + l);
diff --git a/net/9p/Kconfig b/net/9p/Kconfig
index c42c0c400bf9..0663f99e977a 100644
--- a/net/9p/Kconfig
+++ b/net/9p/Kconfig
@@ -13,22 +13,24 @@ menuconfig NET_9P
13 13
14 If unsure, say N. 14 If unsure, say N.
15 15
16if NET_9P
17
16config NET_9P_VIRTIO 18config NET_9P_VIRTIO
17 depends on NET_9P && EXPERIMENTAL && VIRTIO 19 depends on EXPERIMENTAL && VIRTIO
18 tristate "9P Virtio Transport (Experimental)" 20 tristate "9P Virtio Transport (Experimental)"
19 help 21 help
20 This builds support for a transports between 22 This builds support for a transports between
21 guest partitions and a host partition. 23 guest partitions and a host partition.
22 24
23config NET_9P_RDMA 25config NET_9P_RDMA
24 depends on NET_9P && INFINIBAND && EXPERIMENTAL 26 depends on INET && INFINIBAND && EXPERIMENTAL
25 tristate "9P RDMA Transport (Experimental)" 27 tristate "9P RDMA Transport (Experimental)"
26 help 28 help
27 This builds support for a RDMA transport. 29 This builds support for an RDMA transport.
28 30
29config NET_9P_DEBUG 31config NET_9P_DEBUG
30 bool "Debug information" 32 bool "Debug information"
31 depends on NET_9P
32 help 33 help
33 Say Y if you want the 9P subsystem to log debug information. 34 Say Y if you want the 9P subsystem to log debug information.
34 35
36endif
diff --git a/net/compat.c b/net/compat.c
index 6ce1a1cadcc0..a3a2ba0fac08 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -725,7 +725,7 @@ EXPORT_SYMBOL(compat_mc_getsockopt);
725static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 725static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), 727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
728 AL(6)}; 728 AL(4)};
729#undef AL 729#undef AL
730 730
731asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) 731asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags)
@@ -738,52 +738,13 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, uns
738 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); 738 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
739} 739}
740 740
741asmlinkage long compat_sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
742 int __user *upeer_addrlen,
743 const compat_sigset_t __user *sigmask,
744 compat_size_t sigsetsize, int flags)
745{
746 compat_sigset_t ss32;
747 sigset_t ksigmask, sigsaved;
748 int ret;
749
750 if (sigmask) {
751 if (sigsetsize != sizeof(compat_sigset_t))
752 return -EINVAL;
753 if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
754 return -EFAULT;
755 sigset_from_compat(&ksigmask, &ss32);
756
757 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
758 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
759 }
760
761 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
762
763 if (ret == -ERESTARTNOHAND) {
764 /*
765 * Don't restore the signal mask yet. Let do_signal() deliver
766 * the signal on the way back to userspace, before the signal
767 * mask is restored.
768 */
769 if (sigmask) {
770 memcpy(&current->saved_sigmask, &sigsaved,
771 sizeof(sigsaved));
772 set_restore_sigmask();
773 }
774 } else if (sigmask)
775 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
776
777 return ret;
778}
779
780asmlinkage long compat_sys_socketcall(int call, u32 __user *args) 741asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
781{ 742{
782 int ret; 743 int ret;
783 u32 a[6]; 744 u32 a[6];
784 u32 a0, a1; 745 u32 a0, a1;
785 746
786 if (call < SYS_SOCKET || call > SYS_PACCEPT) 747 if (call < SYS_SOCKET || call > SYS_ACCEPT4)
787 return -EINVAL; 748 return -EINVAL;
788 if (copy_from_user(a, args, nas[call])) 749 if (copy_from_user(a, args, nas[call]))
789 return -EFAULT; 750 return -EFAULT;
@@ -804,7 +765,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
804 ret = sys_listen(a0, a1); 765 ret = sys_listen(a0, a1);
805 break; 766 break;
806 case SYS_ACCEPT: 767 case SYS_ACCEPT:
807 ret = do_accept(a0, compat_ptr(a1), compat_ptr(a[2]), 0); 768 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), 0);
808 break; 769 break;
809 case SYS_GETSOCKNAME: 770 case SYS_GETSOCKNAME:
810 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2])); 771 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2]));
@@ -844,9 +805,8 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
844 case SYS_RECVMSG: 805 case SYS_RECVMSG:
845 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); 806 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
846 break; 807 break;
847 case SYS_PACCEPT: 808 case SYS_ACCEPT4:
848 ret = compat_sys_paccept(a0, compat_ptr(a1), compat_ptr(a[2]), 809 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), a[3]);
849 compat_ptr(a[3]), a[4], a[5]);
850 break; 810 break;
851 default: 811 default:
852 ret = -EINVAL; 812 ret = -EINVAL;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index a47f5bad110d..8997e912aaaf 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1973,13 +1973,7 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
1973 1973
1974 /* make sure that we don't pick a non-existing transmit queue */ 1974 /* make sure that we don't pick a non-existing transmit queue */
1975 ntxq = pkt_dev->odev->real_num_tx_queues; 1975 ntxq = pkt_dev->odev->real_num_tx_queues;
1976 if (ntxq > num_online_cpus() && (pkt_dev->flags & F_QUEUE_MAP_CPU)) { 1976
1977 printk(KERN_WARNING "pktgen: WARNING: QUEUE_MAP_CPU "
1978 "disabled because CPU count (%d) exceeds number "
1979 "of tx queues (%d) on %s\n", num_online_cpus(), ntxq,
1980 pkt_dev->odev->name);
1981 pkt_dev->flags &= ~F_QUEUE_MAP_CPU;
1982 }
1983 if (ntxq <= pkt_dev->queue_map_min) { 1977 if (ntxq <= pkt_dev->queue_map_min) {
1984 printk(KERN_WARNING "pktgen: WARNING: Requested " 1978 printk(KERN_WARNING "pktgen: WARNING: Requested "
1985 "queue_map_min (zero-based) (%d) exceeds valid range " 1979 "queue_map_min (zero-based) (%d) exceeds valid range "
@@ -2202,6 +2196,7 @@ static void set_cur_queue_map(struct pktgen_dev *pkt_dev)
2202 } 2196 }
2203 pkt_dev->cur_queue_map = t; 2197 pkt_dev->cur_queue_map = t;
2204 } 2198 }
2199 pkt_dev->cur_queue_map = pkt_dev->cur_queue_map % pkt_dev->odev->real_num_tx_queues;
2205} 2200}
2206 2201
2207/* Increment/randomize headers according to flags and current values 2202/* Increment/randomize headers according to flags and current values
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 31f29d2989fd..4dfb6b4d4559 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -878,7 +878,9 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
878 if (ifm->ifi_change) 878 if (ifm->ifi_change)
879 flags = (flags & ifm->ifi_change) | 879 flags = (flags & ifm->ifi_change) |
880 (dev->flags & ~ifm->ifi_change); 880 (dev->flags & ~ifm->ifi_change);
881 dev_change_flags(dev, flags); 881 err = dev_change_flags(dev, flags);
882 if (err < 0)
883 goto errout;
882 } 884 }
883 885
884 if (tb[IFLA_TXQLEN]) 886 if (tb[IFLA_TXQLEN])
diff --git a/net/core/scm.c b/net/core/scm.c
index ab242cc1acca..b12303dd39d9 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -75,7 +75,6 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
75 if (!fpl) 75 if (!fpl)
76 return -ENOMEM; 76 return -ENOMEM;
77 *fplp = fpl; 77 *fplp = fpl;
78 INIT_LIST_HEAD(&fpl->list);
79 fpl->count = 0; 78 fpl->count = 0;
80 } 79 }
81 fpp = &fpl->fp[fpl->count]; 80 fpp = &fpl->fp[fpl->count];
@@ -301,7 +300,6 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)
301 300
302 new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL); 301 new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL);
303 if (new_fpl) { 302 if (new_fpl) {
304 INIT_LIST_HEAD(&new_fpl->list);
305 for (i=fpl->count-1; i>=0; i--) 303 for (i=fpl->count-1; i>=0; i--)
306 get_file(fpl->fp[i]); 304 get_file(fpl->fp[i]);
307 memcpy(new_fpl, fpl, sizeof(*fpl)); 305 memcpy(new_fpl, fpl, sizeof(*fpl));
diff --git a/net/core/sock.c b/net/core/sock.c
index 5e2a3132a8c9..341e39456952 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -136,7 +136,6 @@
136static struct lock_class_key af_family_keys[AF_MAX]; 136static struct lock_class_key af_family_keys[AF_MAX];
137static struct lock_class_key af_family_slock_keys[AF_MAX]; 137static struct lock_class_key af_family_slock_keys[AF_MAX];
138 138
139#ifdef CONFIG_DEBUG_LOCK_ALLOC
140/* 139/*
141 * Make lock validator output more readable. (we pre-construct these 140 * Make lock validator output more readable. (we pre-construct these
142 * strings build-time, so that runtime initialization of socket 141 * strings build-time, so that runtime initialization of socket
@@ -187,7 +186,6 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = {
187 "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , 186 "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" ,
188 "clock-AF_MAX" 187 "clock-AF_MAX"
189}; 188};
190#endif
191 189
192/* 190/*
193 * sk_callback_lock locking rules are per-address-family, 191 * sk_callback_lock locking rules are per-address-family,
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1fbff5fa4241..1aa2dc9e380e 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1117,6 +1117,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1117 }, 1117 },
1118 }, 1118 },
1119 .proto = sk->sk_protocol, 1119 .proto = sk->sk_protocol,
1120 .flags = inet_sk_flowi_flags(sk),
1120 .uli_u = { 1121 .uli_u = {
1121 .ports = { 1122 .ports = {
1122 .sport = inet->sport, 1123 .sport = inet->sport,
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 861978a4f1a8..cfb38ac9d698 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -209,9 +209,17 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
209 209
210 hash = protocol & (MAX_INET_PROTOS - 1); 210 hash = protocol & (MAX_INET_PROTOS - 1);
211 ipprot = rcu_dereference(inet_protos[hash]); 211 ipprot = rcu_dereference(inet_protos[hash]);
212 if (ipprot != NULL && (net == &init_net || ipprot->netns_ok)) { 212 if (ipprot != NULL) {
213 int ret; 213 int ret;
214 214
215 if (!net_eq(net, &init_net) && !ipprot->netns_ok) {
216 if (net_ratelimit())
217 printk("%s: proto %d isn't netns-ready\n",
218 __func__, protocol);
219 kfree_skb(skb);
220 goto out;
221 }
222
215 if (!ipprot->no_policy) { 223 if (!ipprot->no_policy) {
216 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { 224 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
217 kfree_skb(skb); 225 kfree_skb(skb);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index b42e082cc170..25924b1eb2ef 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1945,13 +1945,14 @@ int __init ip_mr_init(void)
1945 goto proc_cache_fail; 1945 goto proc_cache_fail;
1946#endif 1946#endif
1947 return 0; 1947 return 0;
1948reg_notif_fail:
1949 kmem_cache_destroy(mrt_cachep);
1950#ifdef CONFIG_PROC_FS 1948#ifdef CONFIG_PROC_FS
1951proc_vif_fail:
1952 unregister_netdevice_notifier(&ip_mr_notifier);
1953proc_cache_fail: 1949proc_cache_fail:
1954 proc_net_remove(&init_net, "ip_mr_vif"); 1950 proc_net_remove(&init_net, "ip_mr_vif");
1951proc_vif_fail:
1952 unregister_netdevice_notifier(&ip_mr_notifier);
1955#endif 1953#endif
1954reg_notif_fail:
1955 del_timer(&ipmr_expire_timer);
1956 kmem_cache_destroy(mrt_cachep);
1956 return err; 1957 return err;
1957} 1958}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cf02701ced48..98c1fd09be88 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -633,6 +633,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
633 .saddr = saddr, 633 .saddr = saddr,
634 .tos = tos } }, 634 .tos = tos } },
635 .proto = sk->sk_protocol, 635 .proto = sk->sk_protocol,
636 .flags = inet_sk_flowi_flags(sk),
636 .uli_u = { .ports = 637 .uli_u = { .ports =
637 { .sport = inet->sport, 638 { .sport = inet->sport,
638 .dport = dport } } }; 639 .dport = dport } } };
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 410046a8cc91..e44deb8d4df2 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -661,6 +661,11 @@ int datagram_send_ctl(struct net *net,
661 switch (rthdr->type) { 661 switch (rthdr->type) {
662#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 662#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
663 case IPV6_SRCRT_TYPE_2: 663 case IPV6_SRCRT_TYPE_2:
664 if (rthdr->hdrlen != 2 ||
665 rthdr->segments_left != 1) {
666 err = -EINVAL;
667 goto exit_f;
668 }
664 break; 669 break;
665#endif 670#endif
666 default: 671 default:
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 52a7eb0e2c2c..0524769632e7 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -224,7 +224,7 @@ static struct file_operations ip6mr_vif_fops = {
224 .open = ip6mr_vif_open, 224 .open = ip6mr_vif_open,
225 .read = seq_read, 225 .read = seq_read,
226 .llseek = seq_lseek, 226 .llseek = seq_lseek,
227 .release = seq_release, 227 .release = seq_release_private,
228}; 228};
229 229
230static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) 230static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -338,7 +338,7 @@ static struct file_operations ip6mr_mfc_fops = {
338 .open = ipmr_mfc_open, 338 .open = ipmr_mfc_open,
339 .read = seq_read, 339 .read = seq_read,
340 .llseek = seq_lseek, 340 .llseek = seq_lseek,
341 .release = seq_release, 341 .release = seq_release_private,
342}; 342};
343#endif 343#endif
344 344
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4e5eac301f91..2aa294be0c79 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -366,11 +366,16 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
366 } 366 }
367 367
368 /* routing header option needs extra check */ 368 /* routing header option needs extra check */
369 retv = -EINVAL;
369 if (optname == IPV6_RTHDR && opt && opt->srcrt) { 370 if (optname == IPV6_RTHDR && opt && opt->srcrt) {
370 struct ipv6_rt_hdr *rthdr = opt->srcrt; 371 struct ipv6_rt_hdr *rthdr = opt->srcrt;
371 switch (rthdr->type) { 372 switch (rthdr->type) {
372#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 373#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
373 case IPV6_SRCRT_TYPE_2: 374 case IPV6_SRCRT_TYPE_2:
375 if (rthdr->hdrlen != 2 ||
376 rthdr->segments_left != 1)
377 goto sticky_done;
378
374 break; 379 break;
375#endif 380#endif
376 default: 381 default:
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 07f0b76e7427..97c17fdd6f75 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -132,7 +132,7 @@ static struct snmp_mib snmp6_udplite6_list[] = {
132 132
133static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) 133static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
134{ 134{
135 static char name[32]; 135 char name[32];
136 int i; 136 int i;
137 137
138 /* print by name -- deprecated items */ 138 /* print by name -- deprecated items */
@@ -144,7 +144,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
144 p = icmp6type2name[icmptype]; 144 p = icmp6type2name[icmptype];
145 if (!p) /* don't print un-named types here */ 145 if (!p) /* don't print un-named types here */
146 continue; 146 continue;
147 (void) snprintf(name, sizeof(name)-1, "Icmp6%s%s", 147 snprintf(name, sizeof(name), "Icmp6%s%s",
148 i & 0x100 ? "Out" : "In", p); 148 i & 0x100 ? "Out" : "In", p);
149 seq_printf(seq, "%-32s\t%lu\n", name, 149 seq_printf(seq, "%-32s\t%lu\n", name,
150 snmp_fold_field(mib, i)); 150 snmp_fold_field(mib, i));
@@ -157,7 +157,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib)
157 val = snmp_fold_field(mib, i); 157 val = snmp_fold_field(mib, i);
158 if (!val) 158 if (!val)
159 continue; 159 continue;
160 (void) snprintf(name, sizeof(name)-1, "Icmp6%sType%u", 160 snprintf(name, sizeof(name), "Icmp6%sType%u",
161 i & 0x100 ? "Out" : "In", i & 0xff); 161 i & 0x100 ? "Out" : "In", i & 0xff);
162 seq_printf(seq, "%-32s\t%lu\n", name, val); 162 seq_printf(seq, "%-32s\t%lu\n", name, val);
163 } 163 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 14d165f0df75..409bb7716236 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2560,25 +2560,3 @@ void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
2560 ieee80211_restart_sta_timer(sdata); 2560 ieee80211_restart_sta_timer(sdata);
2561 rcu_read_unlock(); 2561 rcu_read_unlock();
2562} 2562}
2563
2564/* driver notification call */
2565void ieee80211_notify_mac(struct ieee80211_hw *hw,
2566 enum ieee80211_notification_types notif_type)
2567{
2568 struct ieee80211_local *local = hw_to_local(hw);
2569 struct ieee80211_sub_if_data *sdata;
2570
2571 switch (notif_type) {
2572 case IEEE80211_NOTIFY_RE_ASSOC:
2573 rtnl_lock();
2574 list_for_each_entry(sdata, &local->interfaces, list) {
2575 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2576 continue;
2577
2578 ieee80211_sta_req_auth(sdata, &sdata->u.sta);
2579 }
2580 rtnl_unlock();
2581 break;
2582 }
2583}
2584EXPORT_SYMBOL(ieee80211_notify_mac);
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index defeb7a0d502..9d211f12582b 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -33,9 +33,30 @@
33#include <net/phonet/phonet.h> 33#include <net/phonet/phonet.h>
34#include <net/phonet/pn_dev.h> 34#include <net/phonet/pn_dev.h>
35 35
36static struct net_proto_family phonet_proto_family; 36/* Transport protocol registration */
37static struct phonet_protocol *phonet_proto_get(int protocol); 37static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
38static inline void phonet_proto_put(struct phonet_protocol *pp); 38static DEFINE_SPINLOCK(proto_tab_lock);
39
40static struct phonet_protocol *phonet_proto_get(int protocol)
41{
42 struct phonet_protocol *pp;
43
44 if (protocol >= PHONET_NPROTO)
45 return NULL;
46
47 spin_lock(&proto_tab_lock);
48 pp = proto_tab[protocol];
49 if (pp && !try_module_get(pp->prot->owner))
50 pp = NULL;
51 spin_unlock(&proto_tab_lock);
52
53 return pp;
54}
55
56static inline void phonet_proto_put(struct phonet_protocol *pp)
57{
58 module_put(pp->prot->owner);
59}
39 60
40/* protocol family functions */ 61/* protocol family functions */
41 62
@@ -144,8 +165,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev,
144 struct phonethdr *ph; 165 struct phonethdr *ph;
145 int err; 166 int err;
146 167
147 if (skb->len + 2 > 0xffff) { 168 if (skb->len + 2 > 0xffff /* Phonet length field limit */ ||
148 /* Phonet length field would overflow */ 169 skb->len + sizeof(struct phonethdr) > dev->mtu) {
149 err = -EMSGSIZE; 170 err = -EMSGSIZE;
150 goto drop; 171 goto drop;
151 } 172 }
@@ -375,10 +396,6 @@ static struct packet_type phonet_packet_type = {
375 .func = phonet_rcv, 396 .func = phonet_rcv,
376}; 397};
377 398
378/* Transport protocol registration */
379static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
380static DEFINE_SPINLOCK(proto_tab_lock);
381
382int __init_or_module phonet_proto_register(int protocol, 399int __init_or_module phonet_proto_register(int protocol,
383 struct phonet_protocol *pp) 400 struct phonet_protocol *pp)
384{ 401{
@@ -412,27 +429,6 @@ void phonet_proto_unregister(int protocol, struct phonet_protocol *pp)
412} 429}
413EXPORT_SYMBOL(phonet_proto_unregister); 430EXPORT_SYMBOL(phonet_proto_unregister);
414 431
415static struct phonet_protocol *phonet_proto_get(int protocol)
416{
417 struct phonet_protocol *pp;
418
419 if (protocol >= PHONET_NPROTO)
420 return NULL;
421
422 spin_lock(&proto_tab_lock);
423 pp = proto_tab[protocol];
424 if (pp && !try_module_get(pp->prot->owner))
425 pp = NULL;
426 spin_unlock(&proto_tab_lock);
427
428 return pp;
429}
430
431static inline void phonet_proto_put(struct phonet_protocol *pp)
432{
433 module_put(pp->prot->owner);
434}
435
436/* Module registration */ 432/* Module registration */
437static int __init phonet_init(void) 433static int __init phonet_init(void)
438{ 434{
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index b16ad2972c6b..6ab4a2f92ca0 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -417,6 +417,8 @@ static int qdisc_dump_stab(struct sk_buff *skb, struct qdisc_size_table *stab)
417 struct nlattr *nest; 417 struct nlattr *nest;
418 418
419 nest = nla_nest_start(skb, TCA_STAB); 419 nest = nla_nest_start(skb, TCA_STAB);
420 if (nest == NULL)
421 goto nla_put_failure;
420 NLA_PUT(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts); 422 NLA_PUT(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts);
421 nla_nest_end(skb, nest); 423 nla_nest_end(skb, nest);
422 424
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 93cd30ce6501..cdcd16fcfeda 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -270,6 +270,8 @@ static void dev_watchdog_down(struct net_device *dev)
270void netif_carrier_on(struct net_device *dev) 270void netif_carrier_on(struct net_device *dev)
271{ 271{
272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
273 if (dev->reg_state == NETREG_UNINITIALIZED)
274 return;
273 linkwatch_fire_event(dev); 275 linkwatch_fire_event(dev);
274 if (netif_running(dev)) 276 if (netif_running(dev))
275 __netdev_watchdog_up(dev); 277 __netdev_watchdog_up(dev);
@@ -285,8 +287,11 @@ EXPORT_SYMBOL(netif_carrier_on);
285 */ 287 */
286void netif_carrier_off(struct net_device *dev) 288void netif_carrier_off(struct net_device *dev)
287{ 289{
288 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) 290 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
291 if (dev->reg_state == NETREG_UNINITIALIZED)
292 return;
289 linkwatch_fire_event(dev); 293 linkwatch_fire_event(dev);
294 }
290} 295}
291EXPORT_SYMBOL(netif_carrier_off); 296EXPORT_SYMBOL(netif_carrier_off);
292 297
diff --git a/net/socket.c b/net/socket.c
index 57550c3bcabe..92764d836891 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1426,8 +1426,8 @@ asmlinkage long sys_listen(int fd, int backlog)
1426 * clean when we restucture accept also. 1426 * clean when we restucture accept also.
1427 */ 1427 */
1428 1428
1429long do_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1429asmlinkage long sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
1430 int __user *upeer_addrlen, int flags) 1430 int __user *upeer_addrlen, int flags)
1431{ 1431{
1432 struct socket *sock, *newsock; 1432 struct socket *sock, *newsock;
1433 struct file *newfile; 1433 struct file *newfile;
@@ -1510,66 +1510,10 @@ out_fd:
1510 goto out_put; 1510 goto out_put;
1511} 1511}
1512 1512
1513#if 0
1514#ifdef HAVE_SET_RESTORE_SIGMASK
1515asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1516 int __user *upeer_addrlen,
1517 const sigset_t __user *sigmask,
1518 size_t sigsetsize, int flags)
1519{
1520 sigset_t ksigmask, sigsaved;
1521 int ret;
1522
1523 if (sigmask) {
1524 /* XXX: Don't preclude handling different sized sigset_t's. */
1525 if (sigsetsize != sizeof(sigset_t))
1526 return -EINVAL;
1527 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
1528 return -EFAULT;
1529
1530 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
1531 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
1532 }
1533
1534 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1535
1536 if (ret < 0 && signal_pending(current)) {
1537 /*
1538 * Don't restore the signal mask yet. Let do_signal() deliver
1539 * the signal on the way back to userspace, before the signal
1540 * mask is restored.
1541 */
1542 if (sigmask) {
1543 memcpy(&current->saved_sigmask, &sigsaved,
1544 sizeof(sigsaved));
1545 set_restore_sigmask();
1546 }
1547 } else if (sigmask)
1548 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
1549
1550 return ret;
1551}
1552#else
1553asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1554 int __user *upeer_addrlen,
1555 const sigset_t __user *sigmask,
1556 size_t sigsetsize, int flags)
1557{
1558 /* The platform does not support restoring the signal mask in the
1559 * return path. So we do not allow using paccept() with a signal
1560 * mask. */
1561 if (sigmask)
1562 return -EINVAL;
1563
1564 return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1565}
1566#endif
1567#endif
1568
1569asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1513asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1570 int __user *upeer_addrlen) 1514 int __user *upeer_addrlen)
1571{ 1515{
1572 return do_accept(fd, upeer_sockaddr, upeer_addrlen, 0); 1516 return sys_accept4(fd, upeer_sockaddr, upeer_addrlen, 0);
1573} 1517}
1574 1518
1575/* 1519/*
@@ -2096,7 +2040,7 @@ static const unsigned char nargs[19]={
2096 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 2040 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
2097 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 2041 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
2098 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), 2042 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
2099 AL(6) 2043 AL(4)
2100}; 2044};
2101 2045
2102#undef AL 2046#undef AL
@@ -2115,7 +2059,7 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2115 unsigned long a0, a1; 2059 unsigned long a0, a1;
2116 int err; 2060 int err;
2117 2061
2118 if (call < 1 || call > SYS_PACCEPT) 2062 if (call < 1 || call > SYS_ACCEPT4)
2119 return -EINVAL; 2063 return -EINVAL;
2120 2064
2121 /* copy_from_user should be SMP safe. */ 2065 /* copy_from_user should be SMP safe. */
@@ -2143,9 +2087,8 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2143 err = sys_listen(a0, a1); 2087 err = sys_listen(a0, a1);
2144 break; 2088 break;
2145 case SYS_ACCEPT: 2089 case SYS_ACCEPT:
2146 err = 2090 err = sys_accept4(a0, (struct sockaddr __user *)a1,
2147 do_accept(a0, (struct sockaddr __user *)a1, 2091 (int __user *)a[2], 0);
2148 (int __user *)a[2], 0);
2149 break; 2092 break;
2150 case SYS_GETSOCKNAME: 2093 case SYS_GETSOCKNAME:
2151 err = 2094 err =
@@ -2192,12 +2135,9 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2192 case SYS_RECVMSG: 2135 case SYS_RECVMSG:
2193 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]); 2136 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
2194 break; 2137 break;
2195 case SYS_PACCEPT: 2138 case SYS_ACCEPT4:
2196 err = 2139 err = sys_accept4(a0, (struct sockaddr __user *)a1,
2197 sys_paccept(a0, (struct sockaddr __user *)a1, 2140 (int __user *)a[2], a[3]);
2198 (int __user *)a[2],
2199 (const sigset_t __user *) a[3],
2200 a[4], a[5]);
2201 break; 2141 break;
2202 default: 2142 default:
2203 err = -EINVAL; 2143 err = -EINVAL;
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 744b79fdcb19..4028502f0528 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -133,13 +133,29 @@ static int
133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
134{ 134{
135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base);
136 int i;
136 137
137 if (gcred->acred.uid != acred->uid || 138 if (gcred->acred.uid != acred->uid ||
138 gcred->acred.gid != acred->gid || 139 gcred->acred.gid != acred->gid ||
139 gcred->acred.group_info != acred->group_info ||
140 gcred->acred.machine_cred != acred->machine_cred) 140 gcred->acred.machine_cred != acred->machine_cred)
141 return 0; 141 goto out_nomatch;
142
143 /* Optimisation in the case where pointers are identical... */
144 if (gcred->acred.group_info == acred->group_info)
145 goto out_match;
146
147 /* Slow path... */
148 if (gcred->acred.group_info->ngroups != acred->group_info->ngroups)
149 goto out_nomatch;
150 for (i = 0; i < gcred->acred.group_info->ngroups; i++) {
151 if (GROUP_AT(gcred->acred.group_info, i) !=
152 GROUP_AT(acred->group_info, i))
153 goto out_nomatch;
154 }
155out_match:
142 return 1; 156 return 1;
157out_nomatch:
158 return 0;
143} 159}
144 160
145void __init rpc_init_generic_auth(void) 161void __init rpc_init_generic_auth(void)
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 9b77b3e0fa98..3ecd7e797dee 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -37,6 +37,9 @@ static void snd_hda_generate_beep(struct work_struct *work)
37 container_of(work, struct hda_beep, beep_work); 37 container_of(work, struct hda_beep, beep_work);
38 struct hda_codec *codec = beep->codec; 38 struct hda_codec *codec = beep->codec;
39 39
40 if (!beep->enabled)
41 return;
42
40 /* generate tone */ 43 /* generate tone */
41 snd_hda_codec_write_cache(codec, beep->nid, 0, 44 snd_hda_codec_write_cache(codec, beep->nid, 0,
42 AC_VERB_SET_BEEP_CONTROL, beep->tone); 45 AC_VERB_SET_BEEP_CONTROL, beep->tone);
@@ -85,6 +88,10 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
85 snprintf(beep->phys, sizeof(beep->phys), 88 snprintf(beep->phys, sizeof(beep->phys),
86 "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); 89 "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr);
87 input_dev = input_allocate_device(); 90 input_dev = input_allocate_device();
91 if (!input_dev) {
92 kfree(beep);
93 return -ENOMEM;
94 }
88 95
89 /* setup digital beep device */ 96 /* setup digital beep device */
90 input_dev->name = "HDA Digital PCBeep"; 97 input_dev->name = "HDA Digital PCBeep";
@@ -115,6 +122,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
115 beep->nid = nid; 122 beep->nid = nid;
116 beep->dev = input_dev; 123 beep->dev = input_dev;
117 beep->codec = codec; 124 beep->codec = codec;
125 beep->enabled = 1;
118 codec->beep = beep; 126 codec->beep = beep;
119 127
120 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); 128 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index de4036e6e710..b9679f081cae 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -31,6 +31,7 @@ struct hda_beep {
31 char phys[32]; 31 char phys[32];
32 int tone; 32 int tone;
33 int nid; 33 int nid;
34 int enabled;
34 struct work_struct beep_work; /* scheduled task for beep event */ 35 struct work_struct beep_work; /* scheduled task for beep event */
35}; 36};
36 37
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 4300a679cd86..9563b5bbb272 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -36,9 +36,11 @@
36#include "hda_beep.h" 36#include "hda_beep.h"
37 37
38#define NUM_CONTROL_ALLOC 32 38#define NUM_CONTROL_ALLOC 32
39
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
39#define STAC_PWR_EVENT 0x20 42#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30 43#define STAC_HP_EVENT 0x30
41#define STAC_VREF_EVENT 0x40
42 44
43enum { 45enum {
44 STAC_REF, 46 STAC_REF,
@@ -1686,6 +1688,10 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1686 /* SigmaTel reference board */ 1688 /* SigmaTel reference board */
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1688 "DFI LanParty", STAC_92HD71BXX_REF), 1690 "DFI LanParty", STAC_92HD71BXX_REF),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1692 "HP dv5", STAC_HP_M4),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1694 "HP dv7", STAC_HP_M4),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, 1695 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1690 "unknown HP", STAC_HP_M4), 1696 "unknown HP", STAC_HP_M4),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
@@ -2587,8 +2593,10 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2587}; 2593};
2588 2594
2589/* add dynamic controls */ 2595/* add dynamic controls */
2590static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type, 2596static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2591 int idx, const char *name, unsigned long val) 2597 struct snd_kcontrol_new *ktemp,
2598 int idx, const char *name,
2599 unsigned long val)
2592{ 2600{
2593 struct snd_kcontrol_new *knew; 2601 struct snd_kcontrol_new *knew;
2594 2602
@@ -2607,20 +2615,29 @@ static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2607 } 2615 }
2608 2616
2609 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2617 knew = &spec->kctl_alloc[spec->num_kctl_used];
2610 *knew = stac92xx_control_templates[type]; 2618 *knew = *ktemp;
2611 knew->index = idx; 2619 knew->index = idx;
2612 knew->name = kstrdup(name, GFP_KERNEL); 2620 knew->name = kstrdup(name, GFP_KERNEL);
2613 if (! knew->name) 2621 if (!knew->name)
2614 return -ENOMEM; 2622 return -ENOMEM;
2615 knew->private_value = val; 2623 knew->private_value = val;
2616 spec->num_kctl_used++; 2624 spec->num_kctl_used++;
2617 return 0; 2625 return 0;
2618} 2626}
2619 2627
2628static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2629 int type, int idx, const char *name,
2630 unsigned long val)
2631{
2632 return stac92xx_add_control_temp(spec,
2633 &stac92xx_control_templates[type],
2634 idx, name, val);
2635}
2636
2620 2637
2621/* add dynamic controls */ 2638/* add dynamic controls */
2622static int stac92xx_add_control(struct sigmatel_spec *spec, int type, 2639static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2623 const char *name, unsigned long val) 2640 const char *name, unsigned long val)
2624{ 2641{
2625 return stac92xx_add_control_idx(spec, type, 0, name, val); 2642 return stac92xx_add_control_idx(spec, type, 0, name, val);
2626} 2643}
@@ -3062,6 +3079,43 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3062 return 0; 3079 return 0;
3063} 3080}
3064 3081
3082#ifdef CONFIG_SND_HDA_INPUT_BEEP
3083#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3084
3085static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3086 struct snd_ctl_elem_value *ucontrol)
3087{
3088 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3089 ucontrol->value.integer.value[0] = codec->beep->enabled;
3090 return 0;
3091}
3092
3093static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3094 struct snd_ctl_elem_value *ucontrol)
3095{
3096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3097 int enabled = !!ucontrol->value.integer.value[0];
3098 if (codec->beep->enabled != enabled) {
3099 codec->beep->enabled = enabled;
3100 return 1;
3101 }
3102 return 0;
3103}
3104
3105static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3107 .info = stac92xx_dig_beep_switch_info,
3108 .get = stac92xx_dig_beep_switch_get,
3109 .put = stac92xx_dig_beep_switch_put,
3110};
3111
3112static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3113{
3114 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3115 0, "PC Beep Playback Switch", 0);
3116}
3117#endif
3118
3065static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) 3119static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3066{ 3120{
3067 struct sigmatel_spec *spec = codec->spec; 3121 struct sigmatel_spec *spec = codec->spec;
@@ -3368,6 +3422,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3368#ifdef CONFIG_SND_HDA_INPUT_BEEP 3422#ifdef CONFIG_SND_HDA_INPUT_BEEP
3369 if (spec->digbeep_nid > 0) { 3423 if (spec->digbeep_nid > 0) {
3370 hda_nid_t nid = spec->digbeep_nid; 3424 hda_nid_t nid = spec->digbeep_nid;
3425 unsigned int caps;
3371 3426
3372 err = stac92xx_auto_create_beep_ctls(codec, nid); 3427 err = stac92xx_auto_create_beep_ctls(codec, nid);
3373 if (err < 0) 3428 if (err < 0)
@@ -3375,6 +3430,14 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3375 err = snd_hda_attach_beep_device(codec, nid); 3430 err = snd_hda_attach_beep_device(codec, nid);
3376 if (err < 0) 3431 if (err < 0)
3377 return err; 3432 return err;
3433 /* if no beep switch is available, make its own one */
3434 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3435 if (codec->beep &&
3436 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3437 err = stac92xx_beep_switch_ctl(codec);
3438 if (err < 0)
3439 return err;
3440 }
3378 } 3441 }
3379#endif 3442#endif
3380 3443
@@ -4419,6 +4482,13 @@ again:
4419 stac92xx_set_config_regs(codec); 4482 stac92xx_set_config_regs(codec);
4420 } 4483 }
4421 4484
4485 if (spec->board_config > STAC_92HD71BXX_REF) {
4486 /* GPIO0 = EAPD */
4487 spec->gpio_mask = 0x01;
4488 spec->gpio_dir = 0x01;
4489 spec->gpio_data = 0x01;
4490 }
4491
4422 switch (codec->vendor_id) { 4492 switch (codec->vendor_id) {
4423 case 0x111d76b6: /* 4 Port without Analog Mixer */ 4493 case 0x111d76b6: /* 4 Port without Analog Mixer */
4424 case 0x111d76b7: 4494 case 0x111d76b7:
@@ -4429,10 +4499,10 @@ again:
4429 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 4499 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4430 break; 4500 break;
4431 case 0x111d7608: /* 5 Port with Analog Mixer */ 4501 case 0x111d7608: /* 5 Port with Analog Mixer */
4432 switch (codec->subsystem_id) { 4502 switch (spec->board_config) {
4433 case 0x103c361a: 4503 case STAC_HP_M4:
4434 /* Enable VREF power saving on GPIO1 detect */ 4504 /* Enable VREF power saving on GPIO1 detect */
4435 snd_hda_codec_write(codec, codec->afg, 0, 4505 snd_hda_codec_write_cache(codec, codec->afg, 0,
4436 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); 4506 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4437 snd_hda_codec_write_cache(codec, codec->afg, 0, 4507 snd_hda_codec_write_cache(codec, codec->afg, 0,
4438 AC_VERB_SET_UNSOLICITED_ENABLE, 4508 AC_VERB_SET_UNSOLICITED_ENABLE,
@@ -4478,13 +4548,6 @@ again:
4478 spec->aloopback_mask = 0x50; 4548 spec->aloopback_mask = 0x50;
4479 spec->aloopback_shift = 0; 4549 spec->aloopback_shift = 0;
4480 4550
4481 if (spec->board_config > STAC_92HD71BXX_REF) {
4482 /* GPIO0 = EAPD */
4483 spec->gpio_mask = 0x01;
4484 spec->gpio_dir = 0x01;
4485 spec->gpio_data = 0x01;
4486 }
4487
4488 spec->powerdown_adcs = 1; 4551 spec->powerdown_adcs = 1;
4489 spec->digbeep_nid = 0x26; 4552 spec->digbeep_nid = 0x26;
4490 spec->mux_nids = stac92hd71bxx_mux_nids; 4553 spec->mux_nids = stac92hd71bxx_mux_nids;
@@ -4832,7 +4895,7 @@ static int patch_stac9205(struct hda_codec *codec)
4832 stac92xx_set_config_reg(codec, 0x20, 0x1c410030); 4895 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4833 4896
4834 /* Enable unsol response for GPIO4/Dock HP connection */ 4897 /* Enable unsol response for GPIO4/Dock HP connection */
4835 snd_hda_codec_write(codec, codec->afg, 0, 4898 snd_hda_codec_write_cache(codec, codec->afg, 0,
4836 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); 4899 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4837 snd_hda_codec_write_cache(codec, codec->afg, 0, 4900 snd_hda_codec_write_cache(codec, codec->afg, 0,
4838 AC_VERB_SET_UNSOLICITED_ENABLE, 4901 AC_VERB_SET_UNSOLICITED_ENABLE,
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 0e06c6c9fcc0..73de6e989b3d 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1229,8 +1229,11 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
1229 return -ENOMEM; 1229 return -ENOMEM;
1230 } 1230 }
1231 1231
1232 if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) 1232 if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) {
1233 kfree(mgr);
1234 pci_disable_device(pci);
1233 return -ENODEV; 1235 return -ENODEV;
1236 }
1234 card_name = pcxhr_board_params[pci_id->driver_data].board_name; 1237 card_name = pcxhr_board_params[pci_id->driver_data].board_name;
1235 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; 1238 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips;
1236 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; 1239 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips;