aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap2
-rw-r--r--Documentation/ABI/obsolete/dv13949
-rw-r--r--Documentation/cpusets.txt3
-rw-r--r--Documentation/feature-removal-schedule.txt11
-rw-r--r--Documentation/gpio.txt31
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/networking/ax25.txt18
-rw-r--r--Documentation/networking/ip-sysctl.txt9
-rw-r--r--Documentation/power/pci.txt17
-rw-r--r--Documentation/sony-laptop.txt25
-rw-r--r--Documentation/video4linux/meye.txt7
-rw-r--r--Documentation/x86_64/boot-options.txt4
-rw-r--r--MAINTAINERS67
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/core_mcpcia.c2
-rw-r--r--arch/alpha/kernel/err_titan.c1
-rw-r--r--arch/alpha/kernel/module.c8
-rw-r--r--arch/alpha/kernel/sys_nautilus.c6
-rw-r--r--arch/alpha/kernel/sys_noritake.c9
-rw-r--r--arch/alpha/kernel/sys_rawhide.c15
-rw-r--r--arch/alpha/kernel/sys_sio.c14
-rw-r--r--arch/alpha/kernel/sys_sx164.c2
-rw-r--r--arch/alpha/kernel/sys_titan.c3
-rw-r--r--arch/arm/configs/s3c2410_defconfig11
-rw-r--r--arch/arm/kernel/dma.c1
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c8
-rw-r--r--arch/arm/tools/mach-types99
-rw-r--r--arch/cris/arch-v32/drivers/pci/bios.c4
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c3
-rw-r--r--arch/i386/boot/video.S14
-rw-r--r--arch/i386/kernel/alternative.c21
-rw-r--r--arch/i386/kernel/apic.c32
-rw-r--r--arch/i386/kernel/cpu/amd.c34
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.c2
-rw-r--r--arch/i386/kernel/hpet.c70
-rw-r--r--arch/i386/kernel/io_apic.c2
-rw-r--r--arch/i386/kernel/microcode.c71
-rw-r--r--arch/i386/kernel/nmi.c138
-rw-r--r--arch/i386/kernel/vmi.c32
-rw-r--r--arch/i386/kernel/vmlinux.lds.S2
-rw-r--r--arch/i386/lib/usercopy.c9
-rw-r--r--arch/i386/mm/highmem.c2
-rw-r--r--arch/i386/pci/common.c14
-rw-r--r--arch/ia64/kernel/msi_ia64.c6
-rw-r--r--arch/ia64/kernel/setup.c2
-rw-r--r--arch/ia64/kernel/smpboot.c17
-rw-r--r--arch/ia64/mm/init.c2
-rw-r--r--arch/ia64/pci/pci.c7
-rw-r--r--arch/ia64/sn/kernel/bte_error.c6
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_dma.c8
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/gt64120/momenco_ocelot/prom.c1
-rw-r--r--arch/mips/gt64120/momenco_ocelot/setup.c2
-rw-r--r--arch/mips/kernel/entry.S6
-rw-r--r--arch/mips/kernel/genex.S31
-rw-r--r--arch/mips/kernel/r2300_switch.S10
-rw-r--r--arch/mips/kernel/r4k_switch.S10
-rw-r--r--arch/mips/kernel/signal-common.h9
-rw-r--r--arch/mips/kernel/signal.c52
-rw-r--r--arch/mips/kernel/signal32.c52
-rw-r--r--arch/mips/kernel/smtc.c65
-rw-r--r--arch/mips/kernel/traps.c25
-rw-r--r--arch/mips/mm/fault.c6
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c2
-rw-r--r--arch/mips/pci/pci-ev64120.c1
-rw-r--r--arch/mips/sibyte/bcm1480/irq.c4
-rw-r--r--arch/mips/sibyte/sb1250/setup.c12
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c4
-rw-r--r--arch/powerpc/sysdev/dcr.c2
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c6
-rw-r--r--arch/ppc/8xx_io/commproc.c26
-rw-r--r--arch/ppc/configs/ads8272_defconfig592
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c17
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c17
-rw-r--r--arch/ppc/platforms/mpc885ads_setup.c20
-rw-r--r--arch/s390/kernel/kprobes.c2
-rw-r--r--arch/sh/kernel/sh_ksyms.c3
-rw-r--r--arch/sparc/kernel/pcic.c4
-rw-r--r--arch/sparc/kernel/sys_sunos.c4
-rw-r--r--arch/sparc/lib/atomic32.c2
-rw-r--r--arch/sparc64/kernel/pci.c4
-rw-r--r--arch/sparc64/kernel/pci_iommu.c2
-rw-r--r--arch/sparc64/kernel/sbus.c560
-rw-r--r--arch/sparc64/kernel/sys32.S1
-rw-r--r--arch/sparc64/kernel/sys_sunos32.c4
-rw-r--r--arch/sparc64/kernel/systbls.S2
-rw-r--r--arch/sparc64/solaris/misc.c6
-rw-r--r--arch/um/drivers/chan_kern.c12
-rw-r--r--arch/um/drivers/mconsole_kern.c3
-rw-r--r--arch/um/drivers/ubd_kern.c13
-rw-r--r--arch/um/include/mconsole.h2
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h4
-rw-r--r--arch/um/kernel/mem.c3
-rw-r--r--arch/um/os-Linux/skas/mem.c10
-rw-r--r--arch/um/os-Linux/skas/process.c6
-rw-r--r--arch/um/os-Linux/sys-i386/registers.c5
-rw-r--r--arch/um/os-Linux/sys-x86_64/registers.c4
-rw-r--r--arch/um/sys-i386/delay.c11
-rw-r--r--arch/um/sys-i386/ldt.c3
-rw-r--r--arch/um/sys-x86_64/delay.c11
-rw-r--r--arch/x86_64/boot/video.S14
-rw-r--r--arch/x86_64/kernel/acpi/sleep.c4
-rw-r--r--arch/x86_64/kernel/early-quirks.c2
-rw-r--r--arch/x86_64/kernel/functionlist1
-rw-r--r--arch/x86_64/kernel/hpet.c9
-rw-r--r--arch/x86_64/kernel/i8259.c6
-rw-r--r--arch/x86_64/kernel/k8.c4
-rw-r--r--arch/x86_64/kernel/nmi.c130
-rw-r--r--arch/x86_64/kernel/pci-gart.c6
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S2
-rw-r--r--arch/x86_64/mm/pageattr.c2
-rw-r--r--block/cfq-iosched.c46
-rw-r--r--block/elevator.c7
-rw-r--r--block/genhd.c2
-rw-r--r--block/ll_rw_blk.c6
-rw-r--r--crypto/scatterwalk.c10
-rw-r--r--drivers/acpi/tables.c2
-rw-r--r--drivers/acpi/thermal.c3
-rw-r--r--drivers/ata/ahci.c21
-rw-r--r--drivers/ata/libata-acpi.c8
-rw-r--r--drivers/ata/libata-core.c46
-rw-r--r--drivers/ata/libata-eh.c88
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/pata_pdc202xx_old.c2
-rw-r--r--drivers/ata/pata_sis.c10
-rw-r--r--drivers/base/core.c14
-rw-r--r--drivers/base/driver.c9
-rw-r--r--drivers/base/power/main.c6
-rw-r--r--drivers/block/cciss.c36
-rw-r--r--drivers/block/paride/pcd.c2
-rw-r--r--drivers/block/paride/pf.c2
-rw-r--r--drivers/block/pktcdvd.c3
-rw-r--r--drivers/char/Kconfig33
-rw-r--r--drivers/char/agp/intel-agp.c17
-rw-r--r--drivers/char/drm/Makefile2
-rw-r--r--drivers/char/drm/ffb_context.c544
-rw-r--r--drivers/char/drm/ffb_drv.c355
-rw-r--r--drivers/char/drm/ffb_drv.h379
-rw-r--r--drivers/char/generic_serial.c7
-rw-r--r--drivers/char/mem.c2
-rw-r--r--drivers/char/mxser.c48
-rw-r--r--drivers/char/mxser_new.c45
-rw-r--r--drivers/char/sonypi.c53
-rw-r--r--drivers/char/vt_ioctl.c16
-rw-r--r--drivers/clocksource/acpi_pm.c2
-rw-r--r--drivers/cpufreq/cpufreq.c4
-rw-r--r--drivers/eisa/pci_eisa.c4
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hwmon/w83627ehf.c20
-rw-r--r--drivers/i2c/busses/Kconfig3
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c6
-rw-r--r--drivers/ide/Kconfig7
-rw-r--r--drivers/ide/ide-cd.c9
-rw-r--r--drivers/ide/ide-io.c38
-rw-r--r--drivers/ide/ide-iops.c13
-rw-r--r--drivers/ide/ide.c39
-rw-r--r--drivers/ide/pci/delkin_cb.c1
-rw-r--r--drivers/ide/pci/hpt366.c5
-rw-r--r--drivers/ide/pci/pdc202xx_new.c3
-rw-r--r--drivers/ieee1394/Kconfig6
-rw-r--r--drivers/ieee1394/dv1394.c4
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c12
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c12
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c6
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h1
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c17
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c40
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c1
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c4
-rw-r--r--drivers/isdn/gigaset/common.c6
-rw-r--r--drivers/isdn/gigaset/ev-layer.c4
-rw-r--r--drivers/isdn/gigaset/isocdata.c4
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c2
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c4
-rw-r--r--drivers/isdn/hisax/isar.c2
-rw-r--r--drivers/kvm/mmu.c1
-rw-r--r--drivers/kvm/vmx.c39
-rw-r--r--drivers/macintosh/smu.c4
-rw-r--r--drivers/md/bitmap.c4
-rw-r--r--drivers/md/md.c58
-rw-r--r--drivers/md/raid5.c19
-rw-r--r--drivers/media/common/ir-functions.c6
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c12
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c21
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c9
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/dvb/frontends/isl6421.c1
-rw-r--r--drivers/media/dvb/frontends/tda10086.c2
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c22
-rw-r--r--drivers/media/radio/Kconfig2
-rw-r--r--drivers/media/video/Kconfig6
-rw-r--r--drivers/media/video/meye.c62
-rw-r--r--drivers/media/video/meye.h2
-rw-r--r--drivers/media/video/msp3400-driver.c14
-rw-r--r--drivers/media/video/saa7115.c2
-rw-r--r--drivers/media/video/tuner-core.c10
-rw-r--r--drivers/message/fusion/mptsas.c7
-rw-r--r--drivers/message/i2o/i2o_block.c12
-rw-r--r--drivers/mfd/sm501.c2
-rw-r--r--drivers/misc/Kconfig15
-rw-r--r--drivers/misc/asus-laptop.c151
-rw-r--r--drivers/misc/sony-laptop.c2131
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/atl1/atl1_hw.c1
-rw-r--r--drivers/net/atl1/atl1_main.c10
-rw-r--r--drivers/net/b44.c2
-rw-r--r--drivers/net/bnx2.c41
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/net/cxgb3/common.h16
-rw-r--r--drivers/net/cxgb3/cxgb3_defs.h5
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c39
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c87
-rw-r--r--drivers/net/cxgb3/mc5.c3
-rw-r--r--drivers/net/cxgb3/regs.h10
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/cxgb3/t3_hw.c42
-rw-r--r--drivers/net/cxgb3/version.h5
-rw-r--r--drivers/net/cxgb3/xgmac.c108
-rw-r--r--drivers/net/depca.c3
-rw-r--r--drivers/net/e1000/e1000_main.c13
-rw-r--r--drivers/net/forcedeth.c8
-rw-r--r--drivers/net/hamradio/baycom_ser_fdx.c6
-rw-r--r--drivers/net/ifb.c35
-rw-r--r--drivers/net/irda/pxaficp_ir.c30
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c42
-rw-r--r--drivers/net/netxen/netxen_nic_init.c3
-rw-r--r--drivers/net/ppp_async.c4
-rw-r--r--drivers/net/ppp_generic.c3
-rwxr-xr-xdrivers/net/qla3xxx.c110
-rwxr-xr-xdrivers/net/qla3xxx.h3
-rw-r--r--drivers/net/r8169.c46
-rw-r--r--drivers/net/sc92031.c20
-rw-r--r--drivers/net/sis190.c1
-rw-r--r--drivers/net/sis900.c44
-rw-r--r--drivers/net/skge.c93
-rw-r--r--drivers/net/sky2.c188
-rw-r--r--drivers/net/sky2.h11
-rw-r--r--drivers/net/spider_net.c2
-rw-r--r--drivers/net/sun3lance.c16
-rw-r--r--drivers/net/sungem.c30
-rw-r--r--drivers/net/sunhme.c2
-rw-r--r--drivers/net/sunlance.c4
-rw-r--r--drivers/net/sunqe.c4
-rw-r--r--drivers/net/tg3.c136
-rw-r--r--drivers/net/tg3.h5
-rw-r--r--drivers/net/wan/lmc/lmc_media.h65
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c20
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c61
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c12
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c12
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_al2230.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c1
-rw-r--r--drivers/oprofile/event_buffer.c5
-rw-r--r--drivers/oprofile/oprofilefs.c5
-rw-r--r--drivers/parport/parport_sunbpp.c10
-rw-r--r--drivers/pci/msi.c1
-rw-r--r--drivers/pci/pcie/portdrv_pci.c2
-rw-r--r--drivers/pci/probe.c45
-rw-r--r--drivers/pci/quirks.c18
-rw-r--r--drivers/pcmcia/au1000_generic.c2
-rw-r--r--drivers/pcmcia/omap_cf.c41
-rw-r--r--drivers/pnp/system.c13
-rw-r--r--drivers/rtc/rtc-cmos.c50
-rw-r--r--drivers/s390/block/dasd_diag.c10
-rw-r--r--drivers/s390/cio/device_status.c14
-rw-r--r--drivers/s390/crypto/ap_bus.c30
-rw-r--r--drivers/sbus/char/openprom.c3
-rw-r--r--drivers/sbus/char/vfc_dev.c3
-rw-r--r--drivers/scsi/3w-xxxx.c11
-rw-r--r--drivers/scsi/gdth.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c5
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/serial/8250.c8
-rw-r--r--drivers/serial/icom.c9
-rw-r--r--drivers/serial/icom.h1
-rw-r--r--drivers/spi/spi.c10
-rw-r--r--drivers/spi/spi_s3c24xx.c4
-rw-r--r--drivers/tc/zs.c1
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/gadget/omap_udc.c103
-rw-r--r--drivers/usb/host/ehci-hcd.c1
-rw-r--r--drivers/usb/host/uhci-debug.c26
-rw-r--r--drivers/usb/host/uhci-hcd.c3
-rw-r--r--drivers/usb/host/uhci-q.c94
-rw-r--r--drivers/usb/net/pegasus.c17
-rw-r--r--drivers/usb/net/pegasus.h3
-rw-r--r--drivers/usb/serial/airprime.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/serial/generic.c7
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/cg3.c26
-rw-r--r--drivers/video/ffb.c84
-rw-r--r--fs/9p/v9fs_vfs.h1
-rw-r--r--fs/9p/vfs_file.c4
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/aio.c1
-rw-r--r--fs/autofs4/root.c6
-rw-r--r--fs/binfmt_elf.c5
-rw-r--r--fs/binfmt_elf_fdpic.c2
-rw-r--r--fs/char_dev.c2
-rw-r--r--fs/compat_ioctl.c9
-rw-r--r--fs/exec.c18
-rw-r--r--fs/ext3/inode.c85
-rw-r--r--fs/ext4/inode.c85
-rw-r--r--fs/fuse/dir.c5
-rw-r--r--fs/fuse/fuse_i.h5
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/hostfs/hostfs_kern.c25
-rw-r--r--fs/nfs/dir.c3
-rw-r--r--fs/nfs/direct.c11
-rw-r--r--fs/nfs/inode.c6
-rw-r--r--fs/nfs/write.c197
-rw-r--r--fs/nfsd/nfs3xdr.c6
-rw-r--r--fs/nfsd/nfs4acl.c2
-rw-r--r--fs/nfsd/nfs4state.c6
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c8
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c99
-rw-r--r--fs/ocfs2/dlm/dlmthread.c10
-rw-r--r--fs/proc/Makefile3
-rw-r--r--fs/proc/internal.h4
-rw-r--r--fs/proc/root.c2
-rw-r--r--fs/reiserfs/item_ops.c2
-rw-r--r--fs/reiserfs/xattr.c92
-rw-r--r--fs/splice.c109
-rw-r--r--fs/ufs/inode.c29
-rw-r--r--include/asm-alpha/compiler.h47
-rw-r--r--include/asm-alpha/core_mcpcia.h2
-rw-r--r--include/asm-alpha/io.h1
-rw-r--r--include/asm-arm/arch-ixp4xx/io.h17
-rw-r--r--include/asm-arm/system.h34
-rw-r--r--include/asm-arm/unistd.h2
-rw-r--r--include/asm-generic/pgtable.h2
-rw-r--r--include/asm-i386/cpufeature.h1
-rw-r--r--include/asm-i386/msr.h2
-rw-r--r--include/asm-i386/paravirt.h3
-rw-r--r--include/asm-i386/termbits.h2
-rw-r--r--include/asm-ia64/processor.h2
-rw-r--r--include/asm-ia64/sn/pcibr_provider.h5
-rw-r--r--include/asm-mips/bug.h3
-rw-r--r--include/asm-mips/checksum.h2
-rw-r--r--include/asm-mips/fpu.h25
-rw-r--r--include/asm-mips/irqflags.h55
-rw-r--r--include/asm-mips/marvell.h1
-rw-r--r--include/asm-mips/sibyte/sb1250_scd.h1
-rw-r--r--include/asm-mips/smtc_ipi.h16
-rw-r--r--include/asm-mips/thread_info.h1
-rw-r--r--include/asm-powerpc/immap_qe.h3
-rw-r--r--include/asm-powerpc/systbl.h2
-rw-r--r--include/asm-s390/checksum.h59
-rw-r--r--include/asm-sh/hp6xx.h6
-rw-r--r--include/asm-sh/system.h1
-rw-r--r--include/asm-sparc/a.out.h2
-rw-r--r--include/asm-sparc/mostek.h2
-rw-r--r--include/asm-sparc64/a.out.h2
-rw-r--r--include/asm-sparc64/mostek.h2
-rw-r--r--include/asm-um/common.lds.S1
-rw-r--r--include/asm-um/delay.h17
-rw-r--r--include/asm-um/pgtable-2level.h8
-rw-r--r--include/asm-x86_64/hw_irq.h2
-rw-r--r--include/linux/ata.h1
-rw-r--r--include/linux/compiler.h4
-rw-r--r--include/linux/cpu.h4
-rw-r--r--include/linux/device.h1
-rw-r--r--include/linux/eventpoll.h7
-rw-r--r--include/linux/hrtimer.h3
-rw-r--r--include/linux/ide.h3
-rw-r--r--include/linux/io.h13
-rw-r--r--include/linux/ipc.h9
-rw-r--r--include/linux/ipv6.h3
-rw-r--r--include/linux/kdev_t.h2
-rw-r--r--include/linux/libata.h6
-rw-r--r--include/linux/nfs_page.h31
-rw-r--r--include/linux/pipe_fs_i.h4
-rw-r--r--include/linux/plist.h54
-rw-r--r--include/linux/raid/md_k.h1
-rw-r--r--include/linux/skbuff.h15
-rw-r--r--include/linux/sony-laptop.h34
-rw-r--r--include/linux/sysctl.h1
-rw-r--r--include/linux/taskstats.h13
-rw-r--r--include/linux/utsname.h2
-rw-r--r--include/linux/wireless.h21
-rw-r--r--include/media/saa7146_vv.h3
-rw-r--r--include/net/fib_rules.h1
-rw-r--r--include/net/ip6_fib.h1
-rw-r--r--include/net/iw_handler.h30
-rw-r--r--include/net/neighbour.h2
-rw-r--r--include/net/pkt_cls.h7
-rw-r--r--ipc/util.c7
-rw-r--r--kernel/cpu.c32
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/hrtimer.c19
-rw-r--r--kernel/irq/devres.c2
-rw-r--r--kernel/module.c18
-rw-r--r--kernel/params.c4
-rw-r--r--kernel/power/disk.c1
-rw-r--r--kernel/power/swsusp.c2
-rw-r--r--kernel/power/user.c3
-rw-r--r--kernel/sched.c36
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/time.c2
-rw-r--r--kernel/time/clockevents.c69
-rw-r--r--kernel/time/jiffies.c2
-rw-r--r--kernel/time/ntp.c30
-rw-r--r--kernel/timer.c2
-rw-r--r--mm/bounce.c2
-rw-r--r--mm/filemap_xip.c48
-rw-r--r--mm/madvise.c19
-rw-r--r--mm/migrate.c15
-rw-r--r--mm/nommu.c1
-rw-r--r--mm/oom_kill.c4
-rw-r--r--mm/rmap.c4
-rw-r--r--mm/shmem.c132
-rw-r--r--mm/slab.c4
-rw-r--r--net/8021q/vlan_dev.c3
-rw-r--r--net/appletalk/ddp.c7
-rw-r--r--net/atm/clip.c9
-rw-r--r--net/ax25/Kconfig61
-rw-r--r--net/bluetooth/hidp/core.c23
-rw-r--r--net/bridge/br_stp_if.c9
-rw-r--r--net/core/dev.c23
-rw-r--r--net/core/fib_rules.c32
-rw-r--r--net/core/neighbour.c19
-rw-r--r--net/core/netpoll.c7
-rw-r--r--net/core/pktgen.c3
-rw-r--r--net/core/rtnetlink.c3
-rw-r--r--net/core/skbuff.c57
-rw-r--r--net/core/wireless.c82
-rw-r--r--net/dccp/dccp.h1
-rw-r--r--net/dccp/proto.c4
-rw-r--r--net/dccp/timer.c2
-rw-r--r--net/decnet/dn_fib.c5
-rw-r--r--net/decnet/dn_rules.c13
-rw-r--r--net/ipv4/fib_frontend.c13
-rw-r--r--net/ipv4/fib_rules.c14
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/fib_trie.c9
-rw-r--r--net/ipv4/netfilter/arp_tables.c10
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c2
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c7
-rw-r--r--net/ipv4/tcp_cong.c23
-rw-r--r--net/ipv4/tcp_output.c6
-rw-r--r--net/ipv4/xfrm4_mode_beet.c28
-rw-r--r--net/ipv6/addrconf.c14
-rw-r--r--net/ipv6/exthdrs.c40
-rw-r--r--net/ipv6/fib6_rules.c14
-rw-r--r--net/ipv6/ip6_fib.c8
-rw-r--r--net/ipv6/ip6_input.c8
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/ipv6/route.c145
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/irda/af_irda.c3
-rw-r--r--net/key/af_key.c90
-rw-r--r--net/netlink/af_netlink.c6
-rw-r--r--net/sched/Makefile1
-rw-r--r--net/sched/act_mirred.c2
-rw-r--r--net/sched/cls_basic.c17
-rw-r--r--net/sched/cls_tcindex.c4
-rw-r--r--net/sched/sch_hfsc.c4
-rw-r--r--net/sched/sch_htb.c6
-rw-r--r--net/sctp/socket.c54
-rw-r--r--net/sctp/ulpqueue.c9
-rw-r--r--net/socket.c7
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/svcauth_unix.c21
-rw-r--r--net/sunrpc/svcsock.c20
-rw-r--r--net/sunrpc/xprt.c10
-rw-r--r--net/xfrm/xfrm_state.c3
-rw-r--r--net/xfrm/xfrm_user.c7
-rw-r--r--scripts/basic/fixdep.c10
476 files changed, 7409 insertions, 5057 deletions
diff --git a/.mailmap b/.mailmap
index bf62dbea88e6..ebf9bf84da0a 100644
--- a/.mailmap
+++ b/.mailmap
@@ -67,6 +67,8 @@ Koushik <raghavendra.koushik@neterion.com>
67Leonid I Ananiev <leonid.i.ananiev@intel.com> 67Leonid I Ananiev <leonid.i.ananiev@intel.com>
68Linas Vepstas <linas@austin.ibm.com> 68Linas Vepstas <linas@austin.ibm.com>
69Matthieu CASTET <castet.matthieu@free.fr> 69Matthieu CASTET <castet.matthieu@free.fr>
70Michael Buesch <mb@bu3sch.de>
71Michael Buesch <mbuesch@freenet.de>
70Michel Dänzer <michel@tungstengraphics.com> 72Michel Dänzer <michel@tungstengraphics.com>
71Mitesh shah <mshah@teja.com> 73Mitesh shah <mshah@teja.com>
72Morten Welinder <terra@gnome.org> 74Morten Welinder <terra@gnome.org>
diff --git a/Documentation/ABI/obsolete/dv1394 b/Documentation/ABI/obsolete/dv1394
new file mode 100644
index 000000000000..2ee36864ca10
--- /dev/null
+++ b/Documentation/ABI/obsolete/dv1394
@@ -0,0 +1,9 @@
1What: dv1394 (a.k.a. "OHCI-DV I/O support" for FireWire)
2Contact: linux1394-devel@lists.sourceforge.net
3Description:
4 New application development should use raw1394 + userspace libraries
5 instead, notably libiec61883 which is functionally equivalent.
6
7Users:
8 ffmpeg/libavformat (used by a variety of media players)
9 dvgrab v1.x (replaced by dvgrab2 on top of raw1394 and resp. libraries)
diff --git a/Documentation/cpusets.txt b/Documentation/cpusets.txt
index 842f0d1ab216..f2c0a6842930 100644
--- a/Documentation/cpusets.txt
+++ b/Documentation/cpusets.txt
@@ -557,6 +557,9 @@ Set some flags:
557Add some cpus: 557Add some cpus:
558# /bin/echo 0-7 > cpus 558# /bin/echo 0-7 > cpus
559 559
560Add some mems:
561# /bin/echo 0-7 > mems
562
560Now attach your shell to this cpuset: 563Now attach your shell to this cpuset:
561# /bin/echo $$ > tasks 564# /bin/echo $$ > tasks
562 565
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 0bc8b0b2e103..19b4c96b2a49 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -39,17 +39,6 @@ Who: Dan Dennedy <dan@dennedy.org>, Stefan Richter <stefanr@s5r6.in-berlin.de>
39 39
40--------------------------- 40---------------------------
41 41
42What: dv1394 driver (CONFIG_IEEE1394_DV1394)
43When: June 2007
44Why: Replaced by raw1394 + userspace libraries, notably libiec61883. This
45 shift of application support has been indicated on www.linux1394.org
46 and developers' mailinglists for quite some time. Major applications
47 have been converted, with the exception of ffmpeg and hence xine.
48 Piped output of dvgrab2 is a partial equivalent to dv1394.
49Who: Dan Dennedy <dan@dennedy.org>, Stefan Richter <stefanr@s5r6.in-berlin.de>
50
51---------------------------
52
53What: Video4Linux API 1 ioctls and video_decoder.h from Video devices. 42What: Video4Linux API 1 ioctls and video_decoder.h from Video devices.
54When: December 2006 43When: December 2006
55Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6 44Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 989f1130f4f3..f8528db967fa 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -27,7 +27,7 @@ The exact capabilities of GPIOs vary between systems. Common options:
27 - Output values are writable (high=1, low=0). Some chips also have 27 - Output values are writable (high=1, low=0). Some chips also have
28 options about how that value is driven, so that for example only one 28 options about how that value is driven, so that for example only one
29 value might be driven ... supporting "wire-OR" and similar schemes 29 value might be driven ... supporting "wire-OR" and similar schemes
30 for the other value. 30 for the other value (notably, "open drain" signaling).
31 31
32 - Input values are likewise readable (1, 0). Some chips support readback 32 - Input values are likewise readable (1, 0). Some chips support readback
33 of pins configured as "output", which is very useful in such "wire-OR" 33 of pins configured as "output", which is very useful in such "wire-OR"
@@ -247,6 +247,35 @@ with gpio_get_value(), for example to initialize or update driver state
247when the IRQ is edge-triggered. 247when the IRQ is edge-triggered.
248 248
249 249
250Emulating Open Drain Signals
251----------------------------
252Sometimes shared signals need to use "open drain" signaling, where only the
253low signal level is actually driven. (That term applies to CMOS transistors;
254"open collector" is used for TTL.) A pullup resistor causes the high signal
255level. This is sometimes called a "wire-AND"; or more practically, from the
256negative logic (low=true) perspective this is a "wire-OR".
257
258One common example of an open drain signal is a shared active-low IRQ line.
259Also, bidirectional data bus signals sometimes use open drain signals.
260
261Some GPIO controllers directly support open drain outputs; many don't. When
262you need open drain signaling but your hardware doesn't directly support it,
263there's a common idiom you can use to emulate it with any GPIO pin that can
264be used as either an input or an output:
265
266 LOW: gpio_direction_output(gpio, 0) ... this drives the signal
267 and overrides the pullup.
268
269 HIGH: gpio_direction_input(gpio) ... this turns off the output,
270 so the pullup (or some other device) controls the signal.
271
272If you are "driving" the signal high but gpio_get_value(gpio) reports a low
273value (after the appropriate rise time passes), you know some other component
274is driving the shared signal low. That's not necessarily an error. As one
275common example, that's how I2C clocks are stretched: a slave that needs a
276slower clock delays the rising edge of SCK, and the I2C master adjusts its
277signaling rate accordingly.
278
250 279
251What do these conventions omit? 280What do these conventions omit?
252=============================== 281===============================
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ef2ffded1392..12533a958c51 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -142,7 +142,7 @@ and is between 256 and 4096 characters. It is defined in the file
142 Format: <int> 142 Format: <int>
143 2: use 2nd APIC table, if available 143 2: use 2nd APIC table, if available
144 1,0: use 1st APIC table 144 1,0: use 1st APIC table
145 default: 2 145 default: 0
146 146
147 acpi_sleep= [HW,ACPI] Sleep options 147 acpi_sleep= [HW,ACPI] Sleep options
148 Format: { s3_bios, s3_mode } 148 Format: { s3_bios, s3_mode }
diff --git a/Documentation/networking/ax25.txt b/Documentation/networking/ax25.txt
index 37c25b0925f0..8257dbf9be57 100644
--- a/Documentation/networking/ax25.txt
+++ b/Documentation/networking/ax25.txt
@@ -1,16 +1,10 @@
1To use the amateur radio protocols within Linux you will need to get a 1To use the amateur radio protocols within Linux you will need to get a
2suitable copy of the AX.25 Utilities. More detailed information about these 2suitable copy of the AX.25 Utilities. More detailed information about
3and associated programs can be found on http://zone.pspt.fi/~jsn/. 3AX.25, NET/ROM and ROSE, associated programs and and utilities can be
4 4found on http://www.linux-ax25.org.
5For more information about the AX.25, NET/ROM and ROSE protocol stacks, see
6the AX25-HOWTO written by Terry Dawson <terry@perf.no.itg.telstra.com.au>
7who is also the AX.25 Utilities maintainer.
8 5
9There is an active mailing list for discussing Linux amateur radio matters 6There is an active mailing list for discussing Linux amateur radio matters
10called linux-hams. To subscribe to it, send a message to 7called linux-hams@vger.kernel.org. To subscribe to it, send a message to
11majordomo@vger.kernel.org with the words "subscribe linux-hams" in the body 8majordomo@vger.kernel.org with the words "subscribe linux-hams" in the body
12of the message, the subject field is ignored. 9of the message, the subject field is ignored. You don't need to be
13 10subscribed to post but of course that means you might miss an answer.
14Jonathan G4KLX
15
16g4klx@g4klx.demon.co.uk
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index d3aae1f9b4c1..702d1d8dd04a 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -851,6 +851,15 @@ accept_redirects - BOOLEAN
851 Functional default: enabled if local forwarding is disabled. 851 Functional default: enabled if local forwarding is disabled.
852 disabled if local forwarding is enabled. 852 disabled if local forwarding is enabled.
853 853
854accept_source_route - INTEGER
855 Accept source routing (routing extension header).
856
857 > 0: Accept routing header.
858 = 0: Accept only routing header type 2.
859 < 0: Do not accept routing header.
860
861 Default: 0
862
854autoconf - BOOLEAN 863autoconf - BOOLEAN
855 Autoconfigure addresses using Prefix Information in Router 864 Autoconfigure addresses using Prefix Information in Router
856 Advertisements. 865 Advertisements.
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index c750f9f2e76e..b6a3cbf7e846 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -102,31 +102,28 @@ pci_save_state
102-------------- 102--------------
103 103
104Usage: 104Usage:
105 pci_save_state(dev, buffer); 105 pci_save_state(struct pci_dev *dev);
106 106
107Description: 107Description:
108 Save first 64 bytes of PCI config space. Buffer must be allocated by 108 Save first 64 bytes of PCI config space, along with any additional
109 caller. 109 PCI-Express or PCI-X information.
110 110
111 111
112pci_restore_state 112pci_restore_state
113----------------- 113-----------------
114 114
115Usage: 115Usage:
116 pci_restore_state(dev, buffer); 116 pci_restore_state(struct pci_dev *dev);
117 117
118Description: 118Description:
119 Restore previously saved config space. (First 64 bytes only); 119 Restore previously saved config space.
120
121 If buffer is NULL, then restore what information we know about the
122 device from bootup: BARs and interrupt line.
123 120
124 121
125pci_set_power_state 122pci_set_power_state
126------------------- 123-------------------
127 124
128Usage: 125Usage:
129 pci_set_power_state(dev, state); 126 pci_set_power_state(struct pci_dev *dev, pci_power_t state);
130 127
131Description: 128Description:
132 Transition device to low power state using PCI PM Capabilities 129 Transition device to low power state using PCI PM Capabilities
@@ -142,7 +139,7 @@ pci_enable_wake
142--------------- 139---------------
143 140
144Usage: 141Usage:
145 pci_enable_wake(dev, state, enable); 142 pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
146 143
147Description: 144Description:
148 Enable device to generate PME# during low power state using PCI PM 145 Enable device to generate PME# during low power state using PCI PM
diff --git a/Documentation/sony-laptop.txt b/Documentation/sony-laptop.txt
index dfd26df056f4..7a5c1a81905c 100644
--- a/Documentation/sony-laptop.txt
+++ b/Documentation/sony-laptop.txt
@@ -3,12 +3,18 @@ Sony Notebook Control Driver (SNC) Readme
3 Copyright (C) 2004- 2005 Stelian Pop <stelian@popies.net> 3 Copyright (C) 2004- 2005 Stelian Pop <stelian@popies.net>
4 Copyright (C) 2007 Mattia Dongili <malattia@linux.it> 4 Copyright (C) 2007 Mattia Dongili <malattia@linux.it>
5 5
6This mini-driver drives the SNC device present in the ACPI BIOS of 6This mini-driver drives the SNC and SPIC device present in the ACPI BIOS of the
7the Sony Vaio laptops. 7Sony Vaio laptops. This driver mixes both devices functions under the same
8(hopefully consistent) interface. This also means that the sonypi driver is
9obsoleted by sony-laptop now.
8 10
9It gives access to some extra laptop functionalities. In its current 11Fn keys (hotkeys):
10form, this driver let the user set or query the screen brightness 12------------------
11through the backlight subsystem and remove/apply power to some devices. 13Some models report hotkeys through the SNC or SPIC devices, such events are
14reported both through the ACPI subsystem as acpi events and through the INPUT
15subsystem. See the logs of acpid or /proc/acpi/event and
16/proc/bus/input/devices to find out what those events are and which input
17devices are created by the driver.
12 18
13Backlight control: 19Backlight control:
14------------------ 20------------------
@@ -39,6 +45,8 @@ The files are:
39 audiopower power on/off the internal sound card 45 audiopower power on/off the internal sound card
40 lanpower power on/off the internal ethernet card 46 lanpower power on/off the internal ethernet card
41 (only in debug mode) 47 (only in debug mode)
48 bluetoothpower power on/off the internal bluetooth device
49 fanspeed get/set the fan speed
42 50
43Note that some files may be missing if they are not supported 51Note that some files may be missing if they are not supported
44by your particular laptop model. 52by your particular laptop model.
@@ -76,9 +84,9 @@ The sony-laptop driver creates, for some of those methods (the most
76current ones found on several Vaio models), an entry under 84current ones found on several Vaio models), an entry under
77/sys/devices/platform/sony-laptop, just like the 'cdpower' one. 85/sys/devices/platform/sony-laptop, just like the 'cdpower' one.
78You can create other entries corresponding to your own laptop methods by 86You can create other entries corresponding to your own laptop methods by
79further editing the source (see the 'sony_acpi_values' table, and add a new 87further editing the source (see the 'sony_nc_values' table, and add a new
80entry to this table with your get/set method names using the 88entry to this table with your get/set method names using the
81HANDLE_NAMES macro). 89SNC_HANDLE_NAMES macro).
82 90
83Your mission, should you accept it, is to try finding out what 91Your mission, should you accept it, is to try finding out what
84those entries are for, by reading/writing random values from/to those 92those entries are for, by reading/writing random values from/to those
@@ -87,6 +95,9 @@ files and find out what is the impact on your laptop.
87Should you find anything interesting, please report it back to me, 95Should you find anything interesting, please report it back to me,
88I will not disavow all knowledge of your actions :) 96I will not disavow all knowledge of your actions :)
89 97
98See also http://www.linux.it/~malattia/wiki/index.php/Sony_drivers for other
99useful info.
100
90Bugs/Limitations: 101Bugs/Limitations:
91----------------- 102-----------------
92 103
diff --git a/Documentation/video4linux/meye.txt b/Documentation/video4linux/meye.txt
index ecb34160e61d..5e51c59bf2b0 100644
--- a/Documentation/video4linux/meye.txt
+++ b/Documentation/video4linux/meye.txt
@@ -5,10 +5,9 @@ Vaio Picturebook Motion Eye Camera Driver Readme
5 Copyright (C) 2000 Andrew Tridgell <tridge@samba.org> 5 Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
6 6
7This driver enable the use of video4linux compatible applications with the 7This driver enable the use of video4linux compatible applications with the
8Motion Eye camera. This driver requires the "Sony Vaio Programmable I/O 8Motion Eye camera. This driver requires the "Sony Laptop Extras" driver (which
9Control Device" driver (which can be found in the "Character drivers" 9can be found in the "Misc devices" section of the kernel configuration utility)
10section of the kernel configuration utility) to be compiled and installed 10to be compiled and installed (using its "camera=1" parameter).
11(using its "camera=1" parameter).
12 11
13It can do at maximum 30 fps @ 320x240 or 15 fps @ 640x480. 12It can do at maximum 30 fps @ 320x240 or 15 fps @ 640x480.
14 13
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 625a21db0c2a..85f51e5a749f 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -293,7 +293,3 @@ Debugging
293 stuck (default) 293 stuck (default)
294 294
295Miscellaneous 295Miscellaneous
296
297 noreplacement Don't replace instructions with more appropriate ones
298 for the CPU. This may be useful on asymmetric MP systems
299 where some CPUs have less capabilities than others.
diff --git a/MAINTAINERS b/MAINTAINERS
index 7d421831a0cc..d0243d07da20 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -198,10 +198,25 @@ L: linux-sound@vger.kernel.org
198W: http://www.stud.uni-karlsruhe.de/~uh1b/ 198W: http://www.stud.uni-karlsruhe.de/~uh1b/
199S: Maintained 199S: Maintained
200 200
201IPS SCSI RAID DRIVER
202P: Adaptec OEM Raid Solutions
203M: aacraid@adaptec.com
204L: linux-scsi@vger.kernel.org
205W: http://www.adaptec.com/
206S: Maintained
207
208DPT_I2O SCSI RAID DRIVER
209P: Adaptec OEM Raid Solutions
210M: aacraid@adaptec.com
211L: linux-scsi@vger.kernel.org
212W: http://www.adaptec.com/
213S: Maintained
214
201AACRAID SCSI RAID DRIVER 215AACRAID SCSI RAID DRIVER
202P: Adaptec OEM Raid Solutions 216P: Adaptec OEM Raid Solutions
217M: aacraid@adaptec.com
203L: linux-scsi@vger.kernel.org 218L: linux-scsi@vger.kernel.org
204W: http://linux.dell.com/storage.shtml 219W: http://www.adaptec.com/
205S: Supported 220S: Supported
206 221
207ACPI 222ACPI
@@ -1303,7 +1318,7 @@ S: Maintained
1303ETHERNET BRIDGE 1318ETHERNET BRIDGE
1304P: Stephen Hemminger 1319P: Stephen Hemminger
1305M: shemminger@linux-foundation.org 1320M: shemminger@linux-foundation.org
1306L: bridge@lists.osdl.org 1321L: bridge@lists.linux-foundation.org
1307W: http://bridge.sourceforge.net/ 1322W: http://bridge.sourceforge.net/
1308S: Maintained 1323S: Maintained
1309 1324
@@ -1340,6 +1355,11 @@ M: kevin.curtis@farsite.co.uk
1340W: http://www.farsite.co.uk/ 1355W: http://www.farsite.co.uk/
1341S: Supported 1356S: Supported
1342 1357
1358FAULT INJECTION SUPPORT
1359P: Akinobu Mita
1360M: akinobu.mita@gmail.com
1361S: Supported
1362
1343FRAMEBUFFER LAYER 1363FRAMEBUFFER LAYER
1344P: Antonino Daplas 1364P: Antonino Daplas
1345M: adaplas@gmail.com 1365M: adaplas@gmail.com
@@ -1389,7 +1409,7 @@ M: hch@infradead.org
1389W: ftp://ftp.openlinux.org/pub/people/hch/vxfs 1409W: ftp://ftp.openlinux.org/pub/people/hch/vxfs
1390S: Maintained 1410S: Maintained
1391 1411
1392FUJITSU FR-V PORT 1412FUJITSU FR-V (FRV) PORT
1393P: David Howells 1413P: David Howells
1394M: dhowells@redhat.com 1414M: dhowells@redhat.com
1395S: Maintained 1415S: Maintained
@@ -1585,12 +1605,6 @@ L: i2c@lm-sensors.org
1585T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/ 1605T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
1586S: Maintained 1606S: Maintained
1587 1607
1588I2O
1589P: Markus Lidel
1590M: markus.lidel@shadowconnect.com
1591W: http://i2o.shadowconnect.com/
1592S: Maintained
1593
1594i386 BOOT CODE 1608i386 BOOT CODE
1595P: Riley H. Williams 1609P: Riley H. Williams
1596M: Riley@Williams.Name 1610M: Riley@Williams.Name
@@ -1672,7 +1686,7 @@ S: Maintained
1672 1686
1673IEEE 1394 SUBSYSTEM 1687IEEE 1394 SUBSYSTEM
1674P: Ben Collins 1688P: Ben Collins
1675M: bcollins@debian.org 1689M: ben.collins@ubuntu.com
1676P: Stefan Richter 1690P: Stefan Richter
1677M: stefanr@s5r6.in-berlin.de 1691M: stefanr@s5r6.in-berlin.de
1678L: linux1394-devel@lists.sourceforge.net 1692L: linux1394-devel@lists.sourceforge.net
@@ -1680,25 +1694,11 @@ W: http://www.linux1394.org/
1680T: git kernel.org:/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git 1694T: git kernel.org:/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git
1681S: Maintained 1695S: Maintained
1682 1696
1683IEEE 1394 IPV4 DRIVER (eth1394) 1697IEEE 1394 RAW I/O DRIVER (raw1394)
1684P: Stefan Richter
1685M: stefanr@s5r6.in-berlin.de
1686L: linux1394-devel@lists.sourceforge.net
1687S: Odd Fixes
1688
1689IEEE 1394 PCILYNX DRIVER
1690P: Jody McIntyre
1691M: scjody@modernduck.com
1692P: Stefan Richter
1693M: stefanr@s5r6.in-berlin.de
1694L: linux1394-devel@lists.sourceforge.net
1695S: Odd Fixes
1696
1697IEEE 1394 RAW I/O DRIVER
1698P: Ben Collins
1699M: bcollins@debian.org
1700P: Dan Dennedy 1698P: Dan Dennedy
1701M: dan@dennedy.org 1699M: dan@dennedy.org
1700P: Stefan Richter
1701M: stefanr@s5r6.in-berlin.de
1702L: linux1394-devel@lists.sourceforge.net 1702L: linux1394-devel@lists.sourceforge.net
1703S: Maintained 1703S: Maintained
1704 1704
@@ -1933,7 +1933,7 @@ P: Vivek Goyal
1933M: vgoyal@in.ibm.com 1933M: vgoyal@in.ibm.com
1934P: Haren Myneni 1934P: Haren Myneni
1935M: hbabu@us.ibm.com 1935M: hbabu@us.ibm.com
1936L: fastboot@lists.osdl.org 1936L: fastboot@lists.linux-foundation.org
1937L: linux-kernel@vger.kernel.org 1937L: linux-kernel@vger.kernel.org
1938W: http://lse.sourceforge.net/kdump/ 1938W: http://lse.sourceforge.net/kdump/
1939S: Maintained 1939S: Maintained
@@ -1960,7 +1960,7 @@ S: Maintained
1960 1960
1961KERNEL JANITORS 1961KERNEL JANITORS
1962P: Several 1962P: Several
1963L: kernel-janitors@lists.osdl.org 1963L: kernel-janitors@lists.linux-foundation.org
1964W: http://www.kerneljanitors.org/ 1964W: http://www.kerneljanitors.org/
1965S: Maintained 1965S: Maintained
1966 1966
@@ -1983,7 +1983,7 @@ P: Eric Biederman
1983M: ebiederm@xmission.com 1983M: ebiederm@xmission.com
1984W: http://www.xmission.com/~ebiederm/files/kexec/ 1984W: http://www.xmission.com/~ebiederm/files/kexec/
1985L: linux-kernel@vger.kernel.org 1985L: linux-kernel@vger.kernel.org
1986L: fastboot@lists.osdl.org 1986L: fastboot@lists.linux-foundation.org
1987S: Maintained 1987S: Maintained
1988 1988
1989KPROBES 1989KPROBES
@@ -2321,7 +2321,7 @@ S: Maintained
2321NETEM NETWORK EMULATOR 2321NETEM NETWORK EMULATOR
2322P: Stephen Hemminger 2322P: Stephen Hemminger
2323M: shemminger@linux-foundation.org 2323M: shemminger@linux-foundation.org
2324L: netem@lists.osdl.org 2324L: netem@lists.linux-foundation.org
2325S: Maintained 2325S: Maintained
2326 2326
2327NETFILTER/IPTABLES/IPCHAINS 2327NETFILTER/IPTABLES/IPCHAINS
@@ -2919,9 +2919,12 @@ L: linux-scsi@vger.kernel.org
2919S: Maintained 2919S: Maintained
2920 2920
2921SCTP PROTOCOL 2921SCTP PROTOCOL
2922P: Vlad Yasevich
2923M: vladislav.yasevich@hp.com
2922P: Sridhar Samudrala 2924P: Sridhar Samudrala
2923M: sri@us.ibm.com 2925M: sri@us.ibm.com
2924L: lksctp-developers@lists.sourceforge.net 2926L: lksctp-developers@lists.sourceforge.net
2927W: http://lksctp.sourceforge.net
2925S: Supported 2928S: Supported
2926 2929
2927SCx200 CPU SUPPORT 2930SCx200 CPU SUPPORT
@@ -3047,7 +3050,7 @@ S: Supported
3047SOFTWARE SUSPEND: 3050SOFTWARE SUSPEND:
3048P: Pavel Machek 3051P: Pavel Machek
3049M: pavel@suse.cz 3052M: pavel@suse.cz
3050L: linux-pm@lists.osdl.org 3053L: linux-pm@lists.linux-foundation.org
3051S: Maintained 3054S: Maintained
3052 3055
3053SONIC NETWORK DRIVER 3056SONIC NETWORK DRIVER
diff --git a/Makefile b/Makefile
index 2f57f57d0100..d970cb16545a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 21 3SUBLEVEL = 21
4EXTRAVERSION = -rc5 4EXTRAVERSION =
5NAME = Nocturnal Monster Puppy 5NAME = Nocturnal Monster Puppy
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/core_mcpcia.c b/arch/alpha/kernel/core_mcpcia.c
index 8d019071190a..381fec0af52e 100644
--- a/arch/alpha/kernel/core_mcpcia.c
+++ b/arch/alpha/kernel/core_mcpcia.c
@@ -40,8 +40,6 @@
40# define DBG_CFG(args) 40# define DBG_CFG(args)
41#endif 41#endif
42 42
43#define MCPCIA_MAX_HOSES 4
44
45/* 43/*
46 * Given a bus, device, and function number, compute resulting 44 * Given a bus, device, and function number, compute resulting
47 * configuration space address and setup the MCPCIA_HAXR2 register 45 * configuration space address and setup the MCPCIA_HAXR2 register
diff --git a/arch/alpha/kernel/err_titan.c b/arch/alpha/kernel/err_titan.c
index febe71c6869f..543d96d7fa2b 100644
--- a/arch/alpha/kernel/err_titan.c
+++ b/arch/alpha/kernel/err_titan.c
@@ -16,6 +16,7 @@
16#include <asm/smp.h> 16#include <asm/smp.h>
17#include <asm/err_common.h> 17#include <asm/err_common.h>
18#include <asm/err_ev6.h> 18#include <asm/err_ev6.h>
19#include <asm/irq_regs.h>
19 20
20#include "err_impl.h" 21#include "err_impl.h"
21#include "proto.h" 22#include "proto.h"
diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index aac6d4b22f7a..bd03dc94c72b 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -285,12 +285,12 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
285 reloc_overflow: 285 reloc_overflow:
286 if (ELF64_ST_TYPE (sym->st_info) == STT_SECTION) 286 if (ELF64_ST_TYPE (sym->st_info) == STT_SECTION)
287 printk(KERN_ERR 287 printk(KERN_ERR
288 "module %s: Relocation overflow vs section %d\n", 288 "module %s: Relocation (type %lu) overflow vs section %d\n",
289 me->name, sym->st_shndx); 289 me->name, r_type, sym->st_shndx);
290 else 290 else
291 printk(KERN_ERR 291 printk(KERN_ERR
292 "module %s: Relocation overflow vs %s\n", 292 "module %s: Relocation (type %lu) overflow vs %s\n",
293 me->name, strtab + sym->st_name); 293 me->name, r_type, strtab + sym->st_name);
294 return -ENOEXEC; 294 return -ENOEXEC;
295 } 295 }
296 } 296 }
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index e7594a7cf585..920196bcbb61 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -70,6 +70,12 @@ nautilus_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
70 /* Preserve the IRQ set up by the console. */ 70 /* Preserve the IRQ set up by the console. */
71 71
72 u8 irq; 72 u8 irq;
73 /* UP1500: AGP INTA is actually routed to IRQ 5, not IRQ 10 as
74 console reports. Check the device id of AGP bridge to distinguish
75 UP1500 from UP1000/1100. Note: 'pin' is 2 due to bridge swizzle. */
76 if (slot == 1 && pin == 2 &&
77 dev->bus->self && dev->bus->self->device == 0x700f)
78 return 5;
73 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 79 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
74 return irq; 80 return irq;
75} 81}
diff --git a/arch/alpha/kernel/sys_noritake.c b/arch/alpha/kernel/sys_noritake.c
index de6ba3432e8a..eb2a1d63f484 100644
--- a/arch/alpha/kernel/sys_noritake.c
+++ b/arch/alpha/kernel/sys_noritake.c
@@ -66,6 +66,13 @@ noritake_startup_irq(unsigned int irq)
66 return 0; 66 return 0;
67} 67}
68 68
69static void
70noritake_end_irq(unsigned int irq)
71{
72 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
73 noritake_enable_irq(irq);
74}
75
69static struct hw_interrupt_type noritake_irq_type = { 76static struct hw_interrupt_type noritake_irq_type = {
70 .typename = "NORITAKE", 77 .typename = "NORITAKE",
71 .startup = noritake_startup_irq, 78 .startup = noritake_startup_irq,
@@ -73,7 +80,7 @@ static struct hw_interrupt_type noritake_irq_type = {
73 .enable = noritake_enable_irq, 80 .enable = noritake_enable_irq,
74 .disable = noritake_disable_irq, 81 .disable = noritake_disable_irq,
75 .ack = noritake_disable_irq, 82 .ack = noritake_disable_irq,
76 .end = noritake_enable_irq, 83 .end = noritake_end_irq,
77}; 84};
78 85
79static void 86static void
diff --git a/arch/alpha/kernel/sys_rawhide.c b/arch/alpha/kernel/sys_rawhide.c
index 581d08c70b92..672cb2df53df 100644
--- a/arch/alpha/kernel/sys_rawhide.c
+++ b/arch/alpha/kernel/sys_rawhide.c
@@ -52,6 +52,9 @@ rawhide_update_irq_hw(int hose, int mask)
52 *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose)); 52 *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose));
53} 53}
54 54
55#define hose_exists(h) \
56 (((h) < MCPCIA_MAX_HOSES) && (cached_irq_masks[(h)] != 0))
57
55static inline void 58static inline void
56rawhide_enable_irq(unsigned int irq) 59rawhide_enable_irq(unsigned int irq)
57{ 60{
@@ -59,6 +62,9 @@ rawhide_enable_irq(unsigned int irq)
59 62
60 irq -= 16; 63 irq -= 16;
61 hose = irq / 24; 64 hose = irq / 24;
65 if (!hose_exists(hose)) /* if hose non-existent, exit */
66 return;
67
62 irq -= hose * 24; 68 irq -= hose * 24;
63 mask = 1 << irq; 69 mask = 1 << irq;
64 70
@@ -76,6 +82,9 @@ rawhide_disable_irq(unsigned int irq)
76 82
77 irq -= 16; 83 irq -= 16;
78 hose = irq / 24; 84 hose = irq / 24;
85 if (!hose_exists(hose)) /* if hose non-existent, exit */
86 return;
87
79 irq -= hose * 24; 88 irq -= hose * 24;
80 mask = ~(1 << irq) | hose_irq_masks[hose]; 89 mask = ~(1 << irq) | hose_irq_masks[hose];
81 90
@@ -93,6 +102,9 @@ rawhide_mask_and_ack_irq(unsigned int irq)
93 102
94 irq -= 16; 103 irq -= 16;
95 hose = irq / 24; 104 hose = irq / 24;
105 if (!hose_exists(hose)) /* if hose non-existent, exit */
106 return;
107
96 irq -= hose * 24; 108 irq -= hose * 24;
97 mask1 = 1 << irq; 109 mask1 = 1 << irq;
98 mask = ~mask1 | hose_irq_masks[hose]; 110 mask = ~mask1 | hose_irq_masks[hose];
@@ -169,6 +181,9 @@ rawhide_init_irq(void)
169 181
170 mcpcia_init_hoses(); 182 mcpcia_init_hoses();
171 183
184 /* Clear them all; only hoses that exist will be non-zero. */
185 for (i = 0; i < MCPCIA_MAX_HOSES; i++) cached_irq_masks[i] = 0;
186
172 for (hose = hose_head; hose; hose = hose->next) { 187 for (hose = hose_head; hose; hose = hose->next) {
173 unsigned int h = hose->index; 188 unsigned int h = hose->index;
174 unsigned int mask = hose_irq_masks[h]; 189 unsigned int mask = hose_irq_masks[h];
diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c
index a654014d202a..14b5a753aba5 100644
--- a/arch/alpha/kernel/sys_sio.c
+++ b/arch/alpha/kernel/sys_sio.c
@@ -84,12 +84,16 @@ alphabook1_init_arch(void)
84static void __init 84static void __init
85sio_pci_route(void) 85sio_pci_route(void)
86{ 86{
87#if defined(ALPHA_RESTORE_SRM_SETUP) 87 unsigned int orig_route_tab;
88 /* First, read and save the original setting. */ 88
89 /* First, ALWAYS read and print the original setting. */
89 pci_bus_read_config_dword(pci_isa_hose->bus, PCI_DEVFN(7, 0), 0x60, 90 pci_bus_read_config_dword(pci_isa_hose->bus, PCI_DEVFN(7, 0), 0x60,
90 &saved_config.orig_route_tab); 91 &orig_route_tab);
91 printk("%s: PIRQ original 0x%x new 0x%x\n", __FUNCTION__, 92 printk("%s: PIRQ original 0x%x new 0x%x\n", __FUNCTION__,
92 saved_config.orig_route_tab, alpha_mv.sys.sio.route_tab); 93 orig_route_tab, alpha_mv.sys.sio.route_tab);
94
95#if defined(ALPHA_RESTORE_SRM_SETUP)
96 saved_config.orig_route_tab = orig_route_tab;
93#endif 97#endif
94 98
95 /* Now override with desired setting. */ 99 /* Now override with desired setting. */
@@ -334,7 +338,7 @@ struct alpha_machine_vector avanti_mv __initmv = {
334 .pci_swizzle = common_swizzle, 338 .pci_swizzle = common_swizzle,
335 339
336 .sys = { .sio = { 340 .sys = { .sio = {
337 .route_tab = 0x0b0a0e0f, 341 .route_tab = 0x0b0a050f, /* leave 14 for IDE, 9 for SND */
338 }} 342 }}
339}; 343};
340ALIAS_MV(avanti) 344ALIAS_MV(avanti)
diff --git a/arch/alpha/kernel/sys_sx164.c b/arch/alpha/kernel/sys_sx164.c
index 94ad68b7c0ae..41d4ad4c7c44 100644
--- a/arch/alpha/kernel/sys_sx164.c
+++ b/arch/alpha/kernel/sys_sx164.c
@@ -132,7 +132,7 @@ sx164_init_arch(void)
132 132
133 if (amask(AMASK_MAX) != 0 133 if (amask(AMASK_MAX) != 0
134 && alpha_using_srm 134 && alpha_using_srm
135 && (cpu->pal_revision & 0xffff) == 0x117) { 135 && (cpu->pal_revision & 0xffff) <= 0x117) {
136 __asm__ __volatile__( 136 __asm__ __volatile__(
137 "lda $16,8($31)\n" 137 "lda $16,8($31)\n"
138 "call_pal 9\n" /* Allow PALRES insns in kernel mode */ 138 "call_pal 9\n" /* Allow PALRES insns in kernel mode */
diff --git a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c
index 29ab7db81c30..f009b7bc0943 100644
--- a/arch/alpha/kernel/sys_titan.c
+++ b/arch/alpha/kernel/sys_titan.c
@@ -257,8 +257,7 @@ titan_dispatch_irqs(u64 mask)
257 */ 257 */
258 while (mask) { 258 while (mask) {
259 /* convert to SRM vector... priority is <63> -> <0> */ 259 /* convert to SRM vector... priority is <63> -> <0> */
260 __asm__("ctlz %1, %0" : "=r"(vector) : "r"(mask)); 260 vector = 63 - __kernel_ctlz(mask);
261 vector = 63 - vector;
262 mask &= ~(1UL << vector); /* clear it out */ 261 mask &= ~(1UL << vector); /* clear it out */
263 vector = 0x900 + (vector << 4); /* convert to SRM vector */ 262 vector = 0x900 + (vector << 4); /* convert to SRM vector */
264 263
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index d4ca0f06be5f..a850da377a29 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -1,10 +1,11 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc1 3# Linux kernel version: 2.6.21-rc6
4# Wed Feb 21 16:48:01 2007 4# Mon Apr 9 10:12:58 2007
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
8# CONFIG_GENERIC_TIME is not set 9# CONFIG_GENERIC_TIME is not set
9CONFIG_MMU=y 10CONFIG_MMU=y
10CONFIG_NO_IOPORT=y 11CONFIG_NO_IOPORT=y
@@ -45,6 +46,7 @@ CONFIG_SYSVIPC_SYSCTL=y
45# CONFIG_IKCONFIG is not set 46# CONFIG_IKCONFIG is not set
46CONFIG_SYSFS_DEPRECATED=y 47CONFIG_SYSFS_DEPRECATED=y
47# CONFIG_RELAY is not set 48# CONFIG_RELAY is not set
49CONFIG_BLK_DEV_INITRD=y
48CONFIG_INITRAMFS_SOURCE="" 50CONFIG_INITRAMFS_SOURCE=""
49CONFIG_CC_OPTIMIZE_FOR_SIZE=y 51CONFIG_CC_OPTIMIZE_FOR_SIZE=y
50CONFIG_SYSCTL=y 52CONFIG_SYSCTL=y
@@ -531,7 +533,6 @@ CONFIG_BLK_DEV_RAM=y
531CONFIG_BLK_DEV_RAM_COUNT=16 533CONFIG_BLK_DEV_RAM_COUNT=16
532CONFIG_BLK_DEV_RAM_SIZE=4096 534CONFIG_BLK_DEV_RAM_SIZE=4096
533CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 535CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
534CONFIG_BLK_DEV_INITRD=y
535# CONFIG_CDROM_PKTCDVD is not set 536# CONFIG_CDROM_PKTCDVD is not set
536CONFIG_ATA_OVER_ETH=m 537CONFIG_ATA_OVER_ETH=m
537 538
@@ -560,7 +561,6 @@ CONFIG_IDE_GENERIC=y
560CONFIG_BLK_DEV_IDE_BAST=y 561CONFIG_BLK_DEV_IDE_BAST=y
561# CONFIG_IDE_CHIPSETS is not set 562# CONFIG_IDE_CHIPSETS is not set
562# CONFIG_BLK_DEV_IDEDMA is not set 563# CONFIG_BLK_DEV_IDEDMA is not set
563# CONFIG_IDEDMA_AUTO is not set
564# CONFIG_BLK_DEV_HD is not set 564# CONFIG_BLK_DEV_HD is not set
565 565
566# 566#
@@ -941,6 +941,7 @@ CONFIG_LEDS_CLASS=m
941# LED drivers 941# LED drivers
942# 942#
943CONFIG_LEDS_S3C24XX=m 943CONFIG_LEDS_S3C24XX=m
944CONFIG_LEDS_H1940=m
944 945
945# 946#
946# LED Triggers 947# LED Triggers
@@ -1125,6 +1126,7 @@ CONFIG_USB_MON=y
1125# CONFIG_USB_APPLEDISPLAY is not set 1126# CONFIG_USB_APPLEDISPLAY is not set
1126# CONFIG_USB_LD is not set 1127# CONFIG_USB_LD is not set
1127# CONFIG_USB_TRANCEVIBRATOR is not set 1128# CONFIG_USB_TRANCEVIBRATOR is not set
1129# CONFIG_USB_IOWARRIOR is not set
1128# CONFIG_USB_TEST is not set 1130# CONFIG_USB_TEST is not set
1129 1131
1130# 1132#
@@ -1169,7 +1171,6 @@ CONFIG_RTC_INTF_DEV=y
1169# CONFIG_RTC_DRV_DS1672 is not set 1171# CONFIG_RTC_DRV_DS1672 is not set
1170# CONFIG_RTC_DRV_DS1742 is not set 1172# CONFIG_RTC_DRV_DS1742 is not set
1171# CONFIG_RTC_DRV_PCF8563 is not set 1173# CONFIG_RTC_DRV_PCF8563 is not set
1172# CONFIG_RTC_DRV_PCF8583 is not set
1173# CONFIG_RTC_DRV_RS5C348 is not set 1174# CONFIG_RTC_DRV_RS5C348 is not set
1174# CONFIG_RTC_DRV_RS5C372 is not set 1175# CONFIG_RTC_DRV_RS5C372 is not set
1175CONFIG_RTC_DRV_S3C=y 1176CONFIG_RTC_DRV_S3C=y
diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c
index 5a0f4bc5da95..ba99a2035523 100644
--- a/arch/arm/kernel/dma.c
+++ b/arch/arm/kernel/dma.c
@@ -228,6 +228,7 @@ int dma_channel_active(dmach_t channel)
228{ 228{
229 return dma_chan[channel].active; 229 return dma_chan[channel].active;
230} 230}
231EXPORT_SYMBOL(dma_channel_active);
231 232
232void set_dma_page(dmach_t channel, char pagenr) 233void set_dma_page(dmach_t channel, char pagenr)
233{ 234{
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index f7d342ccbebf..40586e22cd38 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -320,16 +320,16 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
320 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) 320 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
321 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); 321 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
322 322
323 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5) 323 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
324 | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5)); 324 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
325 325
326 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7)); 326 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
327 327
328 if (data->bus_width_16) 328 if (data->bus_width_16)
329 mode = AT91_SMC_DBW_16; 329 mode = AT91_SMC_DBW_16;
330 else 330 else
331 mode = AT91_SMC_DBW_8; 331 mode = AT91_SMC_DBW_8;
332 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1)); 332 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
333 333
334 /* enable pin */ 334 /* enable pin */
335 if (data->enable_pin) 335 if (data->enable_pin)
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index bd78058b7178..b1142ce4ac47 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -12,7 +12,7 @@
12# 12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new 13# http://www.arm.linux.org.uk/developer/machines/?action=new
14# 14#
15# Last update: Tue Jan 16 16:52:56 2007 15# Last update: Mon Apr 16 21:01:04 2007
16# 16#
17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
18# 18#
@@ -1190,13 +1190,12 @@ g500 MACH_G500 G500 1178
1190bug MACH_BUG BUG 1179 1190bug MACH_BUG BUG 1179
1191mx33ads MACH_MX33ADS MX33ADS 1180 1191mx33ads MACH_MX33ADS MX33ADS 1180
1192chub MACH_CHUB CHUB 1181 1192chub MACH_CHUB CHUB 1181
1193gta01 MACH_GTA01 GTA01 1182 1193neo1973_gta01 MACH_NEO1973_GTA01 NEO1973_GTA01 1182
1194w90n740 MACH_W90N740 W90N740 1183 1194w90n740 MACH_W90N740 W90N740 1183
1195medallion_sa2410 MACH_MEDALLION_SA2410 MEDALLION_SA2410 1184 1195medallion_sa2410 MACH_MEDALLION_SA2410 MEDALLION_SA2410 1184
1196ia_cpu_9200_2 MACH_IA_CPU_9200_2 IA_CPU_9200_2 1185 1196ia_cpu_9200_2 MACH_IA_CPU_9200_2 IA_CPU_9200_2 1185
1197dimmrm9200 MACH_DIMMRM9200 DIMMRM9200 1186 1197dimmrm9200 MACH_DIMMRM9200 DIMMRM9200 1186
1198pm9261 MACH_PM9261 PM9261 1187 1198pm9261 MACH_PM9261 PM9261 1187
1199mx21 MACH_MX21 MX21 1188
1200ml7304 MACH_ML7304 ML7304 1189 1199ml7304 MACH_ML7304 ML7304 1189
1201ucp250 MACH_UCP250 UCP250 1190 1200ucp250 MACH_UCP250 UCP250 1190
1202intboard MACH_INTBOARD INTBOARD 1191 1201intboard MACH_INTBOARD INTBOARD 1191
@@ -1242,3 +1241,97 @@ xscale_treo680 MACH_XSCALE_TREO680 XSCALE_TREO680 1230
1242tecon_tmezon MACH_TECON_TMEZON TECON_TMEZON 1231 1241tecon_tmezon MACH_TECON_TMEZON TECON_TMEZON 1231
1243zylonite MACH_ZYLONITE ZYLONITE 1233 1242zylonite MACH_ZYLONITE ZYLONITE 1233
1244gene1270 MACH_GENE1270 GENE1270 1234 1243gene1270 MACH_GENE1270 GENE1270 1234
1244zir2412 MACH_ZIR2412 ZIR2412 1235
1245mx31lite MACH_MX31LITE MX31LITE 1236
1246t700wx MACH_T700WX T700WX 1237
1247vf100 MACH_VF100 VF100 1238
1248nsb2 MACH_NSB2 NSB2 1239
1249nxhmi_bb MACH_NXHMI_BB NXHMI_BB 1240
1250nxhmi_re MACH_NXHMI_RE NXHMI_RE 1241
1251n4100pro MACH_N4100PRO N4100PRO 1242
1252sam9260 MACH_SAM9260 SAM9260 1243
1253omap_treo600 MACH_OMAP_TREO600 OMAP_TREO600 1244
1254indy2410 MACH_INDY2410 INDY2410 1245
1255nelt_a MACH_NELT_A NELT_A 1246
1256n311 MACH_N311 N311 1248
1257at91sam9260vgk MACH_AT91SAM9260VGK AT91SAM9260VGK 1249
1258at91leppe MACH_AT91LEPPE AT91LEPPE 1250
1259at91lepccn MACH_AT91LEPCCN AT91LEPCCN 1251
1260apc7100 MACH_APC7100 APC7100 1252
1261stargazer MACH_STARGAZER STARGAZER 1253
1262sonata MACH_SONATA SONATA 1254
1263schmoogie MACH_SCHMOOGIE SCHMOOGIE 1255
1264aztool MACH_AZTOOL AZTOOL 1256
1265mioa701 MACH_MIOA701 MIOA701 1257
1266sxni9260 MACH_SXNI9260 SXNI9260 1258
1267mxc27520evb MACH_MXC27520EVB MXC27520EVB 1259
1268armadillo5x0 MACH_ARMADILLO5X0 ARMADILLO5X0 1260
1269mb9260 MACH_MB9260 MB9260 1261
1270mb9263 MACH_MB9263 MB9263 1262
1271ipac9302 MACH_IPAC9302 IPAC9302 1263
1272cc9p9360js MACH_CC9P9360JS CC9P9360JS 1264
1273gallium MACH_GALLIUM GALLIUM 1265
1274msc2410 MACH_MSC2410 MSC2410 1266
1275ghi270 MACH_GHI270 GHI270 1267
1276davinci_leonardo MACH_DAVINCI_LEONARDO DAVINCI_LEONARDO 1268
1277oiab MACH_OIAB OIAB 1269
1278smdk6400 MACH_SMDK6400 SMDK6400 1270
1279nokia_n800 MACH_NOKIA_N800 NOKIA_N800 1271
1280greenphone MACH_GREENPHONE GREENPHONE 1272
1281compex42x MACH_COMPEXWP18 COMPEXWP18 1273
1282xmate MACH_XMATE XMATE 1274
1283energizer MACH_ENERGIZER ENERGIZER 1275
1284ime1 MACH_IME1 IME1 1276
1285sweda_tms MACH_SWEDATMS SWEDATMS 1277
1286ntnp435c MACH_NTNP435C NTNP435C 1278
1287spectro2 MACH_SPECTRO2 SPECTRO2 1279
1288h6039 MACH_H6039 H6039 1280
1289ep80219 MACH_EP80219 EP80219 1281
1290samoa_ii MACH_SAMOA_II SAMOA_II 1282
1291cwmxl MACH_CWMXL CWMXL 1283
1292as9200 MACH_AS9200 AS9200 1284
1293sfx1149 MACH_SFX1149 SFX1149 1285
1294navi010 MACH_NAVI010 NAVI010 1286
1295multmdp MACH_MULTMDP MULTMDP 1287
1296scb9520 MACH_SCB9520 SCB9520 1288
1297htcathena MACH_HTCATHENA HTCATHENA 1289
1298xp179 MACH_XP179 XP179 1290
1299h4300 MACH_H4300 H4300 1291
1300goramo_mlr MACH_GORAMO_MLR GORAMO_MLR 1292
1301mxc30020evb MACH_MXC30020EVB MXC30020EVB 1293
1302adsbitsymx MACH_ADSBITSIMX ADSBITSIMX 1294
1303adsportalplus MACH_ADSPORTALPLUS ADSPORTALPLUS 1295
1304mmsp2plus MACH_MMSP2PLUS MMSP2PLUS 1296
1305em_x270 MACH_EM_X270 EM_X270 1297
1306tpp302 MACH_TPP302 TPP302 1298
1307tpp104 MACH_TPM104 TPM104 1299
1308tpm102 MACH_TPM102 TPM102 1300
1309tpm109 MACH_TPM109 TPM109 1301
1310fbxo1 MACH_FBXO1 FBXO1 1302
1311hxd8 MACH_HXD8 HXD8 1303
1312neo1973_gta02 MACH_NEO1973_GTA02 NEO1973_GTA02 1304
1313emtest MACH_EMTEST EMTEST 1305
1314ad6900 MACH_AD6900 AD6900 1306
1315europa MACH_EUROPA EUROPA 1307
1316metroconnect MACH_METROCONNECT METROCONNECT 1308
1317ez_s2410 MACH_EZ_S2410 EZ_S2410 1309
1318ez_s2440 MACH_EZ_S2440 EZ_S2440 1310
1319ez_ep9312 MACH_EZ_EP9312 EZ_EP9312 1311
1320ez_ep9315 MACH_EZ_EP9315 EZ_EP9315 1312
1321ez_x7 MACH_EZ_X7 EZ_X7 1313
1322godotdb MACH_GODOTDB GODOTDB 1314
1323mistral MACH_MISTRAL MISTRAL 1315
1324msm MACH_MSM MSM 1316
1325ct5910 MACH_CT5910 CT5910 1317
1326ct5912 MACH_CT5912 CT5912 1318
1327hynet_ine MACH_HYNET_INE HYNET_INE 1319
1328hynet_app MACH_HYNET_APP HYNET_APP 1320
1329msm7200 MACH_MSM7200 MSM7200 1321
1330msm7600 MACH_MSM7600 MSM7600 1322
1331ceb255 MACH_CEB255 CEB255 1323
1332ciel MACH_CIEL CIEL 1324
1333slm5650 MACH_SLM5650 SLM5650 1325
1334at91sam9rlek MACH_AT91SAM9RLEK AT91SAM9RLEK 1326
1335comtech_router MACH_COMTECH_ROUTER COMTECH_ROUTER 1327
1336sbc2410x MACH_SBC2410X SBC2410X 1328
1337at4x0bd MACH_AT4X0BD AT4X0BD 1329
diff --git a/arch/cris/arch-v32/drivers/pci/bios.c b/arch/cris/arch-v32/drivers/pci/bios.c
index a2b9c60c2777..5b79a7a772d4 100644
--- a/arch/cris/arch-v32/drivers/pci/bios.c
+++ b/arch/cris/arch-v32/drivers/pci/bios.c
@@ -100,7 +100,9 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
100 if ((err = pcibios_enable_resources(dev, mask)) < 0) 100 if ((err = pcibios_enable_resources(dev, mask)) < 0)
101 return err; 101 return err;
102 102
103 return pcibios_enable_irq(dev); 103 if (!dev->msi_enabled)
104 pcibios_enable_irq(dev);
105 return 0;
104} 106}
105 107
106int pcibios_assign_resources(void) 108int pcibios_assign_resources(void)
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index f7279d78995a..0b581e3cf7c7 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -466,6 +466,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
466 466
467 if ((err = pcibios_enable_resources(dev, mask)) < 0) 467 if ((err = pcibios_enable_resources(dev, mask)) < 0)
468 return err; 468 return err;
469 pcibios_enable_irq(dev); 469 if (!dev->msi_enabled)
470 pcibios_enable_irq(dev);
470 return 0; 471 return 0;
471} 472}
diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
index 2c5b5cc55f79..8143c9516cb4 100644
--- a/arch/i386/boot/video.S
+++ b/arch/i386/boot/video.S
@@ -571,6 +571,16 @@ setr1: lodsw
571 jmp _m_s 571 jmp _m_s
572 572
573check_vesa: 573check_vesa:
574#ifdef CONFIG_FIRMWARE_EDID
575 leaw modelist+1024, %di
576 movw $0x4f00, %ax
577 int $0x10
578 cmpw $0x004f, %ax
579 jnz setbad
580
581 movw 4(%di), %ax
582 movw %ax, vbe_version
583#endif
574 leaw modelist+1024, %di 584 leaw modelist+1024, %di
575 subb $VIDEO_FIRST_VESA>>8, %bh 585 subb $VIDEO_FIRST_VESA>>8, %bh
576 movw %bx, %cx # Get mode information structure 586 movw %bx, %cx # Get mode information structure
@@ -1945,6 +1955,9 @@ store_edid:
1945 rep 1955 rep
1946 stosl 1956 stosl
1947 1957
1958 cmpw $0x0200, vbe_version # only do EDID on >= VBE2.0
1959 jl no_edid
1960
1948 pushw %es # save ES 1961 pushw %es # save ES
1949 xorw %di, %di # Report Capability 1962 xorw %di, %di # Report Capability
1950 pushw %di 1963 pushw %di
@@ -1987,6 +2000,7 @@ do_restore: .byte 0 # Screen contents altered during mode change
1987svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes 2000svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes
1988graphic_mode: .byte 0 # Graphic mode with a linear frame buffer 2001graphic_mode: .byte 0 # Graphic mode with a linear frame buffer
1989dac_size: .byte 6 # DAC bit depth 2002dac_size: .byte 6 # DAC bit depth
2003vbe_version: .word 0 # VBE bios version
1990 2004
1991# Status messages 2005# Status messages
1992keymsg: .ascii "Press <RETURN> to see video modes available, " 2006keymsg: .ascii "Press <RETURN> to see video modes available, "
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index 9eca21b49f6b..426f59b0106b 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -5,15 +5,9 @@
5#include <asm/alternative.h> 5#include <asm/alternative.h>
6#include <asm/sections.h> 6#include <asm/sections.h>
7 7
8static int no_replacement = 0;
9static int smp_alt_once = 0; 8static int smp_alt_once = 0;
10static int debug_alternative = 0; 9static int debug_alternative = 0;
11 10
12static int __init noreplacement_setup(char *s)
13{
14 no_replacement = 1;
15 return 1;
16}
17static int __init bootonly(char *str) 11static int __init bootonly(char *str)
18{ 12{
19 smp_alt_once = 1; 13 smp_alt_once = 1;
@@ -25,7 +19,6 @@ static int __init debug_alt(char *str)
25 return 1; 19 return 1;
26} 20}
27 21
28__setup("noreplacement", noreplacement_setup);
29__setup("smp-alt-boot", bootonly); 22__setup("smp-alt-boot", bootonly);
30__setup("debug-alternative", debug_alt); 23__setup("debug-alternative", debug_alt);
31 24
@@ -252,9 +245,6 @@ void alternatives_smp_module_add(struct module *mod, char *name,
252 struct smp_alt_module *smp; 245 struct smp_alt_module *smp;
253 unsigned long flags; 246 unsigned long flags;
254 247
255 if (no_replacement)
256 return;
257
258 if (smp_alt_once) { 248 if (smp_alt_once) {
259 if (boot_cpu_has(X86_FEATURE_UP)) 249 if (boot_cpu_has(X86_FEATURE_UP))
260 alternatives_smp_unlock(locks, locks_end, 250 alternatives_smp_unlock(locks, locks_end,
@@ -289,7 +279,7 @@ void alternatives_smp_module_del(struct module *mod)
289 struct smp_alt_module *item; 279 struct smp_alt_module *item;
290 unsigned long flags; 280 unsigned long flags;
291 281
292 if (no_replacement || smp_alt_once) 282 if (smp_alt_once)
293 return; 283 return;
294 284
295 spin_lock_irqsave(&smp_alt, flags); 285 spin_lock_irqsave(&smp_alt, flags);
@@ -320,7 +310,7 @@ void alternatives_smp_switch(int smp)
320 return; 310 return;
321#endif 311#endif
322 312
323 if (no_replacement || smp_alt_once) 313 if (smp_alt_once)
324 return; 314 return;
325 BUG_ON(!smp && (num_online_cpus() > 1)); 315 BUG_ON(!smp && (num_online_cpus() > 1));
326 316
@@ -386,13 +376,6 @@ extern struct paravirt_patch __start_parainstructions[],
386void __init alternative_instructions(void) 376void __init alternative_instructions(void)
387{ 377{
388 unsigned long flags; 378 unsigned long flags;
389 if (no_replacement) {
390 printk(KERN_INFO "(SMP-)alternatives turned off\n");
391 free_init_pages("SMP alternatives",
392 (unsigned long)__smp_alt_begin,
393 (unsigned long)__smp_alt_end);
394 return;
395 }
396 379
397 local_irq_save(flags); 380 local_irq_save(flags);
398 apply_alternatives(__alt_instructions, __alt_instructions_end); 381 apply_alternatives(__alt_instructions, __alt_instructions_end);
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index e88415282a6f..93aa911646ad 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -272,32 +272,6 @@ static void __devinit setup_APIC_timer(void)
272} 272}
273 273
274/* 274/*
275 * Detect systems with known broken BIOS implementations
276 */
277static int __init lapic_check_broken_bios(struct dmi_system_id *d)
278{
279 printk(KERN_NOTICE "%s detected: disabling lapic timer.\n",
280 d->ident);
281 local_apic_timer_disabled = 1;
282 return 0;
283}
284
285static struct dmi_system_id __initdata broken_bios_dmi_table[] = {
286 {
287 /*
288 * BIOS exports only C1 state, but uses deeper power
289 * modes behind the kernels back.
290 */
291 .callback = lapic_check_broken_bios,
292 .ident = "HP nx6325",
293 .matches = {
294 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
295 },
296 },
297 {}
298};
299
300/*
301 * In this functions we calibrate APIC bus clocks to the external timer. 275 * In this functions we calibrate APIC bus clocks to the external timer.
302 * 276 *
303 * We want to do the calibration only once since we want to have local timer 277 * We want to do the calibration only once since we want to have local timer
@@ -372,12 +346,12 @@ void __init setup_boot_APIC_clock(void)
372 long delta, deltapm; 346 long delta, deltapm;
373 int pm_referenced = 0; 347 int pm_referenced = 0;
374 348
375 /* Detect know broken systems */ 349 if (boot_cpu_has(X86_FEATURE_LAPIC_TIMER_BROKEN))
376 dmi_check_system(broken_bios_dmi_table); 350 local_apic_timer_disabled = 1;
377 351
378 /* 352 /*
379 * The local apic timer can be disabled via the kernel 353 * The local apic timer can be disabled via the kernel
380 * commandline or from the dmi quirk above. Register the lapic 354 * commandline or from the test above. Register the lapic
381 * timer as a dummy clock event source on SMP systems, so the 355 * timer as a dummy clock event source on SMP systems, so the
382 * broadcast mechanism is used. On UP systems simply ignore it. 356 * broadcast mechanism is used. On UP systems simply ignore it.
383 */ 357 */
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 41cfea57232b..2d47db482972 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -22,6 +22,37 @@
22extern void vide(void); 22extern void vide(void);
23__asm__(".align 4\nvide: ret"); 23__asm__(".align 4\nvide: ret");
24 24
25#define ENABLE_C1E_MASK 0x18000000
26#define CPUID_PROCESSOR_SIGNATURE 1
27#define CPUID_XFAM 0x0ff00000
28#define CPUID_XFAM_K8 0x00000000
29#define CPUID_XFAM_10H 0x00100000
30#define CPUID_XFAM_11H 0x00200000
31#define CPUID_XMOD 0x000f0000
32#define CPUID_XMOD_REV_F 0x00040000
33
34/* AMD systems with C1E don't have a working lAPIC timer. Check for that. */
35static __cpuinit int amd_apic_timer_broken(void)
36{
37 u32 lo, hi;
38 u32 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
39 switch (eax & CPUID_XFAM) {
40 case CPUID_XFAM_K8:
41 if ((eax & CPUID_XMOD) < CPUID_XMOD_REV_F)
42 break;
43 case CPUID_XFAM_10H:
44 case CPUID_XFAM_11H:
45 rdmsr(MSR_K8_ENABLE_C1E, lo, hi);
46 if (lo & ENABLE_C1E_MASK)
47 return 1;
48 break;
49 default:
50 /* err on the side of caution */
51 return 1;
52 }
53 return 0;
54}
55
25static void __cpuinit init_amd(struct cpuinfo_x86 *c) 56static void __cpuinit init_amd(struct cpuinfo_x86 *c)
26{ 57{
27 u32 l, h; 58 u32 l, h;
@@ -241,6 +272,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
241 272
242 if (cpuid_eax(0x80000000) >= 0x80000006) 273 if (cpuid_eax(0x80000000) >= 0x80000006)
243 num_cache_leaves = 3; 274 num_cache_leaves = 3;
275
276 if (amd_apic_timer_broken())
277 set_bit(X86_FEATURE_LAPIC_TIMER_BROKEN, c->x86_capability);
244} 278}
245 279
246static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) 280static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index a1f1b715bcf8..2b030d6ccbf7 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -758,7 +758,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
758 NULL, (void *)&pr); 758 NULL, (void *)&pr);
759 759
760 /* Check ACPI support for C3 state */ 760 /* Check ACPI support for C3 state */
761 if (pr != NULL && longhaul_version != TYPE_LONGHAUL_V1) { 761 if (pr != NULL && longhaul_version == TYPE_POWERSAVER) {
762 cx = &pr->power.states[ACPI_STATE_C3]; 762 cx = &pr->power.states[ACPI_STATE_C3];
763 if (cx->address > 0 && cx->latency <= 1000) { 763 if (cx->address > 0 && cx->latency <= 1000) {
764 longhaul_flags |= USE_ACPI_C3; 764 longhaul_flags |= USE_ACPI_C3;
diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c
index f3ab61ee7498..17d73459fc5f 100644
--- a/arch/i386/kernel/hpet.c
+++ b/arch/i386/kernel/hpet.c
@@ -3,6 +3,8 @@
3#include <linux/errno.h> 3#include <linux/errno.h>
4#include <linux/hpet.h> 4#include <linux/hpet.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/sysdev.h>
7#include <linux/pm.h>
6 8
7#include <asm/hpet.h> 9#include <asm/hpet.h>
8#include <asm/io.h> 10#include <asm/io.h>
@@ -197,7 +199,7 @@ static int hpet_next_event(unsigned long delta,
197 cnt += delta; 199 cnt += delta;
198 hpet_writel(cnt, HPET_T0_CMP); 200 hpet_writel(cnt, HPET_T0_CMP);
199 201
200 return ((long)(hpet_readl(HPET_COUNTER) - cnt ) > 0); 202 return ((long)(hpet_readl(HPET_COUNTER) - cnt ) > 0) ? -ETIME : 0;
201} 203}
202 204
203/* 205/*
@@ -307,6 +309,7 @@ int __init hpet_enable(void)
307out_nohpet: 309out_nohpet:
308 iounmap(hpet_virt_address); 310 iounmap(hpet_virt_address);
309 hpet_virt_address = NULL; 311 hpet_virt_address = NULL;
312 boot_hpet_disable = 1;
310 return 0; 313 return 0;
311} 314}
312 315
@@ -521,3 +524,68 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
521 return IRQ_HANDLED; 524 return IRQ_HANDLED;
522} 525}
523#endif 526#endif
527
528
529/*
530 * Suspend/resume part
531 */
532
533#ifdef CONFIG_PM
534
535static int hpet_suspend(struct sys_device *sys_device, pm_message_t state)
536{
537 unsigned long cfg = hpet_readl(HPET_CFG);
538
539 cfg &= ~(HPET_CFG_ENABLE|HPET_CFG_LEGACY);
540 hpet_writel(cfg, HPET_CFG);
541
542 return 0;
543}
544
545static int hpet_resume(struct sys_device *sys_device)
546{
547 unsigned int id;
548
549 hpet_start_counter();
550
551 id = hpet_readl(HPET_ID);
552
553 if (id & HPET_ID_LEGSUP)
554 hpet_enable_int();
555
556 return 0;
557}
558
559static struct sysdev_class hpet_class = {
560 set_kset_name("hpet"),
561 .suspend = hpet_suspend,
562 .resume = hpet_resume,
563};
564
565static struct sys_device hpet_device = {
566 .id = 0,
567 .cls = &hpet_class,
568};
569
570
571static __init int hpet_register_sysfs(void)
572{
573 int err;
574
575 if (!is_hpet_capable())
576 return 0;
577
578 err = sysdev_class_register(&hpet_class);
579
580 if (!err) {
581 err = sysdev_register(&hpet_device);
582 if (err)
583 sysdev_class_unregister(&hpet_class);
584 }
585
586 return err;
587}
588
589device_initcall(hpet_register_sysfs);
590
591#endif
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index e4408ff4e674..b3ab8ffebd27 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -736,7 +736,7 @@ failed:
736 return 0; 736 return 0;
737} 737}
738 738
739int __init irqbalance_disable(char *str) 739int __devinit irqbalance_disable(char *str)
740{ 740{
741 irqbalance_disabled = 1; 741 irqbalance_disabled = 1;
742 return 1; 742 return 1;
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index b8f16633a6ec..cbe7ec8dbb9f 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -567,6 +567,53 @@ static int cpu_request_microcode(int cpu)
567 return error; 567 return error;
568} 568}
569 569
570static int apply_microcode_on_cpu(int cpu)
571{
572 struct cpuinfo_x86 *c = cpu_data + cpu;
573 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
574 cpumask_t old;
575 unsigned int val[2];
576 int err = 0;
577
578 if (!uci->mc)
579 return -EINVAL;
580
581 old = current->cpus_allowed;
582 set_cpus_allowed(current, cpumask_of_cpu(cpu));
583
584 /* Check if the microcode we have in memory matches the CPU */
585 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
586 cpu_has(c, X86_FEATURE_IA64) || uci->sig != cpuid_eax(0x00000001))
587 err = -EINVAL;
588
589 if (!err && ((c->x86_model >= 5) || (c->x86 > 6))) {
590 /* get processor flags from MSR 0x17 */
591 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
592 if (uci->pf != (1 << ((val[1] >> 18) & 7)))
593 err = -EINVAL;
594 }
595
596 if (!err) {
597 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
598 /* see notes above for revision 1.07. Apparent chip bug */
599 sync_core();
600 /* get the current revision from MSR 0x8B */
601 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
602 if (uci->rev != val[1])
603 err = -EINVAL;
604 }
605
606 if (!err)
607 apply_microcode(cpu);
608 else
609 printk(KERN_ERR "microcode: Could not apply microcode to CPU%d:"
610 " sig=0x%x, pf=0x%x, rev=0x%x\n",
611 cpu, uci->sig, uci->pf, uci->rev);
612
613 set_cpus_allowed(current, old);
614 return err;
615}
616
570static void microcode_init_cpu(int cpu) 617static void microcode_init_cpu(int cpu)
571{ 618{
572 cpumask_t old; 619 cpumask_t old;
@@ -577,7 +624,8 @@ static void microcode_init_cpu(int cpu)
577 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 624 set_cpus_allowed(current, cpumask_of_cpu(cpu));
578 mutex_lock(&microcode_mutex); 625 mutex_lock(&microcode_mutex);
579 collect_cpu_info(cpu); 626 collect_cpu_info(cpu);
580 if (uci->valid && system_state == SYSTEM_RUNNING) 627 if (uci->valid && system_state == SYSTEM_RUNNING &&
628 !suspend_cpu_hotplug)
581 cpu_request_microcode(cpu); 629 cpu_request_microcode(cpu);
582 mutex_unlock(&microcode_mutex); 630 mutex_unlock(&microcode_mutex);
583 set_cpus_allowed(current, old); 631 set_cpus_allowed(current, old);
@@ -663,13 +711,24 @@ static int mc_sysdev_add(struct sys_device *sys_dev)
663 return 0; 711 return 0;
664 712
665 pr_debug("Microcode:CPU %d added\n", cpu); 713 pr_debug("Microcode:CPU %d added\n", cpu);
666 memset(uci, 0, sizeof(*uci)); 714 /* If suspend_cpu_hotplug is set, the system is resuming and we should
715 * use the data from before the suspend.
716 */
717 if (suspend_cpu_hotplug) {
718 err = apply_microcode_on_cpu(cpu);
719 if (err)
720 microcode_fini_cpu(cpu);
721 }
722 if (!uci->valid)
723 memset(uci, 0, sizeof(*uci));
667 724
668 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group); 725 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
669 if (err) 726 if (err)
670 return err; 727 return err;
671 728
672 microcode_init_cpu(cpu); 729 if (!uci->valid)
730 microcode_init_cpu(cpu);
731
673 return 0; 732 return 0;
674} 733}
675 734
@@ -680,7 +739,11 @@ static int mc_sysdev_remove(struct sys_device *sys_dev)
680 if (!cpu_online(cpu)) 739 if (!cpu_online(cpu))
681 return 0; 740 return 0;
682 pr_debug("Microcode:CPU %d removed\n", cpu); 741 pr_debug("Microcode:CPU %d removed\n", cpu);
683 microcode_fini_cpu(cpu); 742 /* If suspend_cpu_hotplug is set, the system is suspending and we should
743 * keep the microcode in memory for the resume.
744 */
745 if (!suspend_cpu_hotplug)
746 microcode_fini_cpu(cpu);
684 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group); 747 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
685 return 0; 748 return 0;
686} 749}
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 14702427b104..84c3497efb60 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -41,16 +41,17 @@ int nmi_watchdog_enabled;
41 * different subsystems this reservation system just tries to coordinate 41 * different subsystems this reservation system just tries to coordinate
42 * things a little 42 * things a little
43 */ 43 */
44static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner);
45static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]);
46
47static cpumask_t backtrace_mask = CPU_MASK_NONE;
48 44
49/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's 45/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
50 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now) 46 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
51 */ 47 */
52#define NMI_MAX_COUNTER_BITS 66 48#define NMI_MAX_COUNTER_BITS 66
49#define NMI_MAX_COUNTER_LONGS BITS_TO_LONGS(NMI_MAX_COUNTER_BITS)
50
51static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner[NMI_MAX_COUNTER_LONGS]);
52static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[NMI_MAX_COUNTER_LONGS]);
53 53
54static cpumask_t backtrace_mask = CPU_MASK_NONE;
54/* nmi_active: 55/* nmi_active:
55 * >0: the lapic NMI watchdog is active, but can be disabled 56 * >0: the lapic NMI watchdog is active, but can be disabled
56 * <0: the lapic NMI watchdog has not been set up, and cannot 57 * <0: the lapic NMI watchdog has not been set up, and cannot
@@ -122,64 +123,129 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
122/* checks for a bit availability (hack for oprofile) */ 123/* checks for a bit availability (hack for oprofile) */
123int avail_to_resrv_perfctr_nmi_bit(unsigned int counter) 124int avail_to_resrv_perfctr_nmi_bit(unsigned int counter)
124{ 125{
126 int cpu;
125 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 127 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
126 128 for_each_possible_cpu (cpu) {
127 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner))); 129 if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
130 return 0;
131 }
132 return 1;
128} 133}
129 134
130/* checks the an msr for availability */ 135/* checks the an msr for availability */
131int avail_to_resrv_perfctr_nmi(unsigned int msr) 136int avail_to_resrv_perfctr_nmi(unsigned int msr)
132{ 137{
133 unsigned int counter; 138 unsigned int counter;
139 int cpu;
134 140
135 counter = nmi_perfctr_msr_to_bit(msr); 141 counter = nmi_perfctr_msr_to_bit(msr);
136 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 142 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
137 143
138 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner))); 144 for_each_possible_cpu (cpu) {
145 if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
146 return 0;
147 }
148 return 1;
139} 149}
140 150
141int reserve_perfctr_nmi(unsigned int msr) 151static int __reserve_perfctr_nmi(int cpu, unsigned int msr)
142{ 152{
143 unsigned int counter; 153 unsigned int counter;
154 if (cpu < 0)
155 cpu = smp_processor_id();
144 156
145 counter = nmi_perfctr_msr_to_bit(msr); 157 counter = nmi_perfctr_msr_to_bit(msr);
146 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 158 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
147 159
148 if (!test_and_set_bit(counter, &__get_cpu_var(perfctr_nmi_owner))) 160 if (!test_and_set_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
149 return 1; 161 return 1;
150 return 0; 162 return 0;
151} 163}
152 164
153void release_perfctr_nmi(unsigned int msr) 165static void __release_perfctr_nmi(int cpu, unsigned int msr)
154{ 166{
155 unsigned int counter; 167 unsigned int counter;
168 if (cpu < 0)
169 cpu = smp_processor_id();
156 170
157 counter = nmi_perfctr_msr_to_bit(msr); 171 counter = nmi_perfctr_msr_to_bit(msr);
158 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 172 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
159 173
160 clear_bit(counter, &__get_cpu_var(perfctr_nmi_owner)); 174 clear_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]);
161} 175}
162 176
163int reserve_evntsel_nmi(unsigned int msr) 177int reserve_perfctr_nmi(unsigned int msr)
178{
179 int cpu, i;
180 for_each_possible_cpu (cpu) {
181 if (!__reserve_perfctr_nmi(cpu, msr)) {
182 for_each_possible_cpu (i) {
183 if (i >= cpu)
184 break;
185 __release_perfctr_nmi(i, msr);
186 }
187 return 0;
188 }
189 }
190 return 1;
191}
192
193void release_perfctr_nmi(unsigned int msr)
194{
195 int cpu;
196 for_each_possible_cpu (cpu) {
197 __release_perfctr_nmi(cpu, msr);
198 }
199}
200
201int __reserve_evntsel_nmi(int cpu, unsigned int msr)
164{ 202{
165 unsigned int counter; 203 unsigned int counter;
204 if (cpu < 0)
205 cpu = smp_processor_id();
166 206
167 counter = nmi_evntsel_msr_to_bit(msr); 207 counter = nmi_evntsel_msr_to_bit(msr);
168 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 208 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
169 209
170 if (!test_and_set_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0])) 210 if (!test_and_set_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]))
171 return 1; 211 return 1;
172 return 0; 212 return 0;
173} 213}
174 214
175void release_evntsel_nmi(unsigned int msr) 215static void __release_evntsel_nmi(int cpu, unsigned int msr)
176{ 216{
177 unsigned int counter; 217 unsigned int counter;
218 if (cpu < 0)
219 cpu = smp_processor_id();
178 220
179 counter = nmi_evntsel_msr_to_bit(msr); 221 counter = nmi_evntsel_msr_to_bit(msr);
180 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 222 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
181 223
182 clear_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0]); 224 clear_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]);
225}
226
227int reserve_evntsel_nmi(unsigned int msr)
228{
229 int cpu, i;
230 for_each_possible_cpu (cpu) {
231 if (!__reserve_evntsel_nmi(cpu, msr)) {
232 for_each_possible_cpu (i) {
233 if (i >= cpu)
234 break;
235 __release_evntsel_nmi(i, msr);
236 }
237 return 0;
238 }
239 }
240 return 1;
241}
242
243void release_evntsel_nmi(unsigned int msr)
244{
245 int cpu;
246 for_each_possible_cpu (cpu) {
247 __release_evntsel_nmi(cpu, msr);
248 }
183} 249}
184 250
185static __cpuinit inline int nmi_known_cpu(void) 251static __cpuinit inline int nmi_known_cpu(void)
@@ -263,7 +329,7 @@ static int __init check_nmi_watchdog(void)
263 for_each_possible_cpu(cpu) 329 for_each_possible_cpu(cpu)
264 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count; 330 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
265 local_irq_enable(); 331 local_irq_enable();
266 mdelay((10*1000)/nmi_hz); // wait 10 ticks 332 mdelay((20*1000)/nmi_hz); // wait 20 ticks
267 333
268 for_each_possible_cpu(cpu) { 334 for_each_possible_cpu(cpu) {
269#ifdef CONFIG_SMP 335#ifdef CONFIG_SMP
@@ -507,10 +573,10 @@ static int setup_k7_watchdog(void)
507 573
508 perfctr_msr = MSR_K7_PERFCTR0; 574 perfctr_msr = MSR_K7_PERFCTR0;
509 evntsel_msr = MSR_K7_EVNTSEL0; 575 evntsel_msr = MSR_K7_EVNTSEL0;
510 if (!reserve_perfctr_nmi(perfctr_msr)) 576 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
511 goto fail; 577 goto fail;
512 578
513 if (!reserve_evntsel_nmi(evntsel_msr)) 579 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
514 goto fail1; 580 goto fail1;
515 581
516 wrmsrl(perfctr_msr, 0UL); 582 wrmsrl(perfctr_msr, 0UL);
@@ -533,7 +599,7 @@ static int setup_k7_watchdog(void)
533 wd->check_bit = 1ULL<<63; 599 wd->check_bit = 1ULL<<63;
534 return 1; 600 return 1;
535fail1: 601fail1:
536 release_perfctr_nmi(perfctr_msr); 602 __release_perfctr_nmi(-1, perfctr_msr);
537fail: 603fail:
538 return 0; 604 return 0;
539} 605}
@@ -544,8 +610,8 @@ static void stop_k7_watchdog(void)
544 610
545 wrmsr(wd->evntsel_msr, 0, 0); 611 wrmsr(wd->evntsel_msr, 0, 0);
546 612
547 release_evntsel_nmi(wd->evntsel_msr); 613 __release_evntsel_nmi(-1, wd->evntsel_msr);
548 release_perfctr_nmi(wd->perfctr_msr); 614 __release_perfctr_nmi(-1, wd->perfctr_msr);
549} 615}
550 616
551#define P6_EVNTSEL0_ENABLE (1 << 22) 617#define P6_EVNTSEL0_ENABLE (1 << 22)
@@ -563,10 +629,10 @@ static int setup_p6_watchdog(void)
563 629
564 perfctr_msr = MSR_P6_PERFCTR0; 630 perfctr_msr = MSR_P6_PERFCTR0;
565 evntsel_msr = MSR_P6_EVNTSEL0; 631 evntsel_msr = MSR_P6_EVNTSEL0;
566 if (!reserve_perfctr_nmi(perfctr_msr)) 632 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
567 goto fail; 633 goto fail;
568 634
569 if (!reserve_evntsel_nmi(evntsel_msr)) 635 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
570 goto fail1; 636 goto fail1;
571 637
572 wrmsrl(perfctr_msr, 0UL); 638 wrmsrl(perfctr_msr, 0UL);
@@ -590,7 +656,7 @@ static int setup_p6_watchdog(void)
590 wd->check_bit = 1ULL<<39; 656 wd->check_bit = 1ULL<<39;
591 return 1; 657 return 1;
592fail1: 658fail1:
593 release_perfctr_nmi(perfctr_msr); 659 __release_perfctr_nmi(-1, perfctr_msr);
594fail: 660fail:
595 return 0; 661 return 0;
596} 662}
@@ -601,8 +667,8 @@ static void stop_p6_watchdog(void)
601 667
602 wrmsr(wd->evntsel_msr, 0, 0); 668 wrmsr(wd->evntsel_msr, 0, 0);
603 669
604 release_evntsel_nmi(wd->evntsel_msr); 670 __release_evntsel_nmi(-1, wd->evntsel_msr);
605 release_perfctr_nmi(wd->perfctr_msr); 671 __release_perfctr_nmi(-1, wd->perfctr_msr);
606} 672}
607 673
608/* Note that these events don't tick when the CPU idles. This means 674/* Note that these events don't tick when the CPU idles. This means
@@ -668,10 +734,10 @@ static int setup_p4_watchdog(void)
668 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4); 734 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4);
669 } 735 }
670 736
671 if (!reserve_perfctr_nmi(perfctr_msr)) 737 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
672 goto fail; 738 goto fail;
673 739
674 if (!reserve_evntsel_nmi(evntsel_msr)) 740 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
675 goto fail1; 741 goto fail1;
676 742
677 evntsel = P4_ESCR_EVENT_SELECT(0x3F) 743 evntsel = P4_ESCR_EVENT_SELECT(0x3F)
@@ -695,7 +761,7 @@ static int setup_p4_watchdog(void)
695 wd->check_bit = 1ULL<<39; 761 wd->check_bit = 1ULL<<39;
696 return 1; 762 return 1;
697fail1: 763fail1:
698 release_perfctr_nmi(perfctr_msr); 764 __release_perfctr_nmi(-1, perfctr_msr);
699fail: 765fail:
700 return 0; 766 return 0;
701} 767}
@@ -707,8 +773,8 @@ static void stop_p4_watchdog(void)
707 wrmsr(wd->cccr_msr, 0, 0); 773 wrmsr(wd->cccr_msr, 0, 0);
708 wrmsr(wd->evntsel_msr, 0, 0); 774 wrmsr(wd->evntsel_msr, 0, 0);
709 775
710 release_evntsel_nmi(wd->evntsel_msr); 776 __release_evntsel_nmi(-1, wd->evntsel_msr);
711 release_perfctr_nmi(wd->perfctr_msr); 777 __release_perfctr_nmi(-1, wd->perfctr_msr);
712} 778}
713 779
714#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 780#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
@@ -736,10 +802,10 @@ static int setup_intel_arch_watchdog(void)
736 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0; 802 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0;
737 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0; 803 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0;
738 804
739 if (!reserve_perfctr_nmi(perfctr_msr)) 805 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
740 goto fail; 806 goto fail;
741 807
742 if (!reserve_evntsel_nmi(evntsel_msr)) 808 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
743 goto fail1; 809 goto fail1;
744 810
745 wrmsrl(perfctr_msr, 0UL); 811 wrmsrl(perfctr_msr, 0UL);
@@ -764,7 +830,7 @@ static int setup_intel_arch_watchdog(void)
764 wd->check_bit = 1ULL << (eax.split.bit_width - 1); 830 wd->check_bit = 1ULL << (eax.split.bit_width - 1);
765 return 1; 831 return 1;
766fail1: 832fail1:
767 release_perfctr_nmi(perfctr_msr); 833 __release_perfctr_nmi(-1, perfctr_msr);
768fail: 834fail:
769 return 0; 835 return 0;
770} 836}
@@ -787,8 +853,8 @@ static void stop_intel_arch_watchdog(void)
787 return; 853 return;
788 854
789 wrmsr(wd->evntsel_msr, 0, 0); 855 wrmsr(wd->evntsel_msr, 0, 0);
790 release_evntsel_nmi(wd->evntsel_msr); 856 __release_evntsel_nmi(-1, wd->evntsel_msr);
791 release_perfctr_nmi(wd->perfctr_msr); 857 __release_perfctr_nmi(-1, wd->perfctr_msr);
792} 858}
793 859
794void setup_apic_nmi_watchdog (void *unused) 860void setup_apic_nmi_watchdog (void *unused)
diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c
index fb07a1aad225..697a70e8c0c9 100644
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -69,6 +69,7 @@ struct {
69 void (*flush_tlb)(int); 69 void (*flush_tlb)(int);
70 void (*set_initial_ap_state)(int, int); 70 void (*set_initial_ap_state)(int, int);
71 void (*halt)(void); 71 void (*halt)(void);
72 void (*set_lazy_mode)(int mode);
72} vmi_ops; 73} vmi_ops;
73 74
74/* XXX move this to alternative.h */ 75/* XXX move this to alternative.h */
@@ -574,6 +575,26 @@ vmi_startup_ipi_hook(int phys_apicid, unsigned long start_eip,
574} 575}
575#endif 576#endif
576 577
578static void vmi_set_lazy_mode(int mode)
579{
580 static DEFINE_PER_CPU(int, lazy_mode);
581
582 if (!vmi_ops.set_lazy_mode)
583 return;
584
585 /* Modes should never nest or overlap */
586 BUG_ON(__get_cpu_var(lazy_mode) && !(mode == PARAVIRT_LAZY_NONE ||
587 mode == PARAVIRT_LAZY_FLUSH));
588
589 if (mode == PARAVIRT_LAZY_FLUSH) {
590 vmi_ops.set_lazy_mode(0);
591 vmi_ops.set_lazy_mode(__get_cpu_var(lazy_mode));
592 } else {
593 vmi_ops.set_lazy_mode(mode);
594 __get_cpu_var(lazy_mode) = mode;
595 }
596}
597
577static inline int __init check_vmi_rom(struct vrom_header *rom) 598static inline int __init check_vmi_rom(struct vrom_header *rom)
578{ 599{
579 struct pci_header *pci; 600 struct pci_header *pci;
@@ -691,11 +712,14 @@ static void *vmi_get_function(int vmicall)
691do { \ 712do { \
692 reloc = call_vrom_long_func(vmi_rom, get_reloc, \ 713 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
693 VMI_CALL_##vmicall); \ 714 VMI_CALL_##vmicall); \
694 if (rel->type != VMI_RELOCATION_NONE) { \ 715 if (rel->type == VMI_RELOCATION_CALL_REL) \
695 BUG_ON(rel->type != VMI_RELOCATION_CALL_REL); \
696 paravirt_ops.opname = (void *)rel->eip; \ 716 paravirt_ops.opname = (void *)rel->eip; \
697 } else if (rel->type == VMI_RELOCATION_NOP) \ 717 else if (rel->type == VMI_RELOCATION_NOP) \
698 paravirt_ops.opname = (void *)vmi_nop; \ 718 paravirt_ops.opname = (void *)vmi_nop; \
719 else if (rel->type != VMI_RELOCATION_NONE) \
720 printk(KERN_WARNING "VMI: Unknown relocation " \
721 "type %d for " #vmicall"\n",\
722 rel->type); \
699} while (0) 723} while (0)
700 724
701/* 725/*
@@ -804,7 +828,7 @@ static inline int __init activate_vmi(void)
804 para_wrap(load_esp0, vmi_load_esp0, set_kernel_stack, UpdateKernelStack); 828 para_wrap(load_esp0, vmi_load_esp0, set_kernel_stack, UpdateKernelStack);
805 para_fill(set_iopl_mask, SetIOPLMask); 829 para_fill(set_iopl_mask, SetIOPLMask);
806 para_fill(io_delay, IODelay); 830 para_fill(io_delay, IODelay);
807 para_fill(set_lazy_mode, SetLazyMode); 831 para_wrap(set_lazy_mode, vmi_set_lazy_mode, set_lazy_mode, SetLazyMode);
808 832
809 /* user and kernel flush are just handled with different flags to FlushTLB */ 833 /* user and kernel flush are just handled with different flags to FlushTLB */
810 para_wrap(flush_tlb_user, vmi_flush_tlb_user, flush_tlb, FlushTLB); 834 para_wrap(flush_tlb_user, vmi_flush_tlb_user, flush_tlb, FlushTLB);
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index ca51610955df..6f38f818380b 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -26,7 +26,7 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
26OUTPUT_ARCH(i386) 26OUTPUT_ARCH(i386)
27ENTRY(phys_startup_32) 27ENTRY(phys_startup_32)
28jiffies = jiffies_64; 28jiffies = jiffies_64;
29_proxy_pda = 0; 29_proxy_pda = 1;
30 30
31PHDRS { 31PHDRS {
32 text PT_LOAD FLAGS(5); /* R_E */ 32 text PT_LOAD FLAGS(5); /* R_E */
diff --git a/arch/i386/lib/usercopy.c b/arch/i386/lib/usercopy.c
index d22cfc9d656c..086b3726862a 100644
--- a/arch/i386/lib/usercopy.c
+++ b/arch/i386/lib/usercopy.c
@@ -10,6 +10,7 @@
10#include <linux/blkdev.h> 10#include <linux/blkdev.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/backing-dev.h> 12#include <linux/backing-dev.h>
13#include <linux/interrupt.h>
13#include <asm/uaccess.h> 14#include <asm/uaccess.h>
14#include <asm/mmx.h> 15#include <asm/mmx.h>
15 16
@@ -719,6 +720,14 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
719#ifndef CONFIG_X86_WP_WORKS_OK 720#ifndef CONFIG_X86_WP_WORKS_OK
720 if (unlikely(boot_cpu_data.wp_works_ok == 0) && 721 if (unlikely(boot_cpu_data.wp_works_ok == 0) &&
721 ((unsigned long )to) < TASK_SIZE) { 722 ((unsigned long )to) < TASK_SIZE) {
723 /*
724 * When we are in an atomic section (see
725 * mm/filemap.c:file_read_actor), return the full
726 * length to take the slow path.
727 */
728 if (in_atomic())
729 return n;
730
722 /* 731 /*
723 * CPU does not honor the WP bit when writing 732 * CPU does not honor the WP bit when writing
724 * from supervisory mode, and due to preemption or SMP, 733 * from supervisory mode, and due to preemption or SMP,
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c
index bb2de1089add..ac70d09df7ee 100644
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -42,6 +42,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
42 42
43 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 43 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
44 set_pte(kmap_pte-idx, mk_pte(page, kmap_prot)); 44 set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
45 arch_flush_lazy_mmu_mode();
45 46
46 return (void*) vaddr; 47 return (void*) vaddr;
47} 48}
@@ -82,6 +83,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
82 idx = type + KM_TYPE_NR*smp_processor_id(); 83 idx = type + KM_TYPE_NR*smp_processor_id();
83 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 84 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
84 set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot)); 85 set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot));
86 arch_flush_lazy_mmu_mode();
85 87
86 return (void*) vaddr; 88 return (void*) vaddr;
87} 89}
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 1bb069372143..3f78d4d8ecf3 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -193,6 +193,14 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
193 }, 193 },
194 { 194 {
195 .callback = set_bf_sort, 195 .callback = set_bf_sort,
196 .ident = "Dell PowerEdge R900",
197 .matches = {
198 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
199 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
200 },
201 },
202 {
203 .callback = set_bf_sort,
196 .ident = "HP ProLiant BL20p G3", 204 .ident = "HP ProLiant BL20p G3",
197 .matches = { 205 .matches = {
198 DMI_MATCH(DMI_SYS_VENDOR, "HP"), 206 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
@@ -426,11 +434,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
426 if ((err = pcibios_enable_resources(dev, mask)) < 0) 434 if ((err = pcibios_enable_resources(dev, mask)) < 0)
427 return err; 435 return err;
428 436
429 return pcibios_enable_irq(dev); 437 if (!dev->msi_enabled)
438 return pcibios_enable_irq(dev);
439 return 0;
430} 440}
431 441
432void pcibios_disable_device (struct pci_dev *dev) 442void pcibios_disable_device (struct pci_dev *dev)
433{ 443{
434 if (pcibios_disable_irq) 444 if (!dev->msi_enabled && pcibios_disable_irq)
435 pcibios_disable_irq(dev); 445 pcibios_disable_irq(dev);
436} 446}
diff --git a/arch/ia64/kernel/msi_ia64.c b/arch/ia64/kernel/msi_ia64.c
index e7220900ea14..c81080df70df 100644
--- a/arch/ia64/kernel/msi_ia64.c
+++ b/arch/ia64/kernel/msi_ia64.c
@@ -68,7 +68,7 @@ int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
68{ 68{
69 struct msi_msg msg; 69 struct msi_msg msg;
70 unsigned long dest_phys_id; 70 unsigned long dest_phys_id;
71 unsigned int irq, vector; 71 int irq, vector;
72 72
73 irq = create_irq(); 73 irq = create_irq();
74 if (irq < 0) 74 if (irq < 0)
@@ -76,7 +76,7 @@ int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
76 76
77 set_irq_msi(irq, desc); 77 set_irq_msi(irq, desc);
78 dest_phys_id = cpu_physical_id(first_cpu(cpu_online_map)); 78 dest_phys_id = cpu_physical_id(first_cpu(cpu_online_map));
79 vector = irq; 79 vector = irq_to_vector(irq);
80 80
81 msg.address_hi = 0; 81 msg.address_hi = 0;
82 msg.address_lo = 82 msg.address_lo =
@@ -110,7 +110,7 @@ static void ia64_ack_msi_irq(unsigned int irq)
110 110
111static int ia64_msi_retrigger_irq(unsigned int irq) 111static int ia64_msi_retrigger_irq(unsigned int irq)
112{ 112{
113 unsigned int vector = irq; 113 unsigned int vector = irq_to_vector(irq);
114 ia64_resend_irq(vector); 114 ia64_resend_irq(vector);
115 115
116 return 1; 116 return 1;
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 69b9bb3fd7c5..dc7dd7648ec5 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -640,7 +640,7 @@ show_cpuinfo (struct seq_file *m, void *v)
640 "features : %s\n" 640 "features : %s\n"
641 "cpu number : %lu\n" 641 "cpu number : %lu\n"
642 "cpu regs : %u\n" 642 "cpu regs : %u\n"
643 "cpu MHz : %lu.%06lu\n" 643 "cpu MHz : %lu.%03lu\n"
644 "itc MHz : %lu.%06lu\n" 644 "itc MHz : %lu.%06lu\n"
645 "BogoMIPS : %lu.%02lu\n", 645 "BogoMIPS : %lu.%02lu\n",
646 cpunum, c->vendor, c->family, c->model, 646 cpunum, c->vendor, c->family, c->model,
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index b21ddecea943..ff7df439da6d 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -375,6 +375,7 @@ static void __devinit
375smp_callin (void) 375smp_callin (void)
376{ 376{
377 int cpuid, phys_id, itc_master; 377 int cpuid, phys_id, itc_master;
378 struct cpuinfo_ia64 *last_cpuinfo, *this_cpuinfo;
378 extern void ia64_init_itm(void); 379 extern void ia64_init_itm(void);
379 extern volatile int time_keeper_id; 380 extern volatile int time_keeper_id;
380 381
@@ -424,7 +425,21 @@ smp_callin (void)
424 * Get our bogomips. 425 * Get our bogomips.
425 */ 426 */
426 ia64_init_itm(); 427 ia64_init_itm();
427 calibrate_delay(); 428
429 /*
430 * Delay calibration can be skipped if new processor is identical to the
431 * previous processor.
432 */
433 last_cpuinfo = cpu_data(cpuid - 1);
434 this_cpuinfo = local_cpu_data;
435 if (last_cpuinfo->itc_freq != this_cpuinfo->itc_freq ||
436 last_cpuinfo->proc_freq != this_cpuinfo->proc_freq ||
437 last_cpuinfo->features != this_cpuinfo->features ||
438 last_cpuinfo->revision != this_cpuinfo->revision ||
439 last_cpuinfo->family != this_cpuinfo->family ||
440 last_cpuinfo->archrev != this_cpuinfo->archrev ||
441 last_cpuinfo->model != this_cpuinfo->model)
442 calibrate_delay();
428 local_cpu_data->loops_per_jiffy = loops_per_jiffy; 443 local_cpu_data->loops_per_jiffy = loops_per_jiffy;
429 444
430#ifdef CONFIG_IA32_SUPPORT 445#ifdef CONFIG_IA32_SUPPORT
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index c8da621aab17..4f36987eea72 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -155,7 +155,7 @@ ia64_set_rbs_bot (void)
155 155
156 if (stack_size > MAX_USER_STACK_SIZE) 156 if (stack_size > MAX_USER_STACK_SIZE)
157 stack_size = MAX_USER_STACK_SIZE; 157 stack_size = MAX_USER_STACK_SIZE;
158 current->thread.rbs_bot = STACK_TOP - stack_size; 158 current->thread.rbs_bot = PAGE_ALIGN(current->mm->start_stack - stack_size);
159} 159}
160 160
161/* 161/*
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 474d179966dc..0e83f3b419b5 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -557,14 +557,17 @@ pcibios_enable_device (struct pci_dev *dev, int mask)
557 if (ret < 0) 557 if (ret < 0)
558 return ret; 558 return ret;
559 559
560 return acpi_pci_irq_enable(dev); 560 if (!dev->msi_enabled)
561 return acpi_pci_irq_enable(dev);
562 return 0;
561} 563}
562 564
563void 565void
564pcibios_disable_device (struct pci_dev *dev) 566pcibios_disable_device (struct pci_dev *dev)
565{ 567{
566 BUG_ON(atomic_read(&dev->enable_cnt)); 568 BUG_ON(atomic_read(&dev->enable_cnt));
567 acpi_pci_irq_disable(dev); 569 if (!dev->msi_enabled)
570 acpi_pci_irq_disable(dev);
568} 571}
569 572
570void 573void
diff --git a/arch/ia64/sn/kernel/bte_error.c b/arch/ia64/sn/kernel/bte_error.c
index f1ec1370b3e3..b6fcf8164f2b 100644
--- a/arch/ia64/sn/kernel/bte_error.c
+++ b/arch/ia64/sn/kernel/bte_error.c
@@ -78,7 +78,7 @@ int shub1_bte_error_handler(unsigned long _nodepda)
78 * There are errors which still need to be cleaned up by 78 * There are errors which still need to be cleaned up by
79 * hubiio_crb_error_handler 79 * hubiio_crb_error_handler
80 */ 80 */
81 mod_timer(recovery_timer, HZ * 5); 81 mod_timer(recovery_timer, jiffies + (HZ * 5));
82 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda, 82 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda,
83 smp_processor_id())); 83 smp_processor_id()));
84 return 1; 84 return 1;
@@ -95,7 +95,7 @@ int shub1_bte_error_handler(unsigned long _nodepda)
95 icrbd.ii_icrb0_d_regval = 95 icrbd.ii_icrb0_d_regval =
96 REMOTE_HUB_L(nasid, IIO_ICRB_D(i)); 96 REMOTE_HUB_L(nasid, IIO_ICRB_D(i));
97 if (icrbd.d_bteop) { 97 if (icrbd.d_bteop) {
98 mod_timer(recovery_timer, HZ * 5); 98 mod_timer(recovery_timer, jiffies + (HZ * 5));
99 BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n", 99 BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n",
100 err_nodepda, smp_processor_id(), 100 err_nodepda, smp_processor_id(),
101 i)); 101 i));
@@ -150,7 +150,7 @@ int shub2_bte_error_handler(unsigned long _nodepda)
150 status = BTE_LNSTAT_LOAD(bte); 150 status = BTE_LNSTAT_LOAD(bte);
151 if ((status & IBLS_ERROR) || !(status & IBLS_BUSY)) 151 if ((status & IBLS_ERROR) || !(status & IBLS_BUSY))
152 continue; 152 continue;
153 mod_timer(recovery_timer, HZ * 5); 153 mod_timer(recovery_timer, jiffies + (HZ * 5));
154 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda, 154 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda,
155 smp_processor_id())); 155 smp_processor_id()));
156 return 1; 156 return 1;
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_dma.c b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
index 1ee977fb6ebb..95af40cb22f2 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_dma.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
@@ -96,10 +96,14 @@ pcibr_dmamap_ate32(struct pcidev_info *info,
96 } 96 }
97 97
98 /* 98 /*
99 * If we're mapping for MSI, set the MSI bit in the ATE 99 * If we're mapping for MSI, set the MSI bit in the ATE. If it's a
100 * TIOCP based pci bus, we also need to set the PIO bit in the ATE.
100 */ 101 */
101 if (dma_flags & SN_DMA_MSI) 102 if (dma_flags & SN_DMA_MSI) {
102 ate |= PCI32_ATE_MSI; 103 ate |= PCI32_ATE_MSI;
104 if (IS_TIOCP_SOFT(pcibus_info))
105 ate |= PCI32_ATE_PIO;
106 }
103 107
104 ate_write(pcibus_info, ate_index, ate_count, ate); 108 ate_write(pcibus_info, ate_index, ate_count, ate);
105 109
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 656f0ca52782..c78b14380b3e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1606,7 +1606,7 @@ config MIPS_MT_FPAFF
1606 1606
1607config MIPS_MT_SMTC_INSTANT_REPLAY 1607config MIPS_MT_SMTC_INSTANT_REPLAY
1608 bool "Low-latency Dispatch of Deferred SMTC IPIs" 1608 bool "Low-latency Dispatch of Deferred SMTC IPIs"
1609 depends on MIPS_MT_SMTC 1609 depends on MIPS_MT_SMTC && !PREEMPT
1610 default y 1610 default y
1611 help 1611 help
1612 SMTC pseudo-interrupts between TCs are deferred and queued 1612 SMTC pseudo-interrupts between TCs are deferred and queued
diff --git a/arch/mips/gt64120/momenco_ocelot/prom.c b/arch/mips/gt64120/momenco_ocelot/prom.c
index 78f393b2afd9..c71c85276c74 100644
--- a/arch/mips/gt64120/momenco_ocelot/prom.c
+++ b/arch/mips/gt64120/momenco_ocelot/prom.c
@@ -32,7 +32,6 @@ void __init prom_init(void)
32 char **arg = (char **) fw_arg1; 32 char **arg = (char **) fw_arg1;
33 char **env = (char **) fw_arg2; 33 char **env = (char **) fw_arg2;
34 struct callvectors *cv = (struct callvectors *) fw_arg3; 34 struct callvectors *cv = (struct callvectors *) fw_arg3;
35 uint32_t tmp;
36 int i; 35 int i;
37 36
38 /* save the PROM vectors for debugging use */ 37 /* save the PROM vectors for debugging use */
diff --git a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
index 94f94ebbda6c..98b6fb38096d 100644
--- a/arch/mips/gt64120/momenco_ocelot/setup.c
+++ b/arch/mips/gt64120/momenco_ocelot/setup.c
@@ -79,7 +79,7 @@ static char reset_reason;
79static void __init setup_l3cache(unsigned long size); 79static void __init setup_l3cache(unsigned long size);
80 80
81/* setup code for a handoff from a version 1 PMON 2000 PROM */ 81/* setup code for a handoff from a version 1 PMON 2000 PROM */
82void PMON_v1_setup() 82static void PMON_v1_setup(void)
83{ 83{
84 /* A wired TLB entry for the GT64120A and the serial port. The 84 /* A wired TLB entry for the GT64120A and the serial port. The
85 GT64120A is going to be hit on every IRQ anyway - there's 85 GT64120A is going to be hit on every IRQ anyway - there's
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index 0b78fcbf044a..686249c5c328 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -121,7 +121,11 @@ FEXPORT(restore_partial) # restore partial frame
121 SAVE_AT 121 SAVE_AT
122 SAVE_TEMP 122 SAVE_TEMP
123 LONG_L v0, PT_STATUS(sp) 123 LONG_L v0, PT_STATUS(sp)
124 and v0, 1 124#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
125 and v0, ST0_IEP
126#else
127 and v0, ST0_IE
128#endif
125 beqz v0, 1f 129 beqz v0, 1f
126 jal trace_hardirqs_on 130 jal trace_hardirqs_on
127 b 2f 131 b 2f
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index 83843a229be7..297bd56c2347 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -128,6 +128,37 @@ handle_vcei:
128 128
129 .align 5 129 .align 5
130NESTED(handle_int, PT_SIZE, sp) 130NESTED(handle_int, PT_SIZE, sp)
131#ifdef CONFIG_TRACE_IRQFLAGS
132 /*
133 * Check to see if the interrupted code has just disabled
134 * interrupts and ignore this interrupt for now if so.
135 *
136 * local_irq_disable() disables interrupts and then calls
137 * trace_hardirqs_off() to track the state. If an interrupt is taken
138 * after interrupts are disabled but before the state is updated
139 * it will appear to restore_all that it is incorrectly returning with
140 * interrupts disabled
141 */
142 .set push
143 .set noat
144 mfc0 k0, CP0_STATUS
145#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
146 and k0, ST0_IEP
147 bnez k0, 1f
148
149 mfc0 k0, EP0_EPC
150 .set noreorder
151 j k0
152 rfe
153#else
154 and k0, ST0_IE
155 bnez k0, 1f
156
157 eret
158#endif
1591:
160 .set pop
161#endif
131 SAVE_ALL 162 SAVE_ALL
132 CLI 163 CLI
133 TRACE_IRQS_OFF 164 TRACE_IRQS_OFF
diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S
index 28c2e2e6af73..656bde2e11b1 100644
--- a/arch/mips/kernel/r2300_switch.S
+++ b/arch/mips/kernel/r2300_switch.S
@@ -49,7 +49,8 @@ LEAF(resume)
49#ifndef CONFIG_CPU_HAS_LLSC 49#ifndef CONFIG_CPU_HAS_LLSC
50 sw zero, ll_bit 50 sw zero, ll_bit
51#endif 51#endif
52 mfc0 t2, CP0_STATUS 52 mfc0 t1, CP0_STATUS
53 sw t1, THREAD_STATUS(a0)
53 cpu_save_nonscratch a0 54 cpu_save_nonscratch a0
54 sw ra, THREAD_REG31(a0) 55 sw ra, THREAD_REG31(a0)
55 56
@@ -59,8 +60,8 @@ LEAF(resume)
59 lw t3, TASK_THREAD_INFO(a0) 60 lw t3, TASK_THREAD_INFO(a0)
60 lw t0, TI_FLAGS(t3) 61 lw t0, TI_FLAGS(t3)
61 li t1, _TIF_USEDFPU 62 li t1, _TIF_USEDFPU
62 and t1, t0 63 and t2, t0, t1
63 beqz t1, 1f 64 beqz t2, 1f
64 nor t1, zero, t1 65 nor t1, zero, t1
65 66
66 and t0, t0, t1 67 and t0, t0, t1
@@ -73,13 +74,10 @@ LEAF(resume)
73 li t1, ~ST0_CU1 74 li t1, ~ST0_CU1
74 and t0, t0, t1 75 and t0, t0, t1
75 sw t0, ST_OFF(t3) 76 sw t0, ST_OFF(t3)
76 /* clear thread_struct CU1 bit */
77 and t2, t1
78 77
79 fpu_save_single a0, t0 # clobbers t0 78 fpu_save_single a0, t0 # clobbers t0
80 79
811: 801:
82 sw t2, THREAD_STATUS(a0)
83 /* 81 /*
84 * The order of restoring the registers takes care of the race 82 * The order of restoring the registers takes care of the race
85 * updating $28, $29 and kernelsp without disabling ints. 83 * updating $28, $29 and kernelsp without disabling ints.
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index c7698fd9955c..cc566cf12246 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -48,7 +48,8 @@
48#ifndef CONFIG_CPU_HAS_LLSC 48#ifndef CONFIG_CPU_HAS_LLSC
49 sw zero, ll_bit 49 sw zero, ll_bit
50#endif 50#endif
51 mfc0 t2, CP0_STATUS 51 mfc0 t1, CP0_STATUS
52 LONG_S t1, THREAD_STATUS(a0)
52 cpu_save_nonscratch a0 53 cpu_save_nonscratch a0
53 LONG_S ra, THREAD_REG31(a0) 54 LONG_S ra, THREAD_REG31(a0)
54 55
@@ -58,8 +59,8 @@
58 PTR_L t3, TASK_THREAD_INFO(a0) 59 PTR_L t3, TASK_THREAD_INFO(a0)
59 LONG_L t0, TI_FLAGS(t3) 60 LONG_L t0, TI_FLAGS(t3)
60 li t1, _TIF_USEDFPU 61 li t1, _TIF_USEDFPU
61 and t1, t0 62 and t2, t0, t1
62 beqz t1, 1f 63 beqz t2, 1f
63 nor t1, zero, t1 64 nor t1, zero, t1
64 65
65 and t0, t0, t1 66 and t0, t0, t1
@@ -72,13 +73,10 @@
72 li t1, ~ST0_CU1 73 li t1, ~ST0_CU1
73 and t0, t0, t1 74 and t0, t0, t1
74 LONG_S t0, ST_OFF(t3) 75 LONG_S t0, ST_OFF(t3)
75 /* clear thread_struct CU1 bit */
76 and t2, t1
77 76
78 fpu_save_double a0 t0 t1 # c0_status passed in t0 77 fpu_save_double a0 t0 t1 # c0_status passed in t0
79 # clobbers t1 78 # clobbers t1
801: 791:
81 LONG_S t2, THREAD_STATUS(a0)
82 80
83 /* 81 /*
84 * The order of restoring the registers takes care of the race 82 * The order of restoring the registers takes care of the race
diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h
index 297dfcb97524..c0faabd52010 100644
--- a/arch/mips/kernel/signal-common.h
+++ b/arch/mips/kernel/signal-common.h
@@ -34,4 +34,13 @@ extern int install_sigtramp(unsigned int __user *tramp, unsigned int syscall);
34/* Check and clear pending FPU exceptions in saved CSR */ 34/* Check and clear pending FPU exceptions in saved CSR */
35extern int fpcsr_pending(unsigned int __user *fpcsr); 35extern int fpcsr_pending(unsigned int __user *fpcsr);
36 36
37/* Make sure we will not lose FPU ownership */
38#ifdef CONFIG_PREEMPT
39#define lock_fpu_owner() preempt_disable()
40#define unlock_fpu_owner() preempt_enable()
41#else
42#define lock_fpu_owner() pagefault_disable()
43#define unlock_fpu_owner() pagefault_enable()
44#endif
45
37#endif /* __SIGNAL_COMMON_H */ 46#endif /* __SIGNAL_COMMON_H */
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 8c3c5a5789b0..07d67309451a 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -20,6 +20,7 @@
20#include <linux/ptrace.h> 20#include <linux/ptrace.h>
21#include <linux/unistd.h> 21#include <linux/unistd.h>
22#include <linux/compiler.h> 22#include <linux/compiler.h>
23#include <linux/uaccess.h>
23 24
24#include <asm/abi.h> 25#include <asm/abi.h>
25#include <asm/asm.h> 26#include <asm/asm.h>
@@ -27,7 +28,6 @@
27#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
28#include <asm/fpu.h> 29#include <asm/fpu.h>
29#include <asm/sim.h> 30#include <asm/sim.h>
30#include <asm/uaccess.h>
31#include <asm/ucontext.h> 31#include <asm/ucontext.h>
32#include <asm/cpu-features.h> 32#include <asm/cpu-features.h>
33#include <asm/war.h> 33#include <asm/war.h>
@@ -78,6 +78,46 @@ struct rt_sigframe {
78/* 78/*
79 * Helper routines 79 * Helper routines
80 */ 80 */
81static int protected_save_fp_context(struct sigcontext __user *sc)
82{
83 int err;
84 while (1) {
85 lock_fpu_owner();
86 own_fpu_inatomic(1);
87 err = save_fp_context(sc); /* this might fail */
88 unlock_fpu_owner();
89 if (likely(!err))
90 break;
91 /* touch the sigcontext and try again */
92 err = __put_user(0, &sc->sc_fpregs[0]) |
93 __put_user(0, &sc->sc_fpregs[31]) |
94 __put_user(0, &sc->sc_fpc_csr);
95 if (err)
96 break; /* really bad sigcontext */
97 }
98 return err;
99}
100
101static int protected_restore_fp_context(struct sigcontext __user *sc)
102{
103 int err, tmp;
104 while (1) {
105 lock_fpu_owner();
106 own_fpu_inatomic(0);
107 err = restore_fp_context(sc); /* this might fail */
108 unlock_fpu_owner();
109 if (likely(!err))
110 break;
111 /* touch the sigcontext and try again */
112 err = __get_user(tmp, &sc->sc_fpregs[0]) |
113 __get_user(tmp, &sc->sc_fpregs[31]) |
114 __get_user(tmp, &sc->sc_fpc_csr);
115 if (err)
116 break; /* really bad sigcontext */
117 }
118 return err;
119}
120
81int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) 121int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
82{ 122{
83 int err = 0; 123 int err = 0;
@@ -113,10 +153,7 @@ int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
113 * Save FPU state to signal context. Signal handler 153 * Save FPU state to signal context. Signal handler
114 * will "inherit" current FPU state. 154 * will "inherit" current FPU state.
115 */ 155 */
116 own_fpu(1); 156 err |= protected_save_fp_context(sc);
117 enable_fp_in_kernel();
118 err |= save_fp_context(sc);
119 disable_fp_in_kernel();
120 } 157 }
121 return err; 158 return err;
122} 159}
@@ -148,7 +185,7 @@ check_and_restore_fp_context(struct sigcontext __user *sc)
148 err = sig = fpcsr_pending(&sc->sc_fpc_csr); 185 err = sig = fpcsr_pending(&sc->sc_fpc_csr);
149 if (err > 0) 186 if (err > 0)
150 err = 0; 187 err = 0;
151 err |= restore_fp_context(sc); 188 err |= protected_restore_fp_context(sc);
152 return err ?: sig; 189 return err ?: sig;
153} 190}
154 191
@@ -187,11 +224,8 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
187 224
188 if (used_math) { 225 if (used_math) {
189 /* restore fpu context if we have used it before */ 226 /* restore fpu context if we have used it before */
190 own_fpu(0);
191 enable_fp_in_kernel();
192 if (!err) 227 if (!err)
193 err = check_and_restore_fp_context(sc); 228 err = check_and_restore_fp_context(sc);
194 disable_fp_in_kernel();
195 } else { 229 } else {
196 /* signal handler may have used FPU. Give it up. */ 230 /* signal handler may have used FPU. Give it up. */
197 lose_fpu(0); 231 lose_fpu(0);
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index 151fd2f0893a..b9a014411f83 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -22,6 +22,7 @@
22#include <linux/compat.h> 22#include <linux/compat.h>
23#include <linux/suspend.h> 23#include <linux/suspend.h>
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/uaccess.h>
25 26
26#include <asm/abi.h> 27#include <asm/abi.h>
27#include <asm/asm.h> 28#include <asm/asm.h>
@@ -29,7 +30,6 @@
29#include <linux/bitops.h> 30#include <linux/bitops.h>
30#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
31#include <asm/sim.h> 32#include <asm/sim.h>
32#include <asm/uaccess.h>
33#include <asm/ucontext.h> 33#include <asm/ucontext.h>
34#include <asm/system.h> 34#include <asm/system.h>
35#include <asm/fpu.h> 35#include <asm/fpu.h>
@@ -176,6 +176,46 @@ struct rt_sigframe32 {
176/* 176/*
177 * sigcontext handlers 177 * sigcontext handlers
178 */ 178 */
179static int protected_save_fp_context32(struct sigcontext32 __user *sc)
180{
181 int err;
182 while (1) {
183 lock_fpu_owner();
184 own_fpu_inatomic(1);
185 err = save_fp_context32(sc); /* this might fail */
186 unlock_fpu_owner();
187 if (likely(!err))
188 break;
189 /* touch the sigcontext and try again */
190 err = __put_user(0, &sc->sc_fpregs[0]) |
191 __put_user(0, &sc->sc_fpregs[31]) |
192 __put_user(0, &sc->sc_fpc_csr);
193 if (err)
194 break; /* really bad sigcontext */
195 }
196 return err;
197}
198
199static int protected_restore_fp_context32(struct sigcontext32 __user *sc)
200{
201 int err, tmp;
202 while (1) {
203 lock_fpu_owner();
204 own_fpu_inatomic(0);
205 err = restore_fp_context32(sc); /* this might fail */
206 unlock_fpu_owner();
207 if (likely(!err))
208 break;
209 /* touch the sigcontext and try again */
210 err = __get_user(tmp, &sc->sc_fpregs[0]) |
211 __get_user(tmp, &sc->sc_fpregs[31]) |
212 __get_user(tmp, &sc->sc_fpc_csr);
213 if (err)
214 break; /* really bad sigcontext */
215 }
216 return err;
217}
218
179static int setup_sigcontext32(struct pt_regs *regs, 219static int setup_sigcontext32(struct pt_regs *regs,
180 struct sigcontext32 __user *sc) 220 struct sigcontext32 __user *sc)
181{ 221{
@@ -209,10 +249,7 @@ static int setup_sigcontext32(struct pt_regs *regs,
209 * Save FPU state to signal context. Signal handler 249 * Save FPU state to signal context. Signal handler
210 * will "inherit" current FPU state. 250 * will "inherit" current FPU state.
211 */ 251 */
212 own_fpu(1); 252 err |= protected_save_fp_context32(sc);
213 enable_fp_in_kernel();
214 err |= save_fp_context32(sc);
215 disable_fp_in_kernel();
216 } 253 }
217 return err; 254 return err;
218} 255}
@@ -225,7 +262,7 @@ check_and_restore_fp_context32(struct sigcontext32 __user *sc)
225 err = sig = fpcsr_pending(&sc->sc_fpc_csr); 262 err = sig = fpcsr_pending(&sc->sc_fpc_csr);
226 if (err > 0) 263 if (err > 0)
227 err = 0; 264 err = 0;
228 err |= restore_fp_context32(sc); 265 err |= protected_restore_fp_context32(sc);
229 return err ?: sig; 266 return err ?: sig;
230} 267}
231 268
@@ -261,11 +298,8 @@ static int restore_sigcontext32(struct pt_regs *regs,
261 298
262 if (used_math) { 299 if (used_math) {
263 /* restore fpu context if we have used it before */ 300 /* restore fpu context if we have used it before */
264 own_fpu(0);
265 enable_fp_in_kernel();
266 if (!err) 301 if (!err)
267 err = check_and_restore_fp_context32(sc); 302 err = check_and_restore_fp_context32(sc);
268 disable_fp_in_kernel();
269 } else { 303 } else {
270 /* signal handler may have used FPU. Give it up. */ 304 /* signal handler may have used FPU. Give it up. */
271 lose_fpu(0); 305 lose_fpu(0);
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index f253eda27fa3..5dcfab6b288e 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -4,6 +4,7 @@
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/cpumask.h> 5#include <linux/cpumask.h>
6#include <linux/interrupt.h> 6#include <linux/interrupt.h>
7#include <linux/kernel_stat.h>
7#include <linux/module.h> 8#include <linux/module.h>
8 9
9#include <asm/cpu.h> 10#include <asm/cpu.h>
@@ -14,6 +15,7 @@
14#include <asm/hazards.h> 15#include <asm/hazards.h>
15#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
16#include <asm/smp.h> 17#include <asm/smp.h>
18#include <asm/mips-boards/maltaint.h>
17#include <asm/mipsregs.h> 19#include <asm/mipsregs.h>
18#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
19#include <asm/time.h> 21#include <asm/time.h>
@@ -75,7 +77,7 @@ static struct smtc_ipi_q freeIPIq;
75 77
76void ipi_decode(struct smtc_ipi *); 78void ipi_decode(struct smtc_ipi *);
77static void post_direct_ipi(int cpu, struct smtc_ipi *pipi); 79static void post_direct_ipi(int cpu, struct smtc_ipi *pipi);
78static void setup_cross_vpe_interrupts(void); 80static void setup_cross_vpe_interrupts(unsigned int nvpe);
79void init_smtc_stats(void); 81void init_smtc_stats(void);
80 82
81/* Global SMTC Status */ 83/* Global SMTC Status */
@@ -168,7 +170,10 @@ __setup("tintq=", tintq);
168 170
169int imstuckcount[2][8]; 171int imstuckcount[2][8];
170/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */ 172/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */
171int vpemask[2][8] = {{0,1,1,0,0,0,0,1},{0,1,0,0,0,0,0,1}}; 173int vpemask[2][8] = {
174 {0, 0, 1, 0, 0, 0, 0, 1},
175 {0, 0, 0, 0, 0, 0, 0, 1}
176};
172int tcnoprog[NR_CPUS]; 177int tcnoprog[NR_CPUS];
173static atomic_t idle_hook_initialized = {0}; 178static atomic_t idle_hook_initialized = {0};
174static int clock_hang_reported[NR_CPUS]; 179static int clock_hang_reported[NR_CPUS];
@@ -501,8 +506,7 @@ void mipsmt_prepare_cpus(void)
501 506
502 /* If we have multiple VPEs running, set up the cross-VPE interrupt */ 507 /* If we have multiple VPEs running, set up the cross-VPE interrupt */
503 508
504 if (nvpe > 1) 509 setup_cross_vpe_interrupts(nvpe);
505 setup_cross_vpe_interrupts();
506 510
507 /* Set up queue of free IPI "messages". */ 511 /* Set up queue of free IPI "messages". */
508 nipi = NR_CPUS * IPIBUF_PER_CPU; 512 nipi = NR_CPUS * IPIBUF_PER_CPU;
@@ -607,7 +611,12 @@ void smtc_cpus_done(void)
607int setup_irq_smtc(unsigned int irq, struct irqaction * new, 611int setup_irq_smtc(unsigned int irq, struct irqaction * new,
608 unsigned long hwmask) 612 unsigned long hwmask)
609{ 613{
614 unsigned int vpe = current_cpu_data.vpe_id;
615
610 irq_hwmask[irq] = hwmask; 616 irq_hwmask[irq] = hwmask;
617#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG
618 vpemask[vpe][irq - MIPSCPU_INT_BASE] = 1;
619#endif
611 620
612 return setup_irq(irq, new); 621 return setup_irq(irq, new);
613} 622}
@@ -812,12 +821,15 @@ void ipi_decode(struct smtc_ipi *pipi)
812 smtc_ipi_nq(&freeIPIq, pipi); 821 smtc_ipi_nq(&freeIPIq, pipi);
813 switch (type_copy) { 822 switch (type_copy) {
814 case SMTC_CLOCK_TICK: 823 case SMTC_CLOCK_TICK:
824 irq_enter();
825 kstat_this_cpu.irqs[MIPSCPU_INT_BASE + MIPSCPU_INT_CPUCTR]++;
815 /* Invoke Clock "Interrupt" */ 826 /* Invoke Clock "Interrupt" */
816 ipi_timer_latch[dest_copy] = 0; 827 ipi_timer_latch[dest_copy] = 0;
817#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG 828#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG
818 clock_hang_reported[dest_copy] = 0; 829 clock_hang_reported[dest_copy] = 0;
819#endif /* CONFIG_SMTC_IDLE_HOOK_DEBUG */ 830#endif /* CONFIG_SMTC_IDLE_HOOK_DEBUG */
820 local_timer_interrupt(0, NULL); 831 local_timer_interrupt(0, NULL);
832 irq_exit();
821 break; 833 break;
822 case LINUX_SMP_IPI: 834 case LINUX_SMP_IPI:
823 switch ((int)arg_copy) { 835 switch ((int)arg_copy) {
@@ -965,8 +977,11 @@ static void ipi_irq_dispatch(void)
965 977
966static struct irqaction irq_ipi; 978static struct irqaction irq_ipi;
967 979
968static void setup_cross_vpe_interrupts(void) 980static void setup_cross_vpe_interrupts(unsigned int nvpe)
969{ 981{
982 if (nvpe < 1)
983 return;
984
970 if (!cpu_has_vint) 985 if (!cpu_has_vint)
971 panic("SMTC Kernel requires Vectored Interupt support"); 986 panic("SMTC Kernel requires Vectored Interupt support");
972 987
@@ -984,10 +999,17 @@ static void setup_cross_vpe_interrupts(void)
984 999
985/* 1000/*
986 * SMTC-specific hacks invoked from elsewhere in the kernel. 1001 * SMTC-specific hacks invoked from elsewhere in the kernel.
1002 *
1003 * smtc_ipi_replay is called from raw_local_irq_restore which is only ever
1004 * called with interrupts disabled. We do rely on interrupts being disabled
1005 * here because using spin_lock_irqsave()/spin_unlock_irqrestore() would
1006 * result in a recursive call to raw_local_irq_restore().
987 */ 1007 */
988 1008
989void smtc_ipi_replay(void) 1009static void __smtc_ipi_replay(void)
990{ 1010{
1011 unsigned int cpu = smp_processor_id();
1012
991 /* 1013 /*
992 * To the extent that we've ever turned interrupts off, 1014 * To the extent that we've ever turned interrupts off,
993 * we may have accumulated deferred IPIs. This is subtle. 1015 * we may have accumulated deferred IPIs. This is subtle.
@@ -1002,17 +1024,30 @@ void smtc_ipi_replay(void)
1002 * is clear, and we'll handle it as a real pseudo-interrupt 1024 * is clear, and we'll handle it as a real pseudo-interrupt
1003 * and not a pseudo-pseudo interrupt. 1025 * and not a pseudo-pseudo interrupt.
1004 */ 1026 */
1005 if (IPIQ[smp_processor_id()].depth > 0) { 1027 if (IPIQ[cpu].depth > 0) {
1006 struct smtc_ipi *pipi; 1028 while (1) {
1007 extern void self_ipi(struct smtc_ipi *); 1029 struct smtc_ipi_q *q = &IPIQ[cpu];
1030 struct smtc_ipi *pipi;
1031 extern void self_ipi(struct smtc_ipi *);
1032
1033 spin_lock(&q->lock);
1034 pipi = __smtc_ipi_dq(q);
1035 spin_unlock(&q->lock);
1036 if (!pipi)
1037 break;
1008 1038
1009 while ((pipi = smtc_ipi_dq(&IPIQ[smp_processor_id()]))) {
1010 self_ipi(pipi); 1039 self_ipi(pipi);
1011 smtc_cpu_stats[smp_processor_id()].selfipis++; 1040 smtc_cpu_stats[cpu].selfipis++;
1012 } 1041 }
1013 } 1042 }
1014} 1043}
1015 1044
1045void smtc_ipi_replay(void)
1046{
1047 raw_local_irq_disable();
1048 __smtc_ipi_replay();
1049}
1050
1016EXPORT_SYMBOL(smtc_ipi_replay); 1051EXPORT_SYMBOL(smtc_ipi_replay);
1017 1052
1018void smtc_idle_loop_hook(void) 1053void smtc_idle_loop_hook(void)
@@ -1117,7 +1152,13 @@ void smtc_idle_loop_hook(void)
1117 * is in use, there should never be any. 1152 * is in use, there should never be any.
1118 */ 1153 */
1119#ifndef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY 1154#ifndef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY
1120 smtc_ipi_replay(); 1155 {
1156 unsigned long flags;
1157
1158 local_irq_save(flags);
1159 __smtc_ipi_replay();
1160 local_irq_restore(flags);
1161 }
1121#endif /* CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY */ 1162#endif /* CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY */
1122} 1163}
1123 1164
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 7d76a85422b2..493cb29b8a42 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -650,7 +650,7 @@ asmlinkage void do_bp(struct pt_regs *regs)
650 unsigned int opcode, bcode; 650 unsigned int opcode, bcode;
651 siginfo_t info; 651 siginfo_t info;
652 652
653 if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) 653 if (__get_user(opcode, (unsigned int __user *) exception_epc(regs)))
654 goto out_sigsegv; 654 goto out_sigsegv;
655 655
656 /* 656 /*
@@ -700,7 +700,7 @@ asmlinkage void do_tr(struct pt_regs *regs)
700 unsigned int opcode, tcode = 0; 700 unsigned int opcode, tcode = 0;
701 siginfo_t info; 701 siginfo_t info;
702 702
703 if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) 703 if (__get_user(opcode, (unsigned int __user *) exception_epc(regs)))
704 goto out_sigsegv; 704 goto out_sigsegv;
705 705
706 /* Immediate versions don't provide a code. */ 706 /* Immediate versions don't provide a code. */
@@ -757,11 +757,12 @@ asmlinkage void do_cpu(struct pt_regs *regs)
757{ 757{
758 unsigned int cpid; 758 unsigned int cpid;
759 759
760 die_if_kernel("do_cpu invoked from kernel context!", regs);
761
760 cpid = (regs->cp0_cause >> CAUSEB_CE) & 3; 762 cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
761 763
762 switch (cpid) { 764 switch (cpid) {
763 case 0: 765 case 0:
764 die_if_kernel("do_cpu invoked from kernel context!", regs);
765 if (!cpu_has_llsc) 766 if (!cpu_has_llsc)
766 if (!simulate_llsc(regs)) 767 if (!simulate_llsc(regs))
767 return; 768 return;
@@ -772,9 +773,6 @@ asmlinkage void do_cpu(struct pt_regs *regs)
772 break; 773 break;
773 774
774 case 1: 775 case 1:
775 if (!test_thread_flag(TIF_ALLOW_FP_IN_KERNEL))
776 die_if_kernel("do_cpu invoked from kernel context!",
777 regs);
778 if (used_math()) /* Using the FPU again. */ 776 if (used_math()) /* Using the FPU again. */
779 own_fpu(1); 777 own_fpu(1);
780 else { /* First time FPU user. */ 778 else { /* First time FPU user. */
@@ -782,19 +780,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
782 set_used_math(); 780 set_used_math();
783 } 781 }
784 782
785 if (raw_cpu_has_fpu) { 783 if (!raw_cpu_has_fpu) {
786 if (test_thread_flag(TIF_ALLOW_FP_IN_KERNEL)) {
787 local_irq_disable();
788 if (cpu_has_fpu)
789 regs->cp0_status |= ST0_CU1;
790 /*
791 * We must return without enabling
792 * interrupts to ensure keep FPU
793 * ownership until resume.
794 */
795 return;
796 }
797 } else {
798 int sig; 784 int sig;
799 sig = fpu_emulator_cop1Handler(regs, 785 sig = fpu_emulator_cop1Handler(regs,
800 &current->thread.fpu, 0); 786 &current->thread.fpu, 0);
@@ -836,7 +822,6 @@ asmlinkage void do_cpu(struct pt_regs *regs)
836 822
837 case 2: 823 case 2:
838 case 3: 824 case 3:
839 die_if_kernel("do_cpu invoked from kernel context!", regs);
840 break; 825 break;
841 } 826 }
842 827
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 6f90e7ef66ac..f9c595dceba9 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -42,7 +42,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
42 siginfo_t info; 42 siginfo_t info;
43 43
44#if 0 44#if 0
45 printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", smp_processor_id(), 45 printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", raw_smp_processor_id(),
46 current->comm, current->pid, field, address, write, 46 current->comm, current->pid, field, address, write,
47 field, regs->cp0_epc); 47 field, regs->cp0_epc);
48#endif 48#endif
@@ -165,7 +165,7 @@ no_context:
165 165
166 printk(KERN_ALERT "CPU %d Unable to handle kernel paging request at " 166 printk(KERN_ALERT "CPU %d Unable to handle kernel paging request at "
167 "virtual address %0*lx, epc == %0*lx, ra == %0*lx\n", 167 "virtual address %0*lx, epc == %0*lx, ra == %0*lx\n",
168 smp_processor_id(), field, address, field, regs->cp0_epc, 168 raw_smp_processor_id(), field, address, field, regs->cp0_epc,
169 field, regs->regs[31]); 169 field, regs->regs[31]);
170 die("Oops", regs); 170 die("Oops", regs);
171 171
@@ -228,7 +228,7 @@ vmalloc_fault:
228 pmd_t *pmd, *pmd_k; 228 pmd_t *pmd, *pmd_k;
229 pte_t *pte_k; 229 pte_t *pte_k;
230 230
231 pgd = (pgd_t *) pgd_current[smp_processor_id()] + offset; 231 pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset;
232 pgd_k = init_mm.pgd + offset; 232 pgd_k = init_mm.pgd + offset;
233 233
234 if (!pgd_present(*pgd_k)) 234 if (!pgd_present(*pgd_k))
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 69a8bcfe72b2..4f94fa261aae 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -35,7 +35,7 @@
35#define vpe_id() smp_processor_id() 35#define vpe_id() smp_processor_id()
36#else 36#else
37#define WHAT 0 37#define WHAT 0
38#define vpe_id() smp_processor_id() 38#define vpe_id() 0
39#endif 39#endif
40 40
41#define __define_perf_accessors(r, n, np) \ 41#define __define_perf_accessors(r, n, np) \
diff --git a/arch/mips/pci/pci-ev64120.c b/arch/mips/pci/pci-ev64120.c
index 9cd859ef1842..a84f594b5a18 100644
--- a/arch/mips/pci/pci-ev64120.c
+++ b/arch/mips/pci/pci-ev64120.c
@@ -1,4 +1,5 @@
1#include <linux/pci.h> 1#include <linux/pci.h>
2#include <asm/irq.h>
2 3
3int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 4int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
4{ 5{
diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index 20af0f1bb7bf..ba0c4b776c85 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -141,11 +141,11 @@ static void bcm1480_set_affinity(unsigned int irq, cpumask_t mask)
141 unsigned long flags; 141 unsigned long flags;
142 unsigned int irq_dirty; 142 unsigned int irq_dirty;
143 143
144 i = first_cpu(mask); 144 if (cpus_weight(mask) != 1) {
145 if (next_cpu(i, mask) <= NR_CPUS) {
146 printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq); 145 printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq);
147 return; 146 return;
148 } 147 }
148 i = first_cpu(mask);
149 149
150 /* Convert logical CPU to physical CPU */ 150 /* Convert logical CPU to physical CPU */
151 cpu = cpu_logical_map(i); 151 cpu = cpu_logical_map(i);
diff --git a/arch/mips/sibyte/sb1250/setup.c b/arch/mips/sibyte/sb1250/setup.c
index 87188f0f6fbe..f4a6169aa0a4 100644
--- a/arch/mips/sibyte/sb1250/setup.c
+++ b/arch/mips/sibyte/sb1250/setup.c
@@ -141,6 +141,18 @@ static int __init setup_bcm112x(void)
141 periph_rev = 3; 141 periph_rev = 3;
142 pass_str = "A2"; 142 pass_str = "A2";
143 break; 143 break;
144 case K_SYS_REVISION_BCM112x_A3:
145 periph_rev = 3;
146 pass_str = "A3";
147 break;
148 case K_SYS_REVISION_BCM112x_A4:
149 periph_rev = 3;
150 pass_str = "A4";
151 break;
152 case K_SYS_REVISION_BCM112x_B0:
153 periph_rev = 3;
154 pass_str = "B0";
155 break;
144 default: 156 default:
145 printk("Unknown %s rev %x\n", soc_str, soc_pass); 157 printk("Unknown %s rev %x\n", soc_str, soc_pass);
146 ret = 1; 158 ret = 1;
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index c75192567e55..fbfff95b4437 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -128,7 +128,7 @@ static void mpc52xx_main_mask(unsigned int virq)
128 128
129 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq); 129 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
130 130
131 io_be_setbit(&intr->main_mask, 15 - l2irq); 131 io_be_setbit(&intr->main_mask, 16 - l2irq);
132} 132}
133 133
134static void mpc52xx_main_unmask(unsigned int virq) 134static void mpc52xx_main_unmask(unsigned int virq)
@@ -141,7 +141,7 @@ static void mpc52xx_main_unmask(unsigned int virq)
141 141
142 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq); 142 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
143 143
144 io_be_clrbit(&intr->main_mask, 15 - l2irq); 144 io_be_clrbit(&intr->main_mask, 16 - l2irq);
145} 145}
146 146
147static struct irq_chip mpc52xx_main_irqchip = { 147static struct irq_chip mpc52xx_main_irqchip = {
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index dffeeaeca1d9..1fc5819e7d18 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -129,7 +129,7 @@ void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
129 129
130 if (h.token == NULL) 130 if (h.token == NULL)
131 return; 131 return;
132 h.token -= dcr_n * h.stride; 132 h.token += dcr_n * h.stride;
133 iounmap(h.token); 133 iounmap(h.token);
134 h.token = NULL; 134 h.token = NULL;
135} 135}
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index e3d71e083f35..43f6cc9d7ea0 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -251,13 +251,13 @@ static int qe_sdma_init(void)
251 251
252 /* allocate 2 internal temporary buffers (512 bytes size each) for 252 /* allocate 2 internal temporary buffers (512 bytes size each) for
253 * the SDMA */ 253 * the SDMA */
254 sdma_buf_offset = qe_muram_alloc(512 * 2, 64); 254 sdma_buf_offset = qe_muram_alloc(512 * 2, 4096);
255 if (IS_MURAM_ERR(sdma_buf_offset)) 255 if (IS_MURAM_ERR(sdma_buf_offset))
256 return -ENOMEM; 256 return -ENOMEM;
257 257
258 out_be32(&sdma->sdebcr, sdma_buf_offset & QE_SDEBCR_BA_MASK); 258 out_be32(&sdma->sdebcr, sdma_buf_offset & QE_SDEBCR_BA_MASK);
259 out_be32(&sdma->sdmr, (QE_SDMR_GLB_1_MSK | (0x1 >> 259 out_be32(&sdma->sdmr, (QE_SDMR_GLB_1_MSK |
260 QE_SDMR_CEN_SHIFT))); 260 (0x1 << QE_SDMR_CEN_SHIFT)));
261 261
262 return 0; 262 return 0;
263} 263}
diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 3b23bcb35b7a..7a8722beac12 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -39,6 +39,21 @@
39#include <asm/tlbflush.h> 39#include <asm/tlbflush.h>
40#include <asm/rheap.h> 40#include <asm/rheap.h>
41 41
42#define immr_map(member) \
43({ \
44 u32 offset = offsetof(immap_t, member); \
45 void *addr = ioremap (IMAP_ADDR + offset, \
46 sizeof( ((immap_t*)0)->member)); \
47 addr; \
48})
49
50#define immr_map_size(member, size) \
51({ \
52 u32 offset = offsetof(immap_t, member); \
53 void *addr = ioremap (IMAP_ADDR + offset, size); \
54 addr; \
55})
56
42static void m8xx_cpm_dpinit(void); 57static void m8xx_cpm_dpinit(void);
43static uint host_buffer; /* One page of host buffer */ 58static uint host_buffer; /* One page of host buffer */
44static uint host_end; /* end + 1 */ 59static uint host_end; /* end + 1 */
@@ -364,11 +379,16 @@ static rh_block_t cpm_boot_dpmem_rh_block[16];
364static rh_info_t cpm_dpmem_info; 379static rh_info_t cpm_dpmem_info;
365 380
366#define CPM_DPMEM_ALIGNMENT 8 381#define CPM_DPMEM_ALIGNMENT 8
382static u8* dpram_vbase;
383static uint dpram_pbase;
367 384
368void m8xx_cpm_dpinit(void) 385void m8xx_cpm_dpinit(void)
369{ 386{
370 spin_lock_init(&cpm_dpmem_lock); 387 spin_lock_init(&cpm_dpmem_lock);
371 388
389 dpram_vbase = immr_map_size(im_cpm.cp_dpmem, CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE);
390 dpram_pbase = (uint)&((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem;
391
372 /* Initialize the info header */ 392 /* Initialize the info header */
373 rh_init(&cpm_dpmem_info, CPM_DPMEM_ALIGNMENT, 393 rh_init(&cpm_dpmem_info, CPM_DPMEM_ALIGNMENT,
374 sizeof(cpm_boot_dpmem_rh_block) / 394 sizeof(cpm_boot_dpmem_rh_block) /
@@ -442,3 +462,9 @@ void *cpm_dpram_addr(uint offset)
442 return ((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem + offset; 462 return ((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem + offset;
443} 463}
444EXPORT_SYMBOL(cpm_dpram_addr); 464EXPORT_SYMBOL(cpm_dpram_addr);
465
466uint cpm_dpram_phys(u8* addr)
467{
468 return (dpram_pbase + (uint)(addr - dpram_vbase));
469}
470EXPORT_SYMBOL(cpm_dpram_phys);
diff --git a/arch/ppc/configs/ads8272_defconfig b/arch/ppc/configs/ads8272_defconfig
index d1db7d14780e..6619f9118b00 100644
--- a/arch/ppc/configs/ads8272_defconfig
+++ b/arch/ppc/configs/ads8272_defconfig
@@ -1,42 +1,69 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc5
4# Wed Apr 4 20:55:16 2007
3# 5#
4CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y
5CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
6CONFIG_HAVE_DEC_LOCK=y 9CONFIG_ARCH_HAS_ILOG2_U32=y
10# CONFIG_ARCH_HAS_ILOG2_U64 is not set
11CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
7CONFIG_PPC=y 13CONFIG_PPC=y
8CONFIG_PPC32=y 14CONFIG_PPC32=y
9CONFIG_GENERIC_NVRAM=y 15CONFIG_GENERIC_NVRAM=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y
17CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
18CONFIG_ARCH_MAY_HAVE_PC_FDC=y
19CONFIG_GENERIC_BUG=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
10 21
11# 22#
12# Code maturity level options 23# Code maturity level options
13# 24#
14CONFIG_EXPERIMENTAL=y 25CONFIG_EXPERIMENTAL=y
15CONFIG_CLEAN_COMPILE=y
16CONFIG_STANDALONE=y
17CONFIG_BROKEN_ON_SMP=y 26CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32
18 28
19# 29#
20# General setup 30# General setup
21# 31#
32CONFIG_LOCALVERSION=""
33CONFIG_LOCALVERSION_AUTO=y
22CONFIG_SWAP=y 34CONFIG_SWAP=y
23CONFIG_SYSVIPC=y 35CONFIG_SYSVIPC=y
36# CONFIG_IPC_NS is not set
37CONFIG_SYSVIPC_SYSCTL=y
24# CONFIG_POSIX_MQUEUE is not set 38# CONFIG_POSIX_MQUEUE is not set
25# CONFIG_BSD_PROCESS_ACCT is not set 39# CONFIG_BSD_PROCESS_ACCT is not set
26CONFIG_SYSCTL=y 40# CONFIG_TASKSTATS is not set
41# CONFIG_UTS_NS is not set
27# CONFIG_AUDIT is not set 42# CONFIG_AUDIT is not set
28CONFIG_LOG_BUF_SHIFT=14
29# CONFIG_HOTPLUG is not set
30# CONFIG_IKCONFIG is not set 43# CONFIG_IKCONFIG is not set
44CONFIG_SYSFS_DEPRECATED=y
45# CONFIG_RELAY is not set
46CONFIG_BLK_DEV_INITRD=y
47CONFIG_INITRAMFS_SOURCE=""
48# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
49CONFIG_SYSCTL=y
31CONFIG_EMBEDDED=y 50CONFIG_EMBEDDED=y
51CONFIG_SYSCTL_SYSCALL=y
32# CONFIG_KALLSYMS is not set 52# CONFIG_KALLSYMS is not set
53# CONFIG_HOTPLUG is not set
54CONFIG_PRINTK=y
55CONFIG_BUG=y
56CONFIG_ELF_CORE=y
57CONFIG_BASE_FULL=y
33CONFIG_FUTEX=y 58CONFIG_FUTEX=y
34# CONFIG_EPOLL is not set 59# CONFIG_EPOLL is not set
35CONFIG_IOSCHED_NOOP=y 60CONFIG_SHMEM=y
36CONFIG_IOSCHED_AS=y 61CONFIG_SLAB=y
37CONFIG_IOSCHED_DEADLINE=y 62CONFIG_VM_EVENT_COUNTERS=y
38CONFIG_IOSCHED_CFQ=y 63CONFIG_RT_MUTEXES=y
39# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 64# CONFIG_TINY_SHMEM is not set
65CONFIG_BASE_SMALL=0
66# CONFIG_SLOB is not set
40 67
41# 68#
42# Loadable module support 69# Loadable module support
@@ -44,66 +71,124 @@ CONFIG_IOSCHED_CFQ=y
44# CONFIG_MODULES is not set 71# CONFIG_MODULES is not set
45 72
46# 73#
74# Block layer
75#
76CONFIG_BLOCK=y
77# CONFIG_LBD is not set
78# CONFIG_BLK_DEV_IO_TRACE is not set
79# CONFIG_LSF is not set
80
81#
82# IO Schedulers
83#
84CONFIG_IOSCHED_NOOP=y
85CONFIG_IOSCHED_AS=y
86CONFIG_IOSCHED_DEADLINE=y
87CONFIG_IOSCHED_CFQ=y
88# CONFIG_DEFAULT_AS is not set
89# CONFIG_DEFAULT_DEADLINE is not set
90CONFIG_DEFAULT_CFQ=y
91# CONFIG_DEFAULT_NOOP is not set
92CONFIG_DEFAULT_IOSCHED="cfq"
93
94#
47# Processor 95# Processor
48# 96#
49CONFIG_6xx=y 97CONFIG_6xx=y
50# CONFIG_40x is not set 98# CONFIG_40x is not set
51# CONFIG_44x is not set 99# CONFIG_44x is not set
52# CONFIG_POWER3 is not set
53# CONFIG_POWER4 is not set
54# CONFIG_8xx is not set 100# CONFIG_8xx is not set
101# CONFIG_E200 is not set
102# CONFIG_E500 is not set
103CONFIG_PPC_FPU=y
104# CONFIG_PPC_DCR_NATIVE is not set
105# CONFIG_KEXEC is not set
55# CONFIG_CPU_FREQ is not set 106# CONFIG_CPU_FREQ is not set
107# CONFIG_WANT_EARLY_SERIAL is not set
56CONFIG_EMBEDDEDBOOT=y 108CONFIG_EMBEDDEDBOOT=y
57CONFIG_PPC_STD_MMU=y 109CONFIG_PPC_STD_MMU=y
58 110
59# 111#
60# Platform options 112# Platform options
61# 113#
62# CONFIG_PPC_MULTIPLATFORM is not set 114
115#
116# Freescale Ethernet driver platform-specific options
117#
118# CONFIG_PPC_PREP is not set
63# CONFIG_APUS is not set 119# CONFIG_APUS is not set
120# CONFIG_KATANA is not set
64# CONFIG_WILLOW is not set 121# CONFIG_WILLOW is not set
65# CONFIG_PCORE is not set 122# CONFIG_CPCI690 is not set
66# CONFIG_POWERPMC250 is not set 123# CONFIG_POWERPMC250 is not set
67# CONFIG_EV64260 is not set 124# CONFIG_CHESTNUT is not set
68# CONFIG_SPRUCE is not set 125# CONFIG_SPRUCE is not set
126# CONFIG_HDPU is not set
127# CONFIG_EV64260 is not set
69# CONFIG_LOPEC is not set 128# CONFIG_LOPEC is not set
70# CONFIG_MCPN765 is not set
71# CONFIG_MVME5100 is not set 129# CONFIG_MVME5100 is not set
72# CONFIG_PPLUS is not set 130# CONFIG_PPLUS is not set
73# CONFIG_PRPMC750 is not set 131# CONFIG_PRPMC750 is not set
74# CONFIG_PRPMC800 is not set 132# CONFIG_PRPMC800 is not set
75# CONFIG_SANDPOINT is not set 133# CONFIG_SANDPOINT is not set
76# CONFIG_ADIR is not set 134# CONFIG_RADSTONE_PPC7D is not set
77# CONFIG_K2 is not set
78# CONFIG_PAL4 is not set 135# CONFIG_PAL4 is not set
79# CONFIG_GEMINI is not set
80# CONFIG_EST8260 is not set 136# CONFIG_EST8260 is not set
81# CONFIG_SBC82xx is not set 137# CONFIG_SBC82xx is not set
82# CONFIG_SBS8260 is not set 138# CONFIG_SBS8260 is not set
83# CONFIG_RPX6 is not set 139# CONFIG_RPX8260 is not set
84# CONFIG_TQM8260 is not set 140# CONFIG_TQM8260 is not set
85CONFIG_ADS8272=y 141CONFIG_ADS8272=y
142# CONFIG_PQ2FADS is not set
143# CONFIG_LITE5200 is not set
144# CONFIG_MPC834x_SYS is not set
145# CONFIG_EV64360 is not set
86CONFIG_PQ2ADS=y 146CONFIG_PQ2ADS=y
87CONFIG_8260=y 147CONFIG_8260=y
88CONFIG_8272=y 148CONFIG_8272=y
89CONFIG_CPM2=y 149CONFIG_CPM2=y
90# CONFIG_PC_KEYBOARD is not set 150# CONFIG_PC_KEYBOARD is not set
91CONFIG_SERIAL_CONSOLE=y
92# CONFIG_SMP is not set 151# CONFIG_SMP is not set
93# CONFIG_PREEMPT is not set
94# CONFIG_HIGHMEM is not set 152# CONFIG_HIGHMEM is not set
95CONFIG_KERNEL_ELF=y 153CONFIG_ARCH_POPULATES_NODE_MAP=y
154# CONFIG_HZ_100 is not set
155CONFIG_HZ_250=y
156# CONFIG_HZ_300 is not set
157# CONFIG_HZ_1000 is not set
158CONFIG_HZ=250
159CONFIG_PREEMPT_NONE=y
160# CONFIG_PREEMPT_VOLUNTARY is not set
161# CONFIG_PREEMPT is not set
162CONFIG_SELECT_MEMORY_MODEL=y
163CONFIG_FLATMEM_MANUAL=y
164# CONFIG_DISCONTIGMEM_MANUAL is not set
165# CONFIG_SPARSEMEM_MANUAL is not set
166CONFIG_FLATMEM=y
167CONFIG_FLAT_NODE_MEM_MAP=y
168# CONFIG_SPARSEMEM_STATIC is not set
169CONFIG_SPLIT_PTLOCK_CPUS=4
170# CONFIG_RESOURCES_64BIT is not set
171CONFIG_ZONE_DMA_FLAG=1
96CONFIG_BINFMT_ELF=y 172CONFIG_BINFMT_ELF=y
97# CONFIG_BINFMT_MISC is not set 173# CONFIG_BINFMT_MISC is not set
98# CONFIG_CMDLINE_BOOL is not set 174# CONFIG_CMDLINE_BOOL is not set
175# CONFIG_PM is not set
176CONFIG_SECCOMP=y
177CONFIG_ISA_DMA_API=y
99 178
100# 179#
101# Bus options 180# Bus options
102# 181#
182CONFIG_ZONE_DMA=y
183# CONFIG_PPC_I8259 is not set
184CONFIG_PPC_INDIRECT_PCI=y
103CONFIG_PCI=y 185CONFIG_PCI=y
104CONFIG_PCI_DOMAINS=y 186CONFIG_PCI_DOMAINS=y
105# CONFIG_PCI_LEGACY_PROC is not set 187CONFIG_PCI_8260=y
106# CONFIG_PCI_NAMES is not set 188
189#
190# PCCARD (PCMCIA/CardBus) support
191#
107 192
108# 193#
109# Advanced setup 194# Advanced setup
@@ -120,12 +205,110 @@ CONFIG_TASK_SIZE=0x80000000
120CONFIG_BOOT_LOAD=0x00400000 205CONFIG_BOOT_LOAD=0x00400000
121 206
122# 207#
208# Networking
209#
210CONFIG_NET=y
211
212#
213# Networking options
214#
215# CONFIG_NETDEBUG is not set
216CONFIG_PACKET=y
217# CONFIG_PACKET_MMAP is not set
218CONFIG_UNIX=y
219CONFIG_XFRM=y
220# CONFIG_XFRM_USER is not set
221# CONFIG_XFRM_SUB_POLICY is not set
222# CONFIG_XFRM_MIGRATE is not set
223# CONFIG_NET_KEY is not set
224CONFIG_INET=y
225CONFIG_IP_MULTICAST=y
226# CONFIG_IP_ADVANCED_ROUTER is not set
227CONFIG_IP_FIB_HASH=y
228CONFIG_IP_PNP=y
229CONFIG_IP_PNP_DHCP=y
230CONFIG_IP_PNP_BOOTP=y
231# CONFIG_IP_PNP_RARP is not set
232# CONFIG_NET_IPIP is not set
233# CONFIG_NET_IPGRE is not set
234# CONFIG_IP_MROUTE is not set
235# CONFIG_ARPD is not set
236CONFIG_SYN_COOKIES=y
237# CONFIG_INET_AH is not set
238# CONFIG_INET_ESP is not set
239# CONFIG_INET_IPCOMP is not set
240# CONFIG_INET_XFRM_TUNNEL is not set
241# CONFIG_INET_TUNNEL is not set
242CONFIG_INET_XFRM_MODE_TRANSPORT=y
243CONFIG_INET_XFRM_MODE_TUNNEL=y
244CONFIG_INET_XFRM_MODE_BEET=y
245CONFIG_INET_DIAG=y
246CONFIG_INET_TCP_DIAG=y
247# CONFIG_TCP_CONG_ADVANCED is not set
248CONFIG_TCP_CONG_CUBIC=y
249CONFIG_DEFAULT_TCP_CONG="cubic"
250# CONFIG_TCP_MD5SIG is not set
251# CONFIG_IPV6 is not set
252# CONFIG_INET6_XFRM_TUNNEL is not set
253# CONFIG_INET6_TUNNEL is not set
254# CONFIG_NETWORK_SECMARK is not set
255# CONFIG_NETFILTER is not set
256
257#
258# DCCP Configuration (EXPERIMENTAL)
259#
260# CONFIG_IP_DCCP is not set
261
262#
263# SCTP Configuration (EXPERIMENTAL)
264#
265# CONFIG_IP_SCTP is not set
266
267#
268# TIPC Configuration (EXPERIMENTAL)
269#
270# CONFIG_TIPC is not set
271# CONFIG_ATM is not set
272# CONFIG_BRIDGE is not set
273# CONFIG_VLAN_8021Q is not set
274# CONFIG_DECNET is not set
275# CONFIG_LLC2 is not set
276# CONFIG_IPX is not set
277# CONFIG_ATALK is not set
278# CONFIG_X25 is not set
279# CONFIG_LAPB is not set
280# CONFIG_ECONET is not set
281# CONFIG_WAN_ROUTER is not set
282
283#
284# QoS and/or fair queueing
285#
286# CONFIG_NET_SCHED is not set
287
288#
289# Network testing
290#
291# CONFIG_NET_PKTGEN is not set
292# CONFIG_HAMRADIO is not set
293# CONFIG_IRDA is not set
294# CONFIG_BT is not set
295# CONFIG_IEEE80211 is not set
296
297#
123# Device Drivers 298# Device Drivers
124# 299#
125 300
126# 301#
127# Generic Driver Options 302# Generic Driver Options
128# 303#
304CONFIG_STANDALONE=y
305CONFIG_PREVENT_FIRMWARE_BUILD=y
306# CONFIG_SYS_HYPERVISOR is not set
307
308#
309# Connector - unified userspace <-> kernelspace linker
310#
311# CONFIG_CONNECTOR is not set
129 312
130# 313#
131# Memory Technology Devices (MTD) 314# Memory Technology Devices (MTD)
@@ -140,6 +323,7 @@ CONFIG_BOOT_LOAD=0x00400000
140# 323#
141# Plug and Play support 324# Plug and Play support
142# 325#
326# CONFIG_PNPACPI is not set
143 327
144# 328#
145# Block devices 329# Block devices
@@ -149,14 +333,23 @@ CONFIG_BOOT_LOAD=0x00400000
149# CONFIG_BLK_CPQ_CISS_DA is not set 333# CONFIG_BLK_CPQ_CISS_DA is not set
150# CONFIG_BLK_DEV_DAC960 is not set 334# CONFIG_BLK_DEV_DAC960 is not set
151# CONFIG_BLK_DEV_UMEM is not set 335# CONFIG_BLK_DEV_UMEM is not set
336# CONFIG_BLK_DEV_COW_COMMON is not set
152CONFIG_BLK_DEV_LOOP=y 337CONFIG_BLK_DEV_LOOP=y
153# CONFIG_BLK_DEV_CRYPTOLOOP is not set 338# CONFIG_BLK_DEV_CRYPTOLOOP is not set
154# CONFIG_BLK_DEV_NBD is not set 339# CONFIG_BLK_DEV_NBD is not set
155# CONFIG_BLK_DEV_CARMEL is not set 340# CONFIG_BLK_DEV_SX8 is not set
156CONFIG_BLK_DEV_RAM=y 341CONFIG_BLK_DEV_RAM=y
342CONFIG_BLK_DEV_RAM_COUNT=16
157CONFIG_BLK_DEV_RAM_SIZE=32768 343CONFIG_BLK_DEV_RAM_SIZE=32768
158CONFIG_BLK_DEV_INITRD=y 344CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
159# CONFIG_LBD is not set 345# CONFIG_CDROM_PKTCDVD is not set
346# CONFIG_ATA_OVER_ETH is not set
347
348#
349# Misc devices
350#
351# CONFIG_SGI_IOC4 is not set
352# CONFIG_TIFM_CORE is not set
160 353
161# 354#
162# ATA/ATAPI/MFM/RLL support 355# ATA/ATAPI/MFM/RLL support
@@ -166,7 +359,14 @@ CONFIG_BLK_DEV_INITRD=y
166# 359#
167# SCSI device support 360# SCSI device support
168# 361#
362# CONFIG_RAID_ATTRS is not set
169# CONFIG_SCSI is not set 363# CONFIG_SCSI is not set
364# CONFIG_SCSI_NETLINK is not set
365
366#
367# Serial ATA (prod) and Parallel ATA (experimental) drivers
368#
369# CONFIG_ATA is not set
170 370
171# 371#
172# Multi-device support (RAID and LVM) 372# Multi-device support (RAID and LVM)
@@ -176,6 +376,7 @@ CONFIG_BLK_DEV_INITRD=y
176# 376#
177# Fusion MPT device support 377# Fusion MPT device support
178# 378#
379# CONFIG_FUSION is not set
179 380
180# 381#
181# IEEE 1394 (FireWire) support 382# IEEE 1394 (FireWire) support
@@ -190,70 +391,12 @@ CONFIG_BLK_DEV_INITRD=y
190# 391#
191# Macintosh device drivers 392# Macintosh device drivers
192# 393#
394# CONFIG_MAC_EMUMOUSEBTN is not set
395# CONFIG_WINDFARM is not set
193 396
194# 397#
195# Networking support 398# Network device support
196#
197CONFIG_NET=y
198
199#
200# Networking options
201# 399#
202CONFIG_PACKET=y
203# CONFIG_PACKET_MMAP is not set
204# CONFIG_NETLINK_DEV is not set
205CONFIG_UNIX=y
206# CONFIG_NET_KEY is not set
207CONFIG_INET=y
208CONFIG_IP_MULTICAST=y
209# CONFIG_IP_ADVANCED_ROUTER is not set
210CONFIG_IP_PNP=y
211CONFIG_IP_PNP_DHCP=y
212CONFIG_IP_PNP_BOOTP=y
213# CONFIG_IP_PNP_RARP is not set
214# CONFIG_NET_IPIP is not set
215# CONFIG_NET_IPGRE is not set
216# CONFIG_IP_MROUTE is not set
217# CONFIG_ARPD is not set
218CONFIG_SYN_COOKIES=y
219# CONFIG_INET_AH is not set
220# CONFIG_INET_ESP is not set
221# CONFIG_INET_IPCOMP is not set
222# CONFIG_IPV6 is not set
223# CONFIG_NETFILTER is not set
224
225#
226# SCTP Configuration (EXPERIMENTAL)
227#
228# CONFIG_IP_SCTP is not set
229# CONFIG_ATM is not set
230# CONFIG_BRIDGE is not set
231# CONFIG_VLAN_8021Q is not set
232# CONFIG_DECNET is not set
233# CONFIG_LLC2 is not set
234# CONFIG_IPX is not set
235# CONFIG_ATALK is not set
236# CONFIG_X25 is not set
237# CONFIG_LAPB is not set
238# CONFIG_NET_DIVERT is not set
239# CONFIG_ECONET is not set
240# CONFIG_WAN_ROUTER is not set
241# CONFIG_NET_HW_FLOWCONTROL is not set
242
243#
244# QoS and/or fair queueing
245#
246# CONFIG_NET_SCHED is not set
247
248#
249# Network testing
250#
251# CONFIG_NET_PKTGEN is not set
252# CONFIG_NETPOLL is not set
253# CONFIG_NET_POLL_CONTROLLER is not set
254# CONFIG_HAMRADIO is not set
255# CONFIG_IRDA is not set
256# CONFIG_BT is not set
257CONFIG_NETDEVICES=y 400CONFIG_NETDEVICES=y
258# CONFIG_DUMMY is not set 401# CONFIG_DUMMY is not set
259# CONFIG_BONDING is not set 402# CONFIG_BONDING is not set
@@ -266,13 +409,31 @@ CONFIG_NETDEVICES=y
266# CONFIG_ARCNET is not set 409# CONFIG_ARCNET is not set
267 410
268# 411#
412# PHY device support
413#
414CONFIG_PHYLIB=y
415
416#
417# MII PHY device drivers
418#
419# CONFIG_MARVELL_PHY is not set
420CONFIG_DAVICOM_PHY=y
421# CONFIG_QSEMI_PHY is not set
422# CONFIG_LXT_PHY is not set
423# CONFIG_CICADA_PHY is not set
424# CONFIG_VITESSE_PHY is not set
425# CONFIG_SMSC_PHY is not set
426# CONFIG_BROADCOM_PHY is not set
427# CONFIG_FIXED_PHY is not set
428
429#
269# Ethernet (10 or 100Mbit) 430# Ethernet (10 or 100Mbit)
270# 431#
271CONFIG_NET_ETHERNET=y 432CONFIG_NET_ETHERNET=y
272# CONFIG_MII is not set 433CONFIG_MII=y
273# CONFIG_OAKNET is not set
274# CONFIG_HAPPYMEAL is not set 434# CONFIG_HAPPYMEAL is not set
275# CONFIG_SUNGEM is not set 435# CONFIG_SUNGEM is not set
436# CONFIG_CASSINI is not set
276# CONFIG_NET_VENDOR_3COM is not set 437# CONFIG_NET_VENDOR_3COM is not set
277 438
278# 439#
@@ -281,6 +442,9 @@ CONFIG_NET_ETHERNET=y
281# CONFIG_NET_TULIP is not set 442# CONFIG_NET_TULIP is not set
282# CONFIG_HP100 is not set 443# CONFIG_HP100 is not set
283# CONFIG_NET_PCI is not set 444# CONFIG_NET_PCI is not set
445CONFIG_FS_ENET=y
446# CONFIG_FS_ENET_HAS_SCC is not set
447CONFIG_FS_ENET_HAS_FCC=y
284 448
285# 449#
286# Ethernet (1000 Mbit) 450# Ethernet (1000 Mbit)
@@ -292,14 +456,24 @@ CONFIG_NET_ETHERNET=y
292# CONFIG_HAMACHI is not set 456# CONFIG_HAMACHI is not set
293# CONFIG_YELLOWFIN is not set 457# CONFIG_YELLOWFIN is not set
294# CONFIG_R8169 is not set 458# CONFIG_R8169 is not set
459# CONFIG_SIS190 is not set
460# CONFIG_SKGE is not set
461# CONFIG_SKY2 is not set
295# CONFIG_SK98LIN is not set 462# CONFIG_SK98LIN is not set
296# CONFIG_TIGON3 is not set 463# CONFIG_TIGON3 is not set
464# CONFIG_BNX2 is not set
465# CONFIG_QLA3XXX is not set
466# CONFIG_ATL1 is not set
297 467
298# 468#
299# Ethernet (10000 Mbit) 469# Ethernet (10000 Mbit)
300# 470#
471# CONFIG_CHELSIO_T1 is not set
472# CONFIG_CHELSIO_T3 is not set
301# CONFIG_IXGB is not set 473# CONFIG_IXGB is not set
302# CONFIG_S2IO is not set 474# CONFIG_S2IO is not set
475# CONFIG_MYRI10GE is not set
476# CONFIG_NETXEN_NIC is not set
303 477
304# 478#
305# Token Ring devices 479# Token Ring devices
@@ -321,6 +495,8 @@ CONFIG_NET_ETHERNET=y
321# CONFIG_SLIP is not set 495# CONFIG_SLIP is not set
322# CONFIG_SHAPER is not set 496# CONFIG_SHAPER is not set
323# CONFIG_NETCONSOLE is not set 497# CONFIG_NETCONSOLE is not set
498# CONFIG_NETPOLL is not set
499# CONFIG_NET_POLL_CONTROLLER is not set
324 500
325# 501#
326# ISDN subsystem 502# ISDN subsystem
@@ -336,6 +512,7 @@ CONFIG_NET_ETHERNET=y
336# Input device support 512# Input device support
337# 513#
338CONFIG_INPUT=y 514CONFIG_INPUT=y
515# CONFIG_INPUT_FF_MEMLESS is not set
339 516
340# 517#
341# Userland interfaces 518# Userland interfaces
@@ -347,14 +524,6 @@ CONFIG_INPUT=y
347# CONFIG_INPUT_EVBUG is not set 524# CONFIG_INPUT_EVBUG is not set
348 525
349# 526#
350# Input I/O drivers
351#
352# CONFIG_GAMEPORT is not set
353CONFIG_SOUND_GAMEPORT=y
354# CONFIG_SERIO is not set
355# CONFIG_SERIO_I8042 is not set
356
357#
358# Input Device Drivers 527# Input Device Drivers
359# 528#
360# CONFIG_INPUT_KEYBOARD is not set 529# CONFIG_INPUT_KEYBOARD is not set
@@ -364,6 +533,12 @@ CONFIG_SOUND_GAMEPORT=y
364# CONFIG_INPUT_MISC is not set 533# CONFIG_INPUT_MISC is not set
365 534
366# 535#
536# Hardware I/O ports
537#
538# CONFIG_SERIO is not set
539# CONFIG_GAMEPORT is not set
540
541#
367# Character devices 542# Character devices
368# 543#
369# CONFIG_VT is not set 544# CONFIG_VT is not set
@@ -377,10 +552,21 @@ CONFIG_SOUND_GAMEPORT=y
377# 552#
378# Non-8250 serial port support 553# Non-8250 serial port support
379# 554#
555# CONFIG_SERIAL_UARTLITE is not set
556CONFIG_SERIAL_CORE=y
557CONFIG_SERIAL_CORE_CONSOLE=y
558CONFIG_SERIAL_CPM=y
559CONFIG_SERIAL_CPM_CONSOLE=y
560CONFIG_SERIAL_CPM_SCC1=y
561# CONFIG_SERIAL_CPM_SCC2 is not set
562# CONFIG_SERIAL_CPM_SCC3 is not set
563CONFIG_SERIAL_CPM_SCC4=y
564# CONFIG_SERIAL_CPM_SMC1 is not set
565# CONFIG_SERIAL_CPM_SMC2 is not set
566# CONFIG_SERIAL_JSM is not set
380CONFIG_UNIX98_PTYS=y 567CONFIG_UNIX98_PTYS=y
381CONFIG_LEGACY_PTYS=y 568CONFIG_LEGACY_PTYS=y
382CONFIG_LEGACY_PTY_COUNT=256 569CONFIG_LEGACY_PTY_COUNT=256
383# CONFIG_QIC02_TAPE is not set
384 570
385# 571#
386# IPMI 572# IPMI
@@ -391,29 +577,53 @@ CONFIG_LEGACY_PTY_COUNT=256
391# Watchdog Cards 577# Watchdog Cards
392# 578#
393# CONFIG_WATCHDOG is not set 579# CONFIG_WATCHDOG is not set
580CONFIG_HW_RANDOM=y
394# CONFIG_NVRAM is not set 581# CONFIG_NVRAM is not set
395CONFIG_GEN_RTC=y 582CONFIG_GEN_RTC=y
396# CONFIG_GEN_RTC_X is not set 583# CONFIG_GEN_RTC_X is not set
397# CONFIG_DTLK is not set 584# CONFIG_DTLK is not set
398# CONFIG_R3964 is not set 585# CONFIG_R3964 is not set
399# CONFIG_APPLICOM is not set 586# CONFIG_APPLICOM is not set
400
401#
402# Ftape, the floppy tape device driver
403#
404# CONFIG_FTAPE is not set
405# CONFIG_AGP is not set 587# CONFIG_AGP is not set
406# CONFIG_DRM is not set 588# CONFIG_DRM is not set
407# CONFIG_RAW_DRIVER is not set 589# CONFIG_RAW_DRIVER is not set
408 590
409# 591#
592# TPM devices
593#
594# CONFIG_TCG_TPM is not set
595
596#
410# I2C support 597# I2C support
411# 598#
412# CONFIG_I2C is not set 599# CONFIG_I2C is not set
413 600
414# 601#
415# Misc devices 602# SPI support
603#
604# CONFIG_SPI is not set
605# CONFIG_SPI_MASTER is not set
606
416# 607#
608# Dallas's 1-wire bus
609#
610# CONFIG_W1 is not set
611
612#
613# Hardware Monitoring support
614#
615CONFIG_HWMON=y
616# CONFIG_HWMON_VID is not set
617# CONFIG_SENSORS_ABITUGURU is not set
618# CONFIG_SENSORS_F71805F is not set
619# CONFIG_SENSORS_PC87427 is not set
620# CONFIG_SENSORS_VT1211 is not set
621# CONFIG_HWMON_DEBUG_CHIP is not set
622
623#
624# Multifunction device drivers
625#
626# CONFIG_MFD_SM501 is not set
417 627
418# 628#
419# Multimedia devices 629# Multimedia devices
@@ -428,7 +638,9 @@ CONFIG_GEN_RTC=y
428# 638#
429# Graphics support 639# Graphics support
430# 640#
641# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
431# CONFIG_FB is not set 642# CONFIG_FB is not set
643# CONFIG_FB_IBM_GXT4500 is not set
432 644
433# 645#
434# Sound 646# Sound
@@ -436,35 +648,110 @@ CONFIG_GEN_RTC=y
436# CONFIG_SOUND is not set 648# CONFIG_SOUND is not set
437 649
438# 650#
651# HID Devices
652#
653CONFIG_HID=y
654# CONFIG_HID_DEBUG is not set
655
656#
439# USB support 657# USB support
440# 658#
659CONFIG_USB_ARCH_HAS_HCD=y
660CONFIG_USB_ARCH_HAS_OHCI=y
661CONFIG_USB_ARCH_HAS_EHCI=y
441# CONFIG_USB is not set 662# CONFIG_USB is not set
442 663
443# 664#
665# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
666#
667
668#
444# USB Gadget Support 669# USB Gadget Support
445# 670#
446# CONFIG_USB_GADGET is not set 671# CONFIG_USB_GADGET is not set
447 672
448# 673#
674# MMC/SD Card support
675#
676# CONFIG_MMC is not set
677
678#
679# LED devices
680#
681# CONFIG_NEW_LEDS is not set
682
683#
684# LED drivers
685#
686
687#
688# LED Triggers
689#
690
691#
692# InfiniBand support
693#
694# CONFIG_INFINIBAND is not set
695
696#
697# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
698#
699
700#
701# Real Time Clock
702#
703# CONFIG_RTC_CLASS is not set
704
705#
706# DMA Engine support
707#
708# CONFIG_DMA_ENGINE is not set
709
710#
711# DMA Clients
712#
713
714#
715# DMA Devices
716#
717
718#
719# Auxiliary Display support
720#
721
722#
723# Virtualization
724#
725
726#
449# File systems 727# File systems
450# 728#
451CONFIG_EXT2_FS=y 729CONFIG_EXT2_FS=y
452# CONFIG_EXT2_FS_XATTR is not set 730# CONFIG_EXT2_FS_XATTR is not set
731# CONFIG_EXT2_FS_XIP is not set
453CONFIG_EXT3_FS=y 732CONFIG_EXT3_FS=y
454CONFIG_EXT3_FS_XATTR=y 733CONFIG_EXT3_FS_XATTR=y
455# CONFIG_EXT3_FS_POSIX_ACL is not set 734# CONFIG_EXT3_FS_POSIX_ACL is not set
456# CONFIG_EXT3_FS_SECURITY is not set 735# CONFIG_EXT3_FS_SECURITY is not set
736# CONFIG_EXT4DEV_FS is not set
457CONFIG_JBD=y 737CONFIG_JBD=y
458# CONFIG_JBD_DEBUG is not set 738# CONFIG_JBD_DEBUG is not set
459CONFIG_FS_MBCACHE=y 739CONFIG_FS_MBCACHE=y
460# CONFIG_REISERFS_FS is not set 740# CONFIG_REISERFS_FS is not set
461# CONFIG_JFS_FS is not set 741# CONFIG_JFS_FS is not set
742CONFIG_FS_POSIX_ACL=y
462# CONFIG_XFS_FS is not set 743# CONFIG_XFS_FS is not set
744# CONFIG_GFS2_FS is not set
745# CONFIG_OCFS2_FS is not set
463# CONFIG_MINIX_FS is not set 746# CONFIG_MINIX_FS is not set
464# CONFIG_ROMFS_FS is not set 747# CONFIG_ROMFS_FS is not set
748CONFIG_INOTIFY=y
749CONFIG_INOTIFY_USER=y
465# CONFIG_QUOTA is not set 750# CONFIG_QUOTA is not set
751CONFIG_DNOTIFY=y
466# CONFIG_AUTOFS_FS is not set 752# CONFIG_AUTOFS_FS is not set
467# CONFIG_AUTOFS4_FS is not set 753# CONFIG_AUTOFS4_FS is not set
754# CONFIG_FUSE_FS is not set
468 755
469# 756#
470# CD-ROM/DVD Filesystems 757# CD-ROM/DVD Filesystems
@@ -475,7 +762,8 @@ CONFIG_FS_MBCACHE=y
475# 762#
476# DOS/FAT/NT Filesystems 763# DOS/FAT/NT Filesystems
477# 764#
478# CONFIG_FAT_FS is not set 765# CONFIG_MSDOS_FS is not set
766# CONFIG_VFAT_FS is not set
479# CONFIG_NTFS_FS is not set 767# CONFIG_NTFS_FS is not set
480 768
481# 769#
@@ -483,12 +771,13 @@ CONFIG_FS_MBCACHE=y
483# 771#
484CONFIG_PROC_FS=y 772CONFIG_PROC_FS=y
485CONFIG_PROC_KCORE=y 773CONFIG_PROC_KCORE=y
774CONFIG_PROC_SYSCTL=y
486CONFIG_SYSFS=y 775CONFIG_SYSFS=y
487# CONFIG_DEVFS_FS is not set
488# CONFIG_DEVPTS_FS_XATTR is not set
489CONFIG_TMPFS=y 776CONFIG_TMPFS=y
777# CONFIG_TMPFS_POSIX_ACL is not set
490# CONFIG_HUGETLB_PAGE is not set 778# CONFIG_HUGETLB_PAGE is not set
491CONFIG_RAMFS=y 779CONFIG_RAMFS=y
780# CONFIG_CONFIGFS_FS is not set
492 781
493# 782#
494# Miscellaneous filesystems 783# Miscellaneous filesystems
@@ -511,20 +800,26 @@ CONFIG_RAMFS=y
511# Network File Systems 800# Network File Systems
512# 801#
513CONFIG_NFS_FS=y 802CONFIG_NFS_FS=y
514# CONFIG_NFS_V3 is not set 803CONFIG_NFS_V3=y
515# CONFIG_NFS_V4 is not set 804CONFIG_NFS_V3_ACL=y
805CONFIG_NFS_V4=y
516# CONFIG_NFS_DIRECTIO is not set 806# CONFIG_NFS_DIRECTIO is not set
517# CONFIG_NFSD is not set 807# CONFIG_NFSD is not set
518CONFIG_ROOT_NFS=y 808CONFIG_ROOT_NFS=y
519CONFIG_LOCKD=y 809CONFIG_LOCKD=y
520# CONFIG_EXPORTFS is not set 810CONFIG_LOCKD_V4=y
811CONFIG_NFS_ACL_SUPPORT=y
812CONFIG_NFS_COMMON=y
521CONFIG_SUNRPC=y 813CONFIG_SUNRPC=y
522# CONFIG_RPCSEC_GSS_KRB5 is not set 814CONFIG_SUNRPC_GSS=y
815CONFIG_RPCSEC_GSS_KRB5=y
816# CONFIG_RPCSEC_GSS_SPKM3 is not set
523# CONFIG_SMB_FS is not set 817# CONFIG_SMB_FS is not set
524# CONFIG_CIFS is not set 818# CONFIG_CIFS is not set
525# CONFIG_NCP_FS is not set 819# CONFIG_NCP_FS is not set
526# CONFIG_CODA_FS is not set 820# CONFIG_CODA_FS is not set
527# CONFIG_AFS_FS is not set 821# CONFIG_AFS_FS is not set
822# CONFIG_9P_FS is not set
528 823
529# 824#
530# Partition Types 825# Partition Types
@@ -537,46 +832,99 @@ CONFIG_PARTITION_ADVANCED=y
537# CONFIG_MAC_PARTITION is not set 832# CONFIG_MAC_PARTITION is not set
538# CONFIG_MSDOS_PARTITION is not set 833# CONFIG_MSDOS_PARTITION is not set
539# CONFIG_LDM_PARTITION is not set 834# CONFIG_LDM_PARTITION is not set
540# CONFIG_NEC98_PARTITION is not set
541# CONFIG_SGI_PARTITION is not set 835# CONFIG_SGI_PARTITION is not set
542# CONFIG_ULTRIX_PARTITION is not set 836# CONFIG_ULTRIX_PARTITION is not set
543# CONFIG_SUN_PARTITION is not set 837# CONFIG_SUN_PARTITION is not set
838# CONFIG_KARMA_PARTITION is not set
544# CONFIG_EFI_PARTITION is not set 839# CONFIG_EFI_PARTITION is not set
545 840
546# 841#
547# Native Language Support 842# Native Language Support
548# 843#
549# CONFIG_NLS is not set 844# CONFIG_NLS is not set
845
846#
847# Distributed Lock Manager
848#
849# CONFIG_DLM is not set
550# CONFIG_SCC_ENET is not set 850# CONFIG_SCC_ENET is not set
551CONFIG_FEC_ENET=y 851# CONFIG_FEC_ENET is not set
552# CONFIG_USE_MDIO is not set
553 852
554# 853#
555# CPM2 Options 854# CPM2 Options
556# 855#
557CONFIG_SCC_CONSOLE=y
558CONFIG_FCC1_ENET=y
559# CONFIG_FCC2_ENET is not set
560# CONFIG_FCC3_ENET is not set
561 856
562# 857#
563# Library routines 858# Library routines
564# 859#
860# CONFIG_CRC_CCITT is not set
861# CONFIG_CRC16 is not set
565# CONFIG_CRC32 is not set 862# CONFIG_CRC32 is not set
566# CONFIG_LIBCRC32C is not set 863# CONFIG_LIBCRC32C is not set
864CONFIG_PLIST=y
865CONFIG_HAS_IOMEM=y
866CONFIG_HAS_IOPORT=y
867# CONFIG_PROFILING is not set
567 868
568# 869#
569# Kernel hacking 870# Kernel hacking
570# 871#
872# CONFIG_PRINTK_TIME is not set
873CONFIG_ENABLE_MUST_CHECK=y
874# CONFIG_MAGIC_SYSRQ is not set
875# CONFIG_UNUSED_SYMBOLS is not set
876# CONFIG_DEBUG_FS is not set
877# CONFIG_HEADERS_CHECK is not set
571# CONFIG_DEBUG_KERNEL is not set 878# CONFIG_DEBUG_KERNEL is not set
879CONFIG_LOG_BUF_SHIFT=14
880# CONFIG_DEBUG_BUGVERBOSE is not set
572# CONFIG_KGDB_CONSOLE is not set 881# CONFIG_KGDB_CONSOLE is not set
573 882
574# 883#
575# Security options 884# Security options
576# 885#
886# CONFIG_KEYS is not set
577# CONFIG_SECURITY is not set 887# CONFIG_SECURITY is not set
578 888
579# 889#
580# Cryptographic options 890# Cryptographic options
581# 891#
582# CONFIG_CRYPTO is not set 892CONFIG_CRYPTO=y
893CONFIG_CRYPTO_ALGAPI=y
894CONFIG_CRYPTO_BLKCIPHER=y
895CONFIG_CRYPTO_MANAGER=y
896# CONFIG_CRYPTO_HMAC is not set
897# CONFIG_CRYPTO_XCBC is not set
898# CONFIG_CRYPTO_NULL is not set
899# CONFIG_CRYPTO_MD4 is not set
900CONFIG_CRYPTO_MD5=y
901# CONFIG_CRYPTO_SHA1 is not set
902# CONFIG_CRYPTO_SHA256 is not set
903# CONFIG_CRYPTO_SHA512 is not set
904# CONFIG_CRYPTO_WP512 is not set
905# CONFIG_CRYPTO_TGR192 is not set
906# CONFIG_CRYPTO_GF128MUL is not set
907CONFIG_CRYPTO_ECB=y
908CONFIG_CRYPTO_CBC=y
909CONFIG_CRYPTO_PCBC=y
910# CONFIG_CRYPTO_LRW is not set
911CONFIG_CRYPTO_DES=y
912# CONFIG_CRYPTO_FCRYPT is not set
913# CONFIG_CRYPTO_BLOWFISH is not set
914# CONFIG_CRYPTO_TWOFISH is not set
915# CONFIG_CRYPTO_SERPENT is not set
916# CONFIG_CRYPTO_AES is not set
917# CONFIG_CRYPTO_CAST5 is not set
918# CONFIG_CRYPTO_CAST6 is not set
919# CONFIG_CRYPTO_TEA is not set
920# CONFIG_CRYPTO_ARC4 is not set
921# CONFIG_CRYPTO_KHAZAD is not set
922# CONFIG_CRYPTO_ANUBIS is not set
923# CONFIG_CRYPTO_DEFLATE is not set
924# CONFIG_CRYPTO_MICHAEL_MIC is not set
925# CONFIG_CRYPTO_CRC32C is not set
926# CONFIG_CRYPTO_CAMELLIA is not set
927
928#
929# Hardware crypto devices
930#
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
index 0bc06768cf24..47f4b38edb5f 100644
--- a/arch/ppc/platforms/mpc8272ads_setup.c
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -18,6 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/fs_enet_pd.h> 19#include <linux/fs_enet_pd.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/phy.h>
21 22
22#include <asm/io.h> 23#include <asm/io.h>
23#include <asm/mpc8260.h> 24#include <asm/mpc8260.h>
@@ -30,10 +31,10 @@
30 31
31#include "pq2ads_pd.h" 32#include "pq2ads_pd.h"
32 33
33static void init_fcc1_ioports(void); 34static void init_fcc1_ioports(struct fs_platform_info*);
34static void init_fcc2_ioports(void); 35static void init_fcc2_ioports(struct fs_platform_info*);
35static void init_scc1_uart_ioports(void); 36static void init_scc1_uart_ioports(struct fs_uart_platform_info*);
36static void init_scc4_uart_ioports(void); 37static void init_scc4_uart_ioports(struct fs_uart_platform_info*);
37 38
38static struct fs_uart_platform_info mpc8272_uart_pdata[] = { 39static struct fs_uart_platform_info mpc8272_uart_pdata[] = {
39 [fsid_scc1_uart] = { 40 [fsid_scc1_uart] = {
@@ -103,7 +104,7 @@ static struct fs_platform_info mpc82xx_enet_pdata[] = {
103 }, 104 },
104}; 105};
105 106
106static void init_fcc1_ioports(struct fs_platform_info*) 107static void init_fcc1_ioports(struct fs_platform_info* pdata)
107{ 108{
108 struct io_port *io; 109 struct io_port *io;
109 u32 tempval; 110 u32 tempval;
@@ -144,7 +145,7 @@ static void init_fcc1_ioports(struct fs_platform_info*)
144 iounmap(immap); 145 iounmap(immap);
145} 146}
146 147
147static void init_fcc2_ioports(struct fs_platform_info*) 148static void init_fcc2_ioports(struct fs_platform_info* pdata)
148{ 149{
149 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t)); 150 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
150 u32 *bcsr = ioremap(BCSR_ADDR+12, sizeof(u32)); 151 u32 *bcsr = ioremap(BCSR_ADDR+12, sizeof(u32));
@@ -229,7 +230,7 @@ static void mpc8272ads_fixup_uart_pdata(struct platform_device *pdev,
229 } 230 }
230} 231}
231 232
232static void init_scc1_uart_ioports(struct fs_uart_platform_info*) 233static void init_scc1_uart_ioports(struct fs_uart_platform_info* pdata)
233{ 234{
234 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t)); 235 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
235 236
@@ -246,7 +247,7 @@ static void init_scc1_uart_ioports(struct fs_uart_platform_info*)
246 iounmap(immap); 247 iounmap(immap);
247} 248}
248 249
249static void init_scc4_uart_ioports(struct fs_uart_platform_info*) 250static void init_scc4_uart_ioports(struct fs_uart_platform_info* pdata)
250{ 251{
251 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t)); 252 cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
252 253
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
index 5b05d4bd0df7..7ce5364fdb3b 100644
--- a/arch/ppc/platforms/mpc866ads_setup.c
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -21,6 +21,7 @@
21#include <linux/fs_enet_pd.h> 21#include <linux/fs_enet_pd.h>
22#include <linux/fs_uart_pd.h> 22#include <linux/fs_uart_pd.h>
23#include <linux/mii.h> 23#include <linux/mii.h>
24#include <linux/phy.h>
24 25
25#include <asm/delay.h> 26#include <asm/delay.h>
26#include <asm/io.h> 27#include <asm/io.h>
@@ -37,10 +38,10 @@
37 38
38extern unsigned char __res[]; 39extern unsigned char __res[];
39 40
40static void setup_fec1_ioports(void); 41static void setup_fec1_ioports(struct fs_platform_info*);
41static void setup_scc1_ioports(void); 42static void setup_scc1_ioports(struct fs_platform_info*);
42static void setup_smc1_ioports(void); 43static void setup_smc1_ioports(struct fs_uart_platform_info*);
43static void setup_smc2_ioports(void); 44static void setup_smc2_ioports(struct fs_uart_platform_info*);
44 45
45static struct fs_mii_fec_platform_info mpc8xx_mdio_fec_pdata; 46static struct fs_mii_fec_platform_info mpc8xx_mdio_fec_pdata;
46 47
@@ -137,7 +138,7 @@ void __init board_init(void)
137 iounmap(bcsr_io); 138 iounmap(bcsr_io);
138} 139}
139 140
140static void setup_fec1_ioports(struct fs_platform_info*) 141static void setup_fec1_ioports(struct fs_platform_info* pdata)
141{ 142{
142 immap_t *immap = (immap_t *) IMAP_ADDR; 143 immap_t *immap = (immap_t *) IMAP_ADDR;
143 144
@@ -145,7 +146,7 @@ static void setup_fec1_ioports(struct fs_platform_info*)
145 setbits16(&immap->im_ioport.iop_pddir, 0x1fff); 146 setbits16(&immap->im_ioport.iop_pddir, 0x1fff);
146} 147}
147 148
148static void setup_scc1_ioports(struct fs_platform_info*) 149static void setup_scc1_ioports(struct fs_platform_info* pdata)
149{ 150{
150 immap_t *immap = (immap_t *) IMAP_ADDR; 151 immap_t *immap = (immap_t *) IMAP_ADDR;
151 unsigned *bcsr_io; 152 unsigned *bcsr_io;
@@ -194,7 +195,7 @@ static void setup_scc1_ioports(struct fs_platform_info*)
194 195
195} 196}
196 197
197static void setup_smc1_ioports(struct fs_uart_platform_info*) 198static void setup_smc1_ioports(struct fs_uart_platform_info* pdata)
198{ 199{
199 immap_t *immap = (immap_t *) IMAP_ADDR; 200 immap_t *immap = (immap_t *) IMAP_ADDR;
200 unsigned *bcsr_io; 201 unsigned *bcsr_io;
@@ -216,7 +217,7 @@ static void setup_smc1_ioports(struct fs_uart_platform_info*)
216 217
217} 218}
218 219
219static void setup_smc2_ioports(struct fs_uart_platform_info*) 220static void setup_smc2_ioports(struct fs_uart_platform_info* pdata)
220{ 221{
221 immap_t *immap = (immap_t *) IMAP_ADDR; 222 immap_t *immap = (immap_t *) IMAP_ADDR;
222 unsigned *bcsr_io; 223 unsigned *bcsr_io;
diff --git a/arch/ppc/platforms/mpc885ads_setup.c b/arch/ppc/platforms/mpc885ads_setup.c
index f8161f3557f5..87deaefd6c5b 100644
--- a/arch/ppc/platforms/mpc885ads_setup.c
+++ b/arch/ppc/platforms/mpc885ads_setup.c
@@ -35,13 +35,13 @@
35#include <asm/ppc_sys.h> 35#include <asm/ppc_sys.h>
36 36
37extern unsigned char __res[]; 37extern unsigned char __res[];
38static void setup_smc1_ioports(void); 38static void setup_smc1_ioports(struct fs_uart_platform_info*);
39static void setup_smc2_ioports(void); 39static void setup_smc2_ioports(struct fs_uart_platform_info*);
40 40
41static struct fs_mii_fec_platform_info mpc8xx_mdio_fec_pdata; 41static struct fs_mii_fec_platform_info mpc8xx_mdio_fec_pdata;
42static void setup_fec1_ioports(void); 42static void setup_fec1_ioports(struct fs_platform_info*);
43static void setup_fec2_ioports(void); 43static void setup_fec2_ioports(struct fs_platform_info*);
44static void setup_scc3_ioports(void); 44static void setup_scc3_ioports(struct fs_platform_info*);
45 45
46static struct fs_uart_platform_info mpc885_uart_pdata[] = { 46static struct fs_uart_platform_info mpc885_uart_pdata[] = {
47 [fsid_smc1_uart] = { 47 [fsid_smc1_uart] = {
@@ -161,7 +161,7 @@ void __init board_init(void)
161#endif 161#endif
162} 162}
163 163
164static void setup_fec1_ioports(struct fs_platform_info*) 164static void setup_fec1_ioports(struct fs_platform_info* pdata)
165{ 165{
166 immap_t *immap = (immap_t *) IMAP_ADDR; 166 immap_t *immap = (immap_t *) IMAP_ADDR;
167 167
@@ -181,7 +181,7 @@ static void setup_fec1_ioports(struct fs_platform_info*)
181 clrbits32(&immap->im_cpm.cp_cptr, 0x00000100); 181 clrbits32(&immap->im_cpm.cp_cptr, 0x00000100);
182} 182}
183 183
184static void setup_fec2_ioports(struct fs_platform_info*) 184static void setup_fec2_ioports(struct fs_platform_info* pdata)
185{ 185{
186 immap_t *immap = (immap_t *) IMAP_ADDR; 186 immap_t *immap = (immap_t *) IMAP_ADDR;
187 187
@@ -193,7 +193,7 @@ static void setup_fec2_ioports(struct fs_platform_info*)
193 clrbits32(&immap->im_cpm.cp_cptr, 0x00000080); 193 clrbits32(&immap->im_cpm.cp_cptr, 0x00000080);
194} 194}
195 195
196static void setup_scc3_ioports(struct fs_platform_info*) 196static void setup_scc3_ioports(struct fs_platform_info* pdata)
197{ 197{
198 immap_t *immap = (immap_t *) IMAP_ADDR; 198 immap_t *immap = (immap_t *) IMAP_ADDR;
199 unsigned *bcsr_io; 199 unsigned *bcsr_io;
@@ -315,7 +315,7 @@ static void __init mpc885ads_fixup_scc_enet_pdata(struct platform_device *pdev,
315 mpc885ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1); 315 mpc885ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1);
316} 316}
317 317
318static void setup_smc1_ioports(struct fs_uart_platform_info*) 318static void setup_smc1_ioports(struct fs_uart_platform_info* pdata)
319{ 319{
320 immap_t *immap = (immap_t *) IMAP_ADDR; 320 immap_t *immap = (immap_t *) IMAP_ADDR;
321 unsigned *bcsr_io; 321 unsigned *bcsr_io;
@@ -335,7 +335,7 @@ static void setup_smc1_ioports(struct fs_uart_platform_info*)
335 clrbits16(&immap->im_cpm.cp_pbodr, iobits); 335 clrbits16(&immap->im_cpm.cp_pbodr, iobits);
336} 336}
337 337
338static void setup_smc2_ioports(struct fs_uart_platform_info*) 338static void setup_smc2_ioports(struct fs_uart_platform_info* pdata)
339{ 339{
340 immap_t *immap = (immap_t *) IMAP_ADDR; 340 immap_t *immap = (immap_t *) IMAP_ADDR;
341 unsigned *bcsr_io; 341 unsigned *bcsr_io;
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 8af549e95730..993f35381496 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -167,7 +167,7 @@ static int __kprobes swap_instruction(void *aref)
167 * shall not cross any page boundaries (vmalloc area!) when writing 167 * shall not cross any page boundaries (vmalloc area!) when writing
168 * the new instruction. 168 * the new instruction.
169 */ 169 */
170 addr = (u32 *)ALIGN((unsigned long)args->ptr, 4); 170 addr = (u32 *)((unsigned long)args->ptr & -4UL);
171 if ((unsigned long)args->ptr & 2) 171 if ((unsigned long)args->ptr & 2)
172 instr = ((*addr) & 0xffff0000) | args->new; 172 instr = ((*addr) & 0xffff0000) | args->new;
173 else 173 else
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index fe1b276c97c6..6e0d10fac4a8 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -82,9 +82,6 @@ DECLARE_EXPORT(__movstr);
82DECLARE_EXPORT(__movmem_i4_even); 82DECLARE_EXPORT(__movmem_i4_even);
83DECLARE_EXPORT(__movmem_i4_odd); 83DECLARE_EXPORT(__movmem_i4_odd);
84DECLARE_EXPORT(__movmemSI12_i4); 84DECLARE_EXPORT(__movmemSI12_i4);
85DECLARE_EXPORT(__sdivsi3_i4i);
86DECLARE_EXPORT(__udiv_qrnnd_16);
87DECLARE_EXPORT(__udivsi3_i4i);
88#else /* GCC 3.x */ 85#else /* GCC 3.x */
89DECLARE_EXPORT(__movstr_i4_even); 86DECLARE_EXPORT(__movstr_i4_even);
90DECLARE_EXPORT(__movstr_i4_odd); 87DECLARE_EXPORT(__movstr_i4_odd);
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 3fa5f95c4614..1c927c538b8b 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -601,7 +601,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
601/* 601/*
602 * Normally called from {do_}pci_scan_bus... 602 * Normally called from {do_}pci_scan_bus...
603 */ 603 */
604void __init pcibios_fixup_bus(struct pci_bus *bus) 604void __devinit pcibios_fixup_bus(struct pci_bus *bus)
605{ 605{
606 struct pci_dev *dev; 606 struct pci_dev *dev;
607 int i, has_io, has_mem; 607 int i, has_io, has_mem;
@@ -842,7 +842,7 @@ static void watchdog_reset() {
842/* 842/*
843 * Other archs parse arguments here. 843 * Other archs parse arguments here.
844 */ 844 */
845char * __init pcibios_setup(char *str) 845char * __devinit pcibios_setup(char *str)
846{ 846{
847 return str; 847 return str;
848} 848}
diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
index da6606f0cffc..f807172cab0e 100644
--- a/arch/sparc/kernel/sys_sunos.c
+++ b/arch/sparc/kernel/sys_sunos.c
@@ -910,7 +910,7 @@ asmlinkage long sunos_sysconf (int name)
910 ret = ARG_MAX; 910 ret = ARG_MAX;
911 break; 911 break;
912 case _SC_CHILD_MAX: 912 case _SC_CHILD_MAX:
913 ret = -1; /* no limit */ 913 ret = current->signal->rlim[RLIMIT_NPROC].rlim_cur;
914 break; 914 break;
915 case _SC_CLK_TCK: 915 case _SC_CLK_TCK:
916 ret = HZ; 916 ret = HZ;
@@ -919,7 +919,7 @@ asmlinkage long sunos_sysconf (int name)
919 ret = NGROUPS_MAX; 919 ret = NGROUPS_MAX;
920 break; 920 break;
921 case _SC_OPEN_MAX: 921 case _SC_OPEN_MAX:
922 ret = OPEN_MAX; 922 ret = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
923 break; 923 break;
924 case _SC_JOB_CONTROL: 924 case _SC_JOB_CONTROL:
925 ret = 1; /* yes, we do support job control */ 925 ret = 1; /* yes, we do support job control */
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index 53ddcd9d1e60..559335f4917d 100644
--- a/arch/sparc/lib/atomic32.c
+++ b/arch/sparc/lib/atomic32.c
@@ -52,6 +52,7 @@ int atomic_cmpxchg(atomic_t *v, int old, int new)
52 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); 52 spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
53 return ret; 53 return ret;
54} 54}
55EXPORT_SYMBOL(atomic_cmpxchg);
55 56
56int atomic_add_unless(atomic_t *v, int a, int u) 57int atomic_add_unless(atomic_t *v, int a, int u)
57{ 58{
@@ -65,6 +66,7 @@ int atomic_add_unless(atomic_t *v, int a, int u)
65 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); 66 spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
66 return ret != u; 67 return ret != u;
67} 68}
69EXPORT_SYMBOL(atomic_add_unless);
68 70
69/* Atomic operations are already serializing */ 71/* Atomic operations are already serializing */
70void atomic_set(atomic_t *v, int i) 72void atomic_set(atomic_t *v, int i)
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 196b4b72482b..12109886bb1e 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -327,7 +327,7 @@ static int __init pcibios_init(void)
327 327
328subsys_initcall(pcibios_init); 328subsys_initcall(pcibios_init);
329 329
330void pcibios_fixup_bus(struct pci_bus *pbus) 330void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
331{ 331{
332 struct pci_pbm_info *pbm = pbus->sysdata; 332 struct pci_pbm_info *pbm = pbus->sysdata;
333 333
@@ -405,7 +405,7 @@ void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res,
405} 405}
406EXPORT_SYMBOL(pcibios_bus_to_resource); 406EXPORT_SYMBOL(pcibios_bus_to_resource);
407 407
408char * __init pcibios_setup(char *str) 408char * __devinit pcibios_setup(char *str)
409{ 409{
410 return str; 410 return str;
411} 411}
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 2e7f1427088a..7aca0f33f885 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -64,7 +64,7 @@ static void __iommu_flushall(struct pci_iommu *iommu)
64#define IOPTE_IS_DUMMY(iommu, iopte) \ 64#define IOPTE_IS_DUMMY(iommu, iopte) \
65 ((iopte_val(*iopte) & IOPTE_PAGE) == (iommu)->dummy_page_pa) 65 ((iopte_val(*iopte) & IOPTE_PAGE) == (iommu)->dummy_page_pa)
66 66
67static void inline iopte_make_dummy(struct pci_iommu *iommu, iopte_t *iopte) 67static inline void iopte_make_dummy(struct pci_iommu *iommu, iopte_t *iopte)
68{ 68{
69 unsigned long val = iopte_val(*iopte); 69 unsigned long val = iopte_val(*iopte);
70 70
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index 01d6d869ea2b..14f78fb5e890 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -24,48 +24,25 @@
24 24
25#include "iommu_common.h" 25#include "iommu_common.h"
26 26
27/* These should be allocated on an SMP_CACHE_BYTES
28 * aligned boundary for optimal performance.
29 *
30 * On SYSIO, using an 8K page size we have 1GB of SBUS
31 * DMA space mapped. We divide this space into equally
32 * sized clusters. We allocate a DMA mapping from the
33 * cluster that matches the order of the allocation, or
34 * if the order is greater than the number of clusters,
35 * we try to allocate from the last cluster.
36 */
37
38#define NCLUSTERS 8UL
39#define ONE_GIG (1UL * 1024UL * 1024UL * 1024UL)
40#define CLUSTER_SIZE (ONE_GIG / NCLUSTERS)
41#define CLUSTER_MASK (CLUSTER_SIZE - 1)
42#define CLUSTER_NPAGES (CLUSTER_SIZE >> IO_PAGE_SHIFT)
43#define MAP_BASE ((u32)0xc0000000) 27#define MAP_BASE ((u32)0xc0000000)
44 28
29struct sbus_iommu_arena {
30 unsigned long *map;
31 unsigned int hint;
32 unsigned int limit;
33};
34
45struct sbus_iommu { 35struct sbus_iommu {
46/*0x00*/spinlock_t lock; 36 spinlock_t lock;
47 37
48/*0x08*/iopte_t *page_table; 38 struct sbus_iommu_arena arena;
49/*0x10*/unsigned long strbuf_regs;
50/*0x18*/unsigned long iommu_regs;
51/*0x20*/unsigned long sbus_control_reg;
52 39
53/*0x28*/volatile unsigned long strbuf_flushflag; 40 iopte_t *page_table;
41 unsigned long strbuf_regs;
42 unsigned long iommu_regs;
43 unsigned long sbus_control_reg;
54 44
55 /* If NCLUSTERS is ever decresed to 4 or lower, 45 volatile unsigned long strbuf_flushflag;
56 * you must increase the size of the type of
57 * these counters. You have been duly warned. -DaveM
58 */
59/*0x30*/struct {
60 u16 next;
61 u16 flush;
62 } alloc_info[NCLUSTERS];
63
64 /* The lowest used consistent mapping entry. Since
65 * we allocate consistent maps out of cluster 0 this
66 * is relative to the beginning of closter 0.
67 */
68/*0x50*/u32 lowest_consistent_map;
69}; 46};
70 47
71/* Offsets from iommu_regs */ 48/* Offsets from iommu_regs */
@@ -91,19 +68,6 @@ static void __iommu_flushall(struct sbus_iommu *iommu)
91 tag += 8UL; 68 tag += 8UL;
92 } 69 }
93 upa_readq(iommu->sbus_control_reg); 70 upa_readq(iommu->sbus_control_reg);
94
95 for (entry = 0; entry < NCLUSTERS; entry++) {
96 iommu->alloc_info[entry].flush =
97 iommu->alloc_info[entry].next;
98 }
99}
100
101static void iommu_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages)
102{
103 while (npages--)
104 upa_writeq(base + (npages << IO_PAGE_SHIFT),
105 iommu->iommu_regs + IOMMU_FLUSH);
106 upa_readq(iommu->sbus_control_reg);
107} 71}
108 72
109/* Offsets from strbuf_regs */ 73/* Offsets from strbuf_regs */
@@ -156,178 +120,115 @@ static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long
156 base, npages); 120 base, npages);
157} 121}
158 122
159static iopte_t *alloc_streaming_cluster(struct sbus_iommu *iommu, unsigned long npages) 123/* Based largely upon the ppc64 iommu allocator. */
124static long sbus_arena_alloc(struct sbus_iommu *iommu, unsigned long npages)
160{ 125{
161 iopte_t *iopte, *limit, *first, *cluster; 126 struct sbus_iommu_arena *arena = &iommu->arena;
162 unsigned long cnum, ent, nent, flush_point, found; 127 unsigned long n, i, start, end, limit;
163 128 int pass;
164 cnum = 0; 129
165 nent = 1; 130 limit = arena->limit;
166 while ((1UL << cnum) < npages) 131 start = arena->hint;
167 cnum++; 132 pass = 0;
168 if(cnum >= NCLUSTERS) { 133
169 nent = 1UL << (cnum - NCLUSTERS); 134again:
170 cnum = NCLUSTERS - 1; 135 n = find_next_zero_bit(arena->map, limit, start);
171 } 136 end = n + npages;
172 iopte = iommu->page_table + (cnum * CLUSTER_NPAGES); 137 if (unlikely(end >= limit)) {
173 138 if (likely(pass < 1)) {
174 if (cnum == 0) 139 limit = start;
175 limit = (iommu->page_table + 140 start = 0;
176 iommu->lowest_consistent_map); 141 __iommu_flushall(iommu);
177 else 142 pass++;
178 limit = (iopte + CLUSTER_NPAGES); 143 goto again;
179
180 iopte += ((ent = iommu->alloc_info[cnum].next) << cnum);
181 flush_point = iommu->alloc_info[cnum].flush;
182
183 first = iopte;
184 cluster = NULL;
185 found = 0;
186 for (;;) {
187 if (iopte_val(*iopte) == 0UL) {
188 found++;
189 if (!cluster)
190 cluster = iopte;
191 } else { 144 } else {
192 /* Used cluster in the way */ 145 /* Scanned the whole thing, give up. */
193 cluster = NULL; 146 return -1;
194 found = 0;
195 } 147 }
148 }
196 149
197 if (found == nent) 150 for (i = n; i < end; i++) {
198 break; 151 if (test_bit(i, arena->map)) {
199 152 start = i + 1;
200 iopte += (1 << cnum); 153 goto again;
201 ent++;
202 if (iopte >= limit) {
203 iopte = (iommu->page_table + (cnum * CLUSTER_NPAGES));
204 ent = 0;
205
206 /* Multiple cluster allocations must not wrap */
207 cluster = NULL;
208 found = 0;
209 } 154 }
210 if (ent == flush_point)
211 __iommu_flushall(iommu);
212 if (iopte == first)
213 goto bad;
214 } 155 }
215 156
216 /* ent/iopte points to the last cluster entry we're going to use, 157 for (i = n; i < end; i++)
217 * so save our place for the next allocation. 158 __set_bit(i, arena->map);
218 */ 159
219 if ((iopte + (1 << cnum)) >= limit) 160 arena->hint = end;
220 ent = 0; 161
221 else 162 return n;
222 ent = ent + 1;
223 iommu->alloc_info[cnum].next = ent;
224 if (ent == flush_point)
225 __iommu_flushall(iommu);
226
227 /* I've got your streaming cluster right here buddy boy... */
228 return cluster;
229
230bad:
231 printk(KERN_EMERG "sbus: alloc_streaming_cluster of npages(%ld) failed!\n",
232 npages);
233 return NULL;
234} 163}
235 164
236static void free_streaming_cluster(struct sbus_iommu *iommu, u32 base, unsigned long npages) 165static void sbus_arena_free(struct sbus_iommu_arena *arena, unsigned long base, unsigned long npages)
237{ 166{
238 unsigned long cnum, ent, nent; 167 unsigned long i;
239 iopte_t *iopte;
240 168
241 cnum = 0; 169 for (i = base; i < (base + npages); i++)
242 nent = 1; 170 __clear_bit(i, arena->map);
243 while ((1UL << cnum) < npages)
244 cnum++;
245 if(cnum >= NCLUSTERS) {
246 nent = 1UL << (cnum - NCLUSTERS);
247 cnum = NCLUSTERS - 1;
248 }
249 ent = (base & CLUSTER_MASK) >> (IO_PAGE_SHIFT + cnum);
250 iopte = iommu->page_table + ((base - MAP_BASE) >> IO_PAGE_SHIFT);
251 do {
252 iopte_val(*iopte) = 0UL;
253 iopte += 1 << cnum;
254 } while(--nent);
255
256 /* If the global flush might not have caught this entry,
257 * adjust the flush point such that we will flush before
258 * ever trying to reuse it.
259 */
260#define between(X,Y,Z) (((Z) - (Y)) >= ((X) - (Y)))
261 if (between(ent, iommu->alloc_info[cnum].next, iommu->alloc_info[cnum].flush))
262 iommu->alloc_info[cnum].flush = ent;
263#undef between
264} 171}
265 172
266/* We allocate consistent mappings from the end of cluster zero. */ 173static void sbus_iommu_table_init(struct sbus_iommu *iommu, unsigned int tsbsize)
267static iopte_t *alloc_consistent_cluster(struct sbus_iommu *iommu, unsigned long npages)
268{ 174{
269 iopte_t *iopte; 175 unsigned long tsbbase, order, sz, num_tsb_entries;
270 176
271 iopte = iommu->page_table + (1 * CLUSTER_NPAGES); 177 num_tsb_entries = tsbsize / sizeof(iopte_t);
272 while (iopte > iommu->page_table) {
273 iopte--;
274 if (!(iopte_val(*iopte) & IOPTE_VALID)) {
275 unsigned long tmp = npages;
276 178
277 while (--tmp) { 179 /* Setup initial software IOMMU state. */
278 iopte--; 180 spin_lock_init(&iommu->lock);
279 if (iopte_val(*iopte) & IOPTE_VALID)
280 break;
281 }
282 if (tmp == 0) {
283 u32 entry = (iopte - iommu->page_table);
284 181
285 if (entry < iommu->lowest_consistent_map) 182 /* Allocate and initialize the free area map. */
286 iommu->lowest_consistent_map = entry; 183 sz = num_tsb_entries / 8;
287 return iopte; 184 sz = (sz + 7UL) & ~7UL;
288 } 185 iommu->arena.map = kzalloc(sz, GFP_KERNEL);
289 } 186 if (!iommu->arena.map) {
187 prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n");
188 prom_halt();
189 }
190 iommu->arena.limit = num_tsb_entries;
191
192 /* Now allocate and setup the IOMMU page table itself. */
193 order = get_order(tsbsize);
194 tsbbase = __get_free_pages(GFP_KERNEL, order);
195 if (!tsbbase) {
196 prom_printf("IOMMU: Error, gfp(tsb) failed.\n");
197 prom_halt();
290 } 198 }
291 return NULL; 199 iommu->page_table = (iopte_t *)tsbbase;
200 memset(iommu->page_table, 0, tsbsize);
292} 201}
293 202
294static void free_consistent_cluster(struct sbus_iommu *iommu, u32 base, unsigned long npages) 203static inline iopte_t *alloc_npages(struct sbus_iommu *iommu, unsigned long npages)
295{ 204{
296 iopte_t *iopte = iommu->page_table + ((base - MAP_BASE) >> IO_PAGE_SHIFT); 205 long entry;
297 206
298 if ((iopte - iommu->page_table) == iommu->lowest_consistent_map) { 207 entry = sbus_arena_alloc(iommu, npages);
299 iopte_t *walk = iopte + npages; 208 if (unlikely(entry < 0))
300 iopte_t *limit; 209 return NULL;
301 210
302 limit = iommu->page_table + CLUSTER_NPAGES; 211 return iommu->page_table + entry;
303 while (walk < limit) { 212}
304 if (iopte_val(*walk) != 0UL)
305 break;
306 walk++;
307 }
308 iommu->lowest_consistent_map =
309 (walk - iommu->page_table);
310 }
311 213
312 while (npages--) 214static inline void free_npages(struct sbus_iommu *iommu, dma_addr_t base, unsigned long npages)
313 *iopte++ = __iopte(0UL); 215{
216 sbus_arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages);
314} 217}
315 218
316void *sbus_alloc_consistent(struct sbus_dev *sdev, size_t size, dma_addr_t *dvma_addr) 219void *sbus_alloc_consistent(struct sbus_dev *sdev, size_t size, dma_addr_t *dvma_addr)
317{ 220{
318 unsigned long order, first_page, flags;
319 struct sbus_iommu *iommu; 221 struct sbus_iommu *iommu;
320 iopte_t *iopte; 222 iopte_t *iopte;
223 unsigned long flags, order, first_page;
321 void *ret; 224 void *ret;
322 int npages; 225 int npages;
323 226
324 if (size <= 0 || sdev == NULL || dvma_addr == NULL)
325 return NULL;
326
327 size = IO_PAGE_ALIGN(size); 227 size = IO_PAGE_ALIGN(size);
328 order = get_order(size); 228 order = get_order(size);
329 if (order >= 10) 229 if (order >= 10)
330 return NULL; 230 return NULL;
231
331 first_page = __get_free_pages(GFP_KERNEL|__GFP_COMP, order); 232 first_page = __get_free_pages(GFP_KERNEL|__GFP_COMP, order);
332 if (first_page == 0UL) 233 if (first_page == 0UL)
333 return NULL; 234 return NULL;
@@ -336,108 +237,121 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, size_t size, dma_addr_t *dvma
336 iommu = sdev->bus->iommu; 237 iommu = sdev->bus->iommu;
337 238
338 spin_lock_irqsave(&iommu->lock, flags); 239 spin_lock_irqsave(&iommu->lock, flags);
339 iopte = alloc_consistent_cluster(iommu, size >> IO_PAGE_SHIFT); 240 iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT);
340 if (iopte == NULL) { 241 spin_unlock_irqrestore(&iommu->lock, flags);
341 spin_unlock_irqrestore(&iommu->lock, flags); 242
243 if (unlikely(iopte == NULL)) {
342 free_pages(first_page, order); 244 free_pages(first_page, order);
343 return NULL; 245 return NULL;
344 } 246 }
345 247
346 /* Ok, we're committed at this point. */ 248 *dvma_addr = (MAP_BASE +
347 *dvma_addr = MAP_BASE + ((iopte - iommu->page_table) << IO_PAGE_SHIFT); 249 ((iopte - iommu->page_table) << IO_PAGE_SHIFT));
348 ret = (void *) first_page; 250 ret = (void *) first_page;
349 npages = size >> IO_PAGE_SHIFT; 251 npages = size >> IO_PAGE_SHIFT;
252 first_page = __pa(first_page);
350 while (npages--) { 253 while (npages--) {
351 *iopte++ = __iopte(IOPTE_VALID | IOPTE_CACHE | IOPTE_WRITE | 254 iopte_val(*iopte) = (IOPTE_VALID | IOPTE_CACHE |
352 (__pa(first_page) & IOPTE_PAGE)); 255 IOPTE_WRITE |
256 (first_page & IOPTE_PAGE));
257 iopte++;
353 first_page += IO_PAGE_SIZE; 258 first_page += IO_PAGE_SIZE;
354 } 259 }
355 iommu_flush(iommu, *dvma_addr, size >> IO_PAGE_SHIFT);
356 spin_unlock_irqrestore(&iommu->lock, flags);
357 260
358 return ret; 261 return ret;
359} 262}
360 263
361void sbus_free_consistent(struct sbus_dev *sdev, size_t size, void *cpu, dma_addr_t dvma) 264void sbus_free_consistent(struct sbus_dev *sdev, size_t size, void *cpu, dma_addr_t dvma)
362{ 265{
363 unsigned long order, npages;
364 struct sbus_iommu *iommu; 266 struct sbus_iommu *iommu;
365 267 iopte_t *iopte;
366 if (size <= 0 || sdev == NULL || cpu == NULL) 268 unsigned long flags, order, npages;
367 return;
368 269
369 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; 270 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
370 iommu = sdev->bus->iommu; 271 iommu = sdev->bus->iommu;
272 iopte = iommu->page_table +
273 ((dvma - MAP_BASE) >> IO_PAGE_SHIFT);
274
275 spin_lock_irqsave(&iommu->lock, flags);
276
277 free_npages(iommu, dvma - MAP_BASE, npages);
371 278
372 spin_lock_irq(&iommu->lock); 279 spin_unlock_irqrestore(&iommu->lock, flags);
373 free_consistent_cluster(iommu, dvma, npages);
374 iommu_flush(iommu, dvma, npages);
375 spin_unlock_irq(&iommu->lock);
376 280
377 order = get_order(size); 281 order = get_order(size);
378 if (order < 10) 282 if (order < 10)
379 free_pages((unsigned long)cpu, order); 283 free_pages((unsigned long)cpu, order);
380} 284}
381 285
382dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *ptr, size_t size, int dir) 286dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *ptr, size_t sz, int direction)
383{ 287{
384 struct sbus_iommu *iommu = sdev->bus->iommu; 288 struct sbus_iommu *iommu;
385 unsigned long npages, pbase, flags; 289 iopte_t *base;
386 iopte_t *iopte; 290 unsigned long flags, npages, oaddr;
387 u32 dma_base, offset; 291 unsigned long i, base_paddr;
388 unsigned long iopte_bits; 292 u32 bus_addr, ret;
293 unsigned long iopte_protection;
294
295 iommu = sdev->bus->iommu;
389 296
390 if (dir == SBUS_DMA_NONE) 297 if (unlikely(direction == SBUS_DMA_NONE))
391 BUG(); 298 BUG();
392 299
393 pbase = (unsigned long) ptr; 300 oaddr = (unsigned long)ptr;
394 offset = (u32) (pbase & ~IO_PAGE_MASK); 301 npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK);
395 size = (IO_PAGE_ALIGN(pbase + size) - (pbase & IO_PAGE_MASK)); 302 npages >>= IO_PAGE_SHIFT;
396 pbase = (unsigned long) __pa(pbase & IO_PAGE_MASK);
397 303
398 spin_lock_irqsave(&iommu->lock, flags); 304 spin_lock_irqsave(&iommu->lock, flags);
399 npages = size >> IO_PAGE_SHIFT; 305 base = alloc_npages(iommu, npages);
400 iopte = alloc_streaming_cluster(iommu, npages);
401 if (iopte == NULL)
402 goto bad;
403 dma_base = MAP_BASE + ((iopte - iommu->page_table) << IO_PAGE_SHIFT);
404 npages = size >> IO_PAGE_SHIFT;
405 iopte_bits = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
406 if (dir != SBUS_DMA_TODEVICE)
407 iopte_bits |= IOPTE_WRITE;
408 while (npages--) {
409 *iopte++ = __iopte(iopte_bits | (pbase & IOPTE_PAGE));
410 pbase += IO_PAGE_SIZE;
411 }
412 npages = size >> IO_PAGE_SHIFT;
413 spin_unlock_irqrestore(&iommu->lock, flags); 306 spin_unlock_irqrestore(&iommu->lock, flags);
414 307
415 return (dma_base | offset); 308 if (unlikely(!base))
309 BUG();
416 310
417bad: 311 bus_addr = (MAP_BASE +
418 spin_unlock_irqrestore(&iommu->lock, flags); 312 ((base - iommu->page_table) << IO_PAGE_SHIFT));
419 BUG(); 313 ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
420 return 0; 314 base_paddr = __pa(oaddr & IO_PAGE_MASK);
315
316 iopte_protection = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
317 if (direction != SBUS_DMA_TODEVICE)
318 iopte_protection |= IOPTE_WRITE;
319
320 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
321 iopte_val(*base) = iopte_protection | base_paddr;
322
323 return ret;
421} 324}
422 325
423void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t dma_addr, size_t size, int direction) 326void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t bus_addr, size_t sz, int direction)
424{ 327{
425 struct sbus_iommu *iommu = sdev->bus->iommu; 328 struct sbus_iommu *iommu = sdev->bus->iommu;
426 u32 dma_base = dma_addr & IO_PAGE_MASK; 329 iopte_t *base;
427 unsigned long flags; 330 unsigned long flags, npages, i;
331
332 if (unlikely(direction == SBUS_DMA_NONE))
333 BUG();
334
335 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
336 npages >>= IO_PAGE_SHIFT;
337 base = iommu->page_table +
338 ((bus_addr - MAP_BASE) >> IO_PAGE_SHIFT);
428 339
429 size = (IO_PAGE_ALIGN(dma_addr + size) - dma_base); 340 bus_addr &= IO_PAGE_MASK;
430 341
431 spin_lock_irqsave(&iommu->lock, flags); 342 spin_lock_irqsave(&iommu->lock, flags);
432 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); 343 sbus_strbuf_flush(iommu, bus_addr, npages, direction);
433 sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT, direction); 344 for (i = 0; i < npages; i++)
345 iopte_val(base[i]) = 0UL;
346 free_npages(iommu, bus_addr - MAP_BASE, npages);
434 spin_unlock_irqrestore(&iommu->lock, flags); 347 spin_unlock_irqrestore(&iommu->lock, flags);
435} 348}
436 349
437#define SG_ENT_PHYS_ADDRESS(SG) \ 350#define SG_ENT_PHYS_ADDRESS(SG) \
438 (__pa(page_address((SG)->page)) + (SG)->offset) 351 (__pa(page_address((SG)->page)) + (SG)->offset)
439 352
440static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, int nused, int nelems, unsigned long iopte_bits) 353static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
354 int nused, int nelems, unsigned long iopte_protection)
441{ 355{
442 struct scatterlist *dma_sg = sg; 356 struct scatterlist *dma_sg = sg;
443 struct scatterlist *sg_end = sg + nelems; 357 struct scatterlist *sg_end = sg + nelems;
@@ -462,7 +376,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, int nused, in
462 for (;;) { 376 for (;;) {
463 unsigned long tmp; 377 unsigned long tmp;
464 378
465 tmp = (unsigned long) SG_ENT_PHYS_ADDRESS(sg); 379 tmp = SG_ENT_PHYS_ADDRESS(sg);
466 len = sg->length; 380 len = sg->length;
467 if (((tmp ^ pteval) >> IO_PAGE_SHIFT) != 0UL) { 381 if (((tmp ^ pteval) >> IO_PAGE_SHIFT) != 0UL) {
468 pteval = tmp & IO_PAGE_MASK; 382 pteval = tmp & IO_PAGE_MASK;
@@ -478,7 +392,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, int nused, in
478 sg++; 392 sg++;
479 } 393 }
480 394
481 pteval = ((pteval & IOPTE_PAGE) | iopte_bits); 395 pteval = iopte_protection | (pteval & IOPTE_PAGE);
482 while (len > 0) { 396 while (len > 0) {
483 *iopte++ = __iopte(pteval); 397 *iopte++ = __iopte(pteval);
484 pteval += IO_PAGE_SIZE; 398 pteval += IO_PAGE_SIZE;
@@ -509,103 +423,111 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, int nused, in
509 } 423 }
510} 424}
511 425
512int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int dir) 426int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
513{ 427{
514 struct sbus_iommu *iommu = sdev->bus->iommu; 428 struct sbus_iommu *iommu;
515 unsigned long flags, npages; 429 unsigned long flags, npages, iopte_protection;
516 iopte_t *iopte; 430 iopte_t *base;
517 u32 dma_base; 431 u32 dma_base;
518 struct scatterlist *sgtmp; 432 struct scatterlist *sgtmp;
519 int used; 433 int used;
520 unsigned long iopte_bits;
521
522 if (dir == SBUS_DMA_NONE)
523 BUG();
524 434
525 /* Fast path single entry scatterlists. */ 435 /* Fast path single entry scatterlists. */
526 if (nents == 1) { 436 if (nelems == 1) {
527 sg->dma_address = 437 sglist->dma_address =
528 sbus_map_single(sdev, 438 sbus_map_single(sdev,
529 (page_address(sg->page) + sg->offset), 439 (page_address(sglist->page) + sglist->offset),
530 sg->length, dir); 440 sglist->length, direction);
531 sg->dma_length = sg->length; 441 sglist->dma_length = sglist->length;
532 return 1; 442 return 1;
533 } 443 }
534 444
535 npages = prepare_sg(sg, nents); 445 iommu = sdev->bus->iommu;
446
447 if (unlikely(direction == SBUS_DMA_NONE))
448 BUG();
449
450 npages = prepare_sg(sglist, nelems);
536 451
537 spin_lock_irqsave(&iommu->lock, flags); 452 spin_lock_irqsave(&iommu->lock, flags);
538 iopte = alloc_streaming_cluster(iommu, npages); 453 base = alloc_npages(iommu, npages);
539 if (iopte == NULL) 454 spin_unlock_irqrestore(&iommu->lock, flags);
540 goto bad; 455
541 dma_base = MAP_BASE + ((iopte - iommu->page_table) << IO_PAGE_SHIFT); 456 if (unlikely(base == NULL))
457 BUG();
458
459 dma_base = MAP_BASE +
460 ((base - iommu->page_table) << IO_PAGE_SHIFT);
542 461
543 /* Normalize DVMA addresses. */ 462 /* Normalize DVMA addresses. */
544 sgtmp = sg; 463 used = nelems;
545 used = nents;
546 464
465 sgtmp = sglist;
547 while (used && sgtmp->dma_length) { 466 while (used && sgtmp->dma_length) {
548 sgtmp->dma_address += dma_base; 467 sgtmp->dma_address += dma_base;
549 sgtmp++; 468 sgtmp++;
550 used--; 469 used--;
551 } 470 }
552 used = nents - used; 471 used = nelems - used;
553 472
554 iopte_bits = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE; 473 iopte_protection = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
555 if (dir != SBUS_DMA_TODEVICE) 474 if (direction != SBUS_DMA_TODEVICE)
556 iopte_bits |= IOPTE_WRITE; 475 iopte_protection |= IOPTE_WRITE;
476
477 fill_sg(base, sglist, used, nelems, iopte_protection);
557 478
558 fill_sg(iopte, sg, used, nents, iopte_bits);
559#ifdef VERIFY_SG 479#ifdef VERIFY_SG
560 verify_sglist(sg, nents, iopte, npages); 480 verify_sglist(sglist, nelems, base, npages);
561#endif 481#endif
562 spin_unlock_irqrestore(&iommu->lock, flags);
563 482
564 return used; 483 return used;
565
566bad:
567 spin_unlock_irqrestore(&iommu->lock, flags);
568 BUG();
569 return 0;
570} 484}
571 485
572void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int direction) 486void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
573{ 487{
574 unsigned long size, flags;
575 struct sbus_iommu *iommu; 488 struct sbus_iommu *iommu;
576 u32 dvma_base; 489 iopte_t *base;
577 int i; 490 unsigned long flags, i, npages;
491 u32 bus_addr;
578 492
579 /* Fast path single entry scatterlists. */ 493 if (unlikely(direction == SBUS_DMA_NONE))
580 if (nents == 1) { 494 BUG();
581 sbus_unmap_single(sdev, sg->dma_address, sg->dma_length, direction); 495
582 return; 496 iommu = sdev->bus->iommu;
583 } 497
498 bus_addr = sglist->dma_address & IO_PAGE_MASK;
584 499
585 dvma_base = sg[0].dma_address & IO_PAGE_MASK; 500 for (i = 1; i < nelems; i++)
586 for (i = 0; i < nents; i++) { 501 if (sglist[i].dma_length == 0)
587 if (sg[i].dma_length == 0)
588 break; 502 break;
589 }
590 i--; 503 i--;
591 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - dvma_base; 504 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) -
505 bus_addr) >> IO_PAGE_SHIFT;
506
507 base = iommu->page_table +
508 ((bus_addr - MAP_BASE) >> IO_PAGE_SHIFT);
592 509
593 iommu = sdev->bus->iommu;
594 spin_lock_irqsave(&iommu->lock, flags); 510 spin_lock_irqsave(&iommu->lock, flags);
595 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); 511 sbus_strbuf_flush(iommu, bus_addr, npages, direction);
596 sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT, direction); 512 for (i = 0; i < npages; i++)
513 iopte_val(base[i]) = 0UL;
514 free_npages(iommu, bus_addr - MAP_BASE, npages);
597 spin_unlock_irqrestore(&iommu->lock, flags); 515 spin_unlock_irqrestore(&iommu->lock, flags);
598} 516}
599 517
600void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t base, size_t size, int direction) 518void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t bus_addr, size_t sz, int direction)
601{ 519{
602 struct sbus_iommu *iommu = sdev->bus->iommu; 520 struct sbus_iommu *iommu;
603 unsigned long flags; 521 unsigned long flags, npages;
522
523 iommu = sdev->bus->iommu;
604 524
605 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); 525 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
526 npages >>= IO_PAGE_SHIFT;
527 bus_addr &= IO_PAGE_MASK;
606 528
607 spin_lock_irqsave(&iommu->lock, flags); 529 spin_lock_irqsave(&iommu->lock, flags);
608 sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT, direction); 530 sbus_strbuf_flush(iommu, bus_addr, npages, direction);
609 spin_unlock_irqrestore(&iommu->lock, flags); 531 spin_unlock_irqrestore(&iommu->lock, flags);
610} 532}
611 533
@@ -613,23 +535,25 @@ void sbus_dma_sync_single_for_device(struct sbus_dev *sdev, dma_addr_t base, siz
613{ 535{
614} 536}
615 537
616void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int direction) 538void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
617{ 539{
618 struct sbus_iommu *iommu = sdev->bus->iommu; 540 struct sbus_iommu *iommu;
619 unsigned long flags, size; 541 unsigned long flags, npages, i;
620 u32 base; 542 u32 bus_addr;
621 int i; 543
544 iommu = sdev->bus->iommu;
622 545
623 base = sg[0].dma_address & IO_PAGE_MASK; 546 bus_addr = sglist[0].dma_address & IO_PAGE_MASK;
624 for (i = 0; i < nents; i++) { 547 for (i = 0; i < nelems; i++) {
625 if (sg[i].dma_length == 0) 548 if (!sglist[i].dma_length)
626 break; 549 break;
627 } 550 }
628 i--; 551 i--;
629 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; 552 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length)
553 - bus_addr) >> IO_PAGE_SHIFT;
630 554
631 spin_lock_irqsave(&iommu->lock, flags); 555 spin_lock_irqsave(&iommu->lock, flags);
632 sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT, direction); 556 sbus_strbuf_flush(iommu, bus_addr, npages, direction);
633 spin_unlock_irqrestore(&iommu->lock, flags); 557 spin_unlock_irqrestore(&iommu->lock, flags);
634} 558}
635 559
@@ -1104,7 +1028,7 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1104 struct linux_prom64_registers *pr; 1028 struct linux_prom64_registers *pr;
1105 struct device_node *dp; 1029 struct device_node *dp;
1106 struct sbus_iommu *iommu; 1030 struct sbus_iommu *iommu;
1107 unsigned long regs, tsb_base; 1031 unsigned long regs;
1108 u64 control; 1032 u64 control;
1109 int i; 1033 int i;
1110 1034
@@ -1132,14 +1056,6 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1132 1056
1133 memset(iommu, 0, sizeof(*iommu)); 1057 memset(iommu, 0, sizeof(*iommu));
1134 1058
1135 /* We start with no consistent mappings. */
1136 iommu->lowest_consistent_map = CLUSTER_NPAGES;
1137
1138 for (i = 0; i < NCLUSTERS; i++) {
1139 iommu->alloc_info[i].flush = 0;
1140 iommu->alloc_info[i].next = 0;
1141 }
1142
1143 /* Setup spinlock. */ 1059 /* Setup spinlock. */
1144 spin_lock_init(&iommu->lock); 1060 spin_lock_init(&iommu->lock);
1145 1061
@@ -1159,25 +1075,13 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1159 sbus->portid, regs); 1075 sbus->portid, regs);
1160 1076
1161 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */ 1077 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */
1078 sbus_iommu_table_init(iommu, IO_TSB_SIZE);
1079
1162 control = upa_readq(iommu->iommu_regs + IOMMU_CONTROL); 1080 control = upa_readq(iommu->iommu_regs + IOMMU_CONTROL);
1163 control = ((7UL << 16UL) | 1081 control = ((7UL << 16UL) |
1164 (0UL << 2UL) | 1082 (0UL << 2UL) |
1165 (1UL << 1UL) | 1083 (1UL << 1UL) |
1166 (1UL << 0UL)); 1084 (1UL << 0UL));
1167
1168 /* Using the above configuration we need 1MB iommu page
1169 * table (128K ioptes * 8 bytes per iopte). This is
1170 * page order 7 on UltraSparc.
1171 */
1172 tsb_base = __get_free_pages(GFP_ATOMIC, get_order(IO_TSB_SIZE));
1173 if (tsb_base == 0UL) {
1174 prom_printf("sbus_iommu_init: Fatal error, cannot alloc TSB table.\n");
1175 prom_halt();
1176 }
1177
1178 iommu->page_table = (iopte_t *) tsb_base;
1179 memset(iommu->page_table, 0, IO_TSB_SIZE);
1180
1181 upa_writeq(control, iommu->iommu_regs + IOMMU_CONTROL); 1085 upa_writeq(control, iommu->iommu_regs + IOMMU_CONTROL);
1182 1086
1183 /* Clean out any cruft in the IOMMU using 1087 /* Clean out any cruft in the IOMMU using
@@ -1195,7 +1099,7 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1195 upa_readq(iommu->sbus_control_reg); 1099 upa_readq(iommu->sbus_control_reg);
1196 1100
1197 /* Give the TSB to SYSIO. */ 1101 /* Give the TSB to SYSIO. */
1198 upa_writeq(__pa(tsb_base), iommu->iommu_regs + IOMMU_TSBBASE); 1102 upa_writeq(__pa(iommu->page_table), iommu->iommu_regs + IOMMU_TSBBASE);
1199 1103
1200 /* Setup streaming buffer, DE=1 SB_EN=1 */ 1104 /* Setup streaming buffer, DE=1 SB_EN=1 */
1201 control = (1UL << 1UL) | (1UL << 0UL); 1105 control = (1UL << 1UL) | (1UL << 0UL);
diff --git a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
index c09ab4b9431d..010a737908ee 100644
--- a/arch/sparc64/kernel/sys32.S
+++ b/arch/sparc64/kernel/sys32.S
@@ -91,7 +91,6 @@ SIGN1(sys32_select, compat_sys_select, %o0)
91SIGN1(sys32_mkdir, sys_mkdir, %o1) 91SIGN1(sys32_mkdir, sys_mkdir, %o1)
92SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5) 92SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5)
93SIGN1(sys32_sysfs, compat_sys_sysfs, %o0) 93SIGN1(sys32_sysfs, compat_sys_sysfs, %o0)
94SIGN3(sys32_ipc, compat_sys_ipc, %o1, %o2, %o3)
95SIGN2(sys32_sendfile, compat_sys_sendfile, %o0, %o1) 94SIGN2(sys32_sendfile, compat_sys_sendfile, %o0, %o1)
96SIGN2(sys32_sendfile64, compat_sys_sendfile64, %o0, %o1) 95SIGN2(sys32_sendfile64, compat_sys_sendfile64, %o0, %o1)
97SIGN1(sys32_prctl, sys_prctl, %o0) 96SIGN1(sys32_prctl, sys_prctl, %o0)
diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
index 4cff95b7b3a4..8f7a06e2c7e7 100644
--- a/arch/sparc64/kernel/sys_sunos32.c
+++ b/arch/sparc64/kernel/sys_sunos32.c
@@ -871,7 +871,7 @@ asmlinkage s32 sunos_sysconf (int name)
871 ret = ARG_MAX; 871 ret = ARG_MAX;
872 break; 872 break;
873 case _SC_CHILD_MAX: 873 case _SC_CHILD_MAX:
874 ret = -1; /* no limit */ 874 ret = current->signal->rlim[RLIMIT_NPROC].rlim_cur;
875 break; 875 break;
876 case _SC_CLK_TCK: 876 case _SC_CLK_TCK:
877 ret = HZ; 877 ret = HZ;
@@ -880,7 +880,7 @@ asmlinkage s32 sunos_sysconf (int name)
880 ret = NGROUPS_MAX; 880 ret = NGROUPS_MAX;
881 break; 881 break;
882 case _SC_OPEN_MAX: 882 case _SC_OPEN_MAX:
883 ret = OPEN_MAX; 883 ret = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
884 break; 884 break;
885 case _SC_JOB_CONTROL: 885 case _SC_JOB_CONTROL:
886 ret = 1; /* yes, we do support job control */ 886 ret = 1; /* yes, we do support job control */
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index aaeb5e06735c..48c36fe6dc62 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -62,7 +62,7 @@ sys_call_table32:
62/*200*/ .word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir 62/*200*/ .word sys32_ssetmask, sys_sigsuspend, compat_sys_newlstat, sys_uselib, compat_sys_old_readdir
63 .word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64 63 .word sys32_readahead, sys32_socketcall, sys32_syslog, sys32_lookup_dcookie, sys32_fadvise64
64/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, compat_sys_sysinfo 64/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, compat_sys_sysinfo
65 .word sys32_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex 65 .word compat_sys_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex
66/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid 66/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid
67 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16 67 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16
68/*230*/ .word sys32_select, compat_sys_time, sys32_splice, compat_sys_stime, compat_sys_statfs64 68/*230*/ .word sys32_select, compat_sys_time, sys32_splice, compat_sys_stime, compat_sys_statfs64
diff --git a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
index bca16e8c95c3..9fcaad6dd11f 100644
--- a/arch/sparc64/solaris/misc.c
+++ b/arch/sparc64/solaris/misc.c
@@ -363,8 +363,10 @@ asmlinkage int solaris_sysconf(int id)
363{ 363{
364 switch (id) { 364 switch (id) {
365 case SOLARIS_CONFIG_NGROUPS: return NGROUPS_MAX; 365 case SOLARIS_CONFIG_NGROUPS: return NGROUPS_MAX;
366 case SOLARIS_CONFIG_CHILD_MAX: return -1; /* no limit */ 366 case SOLARIS_CONFIG_CHILD_MAX:
367 case SOLARIS_CONFIG_OPEN_FILES: return OPEN_MAX; 367 return current->signal->rlim[RLIMIT_NPROC].rlim_cur;
368 case SOLARIS_CONFIG_OPEN_FILES:
369 return current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
368 case SOLARIS_CONFIG_POSIX_VER: return 199309; 370 case SOLARIS_CONFIG_POSIX_VER: return 199309;
369 case SOLARIS_CONFIG_PAGESIZE: return PAGE_SIZE; 371 case SOLARIS_CONFIG_PAGESIZE: return PAGE_SIZE;
370 case SOLARIS_CONFIG_XOPEN_VER: return 3; 372 case SOLARIS_CONFIG_XOPEN_VER: return 3;
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 7b8baf146acc..9fdfad649536 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -236,11 +236,11 @@ void free_irqs(void)
236 struct chan *chan; 236 struct chan *chan;
237 LIST_HEAD(list); 237 LIST_HEAD(list);
238 struct list_head *ele; 238 struct list_head *ele;
239 unsigned long flags;
239 240
240 spin_lock_irq(&irqs_to_free_lock); 241 spin_lock_irqsave(&irqs_to_free_lock, flags);
241 list_splice_init(&irqs_to_free, &list); 242 list_splice_init(&irqs_to_free, &list);
242 INIT_LIST_HEAD(&irqs_to_free); 243 spin_unlock_irqrestore(&irqs_to_free_lock, flags);
243 spin_unlock_irq(&irqs_to_free_lock);
244 244
245 list_for_each(ele, &list){ 245 list_for_each(ele, &list){
246 chan = list_entry(ele, struct chan, free_list); 246 chan = list_entry(ele, struct chan, free_list);
@@ -255,13 +255,15 @@ void free_irqs(void)
255 255
256static void close_one_chan(struct chan *chan, int delay_free_irq) 256static void close_one_chan(struct chan *chan, int delay_free_irq)
257{ 257{
258 unsigned long flags;
259
258 if(!chan->opened) 260 if(!chan->opened)
259 return; 261 return;
260 262
261 if(delay_free_irq){ 263 if(delay_free_irq){
262 spin_lock_irq(&irqs_to_free_lock); 264 spin_lock_irqsave(&irqs_to_free_lock, flags);
263 list_add(&chan->free_list, &irqs_to_free); 265 list_add(&chan->free_list, &irqs_to_free);
264 spin_unlock_irq(&irqs_to_free_lock); 266 spin_unlock_irqrestore(&irqs_to_free_lock, flags);
265 } 267 }
266 else { 268 else {
267 if(chan->input) 269 if(chan->input)
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 178b2eff4a8c..65ad2932672c 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -615,6 +615,9 @@ void mconsole_remove(struct mc_request *req)
615 err_msg = NULL; 615 err_msg = NULL;
616 err = (*dev->remove)(n, &err_msg); 616 err = (*dev->remove)(n, &err_msg);
617 switch(err){ 617 switch(err){
618 case 0:
619 err_msg = "";
620 break;
618 case -ENODEV: 621 case -ENODEV:
619 if(err_msg == NULL) 622 if(err_msg == NULL)
620 err_msg = "Device doesn't exist"; 623 err_msg = "Device doesn't exist";
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index f98d26e51381..8bd9204ac1ab 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -109,10 +109,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
109 109
110static DEFINE_MUTEX(ubd_lock); 110static DEFINE_MUTEX(ubd_lock);
111 111
112/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
113 * probably it doesn't make sense even for that. */
114static int do_ubd;
115
116static int ubd_open(struct inode * inode, struct file * filp); 112static int ubd_open(struct inode * inode, struct file * filp);
117static int ubd_release(struct inode * inode, struct file * file); 113static int ubd_release(struct inode * inode, struct file * file);
118static int ubd_ioctl(struct inode * inode, struct file * file, 114static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -169,6 +165,7 @@ struct ubd {
169 struct platform_device pdev; 165 struct platform_device pdev;
170 struct request_queue *queue; 166 struct request_queue *queue;
171 spinlock_t lock; 167 spinlock_t lock;
168 int active;
172}; 169};
173 170
174#define DEFAULT_COW { \ 171#define DEFAULT_COW { \
@@ -190,6 +187,7 @@ struct ubd {
190 .shared = 0, \ 187 .shared = 0, \
191 .cow = DEFAULT_COW, \ 188 .cow = DEFAULT_COW, \
192 .lock = SPIN_LOCK_UNLOCKED, \ 189 .lock = SPIN_LOCK_UNLOCKED, \
190 .active = 0, \
193} 191}
194 192
195/* Protected by ubd_lock */ 193/* Protected by ubd_lock */
@@ -507,7 +505,6 @@ static void ubd_handler(void)
507 struct ubd *dev; 505 struct ubd *dev;
508 int n; 506 int n;
509 507
510 do_ubd = 0;
511 n = os_read_file(thread_fd, &req, sizeof(req)); 508 n = os_read_file(thread_fd, &req, sizeof(req));
512 if(n != sizeof(req)){ 509 if(n != sizeof(req)){
513 printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, " 510 printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
@@ -517,6 +514,7 @@ static void ubd_handler(void)
517 514
518 rq = req.req; 515 rq = req.req;
519 dev = rq->rq_disk->private_data; 516 dev = rq->rq_disk->private_data;
517 dev->active = 0;
520 518
521 ubd_finish(rq, req.error); 519 ubd_finish(rq, req.error);
522 reactivate_fd(thread_fd, UBD_IRQ); 520 reactivate_fd(thread_fd, UBD_IRQ);
@@ -1081,11 +1079,12 @@ static void do_ubd_request(request_queue_t *q)
1081 } 1079 }
1082 } 1080 }
1083 else { 1081 else {
1084 if(do_ubd || (req = elv_next_request(q)) == NULL) 1082 struct ubd *dev = q->queuedata;
1083 if(dev->active || (req = elv_next_request(q)) == NULL)
1085 return; 1084 return;
1086 err = prepare_request(req, &io_req); 1085 err = prepare_request(req, &io_req);
1087 if(!err){ 1086 if(!err){
1088 do_ubd = 1; 1087 dev->active = 1;
1089 n = os_write_file(thread_fd, (char *) &io_req, 1088 n = os_write_file(thread_fd, (char *) &io_req,
1090 sizeof(io_req)); 1089 sizeof(io_req));
1091 if(n != sizeof(io_req)) 1090 if(n != sizeof(io_req))
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h
index 2666815b6af5..b282839c1625 100644
--- a/arch/um/include/mconsole.h
+++ b/arch/um/include/mconsole.h
@@ -12,6 +12,8 @@
12#define u32 uint32_t 12#define u32 uint32_t
13#endif 13#endif
14 14
15#include "sysdep/ptrace.h"
16
15#define MCONSOLE_MAGIC (0xcafebabe) 17#define MCONSOLE_MAGIC (0xcafebabe)
16#define MCONSOLE_MAX_DATA (512) 18#define MCONSOLE_MAX_DATA (512)
17#define MCONSOLE_VERSION 2 19#define MCONSOLE_VERSION 2
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 66cb400c2c92..62403bd99661 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -104,10 +104,6 @@ union uml_pt_regs {
104#endif 104#endif
105#ifdef UML_CONFIG_MODE_SKAS 105#ifdef UML_CONFIG_MODE_SKAS
106 struct skas_regs { 106 struct skas_regs {
107 /* x86_64 ptrace uses sizeof(user_regs_struct) as its register
108 * file size, while i386 uses FRAME_SIZE. Therefore, we need
109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
110 */
111 unsigned long regs[MAX_REG_NR]; 107 unsigned long regs[MAX_REG_NR];
112 unsigned long fp[HOST_FP_SIZE]; 108 unsigned long fp[HOST_FP_SIZE];
113 struct faultinfo faultinfo; 109 struct faultinfo faultinfo;
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index e85d65deea0d..df7d662b98ce 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -64,8 +64,6 @@ static void setup_highmem(unsigned long highmem_start,
64 64
65void mem_init(void) 65void mem_init(void)
66{ 66{
67 max_low_pfn = (high_physmem - uml_physmem) >> PAGE_SHIFT;
68
69 /* clear the zero-page */ 67 /* clear the zero-page */
70 memset((void *) empty_zero_page, 0, PAGE_SIZE); 68 memset((void *) empty_zero_page, 0, PAGE_SIZE);
71 69
@@ -80,6 +78,7 @@ void mem_init(void)
80 78
81 /* this will put all low memory onto the freelists */ 79 /* this will put all low memory onto the freelists */
82 totalram_pages = free_all_bootmem(); 80 totalram_pages = free_all_bootmem();
81 max_low_pfn = totalram_pages;
83#ifdef CONFIG_HIGHMEM 82#ifdef CONFIG_HIGHMEM
84 totalhigh_pages = highmem >> PAGE_SHIFT; 83 totalhigh_pages = highmem >> PAGE_SHIFT;
85 totalram_pages += totalhigh_pages; 84 totalram_pages += totalhigh_pages;
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c
index b3c11cfa995a..9383e8751ae7 100644
--- a/arch/um/os-Linux/skas/mem.c
+++ b/arch/um/os-Linux/skas/mem.c
@@ -48,7 +48,7 @@ int multi_op_count = 0;
48static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr) 48static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
49{ 49{
50 unsigned long regs[MAX_REG_NR]; 50 unsigned long regs[MAX_REG_NR];
51 int n; 51 int n, i;
52 long ret, offset; 52 long ret, offset;
53 unsigned long * data; 53 unsigned long * data;
54 unsigned long * syscall; 54 unsigned long * syscall;
@@ -66,9 +66,13 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
66 (unsigned long) &__syscall_stub_start); 66 (unsigned long) &__syscall_stub_start);
67 67
68 n = ptrace_setregs(pid, regs); 68 n = ptrace_setregs(pid, regs);
69 if(n < 0) 69 if(n < 0){
70 printk("Registers - \n");
71 for(i = 0; i < MAX_REG_NR; i++)
72 printk("\t%d\t0x%lx\n", i, regs[i]);
70 panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n", 73 panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
71 n); 74 -n);
75 }
72 76
73 wait_stub_done(pid, 0, "do_syscall_stub"); 77 wait_stub_done(pid, 0, "do_syscall_stub");
74 78
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index dda06789bcb0..0564422c155f 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -67,7 +67,7 @@ void wait_stub_done(int pid, int sig, char * fname)
67 67
68 if((n < 0) || !WIFSTOPPED(status) || 68 if((n < 0) || !WIFSTOPPED(status) ||
69 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ 69 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
70 unsigned long regs[HOST_FRAME_SIZE]; 70 unsigned long regs[MAX_REG_NR];
71 71
72 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) 72 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
73 printk("Failed to get registers from stub, " 73 printk("Failed to get registers from stub, "
@@ -76,7 +76,7 @@ void wait_stub_done(int pid, int sig, char * fname)
76 int i; 76 int i;
77 77
78 printk("Stub registers -\n"); 78 printk("Stub registers -\n");
79 for(i = 0; i < HOST_FRAME_SIZE; i++) 79 for(i = 0; i < ARRAY_SIZE(regs); i++)
80 printk("\t%d - %lx\n", i, regs[i]); 80 printk("\t%d - %lx\n", i, regs[i]);
81 } 81 }
82 panic("%s : failed to wait for SIGUSR1/SIGTRAP, " 82 panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
@@ -328,7 +328,7 @@ void userspace(union uml_pt_regs *regs)
328int copy_context_skas0(unsigned long new_stack, int pid) 328int copy_context_skas0(unsigned long new_stack, int pid)
329{ 329{
330 int err; 330 int err;
331 unsigned long regs[HOST_FRAME_SIZE]; 331 unsigned long regs[MAX_REG_NR];
332 unsigned long fp_regs[HOST_FP_SIZE]; 332 unsigned long fp_regs[HOST_FP_SIZE];
333 unsigned long current_stack = current_stub_stack(); 333 unsigned long current_stack = current_stub_stack();
334 struct stub_data *data = (struct stub_data *) current_stack; 334 struct stub_data *data = (struct stub_data *) current_stack;
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c
index 79cd93c8c5ed..84b44f9cd42a 100644
--- a/arch/um/os-Linux/sys-i386/registers.c
+++ b/arch/um/os-Linux/sys-i386/registers.c
@@ -15,7 +15,7 @@
15 15
16/* These are set once at boot time and not changed thereafter */ 16/* These are set once at boot time and not changed thereafter */
17 17
18static unsigned long exec_regs[HOST_FRAME_SIZE]; 18static unsigned long exec_regs[MAX_REG_NR];
19static unsigned long exec_fp_regs[HOST_FP_SIZE]; 19static unsigned long exec_fp_regs[HOST_FP_SIZE];
20static unsigned long exec_fpx_regs[HOST_XFP_SIZE]; 20static unsigned long exec_fpx_regs[HOST_XFP_SIZE];
21static int have_fpx_regs = 1; 21static int have_fpx_regs = 1;
@@ -101,6 +101,7 @@ void init_registers(int pid)
101{ 101{
102 int err; 102 int err;
103 103
104 memset(exec_regs, 0, sizeof(exec_regs));
104 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs); 105 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
105 if(err) 106 if(err)
106 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d", 107 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
@@ -124,7 +125,7 @@ void init_registers(int pid)
124 125
125void get_safe_registers(unsigned long *regs, unsigned long *fp_regs) 126void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
126{ 127{
127 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); 128 memcpy(regs, exec_regs, sizeof(exec_regs));
128 if(fp_regs != NULL) 129 if(fp_regs != NULL)
129 memcpy(fp_regs, exec_fp_regs, 130 memcpy(fp_regs, exec_fp_regs,
130 HOST_FP_SIZE * sizeof(unsigned long)); 131 HOST_FP_SIZE * sizeof(unsigned long));
diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c
index a2d7e0c603f7..e6fc2179d1bc 100644
--- a/arch/um/os-Linux/sys-x86_64/registers.c
+++ b/arch/um/os-Linux/sys-x86_64/registers.c
@@ -14,7 +14,7 @@
14 14
15/* These are set once at boot time and not changed thereafter */ 15/* These are set once at boot time and not changed thereafter */
16 16
17static unsigned long exec_regs[HOST_FRAME_SIZE]; 17static unsigned long exec_regs[MAX_REG_NR];
18static unsigned long exec_fp_regs[HOST_FP_SIZE]; 18static unsigned long exec_fp_regs[HOST_FP_SIZE];
19 19
20void init_thread_registers(union uml_pt_regs *to) 20void init_thread_registers(union uml_pt_regs *to)
@@ -72,7 +72,7 @@ void init_registers(int pid)
72 72
73void get_safe_registers(unsigned long *regs, unsigned long *fp_regs) 73void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
74{ 74{
75 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); 75 memcpy(regs, exec_regs, sizeof(exec_regs));
76 if(fp_regs != NULL) 76 if(fp_regs != NULL)
77 memcpy(fp_regs, exec_fp_regs, 77 memcpy(fp_regs, exec_fp_regs,
78 HOST_FP_SIZE * sizeof(unsigned long)); 78 HOST_FP_SIZE * sizeof(unsigned long));
diff --git a/arch/um/sys-i386/delay.c b/arch/um/sys-i386/delay.c
index 2c11b9770e8b..d623e074f41d 100644
--- a/arch/um/sys-i386/delay.c
+++ b/arch/um/sys-i386/delay.c
@@ -27,14 +27,3 @@ void __udelay(unsigned long usecs)
27} 27}
28 28
29EXPORT_SYMBOL(__udelay); 29EXPORT_SYMBOL(__udelay);
30
31void __const_udelay(unsigned long usecs)
32{
33 int i, n;
34
35 n = (loops_per_jiffy * HZ * usecs) / MILLION;
36 for(i=0;i<n;i++)
37 cpu_relax();
38}
39
40EXPORT_SYMBOL(__const_udelay);
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 4a8b4202ef9e..a939a7ef0227 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -394,7 +394,8 @@ static short * host_ldt_entries = NULL;
394static void ldt_get_host_info(void) 394static void ldt_get_host_info(void)
395{ 395{
396 long ret; 396 long ret;
397 struct ldt_entry * ldt, *tmp; 397 struct ldt_entry * ldt;
398 short *tmp;
398 int i, size, k, order; 399 int i, size, k, order;
399 400
400 spin_lock(&host_ldt_lock); 401 spin_lock(&host_ldt_lock);
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c
index 137f4446b439..dee5be66da82 100644
--- a/arch/um/sys-x86_64/delay.c
+++ b/arch/um/sys-x86_64/delay.c
@@ -28,14 +28,3 @@ void __udelay(unsigned long usecs)
28} 28}
29 29
30EXPORT_SYMBOL(__udelay); 30EXPORT_SYMBOL(__udelay);
31
32void __const_udelay(unsigned long usecs)
33{
34 unsigned long i, n;
35
36 n = (loops_per_jiffy * HZ * usecs) / MILLION;
37 for(i=0;i<n;i++)
38 cpu_relax();
39}
40
41EXPORT_SYMBOL(__const_udelay);
diff --git a/arch/x86_64/boot/video.S b/arch/x86_64/boot/video.S
index d6ff88f35135..6090516c9c7f 100644
--- a/arch/x86_64/boot/video.S
+++ b/arch/x86_64/boot/video.S
@@ -571,6 +571,16 @@ setr1: lodsw
571 jmp _m_s 571 jmp _m_s
572 572
573check_vesa: 573check_vesa:
574#ifdef CONFIG_FIRMWARE_EDID
575 leaw modelist+1024, %di
576 movw $0x4f00, %ax
577 int $0x10
578 cmpw $0x004f, %ax
579 jnz setbad
580
581 movw 4(%di), %ax
582 movw %ax, vbe_version
583#endif
574 leaw modelist+1024, %di 584 leaw modelist+1024, %di
575 subb $VIDEO_FIRST_VESA>>8, %bh 585 subb $VIDEO_FIRST_VESA>>8, %bh
576 movw %bx, %cx # Get mode information structure 586 movw %bx, %cx # Get mode information structure
@@ -1945,6 +1955,9 @@ store_edid:
1945 rep 1955 rep
1946 stosl 1956 stosl
1947 1957
1958 cmpw $0x0200, vbe_version # only do EDID on >= VBE2.0
1959 jl no_edid
1960
1948 pushw %es # save ES 1961 pushw %es # save ES
1949 xorw %di, %di # Report Capability 1962 xorw %di, %di # Report Capability
1950 pushw %di 1963 pushw %di
@@ -1987,6 +2000,7 @@ do_restore: .byte 0 # Screen contents altered during mode change
1987svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes 2000svga_prefix: .byte VIDEO_FIRST_BIOS>>8 # Default prefix for BIOS modes
1988graphic_mode: .byte 0 # Graphic mode with a linear frame buffer 2001graphic_mode: .byte 0 # Graphic mode with a linear frame buffer
1989dac_size: .byte 6 # DAC bit depth 2002dac_size: .byte 6 # DAC bit depth
2003vbe_version: .word 0 # VBE bios version
1990 2004
1991# Status messages 2005# Status messages
1992keymsg: .ascii "Press <RETURN> to see video modes available, " 2006keymsg: .ascii "Press <RETURN> to see video modes available, "
diff --git a/arch/x86_64/kernel/acpi/sleep.c b/arch/x86_64/kernel/acpi/sleep.c
index 23178ce6c783..e1548fbe95ae 100644
--- a/arch/x86_64/kernel/acpi/sleep.c
+++ b/arch/x86_64/kernel/acpi/sleep.c
@@ -66,8 +66,10 @@ static void init_low_mapping(void)
66{ 66{
67 pgd_t *slot0 = pgd_offset(current->mm, 0UL); 67 pgd_t *slot0 = pgd_offset(current->mm, 0UL);
68 low_ptr = *slot0; 68 low_ptr = *slot0;
69 /* FIXME: We're playing with the current task's page tables here, which
70 * is potentially dangerous on SMP systems.
71 */
69 set_pgd(slot0, *pgd_offset(current->mm, PAGE_OFFSET)); 72 set_pgd(slot0, *pgd_offset(current->mm, PAGE_OFFSET));
70 WARN_ON(num_online_cpus() != 1);
71 local_flush_tlb(); 73 local_flush_tlb();
72} 74}
73 75
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
index 148c6bcf5bb4..fede55a53995 100644
--- a/arch/x86_64/kernel/early-quirks.c
+++ b/arch/x86_64/kernel/early-quirks.c
@@ -88,7 +88,7 @@ struct chipset {
88 void (*f)(void); 88 void (*f)(void);
89}; 89};
90 90
91static struct __initdata chipset early_qrk[] = { 91static struct chipset early_qrk[] __initdata = {
92 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs }, 92 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
93 { PCI_VENDOR_ID_VIA, via_bugs }, 93 { PCI_VENDOR_ID_VIA, via_bugs },
94 { PCI_VENDOR_ID_ATI, ati_bugs }, 94 { PCI_VENDOR_ID_ATI, ati_bugs },
diff --git a/arch/x86_64/kernel/functionlist b/arch/x86_64/kernel/functionlist
index 01fa23580c85..7ae18ec12454 100644
--- a/arch/x86_64/kernel/functionlist
+++ b/arch/x86_64/kernel/functionlist
@@ -514,7 +514,6 @@
514*(.text.dentry_open) 514*(.text.dentry_open)
515*(.text.dentry_iput) 515*(.text.dentry_iput)
516*(.text.bio_alloc) 516*(.text.bio_alloc)
517*(.text.alloc_skb_from_cache)
518*(.text.wait_on_page_bit) 517*(.text.wait_on_page_bit)
519*(.text.vfs_readdir) 518*(.text.vfs_readdir)
520*(.text.vfs_lstat) 519*(.text.vfs_lstat)
diff --git a/arch/x86_64/kernel/hpet.c b/arch/x86_64/kernel/hpet.c
index 8cf0b8a13778..b8286968662d 100644
--- a/arch/x86_64/kernel/hpet.c
+++ b/arch/x86_64/kernel/hpet.c
@@ -191,6 +191,7 @@ int hpet_reenable(void)
191 191
192#define TICK_COUNT 100000000 192#define TICK_COUNT 100000000
193#define TICK_MIN 5000 193#define TICK_MIN 5000
194#define MAX_TRIES 5
194 195
195/* 196/*
196 * Some platforms take periodic SMI interrupts with 5ms duration. Make sure none 197 * Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
@@ -198,13 +199,15 @@ int hpet_reenable(void)
198 */ 199 */
199static void __init read_hpet_tsc(int *hpet, int *tsc) 200static void __init read_hpet_tsc(int *hpet, int *tsc)
200{ 201{
201 int tsc1, tsc2, hpet1; 202 int tsc1, tsc2, hpet1, i;
202 203
203 do { 204 for (i = 0; i < MAX_TRIES; i++) {
204 tsc1 = get_cycles_sync(); 205 tsc1 = get_cycles_sync();
205 hpet1 = hpet_readl(HPET_COUNTER); 206 hpet1 = hpet_readl(HPET_COUNTER);
206 tsc2 = get_cycles_sync(); 207 tsc2 = get_cycles_sync();
207 } while (tsc2 - tsc1 > TICK_MIN); 208 if (tsc2 - tsc1 > TICK_MIN)
209 break;
210 }
208 *hpet = hpet1; 211 *hpet = hpet1;
209 *tsc = tsc2; 212 *tsc = tsc2;
210} 213}
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 21d95b747437..489426682772 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -45,7 +45,7 @@
45 45
46/* 46/*
47 * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts: 47 * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
48 * (these are usually mapped to vectors 0x20-0x2f) 48 * (these are usually mapped to vectors 0x30-0x3f)
49 */ 49 */
50 50
51/* 51/*
@@ -299,7 +299,7 @@ void init_8259A(int auto_eoi)
299 * outb_p - this has to work on a wide range of PC hardware. 299 * outb_p - this has to work on a wide range of PC hardware.
300 */ 300 */
301 outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */ 301 outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */
302 outb_p(IRQ0_VECTOR, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x20-0x27 */ 302 outb_p(IRQ0_VECTOR, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x30-0x37 */
303 outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */ 303 outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */
304 if (auto_eoi) 304 if (auto_eoi)
305 outb_p(0x03, 0x21); /* master does Auto EOI */ 305 outb_p(0x03, 0x21); /* master does Auto EOI */
@@ -307,7 +307,7 @@ void init_8259A(int auto_eoi)
307 outb_p(0x01, 0x21); /* master expects normal EOI */ 307 outb_p(0x01, 0x21); /* master expects normal EOI */
308 308
309 outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */ 309 outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */
310 outb_p(IRQ8_VECTOR, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x28-0x2f */ 310 outb_p(IRQ8_VECTOR, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x38-0x3f */
311 outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */ 311 outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */
312 outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode 312 outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode
313 is to be investigated) */ 313 is to be investigated) */
diff --git a/arch/x86_64/kernel/k8.c b/arch/x86_64/kernel/k8.c
index 6416682d33d0..bc11b32e8b4d 100644
--- a/arch/x86_64/kernel/k8.c
+++ b/arch/x86_64/kernel/k8.c
@@ -61,8 +61,8 @@ int cache_k8_northbridges(void)
61 dev = NULL; 61 dev = NULL;
62 i = 0; 62 i = 0;
63 while ((dev = next_k8_northbridge(dev)) != NULL) { 63 while ((dev = next_k8_northbridge(dev)) != NULL) {
64 k8_northbridges[i++] = dev; 64 k8_northbridges[i] = dev;
65 pci_read_config_dword(dev, 0x9c, &flush_words[i]); 65 pci_read_config_dword(dev, 0x9c, &flush_words[i++]);
66 } 66 }
67 k8_northbridges[i] = NULL; 67 k8_northbridges[i] = NULL;
68 return 0; 68 return 0;
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 82d9d85d5270..dfab9f167366 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -39,15 +39,17 @@ int panic_on_unrecovered_nmi;
39 * different subsystems this reservation system just tries to coordinate 39 * different subsystems this reservation system just tries to coordinate
40 * things a little 40 * things a little
41 */ 41 */
42static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner);
43static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]);
44
45static cpumask_t backtrace_mask = CPU_MASK_NONE;
46 42
47/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's 43/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
48 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now) 44 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
49 */ 45 */
50#define NMI_MAX_COUNTER_BITS 66 46#define NMI_MAX_COUNTER_BITS 66
47#define NMI_MAX_COUNTER_LONGS BITS_TO_LONGS(NMI_MAX_COUNTER_BITS)
48
49static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner[NMI_MAX_COUNTER_LONGS]);
50static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[NMI_MAX_COUNTER_LONGS]);
51
52static cpumask_t backtrace_mask = CPU_MASK_NONE;
51 53
52/* nmi_active: 54/* nmi_active:
53 * >0: the lapic NMI watchdog is active, but can be disabled 55 * >0: the lapic NMI watchdog is active, but can be disabled
@@ -108,64 +110,128 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
108/* checks for a bit availability (hack for oprofile) */ 110/* checks for a bit availability (hack for oprofile) */
109int avail_to_resrv_perfctr_nmi_bit(unsigned int counter) 111int avail_to_resrv_perfctr_nmi_bit(unsigned int counter)
110{ 112{
113 int cpu;
111 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 114 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
112 115 for_each_possible_cpu (cpu) {
113 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner))); 116 if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)))
117 return 0;
118 }
119 return 1;
114} 120}
115 121
116/* checks the an msr for availability */ 122/* checks the an msr for availability */
117int avail_to_resrv_perfctr_nmi(unsigned int msr) 123int avail_to_resrv_perfctr_nmi(unsigned int msr)
118{ 124{
119 unsigned int counter; 125 unsigned int counter;
126 int cpu;
120 127
121 counter = nmi_perfctr_msr_to_bit(msr); 128 counter = nmi_perfctr_msr_to_bit(msr);
122 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 129 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
123 130
124 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner))); 131 for_each_possible_cpu (cpu) {
132 if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)))
133 return 0;
134 }
135 return 1;
125} 136}
126 137
127int reserve_perfctr_nmi(unsigned int msr) 138static int __reserve_perfctr_nmi(int cpu, unsigned int msr)
128{ 139{
129 unsigned int counter; 140 unsigned int counter;
141 if (cpu < 0)
142 cpu = smp_processor_id();
130 143
131 counter = nmi_perfctr_msr_to_bit(msr); 144 counter = nmi_perfctr_msr_to_bit(msr);
132 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 145 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
133 146
134 if (!test_and_set_bit(counter, &__get_cpu_var(perfctr_nmi_owner))) 147 if (!test_and_set_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)))
135 return 1; 148 return 1;
136 return 0; 149 return 0;
137} 150}
138 151
139void release_perfctr_nmi(unsigned int msr) 152static void __release_perfctr_nmi(int cpu, unsigned int msr)
140{ 153{
141 unsigned int counter; 154 unsigned int counter;
155 if (cpu < 0)
156 cpu = smp_processor_id();
142 157
143 counter = nmi_perfctr_msr_to_bit(msr); 158 counter = nmi_perfctr_msr_to_bit(msr);
144 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 159 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
145 160
146 clear_bit(counter, &__get_cpu_var(perfctr_nmi_owner)); 161 clear_bit(counter, &per_cpu(perfctr_nmi_owner, cpu));
147} 162}
148 163
149int reserve_evntsel_nmi(unsigned int msr) 164int reserve_perfctr_nmi(unsigned int msr)
165{
166 int cpu, i;
167 for_each_possible_cpu (cpu) {
168 if (!__reserve_perfctr_nmi(cpu, msr)) {
169 for_each_possible_cpu (i) {
170 if (i >= cpu)
171 break;
172 __release_perfctr_nmi(i, msr);
173 }
174 return 0;
175 }
176 }
177 return 1;
178}
179
180void release_perfctr_nmi(unsigned int msr)
181{
182 int cpu;
183 for_each_possible_cpu (cpu)
184 __release_perfctr_nmi(cpu, msr);
185}
186
187int __reserve_evntsel_nmi(int cpu, unsigned int msr)
150{ 188{
151 unsigned int counter; 189 unsigned int counter;
190 if (cpu < 0)
191 cpu = smp_processor_id();
152 192
153 counter = nmi_evntsel_msr_to_bit(msr); 193 counter = nmi_evntsel_msr_to_bit(msr);
154 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 194 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
155 195
156 if (!test_and_set_bit(counter, &__get_cpu_var(evntsel_nmi_owner))) 196 if (!test_and_set_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]))
157 return 1; 197 return 1;
158 return 0; 198 return 0;
159} 199}
160 200
161void release_evntsel_nmi(unsigned int msr) 201static void __release_evntsel_nmi(int cpu, unsigned int msr)
162{ 202{
163 unsigned int counter; 203 unsigned int counter;
204 if (cpu < 0)
205 cpu = smp_processor_id();
164 206
165 counter = nmi_evntsel_msr_to_bit(msr); 207 counter = nmi_evntsel_msr_to_bit(msr);
166 BUG_ON(counter > NMI_MAX_COUNTER_BITS); 208 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
167 209
168 clear_bit(counter, &__get_cpu_var(evntsel_nmi_owner)); 210 clear_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]);
211}
212
213int reserve_evntsel_nmi(unsigned int msr)
214{
215 int cpu, i;
216 for_each_possible_cpu (cpu) {
217 if (!__reserve_evntsel_nmi(cpu, msr)) {
218 for_each_possible_cpu (i) {
219 if (i >= cpu)
220 break;
221 __release_evntsel_nmi(i, msr);
222 }
223 return 0;
224 }
225 }
226 return 1;
227}
228
229void release_evntsel_nmi(unsigned int msr)
230{
231 int cpu;
232 for_each_possible_cpu (cpu) {
233 __release_evntsel_nmi(cpu, msr);
234 }
169} 235}
170 236
171static __cpuinit inline int nmi_known_cpu(void) 237static __cpuinit inline int nmi_known_cpu(void)
@@ -253,7 +319,7 @@ int __init check_nmi_watchdog (void)
253 for (cpu = 0; cpu < NR_CPUS; cpu++) 319 for (cpu = 0; cpu < NR_CPUS; cpu++)
254 counts[cpu] = cpu_pda(cpu)->__nmi_count; 320 counts[cpu] = cpu_pda(cpu)->__nmi_count;
255 local_irq_enable(); 321 local_irq_enable();
256 mdelay((10*1000)/nmi_hz); // wait 10 ticks 322 mdelay((20*1000)/nmi_hz); // wait 20 ticks
257 323
258 for_each_online_cpu(cpu) { 324 for_each_online_cpu(cpu) {
259 if (!per_cpu(nmi_watchdog_ctlblk, cpu).enabled) 325 if (!per_cpu(nmi_watchdog_ctlblk, cpu).enabled)
@@ -472,10 +538,10 @@ static int setup_k7_watchdog(void)
472 538
473 perfctr_msr = MSR_K7_PERFCTR0; 539 perfctr_msr = MSR_K7_PERFCTR0;
474 evntsel_msr = MSR_K7_EVNTSEL0; 540 evntsel_msr = MSR_K7_EVNTSEL0;
475 if (!reserve_perfctr_nmi(perfctr_msr)) 541 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
476 goto fail; 542 goto fail;
477 543
478 if (!reserve_evntsel_nmi(evntsel_msr)) 544 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
479 goto fail1; 545 goto fail1;
480 546
481 /* Simulator may not support it */ 547 /* Simulator may not support it */
@@ -501,9 +567,9 @@ static int setup_k7_watchdog(void)
501 wd->check_bit = 1ULL<<63; 567 wd->check_bit = 1ULL<<63;
502 return 1; 568 return 1;
503fail2: 569fail2:
504 release_evntsel_nmi(evntsel_msr); 570 __release_evntsel_nmi(-1, evntsel_msr);
505fail1: 571fail1:
506 release_perfctr_nmi(perfctr_msr); 572 __release_perfctr_nmi(-1, perfctr_msr);
507fail: 573fail:
508 return 0; 574 return 0;
509} 575}
@@ -514,8 +580,8 @@ static void stop_k7_watchdog(void)
514 580
515 wrmsr(wd->evntsel_msr, 0, 0); 581 wrmsr(wd->evntsel_msr, 0, 0);
516 582
517 release_evntsel_nmi(wd->evntsel_msr); 583 __release_evntsel_nmi(-1, wd->evntsel_msr);
518 release_perfctr_nmi(wd->perfctr_msr); 584 __release_perfctr_nmi(-1, wd->perfctr_msr);
519} 585}
520 586
521/* Note that these events don't tick when the CPU idles. This means 587/* Note that these events don't tick when the CPU idles. This means
@@ -581,10 +647,10 @@ static int setup_p4_watchdog(void)
581 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4); 647 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4);
582 } 648 }
583 649
584 if (!reserve_perfctr_nmi(perfctr_msr)) 650 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
585 goto fail; 651 goto fail;
586 652
587 if (!reserve_evntsel_nmi(evntsel_msr)) 653 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
588 goto fail1; 654 goto fail1;
589 655
590 evntsel = P4_ESCR_EVENT_SELECT(0x3F) 656 evntsel = P4_ESCR_EVENT_SELECT(0x3F)
@@ -609,7 +675,7 @@ static int setup_p4_watchdog(void)
609 wd->check_bit = 1ULL<<39; 675 wd->check_bit = 1ULL<<39;
610 return 1; 676 return 1;
611fail1: 677fail1:
612 release_perfctr_nmi(perfctr_msr); 678 __release_perfctr_nmi(-1, perfctr_msr);
613fail: 679fail:
614 return 0; 680 return 0;
615} 681}
@@ -621,8 +687,8 @@ static void stop_p4_watchdog(void)
621 wrmsr(wd->cccr_msr, 0, 0); 687 wrmsr(wd->cccr_msr, 0, 0);
622 wrmsr(wd->evntsel_msr, 0, 0); 688 wrmsr(wd->evntsel_msr, 0, 0);
623 689
624 release_evntsel_nmi(wd->evntsel_msr); 690 __release_evntsel_nmi(-1, wd->evntsel_msr);
625 release_perfctr_nmi(wd->perfctr_msr); 691 __release_perfctr_nmi(-1, wd->perfctr_msr);
626} 692}
627 693
628#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 694#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
@@ -650,10 +716,10 @@ static int setup_intel_arch_watchdog(void)
650 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0; 716 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0;
651 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0; 717 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0;
652 718
653 if (!reserve_perfctr_nmi(perfctr_msr)) 719 if (!__reserve_perfctr_nmi(-1, perfctr_msr))
654 goto fail; 720 goto fail;
655 721
656 if (!reserve_evntsel_nmi(evntsel_msr)) 722 if (!__reserve_evntsel_nmi(-1, evntsel_msr))
657 goto fail1; 723 goto fail1;
658 724
659 wrmsrl(perfctr_msr, 0UL); 725 wrmsrl(perfctr_msr, 0UL);
@@ -680,7 +746,7 @@ static int setup_intel_arch_watchdog(void)
680 wd->check_bit = 1ULL << (eax.split.bit_width - 1); 746 wd->check_bit = 1ULL << (eax.split.bit_width - 1);
681 return 1; 747 return 1;
682fail1: 748fail1:
683 release_perfctr_nmi(perfctr_msr); 749 __release_perfctr_nmi(-1, perfctr_msr);
684fail: 750fail:
685 return 0; 751 return 0;
686} 752}
@@ -704,8 +770,8 @@ static void stop_intel_arch_watchdog(void)
704 770
705 wrmsr(wd->evntsel_msr, 0, 0); 771 wrmsr(wd->evntsel_msr, 0, 0);
706 772
707 release_evntsel_nmi(wd->evntsel_msr); 773 __release_evntsel_nmi(-1, wd->evntsel_msr);
708 release_perfctr_nmi(wd->perfctr_msr); 774 __release_perfctr_nmi(-1, wd->perfctr_msr);
709} 775}
710 776
711void setup_apic_nmi_watchdog(void *unused) 777void setup_apic_nmi_watchdog(void *unused)
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 2bac8c60ad61..0bae862e9a55 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -519,7 +519,11 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
519 gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32); 519 gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32);
520 gatt = (void *)__get_free_pages(GFP_KERNEL, get_order(gatt_size)); 520 gatt = (void *)__get_free_pages(GFP_KERNEL, get_order(gatt_size));
521 if (!gatt) 521 if (!gatt)
522 panic("Cannot allocate GATT table"); 522 panic("Cannot allocate GATT table");
523 if (change_page_attr_addr((unsigned long)gatt, gatt_size >> PAGE_SHIFT, PAGE_KERNEL_NOCACHE))
524 panic("Could not set GART PTEs to uncacheable pages");
525 global_flush_tlb();
526
523 memset(gatt, 0, gatt_size); 527 memset(gatt, 0, gatt_size);
524 agp_gatt_table = gatt; 528 agp_gatt_table = gatt;
525 529
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index b73212c0a550..5176ecf006ee 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -13,7 +13,7 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
13OUTPUT_ARCH(i386:x86-64) 13OUTPUT_ARCH(i386:x86-64)
14ENTRY(phys_startup_64) 14ENTRY(phys_startup_64)
15jiffies_64 = jiffies; 15jiffies_64 = jiffies;
16_proxy_pda = 0; 16_proxy_pda = 1;
17PHDRS { 17PHDRS {
18 text PT_LOAD FLAGS(5); /* R_E */ 18 text PT_LOAD FLAGS(5); /* R_E */
19 data PT_LOAD FLAGS(7); /* RWE */ 19 data PT_LOAD FLAGS(7); /* RWE */
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 65c5eaa59905..081409aa3452 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -81,8 +81,8 @@ static void flush_kernel_map(void *arg)
81 void *adr = page_address(pg); 81 void *adr = page_address(pg);
82 if (cpu_has_clflush) 82 if (cpu_has_clflush)
83 cache_flush_page(adr); 83 cache_flush_page(adr);
84 __flush_tlb_one(adr);
85 } 84 }
85 __flush_tlb_all();
86} 86}
87 87
88static inline void flush_map(struct list_head *l) 88static inline void flush_map(struct list_head *l)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index b6491c020f26..f92ba2a869b4 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -532,6 +532,12 @@ static void cfq_add_rq_rb(struct request *rq)
532 532
533 if (!cfq_cfqq_on_rr(cfqq)) 533 if (!cfq_cfqq_on_rr(cfqq))
534 cfq_add_cfqq_rr(cfqd, cfqq); 534 cfq_add_cfqq_rr(cfqd, cfqq);
535
536 /*
537 * check if this request is a better next-serve candidate
538 */
539 cfqq->next_rq = cfq_choose_req(cfqd, cfqq->next_rq, rq);
540 BUG_ON(!cfqq->next_rq);
535} 541}
536 542
537static inline void 543static inline void
@@ -986,9 +992,9 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
986 * expire an async queue immediately if it has used up its slice. idle 992 * expire an async queue immediately if it has used up its slice. idle
987 * queue always expire after 1 dispatch round. 993 * queue always expire after 1 dispatch round.
988 */ 994 */
989 if ((!cfq_cfqq_sync(cfqq) && 995 if (cfqd->busy_queues > 1 && ((!cfq_cfqq_sync(cfqq) &&
990 cfqd->dispatch_slice >= cfq_prio_to_maxrq(cfqd, cfqq)) || 996 cfqd->dispatch_slice >= cfq_prio_to_maxrq(cfqd, cfqq)) ||
991 cfq_class_idle(cfqq)) { 997 cfq_class_idle(cfqq))) {
992 cfqq->slice_end = jiffies + 1; 998 cfqq->slice_end = jiffies + 1;
993 cfq_slice_expired(cfqd, 0, 0); 999 cfq_slice_expired(cfqd, 0, 0);
994 } 1000 }
@@ -1051,19 +1057,21 @@ cfq_dispatch_requests(request_queue_t *q, int force)
1051 while ((cfqq = cfq_select_queue(cfqd)) != NULL) { 1057 while ((cfqq = cfq_select_queue(cfqd)) != NULL) {
1052 int max_dispatch; 1058 int max_dispatch;
1053 1059
1054 /* 1060 if (cfqd->busy_queues > 1) {
1055 * Don't repeat dispatch from the previous queue. 1061 /*
1056 */ 1062 * Don't repeat dispatch from the previous queue.
1057 if (prev_cfqq == cfqq) 1063 */
1058 break; 1064 if (prev_cfqq == cfqq)
1065 break;
1059 1066
1060 /* 1067 /*
1061 * So we have dispatched before in this round, if the 1068 * So we have dispatched before in this round, if the
1062 * next queue has idling enabled (must be sync), don't 1069 * next queue has idling enabled (must be sync), don't
1063 * allow it service until the previous have continued. 1070 * allow it service until the previous have continued.
1064 */ 1071 */
1065 if (cfqd->rq_in_driver && cfq_cfqq_idle_window(cfqq)) 1072 if (cfqd->rq_in_driver && cfq_cfqq_idle_window(cfqq))
1066 break; 1073 break;
1074 }
1067 1075
1068 cfq_clear_cfqq_must_dispatch(cfqq); 1076 cfq_clear_cfqq_must_dispatch(cfqq);
1069 cfq_clear_cfqq_wait_request(cfqq); 1077 cfq_clear_cfqq_wait_request(cfqq);
@@ -1370,7 +1378,9 @@ retry:
1370 atomic_set(&cfqq->ref, 0); 1378 atomic_set(&cfqq->ref, 0);
1371 cfqq->cfqd = cfqd; 1379 cfqq->cfqd = cfqd;
1372 1380
1373 cfq_mark_cfqq_idle_window(cfqq); 1381 if (key != CFQ_KEY_ASYNC)
1382 cfq_mark_cfqq_idle_window(cfqq);
1383
1374 cfq_mark_cfqq_prio_changed(cfqq); 1384 cfq_mark_cfqq_prio_changed(cfqq);
1375 cfq_mark_cfqq_queue_new(cfqq); 1385 cfq_mark_cfqq_queue_new(cfqq);
1376 cfq_init_prio_data(cfqq); 1386 cfq_init_prio_data(cfqq);
@@ -1635,12 +1645,6 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1635 cfqq->meta_pending++; 1645 cfqq->meta_pending++;
1636 1646
1637 /* 1647 /*
1638 * check if this request is a better next-serve candidate)) {
1639 */
1640 cfqq->next_rq = cfq_choose_req(cfqd, cfqq->next_rq, rq);
1641 BUG_ON(!cfqq->next_rq);
1642
1643 /*
1644 * we never wait for an async request and we don't allow preemption 1648 * we never wait for an async request and we don't allow preemption
1645 * of an async request. so just return early 1649 * of an async request. so just return early
1646 */ 1650 */
diff --git a/block/elevator.c b/block/elevator.c
index 25f6ef28e3bb..96a00c822748 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -964,17 +964,18 @@ void elv_unregister_queue(struct request_queue *q)
964 964
965int elv_register(struct elevator_type *e) 965int elv_register(struct elevator_type *e)
966{ 966{
967 char *def = "";
967 spin_lock_irq(&elv_list_lock); 968 spin_lock_irq(&elv_list_lock);
968 BUG_ON(elevator_find(e->elevator_name)); 969 BUG_ON(elevator_find(e->elevator_name));
969 list_add_tail(&e->list, &elv_list); 970 list_add_tail(&e->list, &elv_list);
970 spin_unlock_irq(&elv_list_lock); 971 spin_unlock_irq(&elv_list_lock);
971 972
972 printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
973 if (!strcmp(e->elevator_name, chosen_elevator) || 973 if (!strcmp(e->elevator_name, chosen_elevator) ||
974 (!*chosen_elevator && 974 (!*chosen_elevator &&
975 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED))) 975 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
976 printk(" (default)"); 976 def = " (default)";
977 printk("\n"); 977
978 printk(KERN_INFO "io scheduler %s registered%s\n", e->elevator_name, def);
978 return 0; 979 return 0;
979} 980}
980EXPORT_SYMBOL_GPL(elv_register); 981EXPORT_SYMBOL_GPL(elv_register);
diff --git a/block/genhd.c b/block/genhd.c
index 050a1f0f3a86..441432a142f2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -62,8 +62,6 @@ int register_blkdev(unsigned int major, const char *name)
62 /* temporary */ 62 /* temporary */
63 if (major == 0) { 63 if (major == 0) {
64 for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) { 64 for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) {
65 if (is_lanana_major(index))
66 continue;
67 if (major_names[index] == NULL) 65 if (major_names[index] == NULL)
68 break; 66 break;
69 } 67 }
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 38c293b987b7..3de06953ac33 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1221,7 +1221,7 @@ void blk_recount_segments(request_queue_t *q, struct bio *bio)
1221 * considered part of another segment, since that might 1221 * considered part of another segment, since that might
1222 * change with the bounce page. 1222 * change with the bounce page.
1223 */ 1223 */
1224 high = page_to_pfn(bv->bv_page) >= q->bounce_pfn; 1224 high = page_to_pfn(bv->bv_page) > q->bounce_pfn;
1225 if (high || highprv) 1225 if (high || highprv)
1226 goto new_hw_segment; 1226 goto new_hw_segment;
1227 if (cluster) { 1227 if (cluster) {
@@ -3658,8 +3658,8 @@ int __init blk_dev_init(void)
3658 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL); 3658 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL);
3659 register_hotcpu_notifier(&blk_cpu_notifier); 3659 register_hotcpu_notifier(&blk_cpu_notifier);
3660 3660
3661 blk_max_low_pfn = max_low_pfn; 3661 blk_max_low_pfn = max_low_pfn - 1;
3662 blk_max_pfn = max_pfn; 3662 blk_max_pfn = max_pfn - 1;
3663 3663
3664 return 0; 3664 return 0;
3665} 3665}
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
index a66423121773..81afd1790a1d 100644
--- a/crypto/scatterwalk.c
+++ b/crypto/scatterwalk.c
@@ -59,8 +59,12 @@ EXPORT_SYMBOL_GPL(scatterwalk_map);
59static void scatterwalk_pagedone(struct scatter_walk *walk, int out, 59static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
60 unsigned int more) 60 unsigned int more)
61{ 61{
62 if (out) 62 if (out) {
63 flush_dcache_page(scatterwalk_page(walk)); 63 struct page *page;
64
65 page = walk->sg->page + ((walk->offset - 1) >> PAGE_SHIFT);
66 flush_dcache_page(page);
67 }
64 68
65 if (more) { 69 if (more) {
66 walk->offset += PAGE_SIZE - 1; 70 walk->offset += PAGE_SIZE - 1;
@@ -91,7 +95,7 @@ void scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
91 memcpy_dir(buf, vaddr, len_this_page, out); 95 memcpy_dir(buf, vaddr, len_this_page, out);
92 scatterwalk_unmap(vaddr, out); 96 scatterwalk_unmap(vaddr, out);
93 97
94 scatterwalk_advance(walk, nbytes); 98 scatterwalk_advance(walk, len_this_page);
95 99
96 if (nbytes == len_this_page) 100 if (nbytes == len_this_page)
97 break; 101 break;
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 96792a6cc164..c3419182c9a7 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -42,7 +42,7 @@ static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
42 42
43static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; 43static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
44 44
45static int acpi_apic_instance __initdata = 2; 45static int acpi_apic_instance __initdata;
46 46
47void acpi_table_print_madt_entry(struct acpi_subtable_header *header) 47void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
48{ 48{
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0ae8b9310cbf..589b98b7b216 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -758,7 +758,8 @@ static void acpi_thermal_check(void *data)
758 del_timer(&(tz->timer)); 758 del_timer(&(tz->timer));
759 } else { 759 } else {
760 if (timer_pending(&(tz->timer))) 760 if (timer_pending(&(tz->timer)))
761 mod_timer(&(tz->timer), (HZ * sleep_time) / 1000); 761 mod_timer(&(tz->timer),
762 jiffies + (HZ * sleep_time) / 1000);
762 else { 763 else {
763 tz->timer.data = (unsigned long)tz; 764 tz->timer.data = (unsigned long)tz;
764 tz->timer.function = acpi_thermal_run; 765 tz->timer.function = acpi_thermal_run;
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index dc7b56225923..fd27227771b4 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -80,6 +80,7 @@ enum {
80 board_ahci_pi = 1, 80 board_ahci_pi = 1,
81 board_ahci_vt8251 = 2, 81 board_ahci_vt8251 = 2,
82 board_ahci_ign_iferr = 3, 82 board_ahci_ign_iferr = 3,
83 board_ahci_sb600 = 4,
83 84
84 /* global controller registers */ 85 /* global controller registers */
85 HOST_CAP = 0x00, /* host capabilities */ 86 HOST_CAP = 0x00, /* host capabilities */
@@ -168,6 +169,7 @@ enum {
168 AHCI_FLAG_NO_NCQ = (1 << 24), 169 AHCI_FLAG_NO_NCQ = (1 << 24),
169 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */ 170 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */
170 AHCI_FLAG_HONOR_PI = (1 << 26), /* honor PORTS_IMPL */ 171 AHCI_FLAG_HONOR_PI = (1 << 26), /* honor PORTS_IMPL */
172 AHCI_FLAG_IGN_SERR_INTERNAL = (1 << 27), /* ignore SERR_INTERNAL */
171}; 173};
172 174
173struct ahci_cmd_hdr { 175struct ahci_cmd_hdr {
@@ -362,6 +364,18 @@ static const struct ata_port_info ahci_port_info[] = {
362 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 364 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
363 .port_ops = &ahci_ops, 365 .port_ops = &ahci_ops,
364 }, 366 },
367 /* board_ahci_sb600 */
368 {
369 .sht = &ahci_sht,
370 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
371 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
372 ATA_FLAG_SKIP_D2H_BSY |
373 AHCI_FLAG_IGN_SERR_INTERNAL,
374 .pio_mask = 0x1f, /* pio0-4 */
375 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
376 .port_ops = &ahci_ops,
377 },
378
365}; 379};
366 380
367static const struct pci_device_id ahci_pci_tbl[] = { 381static const struct pci_device_id ahci_pci_tbl[] = {
@@ -399,7 +413,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
399 PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr }, 413 PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr },
400 414
401 /* ATI */ 415 /* ATI */
402 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */ 416 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 non-raid */
403 { PCI_VDEVICE(ATI, 0x4381), board_ahci }, /* ATI SB600 raid */ 417 { PCI_VDEVICE(ATI, 0x4381), board_ahci }, /* ATI SB600 raid */
404 418
405 /* VIA */ 419 /* VIA */
@@ -1067,8 +1081,11 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1067 if (ap->flags & AHCI_FLAG_IGN_IRQ_IF_ERR) 1081 if (ap->flags & AHCI_FLAG_IGN_IRQ_IF_ERR)
1068 irq_stat &= ~PORT_IRQ_IF_ERR; 1082 irq_stat &= ~PORT_IRQ_IF_ERR;
1069 1083
1070 if (irq_stat & PORT_IRQ_TF_ERR) 1084 if (irq_stat & PORT_IRQ_TF_ERR) {
1071 err_mask |= AC_ERR_DEV; 1085 err_mask |= AC_ERR_DEV;
1086 if (ap->flags & AHCI_FLAG_IGN_SERR_INTERNAL)
1087 serror &= ~SERR_INTERNAL;
1088 }
1072 1089
1073 if (irq_stat & (PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR)) { 1090 if (irq_stat & (PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR)) {
1074 err_mask |= AC_ERR_HOST_BUS; 1091 err_mask |= AC_ERR_HOST_BUS;
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index c428a56e6f31..03a0acff6cfa 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -305,7 +305,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
305 *gtf_address = 0UL; 305 *gtf_address = 0UL;
306 *obj_loc = 0UL; 306 *obj_loc = 0UL;
307 307
308 if (noacpi) 308 if (libata_noacpi)
309 return 0; 309 return 0;
310 310
311 if (ata_msg_probe(ap)) 311 if (ata_msg_probe(ap))
@@ -531,7 +531,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap,
531 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 531 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
532 __FUNCTION__, ap->port_no); 532 __FUNCTION__, ap->port_no);
533 533
534 if (noacpi || !(ap->cbl == ATA_CBL_SATA)) 534 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA))
535 return 0; 535 return 0;
536 536
537 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) 537 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED))
@@ -574,7 +574,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
574 unsigned long gtf_address; 574 unsigned long gtf_address;
575 unsigned long obj_loc; 575 unsigned long obj_loc;
576 576
577 if (noacpi) 577 if (libata_noacpi)
578 return 0; 578 return 0;
579 /* 579 /*
580 * TBD - implement PATA support. For now, 580 * TBD - implement PATA support. For now,
@@ -636,7 +636,7 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
636 struct acpi_object_list input; 636 struct acpi_object_list input;
637 union acpi_object in_params[1]; 637 union acpi_object in_params[1];
638 638
639 if (noacpi) 639 if (libata_noacpi)
640 return 0; 640 return 0;
641 641
642 if (ata_msg_probe(ap)) 642 if (ata_msg_probe(ap))
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index bf327d473ce9..0abd72d0dec2 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -93,8 +93,8 @@ static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ;
93module_param(ata_probe_timeout, int, 0444); 93module_param(ata_probe_timeout, int, 0444);
94MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); 94MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
95 95
96int noacpi; 96int libata_noacpi = 1;
97module_param(noacpi, int, 0444); 97module_param_named(noacpi, libata_noacpi, int, 0444);
98MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); 98MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
99 99
100MODULE_AUTHOR("Jeff Garzik"); 100MODULE_AUTHOR("Jeff Garzik");
@@ -1784,6 +1784,13 @@ int ata_dev_configure(struct ata_device *dev)
1784 dev->max_sectors = ATA_MAX_SECTORS; 1784 dev->max_sectors = ATA_MAX_SECTORS;
1785 } 1785 }
1786 1786
1787 if (ata_device_blacklisted(dev) & ATA_HORKAGE_MAX_SEC_128)
1788 dev->max_sectors = min(ATA_MAX_SECTORS_128, dev->max_sectors);
1789
1790 /* limit ATAPI DMA to R/W commands only */
1791 if (ata_device_blacklisted(dev) & ATA_HORKAGE_DMA_RW_ONLY)
1792 dev->horkage |= ATA_HORKAGE_DMA_RW_ONLY;
1793
1787 if (ap->ops->dev_config) 1794 if (ap->ops->dev_config)
1788 ap->ops->dev_config(ap, dev); 1795 ap->ops->dev_config(ap, dev);
1789 1796
@@ -3352,6 +3359,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3352 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, 3359 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
3353 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, 3360 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA },
3354 3361
3362 /* Weird ATAPI devices */
3363 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 |
3364 ATA_HORKAGE_DMA_RW_ONLY },
3365
3355 /* Devices we expect to fail diagnostics */ 3366 /* Devices we expect to fail diagnostics */
3356 3367
3357 /* Devices where NCQ should be avoided */ 3368 /* Devices where NCQ should be avoided */
@@ -3359,6 +3370,15 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3359 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, 3370 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ },
3360 /* http://thread.gmane.org/gmane.linux.ide/14907 */ 3371 /* http://thread.gmane.org/gmane.linux.ide/14907 */
3361 { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ }, 3372 { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ },
3373 /* NCQ is broken */
3374 { "Maxtor 6L250S0", "BANC1G10", ATA_HORKAGE_NONCQ },
3375 /* NCQ hard hangs device under heavier load, needs hard power cycle */
3376 { "Maxtor 6B250S0", "BANC1B70", ATA_HORKAGE_NONCQ },
3377 /* Blacklist entries taken from Silicon Image 3124/3132
3378 Windows driver .inf file - also several Linux problem reports */
3379 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, },
3380 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, },
3381 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, },
3362 3382
3363 /* Devices with NCQ limits */ 3383 /* Devices with NCQ limits */
3364 3384
@@ -3670,6 +3690,26 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
3670 struct ata_port *ap = qc->ap; 3690 struct ata_port *ap = qc->ap;
3671 int rc = 0; /* Assume ATAPI DMA is OK by default */ 3691 int rc = 0; /* Assume ATAPI DMA is OK by default */
3672 3692
3693 /* some drives can only do ATAPI DMA on read/write */
3694 if (unlikely(qc->dev->horkage & ATA_HORKAGE_DMA_RW_ONLY)) {
3695 struct scsi_cmnd *cmd = qc->scsicmd;
3696 u8 *scsicmd = cmd->cmnd;
3697
3698 switch (scsicmd[0]) {
3699 case READ_10:
3700 case WRITE_10:
3701 case READ_12:
3702 case WRITE_12:
3703 case READ_6:
3704 case WRITE_6:
3705 /* atapi dma maybe ok */
3706 break;
3707 default:
3708 /* turn off atapi dma */
3709 return 1;
3710 }
3711 }
3712
3673 if (ap->ops->check_atapi_dma) 3713 if (ap->ops->check_atapi_dma)
3674 rc = ap->ops->check_atapi_dma(qc); 3714 rc = ap->ops->check_atapi_dma(qc);
3675 3715
@@ -4713,8 +4753,8 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
4713{ 4753{
4714 struct ata_port *ap = qc->ap; 4754 struct ata_port *ap = qc->ap;
4715 4755
4716 ap->ops->tf_read(ap, &qc->result_tf);
4717 qc->result_tf.flags = qc->tf.flags; 4756 qc->result_tf.flags = qc->tf.flags;
4757 ap->ops->tf_read(ap, &qc->result_tf);
4718} 4758}
4719 4759
4720/** 4760/**
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 361953a50203..39f556c02992 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -982,26 +982,27 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
982 * RETURNS: 982 * RETURNS:
983 * 0 on success, AC_ERR_* mask on failure 983 * 0 on success, AC_ERR_* mask on failure
984 */ 984 */
985static unsigned int atapi_eh_request_sense(struct ata_device *dev, 985static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
986 unsigned char *sense_buf)
987{ 986{
987 struct ata_device *dev = qc->dev;
988 unsigned char *sense_buf = qc->scsicmd->sense_buffer;
988 struct ata_port *ap = dev->ap; 989 struct ata_port *ap = dev->ap;
989 struct ata_taskfile tf; 990 struct ata_taskfile tf;
990 u8 cdb[ATAPI_CDB_LEN]; 991 u8 cdb[ATAPI_CDB_LEN];
991 992
992 DPRINTK("ATAPI request sense\n"); 993 DPRINTK("ATAPI request sense\n");
993 994
994 ata_tf_init(dev, &tf);
995
996 /* FIXME: is this needed? */ 995 /* FIXME: is this needed? */
997 memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE); 996 memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE);
998 997
999 /* XXX: why tf_read here? */ 998 /* initialize sense_buf with the error register,
1000 ap->ops->tf_read(ap, &tf); 999 * for the case where they are -not- overwritten
1001 1000 */
1002 /* fill these in, for the case where they are -not- overwritten */
1003 sense_buf[0] = 0x70; 1001 sense_buf[0] = 0x70;
1004 sense_buf[2] = tf.feature >> 4; 1002 sense_buf[2] = qc->result_tf.feature >> 4;
1003
1004 /* some devices time out if garbage left in tf */
1005 ata_tf_init(dev, &tf);
1005 1006
1006 memset(cdb, 0, ATAPI_CDB_LEN); 1007 memset(cdb, 0, ATAPI_CDB_LEN);
1007 cdb[0] = REQUEST_SENSE; 1008 cdb[0] = REQUEST_SENSE;
@@ -1165,8 +1166,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1165 1166
1166 case ATA_DEV_ATAPI: 1167 case ATA_DEV_ATAPI:
1167 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { 1168 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1168 tmp = atapi_eh_request_sense(qc->dev, 1169 tmp = atapi_eh_request_sense(qc);
1169 qc->scsicmd->sense_buffer);
1170 if (!tmp) { 1170 if (!tmp) {
1171 /* ATA_QCFLAG_SENSE_VALID is used to 1171 /* ATA_QCFLAG_SENSE_VALID is used to
1172 * tell atapi_qc_complete() that sense 1172 * tell atapi_qc_complete() that sense
@@ -1743,12 +1743,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1743{ 1743{
1744 struct ata_eh_context *ehc = &ap->eh_context; 1744 struct ata_eh_context *ehc = &ap->eh_context;
1745 struct ata_device *dev; 1745 struct ata_device *dev;
1746 unsigned int new_mask = 0;
1746 unsigned long flags; 1747 unsigned long flags;
1747 int i, rc = 0; 1748 int i, rc = 0;
1748 1749
1749 DPRINTK("ENTER\n"); 1750 DPRINTK("ENTER\n");
1750 1751
1751 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1752 /* For PATA drive side cable detection to work, IDENTIFY must
1753 * be done backwards such that PDIAG- is released by the slave
1754 * device before the master device is identified.
1755 */
1756 for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) {
1752 unsigned int action, readid_flags = 0; 1757 unsigned int action, readid_flags = 0;
1753 1758
1754 dev = &ap->device[i]; 1759 dev = &ap->device[i];
@@ -1760,13 +1765,13 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1760 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { 1765 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
1761 if (ata_port_offline(ap)) { 1766 if (ata_port_offline(ap)) {
1762 rc = -EIO; 1767 rc = -EIO;
1763 break; 1768 goto err;
1764 } 1769 }
1765 1770
1766 ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE); 1771 ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE);
1767 rc = ata_dev_revalidate(dev, readid_flags); 1772 rc = ata_dev_revalidate(dev, readid_flags);
1768 if (rc) 1773 if (rc)
1769 break; 1774 goto err;
1770 1775
1771 ata_eh_done(ap, dev, ATA_EH_REVALIDATE); 1776 ata_eh_done(ap, dev, ATA_EH_REVALIDATE);
1772 1777
@@ -1784,40 +1789,53 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1784 1789
1785 rc = ata_dev_read_id(dev, &dev->class, readid_flags, 1790 rc = ata_dev_read_id(dev, &dev->class, readid_flags,
1786 dev->id); 1791 dev->id);
1787 if (rc == 0) { 1792 switch (rc) {
1788 ehc->i.flags |= ATA_EHI_PRINTINFO; 1793 case 0:
1789 rc = ata_dev_configure(dev); 1794 new_mask |= 1 << i;
1790 ehc->i.flags &= ~ATA_EHI_PRINTINFO; 1795 break;
1791 } else if (rc == -ENOENT) { 1796 case -ENOENT:
1792 /* IDENTIFY was issued to non-existent 1797 /* IDENTIFY was issued to non-existent
1793 * device. No need to reset. Just 1798 * device. No need to reset. Just
1794 * thaw and kill the device. 1799 * thaw and kill the device.
1795 */ 1800 */
1796 ata_eh_thaw_port(ap); 1801 ata_eh_thaw_port(ap);
1797 dev->class = ATA_DEV_UNKNOWN; 1802 dev->class = ATA_DEV_UNKNOWN;
1798 rc = 0;
1799 }
1800
1801 if (rc) {
1802 dev->class = ATA_DEV_UNKNOWN;
1803 break; 1803 break;
1804 default:
1805 dev->class = ATA_DEV_UNKNOWN;
1806 goto err;
1804 } 1807 }
1808 }
1809 }
1805 1810
1806 if (ata_dev_enabled(dev)) { 1811 /* Configure new devices forward such that user doesn't see
1807 spin_lock_irqsave(ap->lock, flags); 1812 * device detection messages backwards.
1808 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; 1813 */
1809 spin_unlock_irqrestore(ap->lock, flags); 1814 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1815 dev = &ap->device[i];
1810 1816
1811 /* new device discovered, configure xfermode */ 1817 if (!(new_mask & (1 << i)))
1812 ehc->i.flags |= ATA_EHI_SETMODE; 1818 continue;
1813 } 1819
1814 } 1820 ehc->i.flags |= ATA_EHI_PRINTINFO;
1821 rc = ata_dev_configure(dev);
1822 ehc->i.flags &= ~ATA_EHI_PRINTINFO;
1823 if (rc)
1824 goto err;
1825
1826 spin_lock_irqsave(ap->lock, flags);
1827 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
1828 spin_unlock_irqrestore(ap->lock, flags);
1829
1830 /* new device discovered, configure xfermode */
1831 ehc->i.flags |= ATA_EHI_SETMODE;
1815 } 1832 }
1816 1833
1817 if (rc) 1834 return 0;
1818 *r_failed_dev = dev;
1819 1835
1820 DPRINTK("EXIT\n"); 1836 err:
1837 *r_failed_dev = dev;
1838 DPRINTK("EXIT rc=%d\n", rc);
1821 return rc; 1839 return rc;
1822} 1840}
1823 1841
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 6cc817a10204..e9364434182c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -333,7 +333,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
333 scsi_cmd[8] = args[3]; 333 scsi_cmd[8] = args[3];
334 scsi_cmd[10] = args[4]; 334 scsi_cmd[10] = args[4];
335 scsi_cmd[12] = args[5]; 335 scsi_cmd[12] = args[5];
336 scsi_cmd[13] = args[6] & 0x0f; 336 scsi_cmd[13] = args[6] & 0x4f;
337 scsi_cmd[14] = args[0]; 337 scsi_cmd[14] = args[0];
338 338
339 /* Good values for timeout and retries? Values below 339 /* Good values for timeout and retries? Values below
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index c42671493e8c..1f1e3a51f859 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -56,7 +56,7 @@ extern struct workqueue_struct *ata_aux_wq;
56extern int atapi_enabled; 56extern int atapi_enabled;
57extern int atapi_dmadir; 57extern int atapi_dmadir;
58extern int libata_fua; 58extern int libata_fua;
59extern int noacpi; 59extern int libata_noacpi;
60extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 60extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
61extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 61extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
62 u64 block, u32 n_block, unsigned int tf_flags, 62 u64 block, u32 n_block, unsigned int tf_flags,
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index acdc52cbe38a..0a1493398913 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -195,7 +195,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
195 /* Cases the state machine will not complete correctly without help */ 195 /* Cases the state machine will not complete correctly without help */
196 if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA) 196 if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA)
197 { 197 {
198 len = qc->nbytes; 198 len = qc->nbytes / 2;
199 199
200 if (tf->flags & ATA_TFLAG_WRITE) 200 if (tf->flags & ATA_TFLAG_WRITE)
201 len |= 0x06000000; 201 len |= 0x06000000;
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index f48207865930..8dc3bc4f5863 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -878,6 +878,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
878 struct ata_port_info *port; 878 struct ata_port_info *port;
879 struct pci_dev *host = NULL; 879 struct pci_dev *host = NULL;
880 struct sis_chipset *chipset = NULL; 880 struct sis_chipset *chipset = NULL;
881 struct sis_chipset *sets;
881 882
882 static struct sis_chipset sis_chipsets[] = { 883 static struct sis_chipset sis_chipsets[] = {
883 884
@@ -932,10 +933,11 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
932 933
933 /* We have to find the bridge first */ 934 /* We have to find the bridge first */
934 935
935 for (chipset = &sis_chipsets[0]; chipset->device; chipset++) { 936 for (sets = &sis_chipsets[0]; sets->device; sets++) {
936 host = pci_get_device(PCI_VENDOR_ID_SI, chipset->device, NULL); 937 host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);
937 if (host != NULL) { 938 if (host != NULL) {
938 if (chipset->device == 0x630) { /* SIS630 */ 939 chipset = sets; /* Match found */
940 if (sets->device == 0x630) { /* SIS630 */
939 u8 host_rev; 941 u8 host_rev;
940 pci_read_config_byte(host, PCI_REVISION_ID, &host_rev); 942 pci_read_config_byte(host, PCI_REVISION_ID, &host_rev);
941 if (host_rev >= 0x30) /* 630 ET */ 943 if (host_rev >= 0x30) /* 630 ET */
@@ -946,7 +948,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
946 } 948 }
947 949
948 /* Look for concealed bridges */ 950 /* Look for concealed bridges */
949 if (host == NULL) { 951 if (chipset == NULL) {
950 /* Second check */ 952 /* Second check */
951 u32 idemisc; 953 u32 idemisc;
952 u16 trueid; 954 u16 trueid;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index ad0f4a2f25c4..d7fcf823a42a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -28,20 +28,6 @@ int (*platform_notify)(struct device * dev) = NULL;
28int (*platform_notify_remove)(struct device * dev) = NULL; 28int (*platform_notify_remove)(struct device * dev) = NULL;
29 29
30/* 30/*
31 * Detect the LANANA-assigned LOCAL/EXPERIMENTAL majors
32 */
33bool is_lanana_major(unsigned int major)
34{
35 if (major >= 60 && major <= 63)
36 return 1;
37 if (major >= 120 && major <= 127)
38 return 1;
39 if (major >= 240 && major <= 254)
40 return 1;
41 return 0;
42}
43
44/*
45 * sysfs bindings for devices. 31 * sysfs bindings for devices.
46 */ 32 */
47 33
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1214cbd17d86..082bfded3854 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -183,7 +183,14 @@ int driver_register(struct device_driver * drv)
183void driver_unregister(struct device_driver * drv) 183void driver_unregister(struct device_driver * drv)
184{ 184{
185 bus_remove_driver(drv); 185 bus_remove_driver(drv);
186 wait_for_completion(&drv->unloaded); 186 /*
187 * If the driver is a module, we are probably in
188 * the module unload path, and we want to wait
189 * for everything to unload before we can actually
190 * finish the unload.
191 */
192 if (drv->owner)
193 wait_for_completion(&drv->unloaded);
187} 194}
188 195
189/** 196/**
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index fdfa3d0cf6af..bbbb973a9d3c 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -54,7 +54,8 @@ int device_pm_add(struct device * dev)
54 int error; 54 int error;
55 55
56 pr_debug("PM: Adding info for %s:%s\n", 56 pr_debug("PM: Adding info for %s:%s\n",
57 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 57 dev->bus ? dev->bus->name : "No Bus",
58 kobject_name(&dev->kobj));
58 down(&dpm_list_sem); 59 down(&dpm_list_sem);
59 list_add_tail(&dev->power.entry, &dpm_active); 60 list_add_tail(&dev->power.entry, &dpm_active);
60 device_pm_set_parent(dev, dev->parent); 61 device_pm_set_parent(dev, dev->parent);
@@ -67,7 +68,8 @@ int device_pm_add(struct device * dev)
67void device_pm_remove(struct device * dev) 68void device_pm_remove(struct device * dev)
68{ 69{
69 pr_debug("PM: Removing info for %s:%s\n", 70 pr_debug("PM: Removing info for %s:%s\n",
70 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 71 dev->bus ? dev->bus->name : "No Bus",
72 kobject_name(&dev->kobj));
71 down(&dpm_list_sem); 73 down(&dpm_list_sem);
72 dpm_sysfs_remove(dev); 74 dpm_sysfs_remove(dev);
73 put_device(dev->power.pm_parent); 75 put_device(dev->power.pm_parent);
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 072e18e6d76d..65a725cd3422 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1915,6 +1915,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1915 "does not support reading geometry\n"); 1915 "does not support reading geometry\n");
1916 drv->heads = 255; 1916 drv->heads = 255;
1917 drv->sectors = 32; // Sectors per track 1917 drv->sectors = 32; // Sectors per track
1918 drv->cylinders = total_size + 1;
1918 drv->raid_level = RAID_UNKNOWN; 1919 drv->raid_level = RAID_UNKNOWN;
1919 } else { 1920 } else {
1920 drv->heads = inq_buff->data_byte[6]; 1921 drv->heads = inq_buff->data_byte[6];
@@ -3422,6 +3423,25 @@ static void cciss_remove_one(struct pci_dev *pdev)
3422 "already be removed \n"); 3423 "already be removed \n");
3423 return; 3424 return;
3424 } 3425 }
3426
3427 remove_proc_entry(hba[i]->devname, proc_cciss);
3428 unregister_blkdev(hba[i]->major, hba[i]->devname);
3429
3430 /* remove it from the disk list */
3431 for (j = 0; j < CISS_MAX_LUN; j++) {
3432 struct gendisk *disk = hba[i]->gendisk[j];
3433 if (disk) {
3434 request_queue_t *q = disk->queue;
3435
3436 if (disk->flags & GENHD_FL_UP)
3437 del_gendisk(disk);
3438 if (q)
3439 blk_cleanup_queue(q);
3440 }
3441 }
3442
3443 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3444
3425 /* Turn board interrupts off and send the flush cache command */ 3445 /* Turn board interrupts off and send the flush cache command */
3426 /* sendcmd will turn off interrupt, and send the flush... 3446 /* sendcmd will turn off interrupt, and send the flush...
3427 * To write all data in the battery backed cache to disks */ 3447 * To write all data in the battery backed cache to disks */
@@ -3443,22 +3463,6 @@ static void cciss_remove_one(struct pci_dev *pdev)
3443#endif /* CONFIG_PCI_MSI */ 3463#endif /* CONFIG_PCI_MSI */
3444 3464
3445 iounmap(hba[i]->vaddr); 3465 iounmap(hba[i]->vaddr);
3446 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3447 unregister_blkdev(hba[i]->major, hba[i]->devname);
3448 remove_proc_entry(hba[i]->devname, proc_cciss);
3449
3450 /* remove it from the disk list */
3451 for (j = 0; j < CISS_MAX_LUN; j++) {
3452 struct gendisk *disk = hba[i]->gendisk[j];
3453 if (disk) {
3454 request_queue_t *q = disk->queue;
3455
3456 if (disk->flags & GENHD_FL_UP)
3457 del_gendisk(disk);
3458 if (q)
3459 blk_cleanup_queue(q);
3460 }
3461 }
3462 3466
3463 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct), 3467 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct),
3464 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3468 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index c852eed91e4b..1eeb8f2cde71 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -140,7 +140,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
140#include <linux/blkdev.h> 140#include <linux/blkdev.h>
141#include <asm/uaccess.h> 141#include <asm/uaccess.h>
142 142
143static spinlock_t pcd_lock; 143static DEFINE_SPINLOCK(pcd_lock);
144 144
145module_param(verbose, bool, 0644); 145module_param(verbose, bool, 0644);
146module_param(major, int, 0); 146module_param(major, int, 0);
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 7cdaa1951260..5826508f6731 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -154,7 +154,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY};
154#include <linux/blkpg.h> 154#include <linux/blkpg.h>
155#include <asm/uaccess.h> 155#include <asm/uaccess.h>
156 156
157static spinlock_t pf_spin_lock; 157static DEFINE_SPINLOCK(pf_spin_lock);
158 158
159module_param(verbose, bool, 0644); 159module_param(verbose, bool, 0644);
160module_param(major, int, 0); 160module_param(major, int, 0);
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index a4fb70383188..f1b9dd7d47d6 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -777,7 +777,8 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
777 rq->cmd_flags |= REQ_QUIET; 777 rq->cmd_flags |= REQ_QUIET;
778 778
779 blk_execute_rq(rq->q, pd->bdev->bd_disk, rq, 0); 779 blk_execute_rq(rq->q, pd->bdev->bd_disk, rq, 0);
780 ret = rq->errors; 780 if (rq->errors)
781 ret = -EIO;
781out: 782out:
782 blk_put_request(rq); 783 blk_put_request(rq);
783 return ret; 784 return ret;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 3429ece4ef92..d0c978fbc204 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -386,6 +386,39 @@ config AU1000_SERIAL_CONSOLE
386 If you have an Alchemy AU1000 processor (MIPS based) and you want 386 If you have an Alchemy AU1000 processor (MIPS based) and you want
387 to use a console on a serial port, say Y. Otherwise, say N. 387 to use a console on a serial port, say Y. Otherwise, say N.
388 388
389config SERIAL_DEC
390 bool "DECstation serial support"
391 depends on MACH_DECSTATION
392 default y
393 help
394 This selects whether you want to be asked about drivers for
395 DECstation serial ports.
396
397 Note that the answer to this question won't directly affect the
398 kernel: saying N will just cause the configurator to skip all
399 the questions about DECstation serial ports.
400
401config SERIAL_DEC_CONSOLE
402 bool "Support for console on a DECstation serial port"
403 depends on SERIAL_DEC
404 default y
405 help
406 If you say Y here, it will be possible to use a serial port as the
407 system console (the system console is the device which receives all
408 kernel messages and warnings and which allows logins in single user
409 mode). Note that the firmware uses ttyS0 as the serial console on
410 the Maxine and ttyS2 on the others.
411
412 If unsure, say Y.
413
414config ZS
415 bool "Z85C30 Serial Support"
416 depends on SERIAL_DEC
417 default y
418 help
419 Documentation on the Zilog 85C350 serial communications controller
420 is downloadable at <http://www.zilog.com/pdfs/serial/z85c30.pdf>
421
389config A2232 422config A2232
390 tristate "Commodore A2232 serial support (EXPERIMENTAL)" 423 tristate "Commodore A2232 serial support (EXPERIMENTAL)"
391 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP 424 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index e542a628f1c7..55392a45a14b 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -18,11 +18,14 @@
18#define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992 18#define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
19#define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0 19#define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
21 23
22#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 24#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
23 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ 25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
24 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ 26 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) 27 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
28 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB)
26 29
27 30
28extern int agp_memory_reserved; 31extern int agp_memory_reserved;
@@ -428,9 +431,8 @@ static void intel_i830_init_gtt_entries(void)
428 431
429 if (IS_I965) { 432 if (IS_I965) {
430 u32 pgetbl_ctl; 433 u32 pgetbl_ctl;
434 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL);
431 435
432 pci_read_config_dword(agp_bridge->dev, I810_PGETBL_CTL,
433 &pgetbl_ctl);
434 /* The 965 has a field telling us the size of the GTT, 436 /* The 965 has a field telling us the size of the GTT,
435 * which may be larger than what is necessary to map the 437 * which may be larger than what is necessary to map the
436 * aperture. 438 * aperture.
@@ -1921,7 +1923,13 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1921 bridge->driver = &intel_845_driver; 1923 bridge->driver = &intel_845_driver;
1922 name = "965G"; 1924 name = "965G";
1923 break; 1925 break;
1924 1926 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1927 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1928 bridge->driver = &intel_i965_driver;
1929 else
1930 bridge->driver = &intel_845_driver;
1931 name = "965GM";
1932 break;
1925 case PCI_DEVICE_ID_INTEL_7505_0: 1933 case PCI_DEVICE_ID_INTEL_7505_0:
1926 bridge->driver = &intel_7505_driver; 1934 bridge->driver = &intel_7505_driver;
1927 name = "E7505"; 1935 name = "E7505";
@@ -2080,6 +2088,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
2080 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB), 2088 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
2081 ID(PCI_DEVICE_ID_INTEL_82965Q_HB), 2089 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2082 ID(PCI_DEVICE_ID_INTEL_82965G_HB), 2090 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2091 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2083 { } 2092 { }
2084}; 2093};
2085 2094
diff --git a/drivers/char/drm/Makefile b/drivers/char/drm/Makefile
index 3ad0f648c6b2..6915a0599dfb 100644
--- a/drivers/char/drm/Makefile
+++ b/drivers/char/drm/Makefile
@@ -15,7 +15,6 @@ i810-objs := i810_drv.o i810_dma.o
15i830-objs := i830_drv.o i830_dma.o i830_irq.o 15i830-objs := i830_drv.o i830_dma.o i830_irq.o
16i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o 16i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o
17radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o r300_cmdbuf.o 17radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o r300_cmdbuf.o
18ffb-objs := ffb_drv.o ffb_context.o
19sis-objs := sis_drv.o sis_mm.o 18sis-objs := sis_drv.o sis_mm.o
20savage-objs := savage_drv.o savage_bci.o savage_state.o 19savage-objs := savage_drv.o savage_bci.o savage_state.o
21via-objs := via_irq.o via_drv.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o via_dmablit.o 20via-objs := via_irq.o via_drv.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o via_dmablit.o
@@ -36,7 +35,6 @@ obj-$(CONFIG_DRM_MGA) += mga.o
36obj-$(CONFIG_DRM_I810) += i810.o 35obj-$(CONFIG_DRM_I810) += i810.o
37obj-$(CONFIG_DRM_I830) += i830.o 36obj-$(CONFIG_DRM_I830) += i830.o
38obj-$(CONFIG_DRM_I915) += i915.o 37obj-$(CONFIG_DRM_I915) += i915.o
39obj-$(CONFIG_DRM_FFB) += ffb.o
40obj-$(CONFIG_DRM_SIS) += sis.o 38obj-$(CONFIG_DRM_SIS) += sis.o
41obj-$(CONFIG_DRM_SAVAGE)+= savage.o 39obj-$(CONFIG_DRM_SAVAGE)+= savage.o
42obj-$(CONFIG_DRM_VIA) +=via.o 40obj-$(CONFIG_DRM_VIA) +=via.o
diff --git a/drivers/char/drm/ffb_context.c b/drivers/char/drm/ffb_context.c
deleted file mode 100644
index ac9ab40d57aa..000000000000
--- a/drivers/char/drm/ffb_context.c
+++ /dev/null
@@ -1,544 +0,0 @@
1/* $Id: ffb_context.c,v 1.5 2001/08/09 17:47:51 davem Exp $
2 * ffb_context.c: Creator/Creator3D DRI/DRM context switching.
3 *
4 * Copyright (C) 2000 David S. Miller (davem@redhat.com)
5 *
6 * Almost entirely stolen from tdfx_context.c, see there
7 * for authors.
8 */
9
10#include <asm/upa.h>
11
12#include "ffb.h"
13#include "drmP.h"
14
15#include "ffb_drv.h"
16
17static int DRM(alloc_queue) (drm_device_t * dev, int is_2d_only) {
18 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
19 int i;
20
21 for (i = 0; i < FFB_MAX_CTXS; i++) {
22 if (fpriv->hw_state[i] == NULL)
23 break;
24 }
25 if (i == FFB_MAX_CTXS)
26 return -1;
27
28 fpriv->hw_state[i] = kmalloc(sizeof(struct ffb_hw_context), GFP_KERNEL);
29 if (fpriv->hw_state[i] == NULL)
30 return -1;
31
32 fpriv->hw_state[i]->is_2d_only = is_2d_only;
33
34 /* Plus one because 0 is the special DRM_KERNEL_CONTEXT. */
35 return i + 1;
36}
37
38static void ffb_save_context(ffb_dev_priv_t * fpriv, int idx)
39{
40 ffb_fbcPtr ffb = fpriv->regs;
41 struct ffb_hw_context *ctx;
42 int i;
43
44 ctx = fpriv->hw_state[idx - 1];
45 if (idx == 0 || ctx == NULL)
46 return;
47
48 if (ctx->is_2d_only) {
49 /* 2D applications only care about certain pieces
50 * of state.
51 */
52 ctx->drawop = upa_readl(&ffb->drawop);
53 ctx->ppc = upa_readl(&ffb->ppc);
54 ctx->wid = upa_readl(&ffb->wid);
55 ctx->fg = upa_readl(&ffb->fg);
56 ctx->bg = upa_readl(&ffb->bg);
57 ctx->xclip = upa_readl(&ffb->xclip);
58 ctx->fbc = upa_readl(&ffb->fbc);
59 ctx->rop = upa_readl(&ffb->rop);
60 ctx->cmp = upa_readl(&ffb->cmp);
61 ctx->matchab = upa_readl(&ffb->matchab);
62 ctx->magnab = upa_readl(&ffb->magnab);
63 ctx->pmask = upa_readl(&ffb->pmask);
64 ctx->xpmask = upa_readl(&ffb->xpmask);
65 ctx->lpat = upa_readl(&ffb->lpat);
66 ctx->fontxy = upa_readl(&ffb->fontxy);
67 ctx->fontw = upa_readl(&ffb->fontw);
68 ctx->fontinc = upa_readl(&ffb->fontinc);
69
70 /* stencil/stencilctl only exists on FFB2+ and later
71 * due to the introduction of 3DRAM-III.
72 */
73 if (fpriv->ffb_type == ffb2_vertical_plus ||
74 fpriv->ffb_type == ffb2_horizontal_plus) {
75 ctx->stencil = upa_readl(&ffb->stencil);
76 ctx->stencilctl = upa_readl(&ffb->stencilctl);
77 }
78
79 for (i = 0; i < 32; i++)
80 ctx->area_pattern[i] = upa_readl(&ffb->pattern[i]);
81 ctx->ucsr = upa_readl(&ffb->ucsr);
82 return;
83 }
84
85 /* Fetch drawop. */
86 ctx->drawop = upa_readl(&ffb->drawop);
87
88 /* If we were saving the vertex registers, this is where
89 * we would do it. We would save 32 32-bit words starting
90 * at ffb->suvtx.
91 */
92
93 /* Capture rendering attributes. */
94
95 ctx->ppc = upa_readl(&ffb->ppc); /* Pixel Processor Control */
96 ctx->wid = upa_readl(&ffb->wid); /* Current WID */
97 ctx->fg = upa_readl(&ffb->fg); /* Constant FG color */
98 ctx->bg = upa_readl(&ffb->bg); /* Constant BG color */
99 ctx->consty = upa_readl(&ffb->consty); /* Constant Y */
100 ctx->constz = upa_readl(&ffb->constz); /* Constant Z */
101 ctx->xclip = upa_readl(&ffb->xclip); /* X plane clip */
102 ctx->dcss = upa_readl(&ffb->dcss); /* Depth Cue Scale Slope */
103 ctx->vclipmin = upa_readl(&ffb->vclipmin); /* Primary XY clip, minimum */
104 ctx->vclipmax = upa_readl(&ffb->vclipmax); /* Primary XY clip, maximum */
105 ctx->vclipzmin = upa_readl(&ffb->vclipzmin); /* Primary Z clip, minimum */
106 ctx->vclipzmax = upa_readl(&ffb->vclipzmax); /* Primary Z clip, maximum */
107 ctx->dcsf = upa_readl(&ffb->dcsf); /* Depth Cue Scale Front Bound */
108 ctx->dcsb = upa_readl(&ffb->dcsb); /* Depth Cue Scale Back Bound */
109 ctx->dczf = upa_readl(&ffb->dczf); /* Depth Cue Scale Z Front */
110 ctx->dczb = upa_readl(&ffb->dczb); /* Depth Cue Scale Z Back */
111 ctx->blendc = upa_readl(&ffb->blendc); /* Alpha Blend Control */
112 ctx->blendc1 = upa_readl(&ffb->blendc1); /* Alpha Blend Color 1 */
113 ctx->blendc2 = upa_readl(&ffb->blendc2); /* Alpha Blend Color 2 */
114 ctx->fbc = upa_readl(&ffb->fbc); /* Frame Buffer Control */
115 ctx->rop = upa_readl(&ffb->rop); /* Raster Operation */
116 ctx->cmp = upa_readl(&ffb->cmp); /* Compare Controls */
117 ctx->matchab = upa_readl(&ffb->matchab); /* Buffer A/B Match Ops */
118 ctx->matchc = upa_readl(&ffb->matchc); /* Buffer C Match Ops */
119 ctx->magnab = upa_readl(&ffb->magnab); /* Buffer A/B Magnitude Ops */
120 ctx->magnc = upa_readl(&ffb->magnc); /* Buffer C Magnitude Ops */
121 ctx->pmask = upa_readl(&ffb->pmask); /* RGB Plane Mask */
122 ctx->xpmask = upa_readl(&ffb->xpmask); /* X Plane Mask */
123 ctx->ypmask = upa_readl(&ffb->ypmask); /* Y Plane Mask */
124 ctx->zpmask = upa_readl(&ffb->zpmask); /* Z Plane Mask */
125
126 /* Auxiliary Clips. */
127 ctx->auxclip0min = upa_readl(&ffb->auxclip[0].min);
128 ctx->auxclip0max = upa_readl(&ffb->auxclip[0].max);
129 ctx->auxclip1min = upa_readl(&ffb->auxclip[1].min);
130 ctx->auxclip1max = upa_readl(&ffb->auxclip[1].max);
131 ctx->auxclip2min = upa_readl(&ffb->auxclip[2].min);
132 ctx->auxclip2max = upa_readl(&ffb->auxclip[2].max);
133 ctx->auxclip3min = upa_readl(&ffb->auxclip[3].min);
134 ctx->auxclip3max = upa_readl(&ffb->auxclip[3].max);
135
136 ctx->lpat = upa_readl(&ffb->lpat); /* Line Pattern */
137 ctx->fontxy = upa_readl(&ffb->fontxy); /* XY Font Coordinate */
138 ctx->fontw = upa_readl(&ffb->fontw); /* Font Width */
139 ctx->fontinc = upa_readl(&ffb->fontinc); /* Font X/Y Increment */
140
141 /* These registers/features only exist on FFB2 and later chips. */
142 if (fpriv->ffb_type >= ffb2_prototype) {
143 ctx->dcss1 = upa_readl(&ffb->dcss1); /* Depth Cue Scale Slope 1 */
144 ctx->dcss2 = upa_readl(&ffb->dcss2); /* Depth Cue Scale Slope 2 */
145 ctx->dcss2 = upa_readl(&ffb->dcss3); /* Depth Cue Scale Slope 3 */
146 ctx->dcs2 = upa_readl(&ffb->dcs2); /* Depth Cue Scale 2 */
147 ctx->dcs3 = upa_readl(&ffb->dcs3); /* Depth Cue Scale 3 */
148 ctx->dcs4 = upa_readl(&ffb->dcs4); /* Depth Cue Scale 4 */
149 ctx->dcd2 = upa_readl(&ffb->dcd2); /* Depth Cue Depth 2 */
150 ctx->dcd3 = upa_readl(&ffb->dcd3); /* Depth Cue Depth 3 */
151 ctx->dcd4 = upa_readl(&ffb->dcd4); /* Depth Cue Depth 4 */
152
153 /* And stencil/stencilctl only exists on FFB2+ and later
154 * due to the introduction of 3DRAM-III.
155 */
156 if (fpriv->ffb_type == ffb2_vertical_plus ||
157 fpriv->ffb_type == ffb2_horizontal_plus) {
158 ctx->stencil = upa_readl(&ffb->stencil);
159 ctx->stencilctl = upa_readl(&ffb->stencilctl);
160 }
161 }
162
163 /* Save the 32x32 area pattern. */
164 for (i = 0; i < 32; i++)
165 ctx->area_pattern[i] = upa_readl(&ffb->pattern[i]);
166
167 /* Finally, stash away the User Constol/Status Register. */
168 ctx->ucsr = upa_readl(&ffb->ucsr);
169}
170
171static void ffb_restore_context(ffb_dev_priv_t * fpriv, int old, int idx)
172{
173 ffb_fbcPtr ffb = fpriv->regs;
174 struct ffb_hw_context *ctx;
175 int i;
176
177 ctx = fpriv->hw_state[idx - 1];
178 if (idx == 0 || ctx == NULL)
179 return;
180
181 if (ctx->is_2d_only) {
182 /* 2D applications only care about certain pieces
183 * of state.
184 */
185 upa_writel(ctx->drawop, &ffb->drawop);
186
187 /* If we were restoring the vertex registers, this is where
188 * we would do it. We would restore 32 32-bit words starting
189 * at ffb->suvtx.
190 */
191
192 upa_writel(ctx->ppc, &ffb->ppc);
193 upa_writel(ctx->wid, &ffb->wid);
194 upa_writel(ctx->fg, &ffb->fg);
195 upa_writel(ctx->bg, &ffb->bg);
196 upa_writel(ctx->xclip, &ffb->xclip);
197 upa_writel(ctx->fbc, &ffb->fbc);
198 upa_writel(ctx->rop, &ffb->rop);
199 upa_writel(ctx->cmp, &ffb->cmp);
200 upa_writel(ctx->matchab, &ffb->matchab);
201 upa_writel(ctx->magnab, &ffb->magnab);
202 upa_writel(ctx->pmask, &ffb->pmask);
203 upa_writel(ctx->xpmask, &ffb->xpmask);
204 upa_writel(ctx->lpat, &ffb->lpat);
205 upa_writel(ctx->fontxy, &ffb->fontxy);
206 upa_writel(ctx->fontw, &ffb->fontw);
207 upa_writel(ctx->fontinc, &ffb->fontinc);
208
209 /* stencil/stencilctl only exists on FFB2+ and later
210 * due to the introduction of 3DRAM-III.
211 */
212 if (fpriv->ffb_type == ffb2_vertical_plus ||
213 fpriv->ffb_type == ffb2_horizontal_plus) {
214 upa_writel(ctx->stencil, &ffb->stencil);
215 upa_writel(ctx->stencilctl, &ffb->stencilctl);
216 upa_writel(0x80000000, &ffb->fbc);
217 upa_writel((ctx->stencilctl | 0x80000),
218 &ffb->rawstencilctl);
219 upa_writel(ctx->fbc, &ffb->fbc);
220 }
221
222 for (i = 0; i < 32; i++)
223 upa_writel(ctx->area_pattern[i], &ffb->pattern[i]);
224 upa_writel((ctx->ucsr & 0xf0000), &ffb->ucsr);
225 return;
226 }
227
228 /* Restore drawop. */
229 upa_writel(ctx->drawop, &ffb->drawop);
230
231 /* If we were restoring the vertex registers, this is where
232 * we would do it. We would restore 32 32-bit words starting
233 * at ffb->suvtx.
234 */
235
236 /* Restore rendering attributes. */
237
238 upa_writel(ctx->ppc, &ffb->ppc); /* Pixel Processor Control */
239 upa_writel(ctx->wid, &ffb->wid); /* Current WID */
240 upa_writel(ctx->fg, &ffb->fg); /* Constant FG color */
241 upa_writel(ctx->bg, &ffb->bg); /* Constant BG color */
242 upa_writel(ctx->consty, &ffb->consty); /* Constant Y */
243 upa_writel(ctx->constz, &ffb->constz); /* Constant Z */
244 upa_writel(ctx->xclip, &ffb->xclip); /* X plane clip */
245 upa_writel(ctx->dcss, &ffb->dcss); /* Depth Cue Scale Slope */
246 upa_writel(ctx->vclipmin, &ffb->vclipmin); /* Primary XY clip, minimum */
247 upa_writel(ctx->vclipmax, &ffb->vclipmax); /* Primary XY clip, maximum */
248 upa_writel(ctx->vclipzmin, &ffb->vclipzmin); /* Primary Z clip, minimum */
249 upa_writel(ctx->vclipzmax, &ffb->vclipzmax); /* Primary Z clip, maximum */
250 upa_writel(ctx->dcsf, &ffb->dcsf); /* Depth Cue Scale Front Bound */
251 upa_writel(ctx->dcsb, &ffb->dcsb); /* Depth Cue Scale Back Bound */
252 upa_writel(ctx->dczf, &ffb->dczf); /* Depth Cue Scale Z Front */
253 upa_writel(ctx->dczb, &ffb->dczb); /* Depth Cue Scale Z Back */
254 upa_writel(ctx->blendc, &ffb->blendc); /* Alpha Blend Control */
255 upa_writel(ctx->blendc1, &ffb->blendc1); /* Alpha Blend Color 1 */
256 upa_writel(ctx->blendc2, &ffb->blendc2); /* Alpha Blend Color 2 */
257 upa_writel(ctx->fbc, &ffb->fbc); /* Frame Buffer Control */
258 upa_writel(ctx->rop, &ffb->rop); /* Raster Operation */
259 upa_writel(ctx->cmp, &ffb->cmp); /* Compare Controls */
260 upa_writel(ctx->matchab, &ffb->matchab); /* Buffer A/B Match Ops */
261 upa_writel(ctx->matchc, &ffb->matchc); /* Buffer C Match Ops */
262 upa_writel(ctx->magnab, &ffb->magnab); /* Buffer A/B Magnitude Ops */
263 upa_writel(ctx->magnc, &ffb->magnc); /* Buffer C Magnitude Ops */
264 upa_writel(ctx->pmask, &ffb->pmask); /* RGB Plane Mask */
265 upa_writel(ctx->xpmask, &ffb->xpmask); /* X Plane Mask */
266 upa_writel(ctx->ypmask, &ffb->ypmask); /* Y Plane Mask */
267 upa_writel(ctx->zpmask, &ffb->zpmask); /* Z Plane Mask */
268
269 /* Auxiliary Clips. */
270 upa_writel(ctx->auxclip0min, &ffb->auxclip[0].min);
271 upa_writel(ctx->auxclip0max, &ffb->auxclip[0].max);
272 upa_writel(ctx->auxclip1min, &ffb->auxclip[1].min);
273 upa_writel(ctx->auxclip1max, &ffb->auxclip[1].max);
274 upa_writel(ctx->auxclip2min, &ffb->auxclip[2].min);
275 upa_writel(ctx->auxclip2max, &ffb->auxclip[2].max);
276 upa_writel(ctx->auxclip3min, &ffb->auxclip[3].min);
277 upa_writel(ctx->auxclip3max, &ffb->auxclip[3].max);
278
279 upa_writel(ctx->lpat, &ffb->lpat); /* Line Pattern */
280 upa_writel(ctx->fontxy, &ffb->fontxy); /* XY Font Coordinate */
281 upa_writel(ctx->fontw, &ffb->fontw); /* Font Width */
282 upa_writel(ctx->fontinc, &ffb->fontinc); /* Font X/Y Increment */
283
284 /* These registers/features only exist on FFB2 and later chips. */
285 if (fpriv->ffb_type >= ffb2_prototype) {
286 upa_writel(ctx->dcss1, &ffb->dcss1); /* Depth Cue Scale Slope 1 */
287 upa_writel(ctx->dcss2, &ffb->dcss2); /* Depth Cue Scale Slope 2 */
288 upa_writel(ctx->dcss3, &ffb->dcss2); /* Depth Cue Scale Slope 3 */
289 upa_writel(ctx->dcs2, &ffb->dcs2); /* Depth Cue Scale 2 */
290 upa_writel(ctx->dcs3, &ffb->dcs3); /* Depth Cue Scale 3 */
291 upa_writel(ctx->dcs4, &ffb->dcs4); /* Depth Cue Scale 4 */
292 upa_writel(ctx->dcd2, &ffb->dcd2); /* Depth Cue Depth 2 */
293 upa_writel(ctx->dcd3, &ffb->dcd3); /* Depth Cue Depth 3 */
294 upa_writel(ctx->dcd4, &ffb->dcd4); /* Depth Cue Depth 4 */
295
296 /* And stencil/stencilctl only exists on FFB2+ and later
297 * due to the introduction of 3DRAM-III.
298 */
299 if (fpriv->ffb_type == ffb2_vertical_plus ||
300 fpriv->ffb_type == ffb2_horizontal_plus) {
301 /* Unfortunately, there is a hardware bug on
302 * the FFB2+ chips which prevents a normal write
303 * to the stencil control register from working
304 * as it should.
305 *
306 * The state controlled by the FFB stencilctl register
307 * really gets transferred to the per-buffer instances
308 * of the stencilctl register in the 3DRAM chips.
309 *
310 * The bug is that FFB does not update buffer C correctly,
311 * so we have to do it by hand for them.
312 */
313
314 /* This will update buffers A and B. */
315 upa_writel(ctx->stencil, &ffb->stencil);
316 upa_writel(ctx->stencilctl, &ffb->stencilctl);
317
318 /* Force FFB to use buffer C 3dram regs. */
319 upa_writel(0x80000000, &ffb->fbc);
320 upa_writel((ctx->stencilctl | 0x80000),
321 &ffb->rawstencilctl);
322
323 /* Now restore the correct FBC controls. */
324 upa_writel(ctx->fbc, &ffb->fbc);
325 }
326 }
327
328 /* Restore the 32x32 area pattern. */
329 for (i = 0; i < 32; i++)
330 upa_writel(ctx->area_pattern[i], &ffb->pattern[i]);
331
332 /* Finally, stash away the User Constol/Status Register.
333 * The only state we really preserve here is the picking
334 * control.
335 */
336 upa_writel((ctx->ucsr & 0xf0000), &ffb->ucsr);
337}
338
339#define FFB_UCSR_FB_BUSY 0x01000000
340#define FFB_UCSR_RP_BUSY 0x02000000
341#define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
342
343static void FFBWait(ffb_fbcPtr ffb)
344{
345 int limit = 100000;
346
347 do {
348 u32 regval = upa_readl(&ffb->ucsr);
349
350 if ((regval & FFB_UCSR_ALL_BUSY) == 0)
351 break;
352 } while (--limit);
353}
354
355int ffb_driver_context_switch(drm_device_t * dev, int old, int new)
356{
357 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
358
359#ifdef DRM_DMA_HISTOGRAM
360 dev->ctx_start = get_cycles();
361#endif
362
363 DRM_DEBUG("Context switch from %d to %d\n", old, new);
364
365 if (new == dev->last_context || dev->last_context == 0) {
366 dev->last_context = new;
367 return 0;
368 }
369
370 FFBWait(fpriv->regs);
371 ffb_save_context(fpriv, old);
372 ffb_restore_context(fpriv, old, new);
373 FFBWait(fpriv->regs);
374
375 dev->last_context = new;
376
377 return 0;
378}
379
380int ffb_driver_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
381 unsigned long arg)
382{
383 drm_ctx_res_t res;
384 drm_ctx_t ctx;
385 int i;
386
387 DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
388 if (copy_from_user(&res, (drm_ctx_res_t __user *) arg, sizeof(res)))
389 return -EFAULT;
390 if (res.count >= DRM_RESERVED_CONTEXTS) {
391 memset(&ctx, 0, sizeof(ctx));
392 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
393 ctx.handle = i;
394 if (copy_to_user(&res.contexts[i], &i, sizeof(i)))
395 return -EFAULT;
396 }
397 }
398 res.count = DRM_RESERVED_CONTEXTS;
399 if (copy_to_user((drm_ctx_res_t __user *) arg, &res, sizeof(res)))
400 return -EFAULT;
401 return 0;
402}
403
404int ffb_driver_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
405 unsigned long arg)
406{
407 drm_file_t *priv = filp->private_data;
408 drm_device_t *dev = priv->dev;
409 drm_ctx_t ctx;
410 int idx;
411
412 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
413 return -EFAULT;
414 idx = DRM(alloc_queue) (dev, (ctx.flags & _DRM_CONTEXT_2DONLY));
415 if (idx < 0)
416 return -ENFILE;
417
418 DRM_DEBUG("%d\n", ctx.handle);
419 ctx.handle = idx;
420 if (copy_to_user((drm_ctx_t __user *) arg, &ctx, sizeof(ctx)))
421 return -EFAULT;
422 return 0;
423}
424
425int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
426 unsigned long arg)
427{
428 drm_file_t *priv = filp->private_data;
429 drm_device_t *dev = priv->dev;
430 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
431 struct ffb_hw_context *hwctx;
432 drm_ctx_t ctx;
433 int idx;
434
435 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
436 return -EFAULT;
437
438 idx = ctx.handle;
439 if (idx <= 0 || idx >= FFB_MAX_CTXS)
440 return -EINVAL;
441
442 hwctx = fpriv->hw_state[idx - 1];
443 if (hwctx == NULL)
444 return -EINVAL;
445
446 if ((ctx.flags & _DRM_CONTEXT_2DONLY) == 0)
447 hwctx->is_2d_only = 0;
448 else
449 hwctx->is_2d_only = 1;
450
451 return 0;
452}
453
454int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
455 unsigned long arg)
456{
457 drm_file_t *priv = filp->private_data;
458 drm_device_t *dev = priv->dev;
459 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
460 struct ffb_hw_context *hwctx;
461 drm_ctx_t ctx;
462 int idx;
463
464 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
465 return -EFAULT;
466
467 idx = ctx.handle;
468 if (idx <= 0 || idx >= FFB_MAX_CTXS)
469 return -EINVAL;
470
471 hwctx = fpriv->hw_state[idx - 1];
472 if (hwctx == NULL)
473 return -EINVAL;
474
475 if (hwctx->is_2d_only != 0)
476 ctx.flags = _DRM_CONTEXT_2DONLY;
477 else
478 ctx.flags = 0;
479
480 if (copy_to_user((drm_ctx_t __user *) arg, &ctx, sizeof(ctx)))
481 return -EFAULT;
482
483 return 0;
484}
485
486int ffb_driver_switchctx(struct inode *inode, struct file *filp,
487 unsigned int cmd, unsigned long arg)
488{
489 drm_file_t *priv = filp->private_data;
490 drm_device_t *dev = priv->dev;
491 drm_ctx_t ctx;
492
493 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
494 return -EFAULT;
495 DRM_DEBUG("%d\n", ctx.handle);
496 return ffb_driver_context_switch(dev, dev->last_context, ctx.handle);
497}
498
499int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
500 unsigned long arg)
501{
502 drm_ctx_t ctx;
503
504 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
505 return -EFAULT;
506 DRM_DEBUG("%d\n", ctx.handle);
507
508 return 0;
509}
510
511int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
512 unsigned long arg)
513{
514 drm_ctx_t ctx;
515 drm_file_t *priv = filp->private_data;
516 drm_device_t *dev = priv->dev;
517 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
518 int idx;
519
520 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
521 return -EFAULT;
522 DRM_DEBUG("%d\n", ctx.handle);
523
524 idx = ctx.handle - 1;
525 if (idx < 0 || idx >= FFB_MAX_CTXS)
526 return -EINVAL;
527
528 kfree(fpriv->hw_state[idx]);
529 fpriv->hw_state[idx] = NULL;
530 return 0;
531}
532
533void ffb_set_context_ioctls(void)
534{
535 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)].func = ffb_driver_addctx;
536 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)].func = ffb_driver_rmctx;
537 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)].func = ffb_driver_modctx;
538 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)].func = ffb_driver_getctx;
539 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)].func =
540 ffb_driver_switchctx;
541 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)].func = ffb_driver_newctx;
542 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)].func = ffb_driver_resctx;
543
544}
diff --git a/drivers/char/drm/ffb_drv.c b/drivers/char/drm/ffb_drv.c
deleted file mode 100644
index 9a19879e3b68..000000000000
--- a/drivers/char/drm/ffb_drv.c
+++ /dev/null
@@ -1,355 +0,0 @@
1/* $Id: ffb_drv.c,v 1.16 2001/10/18 16:00:24 davem Exp $
2 * ffb_drv.c: Creator/Creator3D direct rendering driver.
3 *
4 * Copyright (C) 2000 David S. Miller (davem@redhat.com)
5 */
6
7#include "ffb.h"
8#include "drmP.h"
9
10#include "ffb_drv.h"
11
12#include <linux/smp_lock.h>
13#include <asm/shmparam.h>
14#include <asm/oplib.h>
15#include <asm/upa.h>
16
17#define DRIVER_AUTHOR "David S. Miller"
18
19#define DRIVER_NAME "ffb"
20#define DRIVER_DESC "Creator/Creator3D"
21#define DRIVER_DATE "20000517"
22
23#define DRIVER_MAJOR 0
24#define DRIVER_MINOR 0
25#define DRIVER_PATCHLEVEL 1
26
27typedef struct _ffb_position_t {
28 int node;
29 int root;
30} ffb_position_t;
31
32static ffb_position_t *ffb_position;
33
34static void get_ffb_type(ffb_dev_priv_t * ffb_priv, int instance)
35{
36 volatile unsigned char *strap_bits;
37 unsigned char val;
38
39 strap_bits = (volatile unsigned char *)
40 (ffb_priv->card_phys_base + 0x00200000UL);
41
42 /* Don't ask, you have to read the value twice for whatever
43 * reason to get correct contents.
44 */
45 val = upa_readb(strap_bits);
46 val = upa_readb(strap_bits);
47 switch (val & 0x78) {
48 case (0x0 << 5) | (0x0 << 3):
49 ffb_priv->ffb_type = ffb1_prototype;
50 printk("ffb%d: Detected FFB1 pre-FCS prototype\n", instance);
51 break;
52 case (0x0 << 5) | (0x1 << 3):
53 ffb_priv->ffb_type = ffb1_standard;
54 printk("ffb%d: Detected FFB1\n", instance);
55 break;
56 case (0x0 << 5) | (0x3 << 3):
57 ffb_priv->ffb_type = ffb1_speedsort;
58 printk("ffb%d: Detected FFB1-SpeedSort\n", instance);
59 break;
60 case (0x1 << 5) | (0x0 << 3):
61 ffb_priv->ffb_type = ffb2_prototype;
62 printk("ffb%d: Detected FFB2/vertical pre-FCS prototype\n",
63 instance);
64 break;
65 case (0x1 << 5) | (0x1 << 3):
66 ffb_priv->ffb_type = ffb2_vertical;
67 printk("ffb%d: Detected FFB2/vertical\n", instance);
68 break;
69 case (0x1 << 5) | (0x2 << 3):
70 ffb_priv->ffb_type = ffb2_vertical_plus;
71 printk("ffb%d: Detected FFB2+/vertical\n", instance);
72 break;
73 case (0x2 << 5) | (0x0 << 3):
74 ffb_priv->ffb_type = ffb2_horizontal;
75 printk("ffb%d: Detected FFB2/horizontal\n", instance);
76 break;
77 case (0x2 << 5) | (0x2 << 3):
78 ffb_priv->ffb_type = ffb2_horizontal;
79 printk("ffb%d: Detected FFB2+/horizontal\n", instance);
80 break;
81 default:
82 ffb_priv->ffb_type = ffb2_vertical;
83 printk("ffb%d: Unknown boardID[%08x], assuming FFB2\n",
84 instance, val);
85 break;
86 };
87}
88
89static void ffb_apply_upa_parent_ranges(int parent,
90 struct linux_prom64_registers *regs)
91{
92 struct linux_prom64_ranges ranges[PROMREG_MAX];
93 char name[128];
94 int len, i;
95
96 prom_getproperty(parent, "name", name, sizeof(name));
97 if (strcmp(name, "upa") != 0)
98 return;
99
100 len =
101 prom_getproperty(parent, "ranges", (void *)ranges, sizeof(ranges));
102 if (len <= 0)
103 return;
104
105 len /= sizeof(struct linux_prom64_ranges);
106 for (i = 0; i < len; i++) {
107 struct linux_prom64_ranges *rng = &ranges[i];
108 u64 phys_addr = regs->phys_addr;
109
110 if (phys_addr >= rng->ot_child_base &&
111 phys_addr < (rng->ot_child_base + rng->or_size)) {
112 regs->phys_addr -= rng->ot_child_base;
113 regs->phys_addr += rng->ot_parent_base;
114 return;
115 }
116 }
117
118 return;
119}
120
121static int ffb_init_one(drm_device_t * dev, int prom_node, int parent_node,
122 int instance)
123{
124 struct linux_prom64_registers regs[2 * PROMREG_MAX];
125 ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *) dev->dev_private;
126 int i;
127
128 ffb_priv->prom_node = prom_node;
129 if (prom_getproperty(ffb_priv->prom_node, "reg",
130 (void *)regs, sizeof(regs)) <= 0) {
131 return -EINVAL;
132 }
133 ffb_apply_upa_parent_ranges(parent_node, &regs[0]);
134 ffb_priv->card_phys_base = regs[0].phys_addr;
135 ffb_priv->regs = (ffb_fbcPtr)
136 (regs[0].phys_addr + 0x00600000UL);
137 get_ffb_type(ffb_priv, instance);
138 for (i = 0; i < FFB_MAX_CTXS; i++)
139 ffb_priv->hw_state[i] = NULL;
140
141 return 0;
142}
143
144static drm_map_t *ffb_find_map(struct file *filp, unsigned long off)
145{
146 drm_file_t *priv = filp->private_data;
147 drm_device_t *dev;
148 drm_map_list_t *r_list;
149 struct list_head *list;
150 drm_map_t *map;
151
152 if (!priv || (dev = priv->dev) == NULL)
153 return NULL;
154
155 list_for_each(list, &dev->maplist->head) {
156 r_list = (drm_map_list_t *) list;
157 map = r_list->map;
158 if (!map)
159 continue;
160 if (r_list->user_token == off)
161 return map;
162 }
163
164 return NULL;
165}
166
167unsigned long ffb_get_unmapped_area(struct file *filp,
168 unsigned long hint,
169 unsigned long len,
170 unsigned long pgoff, unsigned long flags)
171{
172 drm_map_t *map = ffb_find_map(filp, pgoff << PAGE_SHIFT);
173 unsigned long addr = -ENOMEM;
174
175 if (!map)
176 return get_unmapped_area(NULL, hint, len, pgoff, flags);
177
178 if (map->type == _DRM_FRAME_BUFFER || map->type == _DRM_REGISTERS) {
179#ifdef HAVE_ARCH_FB_UNMAPPED_AREA
180 addr = get_fb_unmapped_area(filp, hint, len, pgoff, flags);
181#else
182 addr = get_unmapped_area(NULL, hint, len, pgoff, flags);
183#endif
184 } else if (map->type == _DRM_SHM && SHMLBA > PAGE_SIZE) {
185 unsigned long slack = SHMLBA - PAGE_SIZE;
186
187 addr = get_unmapped_area(NULL, hint, len + slack, pgoff, flags);
188 if (!(addr & ~PAGE_MASK)) {
189 unsigned long kvirt = (unsigned long)map->handle;
190
191 if ((kvirt & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) {
192 unsigned long koff, aoff;
193
194 koff = kvirt & (SHMLBA - 1);
195 aoff = addr & (SHMLBA - 1);
196 if (koff < aoff)
197 koff += SHMLBA;
198
199 addr += (koff - aoff);
200 }
201 }
202 } else {
203 addr = get_unmapped_area(NULL, hint, len, pgoff, flags);
204 }
205
206 return addr;
207}
208
209static int ffb_presetup(drm_device_t * dev)
210{
211 ffb_dev_priv_t *ffb_priv;
212 int ret = 0;
213 int i = 0;
214
215 /* Check for the case where no device was found. */
216 if (ffb_position == NULL)
217 return -ENODEV;
218
219 /* code used to use numdevs no numdevs anymore */
220 ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
221 if (!ffb_priv)
222 return -ENOMEM;
223 memset(ffb_priv, 0, sizeof(*ffb_priv));
224 dev->dev_private = ffb_priv;
225
226 ret = ffb_init_one(dev, ffb_position[i].node, ffb_position[i].root, i);
227 return ret;
228}
229
230static void ffb_driver_release(drm_device_t * dev, struct file *filp)
231{
232 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
233 int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock);
234 int idx;
235
236 idx = context - 1;
237 if (fpriv &&
238 context != DRM_KERNEL_CONTEXT && fpriv->hw_state[idx] != NULL) {
239 kfree(fpriv->hw_state[idx]);
240 fpriv->hw_state[idx] = NULL;
241 }
242}
243
244static void ffb_driver_pretakedown(drm_device_t * dev)
245{
246 kfree(dev->dev_private);
247}
248
249static int ffb_driver_postcleanup(drm_device_t * dev)
250{
251 kfree(ffb_position);
252 return 0;
253}
254
255static void ffb_driver_kernel_context_switch_unlock(struct drm_device *dev,
256 drm_lock_t * lock)
257{
258 dev->lock.filp = 0;
259 {
260 __volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
261 unsigned int old, new, prev, ctx;
262
263 ctx = lock->context;
264 do {
265 old = *plock;
266 new = ctx;
267 prev = cmpxchg(plock, old, new);
268 } while (prev != old);
269 }
270 wake_up_interruptible(&dev->lock.lock_queue);
271}
272
273static unsigned long ffb_driver_get_map_ofs(drm_map_t * map)
274{
275 return (map->offset & 0xffffffff);
276}
277
278static unsigned long ffb_driver_get_reg_ofs(drm_device_t * dev)
279{
280 ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *) dev->dev_private;
281
282 if (ffb_priv)
283 return ffb_priv->card_phys_base;
284
285 return 0;
286}
287
288static int postinit(struct drm_device *dev, unsigned long flags)
289{
290 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
291 DRIVER_NAME,
292 DRIVER_MAJOR,
293 DRIVER_MINOR, DRIVER_PATCHLEVEL, DRIVER_DATE, dev->minor);
294 return 0;
295}
296
297static int version(drm_version_t * version)
298{
299 int len;
300
301 version->version_major = DRIVER_MAJOR;
302 version->version_minor = DRIVER_MINOR;
303 version->version_patchlevel = DRIVER_PATCHLEVEL;
304 DRM_COPY(version->name, DRIVER_NAME);
305 DRM_COPY(version->date, DRIVER_DATE);
306 DRM_COPY(version->desc, DRIVER_DESC);
307 return 0;
308}
309
310static drm_ioctl_desc_t ioctls[] = {
311
312};
313
314static struct drm_driver driver = {
315 .driver_features = 0,
316 .dev_priv_size = sizeof(u32),
317 .release = ffb_driver_release,
318 .presetup = ffb_presetup,
319 .pretakedown = ffb_driver_pretakedown,
320 .postcleanup = ffb_driver_postcleanup,
321 .kernel_context_switch = ffb_driver_context_switch,
322 .kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock,
323 .get_map_ofs = ffb_driver_get_map_ofs,
324 .get_reg_ofs = ffb_driver_get_reg_ofs,
325 .postinit = postinit,
326 .version = version,
327 .ioctls = ioctls,
328 .num_ioctls = DRM_ARRAY_SIZE(ioctls),
329 .fops = {
330 .owner = THIS_MODULE,
331 .open = drm_open,
332 .release = drm_release,
333 .ioctl = drm_ioctl,
334 .mmap = drm_mmap,
335 .poll = drm_poll,
336 .fasync = drm_fasync,
337 }
338 ,
339};
340
341static int __init ffb_init(void)
342{
343 return -ENODEV;
344}
345
346static void __exit ffb_exit(void)
347{
348}
349
350module_init(ffb_init);
351module_exit(ffb_exit);
352
353MODULE_AUTHOR(DRIVER_AUTHOR);
354MODULE_DESCRIPTION(DRIVER_DESC);
355MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/char/drm/ffb_drv.h b/drivers/char/drm/ffb_drv.h
deleted file mode 100644
index 582afa6dd2b4..000000000000
--- a/drivers/char/drm/ffb_drv.h
+++ /dev/null
@@ -1,379 +0,0 @@
1/* $Id: ffb_drv.h,v 1.1 2000/06/01 04:24:39 davem Exp $
2 * ffb_drv.h: Creator/Creator3D direct rendering driver.
3 *
4 * Copyright (C) 2000 David S. Miller (davem@redhat.com)
5 */
6
7/* Auxilliary clips. */
8typedef struct {
9 volatile unsigned int min;
10 volatile unsigned int max;
11} ffb_auxclip, *ffb_auxclipPtr;
12
13/* FFB register set. */
14typedef struct _ffb_fbc {
15 /* Next vertex registers, on the right we list which drawops
16 * use said register and the logical name the register has in
17 * that context.
18 *//* DESCRIPTION DRAWOP(NAME) */
19 /*0x00*/ unsigned int pad1[3];
20 /* Reserved */
21 /*0x0c*/ volatile unsigned int alpha;
22 /* ALPHA Transparency */
23 /*0x10*/ volatile unsigned int red;
24 /* RED */
25 /*0x14*/ volatile unsigned int green;
26 /* GREEN */
27 /*0x18*/ volatile unsigned int blue;
28 /* BLUE */
29 /*0x1c*/ volatile unsigned int z;
30 /* DEPTH */
31 /*0x20*/ volatile unsigned int y;
32 /* Y triangle(DOYF) */
33 /* aadot(DYF) */
34 /* ddline(DYF) */
35 /* aaline(DYF) */
36 /*0x24*/ volatile unsigned int x;
37 /* X triangle(DOXF) */
38 /* aadot(DXF) */
39 /* ddline(DXF) */
40 /* aaline(DXF) */
41 /*0x28*/ unsigned int pad2[2];
42 /* Reserved */
43 /*0x30*/ volatile unsigned int ryf;
44 /* Y (alias to DOYF) ddline(RYF) */
45 /* aaline(RYF) */
46 /* triangle(RYF) */
47 /*0x34*/ volatile unsigned int rxf;
48 /* X ddline(RXF) */
49 /* aaline(RXF) */
50 /* triangle(RXF) */
51 /*0x38*/ unsigned int pad3[2];
52 /* Reserved */
53 /*0x40*/ volatile unsigned int dmyf;
54 /* Y (alias to DOYF) triangle(DMYF) */
55 /*0x44*/ volatile unsigned int dmxf;
56 /* X triangle(DMXF) */
57 /*0x48*/ unsigned int pad4[2];
58 /* Reserved */
59 /*0x50*/ volatile unsigned int ebyi;
60 /* Y (alias to RYI) polygon(EBYI) */
61 /*0x54*/ volatile unsigned int ebxi;
62 /* X polygon(EBXI) */
63 /*0x58*/ unsigned int pad5[2];
64 /* Reserved */
65 /*0x60*/ volatile unsigned int by;
66 /* Y brline(RYI) */
67 /* fastfill(OP) */
68 /* polygon(YI) */
69 /* rectangle(YI) */
70 /* bcopy(SRCY) */
71 /* vscroll(SRCY) */
72 /*0x64*/ volatile unsigned int bx;
73 /* X brline(RXI) */
74 /* polygon(XI) */
75 /* rectangle(XI) */
76 /* bcopy(SRCX) */
77 /* vscroll(SRCX) */
78 /* fastfill(GO) */
79 /*0x68*/ volatile unsigned int dy;
80 /* destination Y fastfill(DSTY) */
81 /* bcopy(DSRY) */
82 /* vscroll(DSRY) */
83 /*0x6c*/ volatile unsigned int dx;
84 /* destination X fastfill(DSTX) */
85 /* bcopy(DSTX) */
86 /* vscroll(DSTX) */
87 /*0x70*/ volatile unsigned int bh;
88 /* Y (alias to RYI) brline(DYI) */
89 /* dot(DYI) */
90 /* polygon(ETYI) */
91 /* Height fastfill(H) */
92 /* bcopy(H) */
93 /* vscroll(H) */
94 /* Y count fastfill(NY) */
95 /*0x74*/ volatile unsigned int bw;
96 /* X dot(DXI) */
97 /* brline(DXI) */
98 /* polygon(ETXI) */
99 /* fastfill(W) */
100 /* bcopy(W) */
101 /* vscroll(W) */
102 /* fastfill(NX) */
103 /*0x78*/ unsigned int pad6[2];
104 /* Reserved */
105 /*0x80*/ unsigned int pad7[32];
106 /* Reserved */
107
108 /* Setup Unit's vertex state register */
109/*100*/ volatile unsigned int suvtx;
110 /*104*/ unsigned int pad8[63];
111 /* Reserved */
112
113 /* Frame Buffer Control Registers */
114 /*200*/ volatile unsigned int ppc;
115 /* Pixel Processor Control */
116 /*204*/ volatile unsigned int wid;
117 /* Current WID */
118 /*208*/ volatile unsigned int fg;
119 /* FG data */
120 /*20c*/ volatile unsigned int bg;
121 /* BG data */
122 /*210*/ volatile unsigned int consty;
123 /* Constant Y */
124 /*214*/ volatile unsigned int constz;
125 /* Constant Z */
126 /*218*/ volatile unsigned int xclip;
127 /* X Clip */
128 /*21c*/ volatile unsigned int dcss;
129 /* Depth Cue Scale Slope */
130 /*220*/ volatile unsigned int vclipmin;
131 /* Viewclip XY Min Bounds */
132 /*224*/ volatile unsigned int vclipmax;
133 /* Viewclip XY Max Bounds */
134 /*228*/ volatile unsigned int vclipzmin;
135 /* Viewclip Z Min Bounds */
136 /*22c*/ volatile unsigned int vclipzmax;
137 /* Viewclip Z Max Bounds */
138 /*230*/ volatile unsigned int dcsf;
139 /* Depth Cue Scale Front Bound */
140 /*234*/ volatile unsigned int dcsb;
141 /* Depth Cue Scale Back Bound */
142 /*238*/ volatile unsigned int dczf;
143 /* Depth Cue Z Front */
144 /*23c*/ volatile unsigned int dczb;
145 /* Depth Cue Z Back */
146 /*240*/ unsigned int pad9;
147 /* Reserved */
148 /*244*/ volatile unsigned int blendc;
149 /* Alpha Blend Control */
150 /*248*/ volatile unsigned int blendc1;
151 /* Alpha Blend Color 1 */
152 /*24c*/ volatile unsigned int blendc2;
153 /* Alpha Blend Color 2 */
154 /*250*/ volatile unsigned int fbramitc;
155 /* FB RAM Interleave Test Control */
156 /*254*/ volatile unsigned int fbc;
157 /* Frame Buffer Control */
158 /*258*/ volatile unsigned int rop;
159 /* Raster OPeration */
160 /*25c*/ volatile unsigned int cmp;
161 /* Frame Buffer Compare */
162 /*260*/ volatile unsigned int matchab;
163 /* Buffer AB Match Mask */
164 /*264*/ volatile unsigned int matchc;
165 /* Buffer C(YZ) Match Mask */
166 /*268*/ volatile unsigned int magnab;
167 /* Buffer AB Magnitude Mask */
168 /*26c*/ volatile unsigned int magnc;
169 /* Buffer C(YZ) Magnitude Mask */
170 /*270*/ volatile unsigned int fbcfg0;
171 /* Frame Buffer Config 0 */
172 /*274*/ volatile unsigned int fbcfg1;
173 /* Frame Buffer Config 1 */
174 /*278*/ volatile unsigned int fbcfg2;
175 /* Frame Buffer Config 2 */
176 /*27c*/ volatile unsigned int fbcfg3;
177 /* Frame Buffer Config 3 */
178 /*280*/ volatile unsigned int ppcfg;
179 /* Pixel Processor Config */
180 /*284*/ volatile unsigned int pick;
181 /* Picking Control */
182 /*288*/ volatile unsigned int fillmode;
183 /* FillMode */
184 /*28c*/ volatile unsigned int fbramwac;
185 /* FB RAM Write Address Control */
186 /*290*/ volatile unsigned int pmask;
187 /* RGB PlaneMask */
188 /*294*/ volatile unsigned int xpmask;
189 /* X PlaneMask */
190 /*298*/ volatile unsigned int ypmask;
191 /* Y PlaneMask */
192 /*29c*/ volatile unsigned int zpmask;
193 /* Z PlaneMask */
194 /*2a0*/ ffb_auxclip auxclip[4];
195 /* Auxilliary Viewport Clip */
196
197 /* New 3dRAM III support regs */
198/*2c0*/ volatile unsigned int rawblend2;
199/*2c4*/ volatile unsigned int rawpreblend;
200/*2c8*/ volatile unsigned int rawstencil;
201/*2cc*/ volatile unsigned int rawstencilctl;
202/*2d0*/ volatile unsigned int threedram1;
203/*2d4*/ volatile unsigned int threedram2;
204/*2d8*/ volatile unsigned int passin;
205/*2dc*/ volatile unsigned int rawclrdepth;
206/*2e0*/ volatile unsigned int rawpmask;
207/*2e4*/ volatile unsigned int rawcsrc;
208/*2e8*/ volatile unsigned int rawmatch;
209/*2ec*/ volatile unsigned int rawmagn;
210/*2f0*/ volatile unsigned int rawropblend;
211/*2f4*/ volatile unsigned int rawcmp;
212/*2f8*/ volatile unsigned int rawwac;
213/*2fc*/ volatile unsigned int fbramid;
214
215 /*300*/ volatile unsigned int drawop;
216 /* Draw OPeration */
217 /*304*/ unsigned int pad10[2];
218 /* Reserved */
219 /*30c*/ volatile unsigned int lpat;
220 /* Line Pattern control */
221 /*310*/ unsigned int pad11;
222 /* Reserved */
223 /*314*/ volatile unsigned int fontxy;
224 /* XY Font coordinate */
225 /*318*/ volatile unsigned int fontw;
226 /* Font Width */
227 /*31c*/ volatile unsigned int fontinc;
228 /* Font Increment */
229 /*320*/ volatile unsigned int font;
230 /* Font bits */
231 /*324*/ unsigned int pad12[3];
232 /* Reserved */
233/*330*/ volatile unsigned int blend2;
234/*334*/ volatile unsigned int preblend;
235/*338*/ volatile unsigned int stencil;
236/*33c*/ volatile unsigned int stencilctl;
237
238 /*340*/ unsigned int pad13[4];
239 /* Reserved */
240 /*350*/ volatile unsigned int dcss1;
241 /* Depth Cue Scale Slope 1 */
242 /*354*/ volatile unsigned int dcss2;
243 /* Depth Cue Scale Slope 2 */
244 /*358*/ volatile unsigned int dcss3;
245 /* Depth Cue Scale Slope 3 */
246/*35c*/ volatile unsigned int widpmask;
247/*360*/ volatile unsigned int dcs2;
248/*364*/ volatile unsigned int dcs3;
249/*368*/ volatile unsigned int dcs4;
250 /*36c*/ unsigned int pad14;
251 /* Reserved */
252/*370*/ volatile unsigned int dcd2;
253/*374*/ volatile unsigned int dcd3;
254/*378*/ volatile unsigned int dcd4;
255 /*37c*/ unsigned int pad15;
256 /* Reserved */
257 /*380*/ volatile unsigned int pattern[32];
258 /* area Pattern */
259 /*400*/ unsigned int pad16[8];
260 /* Reserved */
261 /*420*/ volatile unsigned int reset;
262 /* chip RESET */
263 /*424*/ unsigned int pad17[247];
264 /* Reserved */
265 /*800*/ volatile unsigned int devid;
266 /* Device ID */
267 /*804*/ unsigned int pad18[63];
268 /* Reserved */
269 /*900*/ volatile unsigned int ucsr;
270 /* User Control & Status Register */
271 /*904*/ unsigned int pad19[31];
272 /* Reserved */
273 /*980*/ volatile unsigned int mer;
274 /* Mode Enable Register */
275 /*984*/ unsigned int pad20[1439];
276 /* Reserved */
277} ffb_fbc, *ffb_fbcPtr;
278
279struct ffb_hw_context {
280 int is_2d_only;
281
282 unsigned int ppc;
283 unsigned int wid;
284 unsigned int fg;
285 unsigned int bg;
286 unsigned int consty;
287 unsigned int constz;
288 unsigned int xclip;
289 unsigned int dcss;
290 unsigned int vclipmin;
291 unsigned int vclipmax;
292 unsigned int vclipzmin;
293 unsigned int vclipzmax;
294 unsigned int dcsf;
295 unsigned int dcsb;
296 unsigned int dczf;
297 unsigned int dczb;
298 unsigned int blendc;
299 unsigned int blendc1;
300 unsigned int blendc2;
301 unsigned int fbc;
302 unsigned int rop;
303 unsigned int cmp;
304 unsigned int matchab;
305 unsigned int matchc;
306 unsigned int magnab;
307 unsigned int magnc;
308 unsigned int pmask;
309 unsigned int xpmask;
310 unsigned int ypmask;
311 unsigned int zpmask;
312 unsigned int auxclip0min;
313 unsigned int auxclip0max;
314 unsigned int auxclip1min;
315 unsigned int auxclip1max;
316 unsigned int auxclip2min;
317 unsigned int auxclip2max;
318 unsigned int auxclip3min;
319 unsigned int auxclip3max;
320 unsigned int drawop;
321 unsigned int lpat;
322 unsigned int fontxy;
323 unsigned int fontw;
324 unsigned int fontinc;
325 unsigned int area_pattern[32];
326 unsigned int ucsr;
327 unsigned int stencil;
328 unsigned int stencilctl;
329 unsigned int dcss1;
330 unsigned int dcss2;
331 unsigned int dcss3;
332 unsigned int dcs2;
333 unsigned int dcs3;
334 unsigned int dcs4;
335 unsigned int dcd2;
336 unsigned int dcd3;
337 unsigned int dcd4;
338 unsigned int mer;
339};
340
341#define FFB_MAX_CTXS 32
342
343enum ffb_chip_type {
344 ffb1_prototype = 0, /* Early pre-FCS FFB */
345 ffb1_standard, /* First FCS FFB, 100Mhz UPA, 66MHz gclk */
346 ffb1_speedsort, /* Second FCS FFB, 100Mhz UPA, 75MHz gclk */
347 ffb2_prototype, /* Early pre-FCS vertical FFB2 */
348 ffb2_vertical, /* First FCS FFB2/vertical, 100Mhz UPA, 100MHZ gclk,
349 75(SingleBuffer)/83(DoubleBuffer) MHz fclk */
350 ffb2_vertical_plus, /* Second FCS FFB2/vertical, same timings */
351 ffb2_horizontal, /* First FCS FFB2/horizontal, same timings as FFB2/vert */
352 ffb2_horizontal_plus, /* Second FCS FFB2/horizontal, same timings */
353 afb_m3, /* FCS Elite3D, 3 float chips */
354 afb_m6 /* FCS Elite3D, 6 float chips */
355};
356
357typedef struct ffb_dev_priv {
358 /* Misc software state. */
359 int prom_node;
360 enum ffb_chip_type ffb_type;
361 u64 card_phys_base;
362 struct miscdevice miscdev;
363
364 /* Controller registers. */
365 ffb_fbcPtr regs;
366
367 /* Context table. */
368 struct ffb_hw_context *hw_state[FFB_MAX_CTXS];
369} ffb_dev_priv_t;
370
371extern unsigned long ffb_get_unmapped_area(struct file *filp,
372 unsigned long hint,
373 unsigned long len,
374 unsigned long pgoff,
375 unsigned long flags);
376extern void ffb_set_context_ioctls(void);
377extern drm_ioctl_desc_t DRM(ioctls)[];
378
379extern int ffb_driver_context_switch(drm_device_t * dev, int old, int new);
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index 337bbcdcf13d..8ea02755b1c9 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -710,12 +710,6 @@ void gs_close(struct tty_struct * tty, struct file * filp)
710} 710}
711 711
712 712
713static unsigned int gs_baudrates[] = {
714 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
715 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
716};
717
718
719void gs_set_termios (struct tty_struct * tty, 713void gs_set_termios (struct tty_struct * tty,
720 struct ktermios * old_termios) 714 struct ktermios * old_termios)
721{ 715{
@@ -771,7 +765,6 @@ void gs_set_termios (struct tty_struct * tty,
771 765
772 baudrate = tty_get_baud_rate(tty); 766 baudrate = tty_get_baud_rate(tty);
773 767
774 baudrate = gs_baudrates[baudrate];
775 if ((tiosp->c_cflag & CBAUD) == B38400) { 768 if ((tiosp->c_cflag & CBAUD) == B38400) {
776 if ( (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 769 if ( (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
777 baudrate = 57600; 770 baudrate = 57600;
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f5c160caf9f4..5f066963f171 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -248,7 +248,7 @@ static unsigned long get_unmapped_area_mem(struct file *file,
248{ 248{
249 if (!valid_mmap_phys_addr_range(pgoff, len)) 249 if (!valid_mmap_phys_addr_range(pgoff, len))
250 return (unsigned long) -EINVAL; 250 return (unsigned long) -EINVAL;
251 return pgoff; 251 return pgoff << PAGE_SHIFT;
252} 252}
253 253
254/* can't do an in-place private mapping if there's no MMU */ 254/* can't do an in-place private mapping if there's no MMU */
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index a61fb6da5d03..80a01150b86c 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -1338,43 +1338,23 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1338 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1338 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1339 * Caller should use TIOCGICOUNT to see which one it was 1339 * Caller should use TIOCGICOUNT to see which one it was
1340 */ 1340 */
1341 case TIOCMIWAIT: { 1341 case TIOCMIWAIT:
1342 DECLARE_WAITQUEUE(wait, current); 1342 spin_lock_irqsave(&info->slock, flags);
1343 int ret; 1343 cnow = info->icount; /* note the counters on entry */
1344 spin_unlock_irqrestore(&info->slock, flags);
1345
1346 wait_event_interruptible(info->delta_msr_wait, ({
1347 cprev = cnow;
1344 spin_lock_irqsave(&info->slock, flags); 1348 spin_lock_irqsave(&info->slock, flags);
1345 cprev = info->icount; /* note the counters on entry */ 1349 cnow = info->icount; /* atomic copy */
1346 spin_unlock_irqrestore(&info->slock, flags); 1350 spin_unlock_irqrestore(&info->slock, flags);
1347 1351
1348 add_wait_queue(&info->delta_msr_wait, &wait); 1352 ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1349 while (1) { 1353 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1350 spin_lock_irqsave(&info->slock, flags); 1354 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
1351 cnow = info->icount; /* atomic copy */ 1355 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
1352 spin_unlock_irqrestore(&info->slock, flags); 1356 }));
1353 1357 break;
1354 set_current_state(TASK_INTERRUPTIBLE);
1355 if (((arg & TIOCM_RNG) &&
1356 (cnow.rng != cprev.rng)) ||
1357 ((arg & TIOCM_DSR) &&
1358 (cnow.dsr != cprev.dsr)) ||
1359 ((arg & TIOCM_CD) &&
1360 (cnow.dcd != cprev.dcd)) ||
1361 ((arg & TIOCM_CTS) &&
1362 (cnow.cts != cprev.cts))) {
1363 ret = 0;
1364 break;
1365 }
1366 /* see if a signal did it */
1367 if (signal_pending(current)) {
1368 ret = -ERESTARTSYS;
1369 break;
1370 }
1371 cprev = cnow;
1372 }
1373 current->state = TASK_RUNNING;
1374 remove_wait_queue(&info->delta_msr_wait, &wait);
1375 break;
1376 }
1377 /* NOTREACHED */
1378 /* 1358 /*
1379 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1359 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1380 * Return: write counters to the user passed counter struct 1360 * Return: write counters to the user passed counter struct
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index 9af07e4999d5..f7603b6aeb87 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -1758,43 +1758,23 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1758 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1758 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1759 * Caller should use TIOCGICOUNT to see which one it was 1759 * Caller should use TIOCGICOUNT to see which one it was
1760 */ 1760 */
1761 case TIOCMIWAIT: { 1761 case TIOCMIWAIT:
1762 DECLARE_WAITQUEUE(wait, current);
1763 int ret;
1764 spin_lock_irqsave(&info->slock, flags); 1762 spin_lock_irqsave(&info->slock, flags);
1765 cprev = info->icount; /* note the counters on entry */ 1763 cnow = info->icount; /* note the counters on entry */
1766 spin_unlock_irqrestore(&info->slock, flags); 1764 spin_unlock_irqrestore(&info->slock, flags);
1767 1765
1768 add_wait_queue(&info->delta_msr_wait, &wait); 1766 wait_event_interruptible(info->delta_msr_wait, ({
1769 while (1) { 1767 cprev = cnow;
1770 spin_lock_irqsave(&info->slock, flags); 1768 spin_lock_irqsave(&info->slock, flags);
1771 cnow = info->icount; /* atomic copy */ 1769 cnow = info->icount; /* atomic copy */
1772 spin_unlock_irqrestore(&info->slock, flags); 1770 spin_unlock_irqrestore(&info->slock, flags);
1773 1771
1774 set_current_state(TASK_INTERRUPTIBLE); 1772 ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1775 if (((arg & TIOCM_RNG) && 1773 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1776 (cnow.rng != cprev.rng)) || 1774 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
1777 ((arg & TIOCM_DSR) && 1775 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
1778 (cnow.dsr != cprev.dsr)) || 1776 }));
1779 ((arg & TIOCM_CD) &&
1780 (cnow.dcd != cprev.dcd)) ||
1781 ((arg & TIOCM_CTS) &&
1782 (cnow.cts != cprev.cts))) {
1783 ret = 0;
1784 break;
1785 }
1786 /* see if a signal did it */
1787 if (signal_pending(current)) {
1788 ret = -ERESTARTSYS;
1789 break;
1790 }
1791 cprev = cnow;
1792 }
1793 current->state = TASK_RUNNING;
1794 remove_wait_queue(&info->delta_msr_wait, &wait);
1795 break; 1777 break;
1796 }
1797 /* NOTREACHED */
1798 /* 1778 /*
1799 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1779 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1800 * Return: write counters to the user passed counter struct 1780 * Return: write counters to the user passed counter struct
@@ -2230,7 +2210,14 @@ end_intr:
2230 port->mon_data.rxcnt += cnt; 2210 port->mon_data.rxcnt += cnt;
2231 port->mon_data.up_rxcnt += cnt; 2211 port->mon_data.up_rxcnt += cnt;
2232 2212
2213 /*
2214 * We are called from an interrupt context with &port->slock
2215 * being held. Drop it temporarily in order to prevent
2216 * recursive locking.
2217 */
2218 spin_unlock(&port->slock);
2233 tty_flip_buffer_push(tty); 2219 tty_flip_buffer_push(tty);
2220 spin_lock(&port->slock);
2234} 2221}
2235 2222
2236static void mxser_transmit_chars(struct mxser_port *port) 2223static void mxser_transmit_chars(struct mxser_port *port)
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 78237577b05a..3ef593a9015f 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * Sony Programmable I/O Control Device driver for VAIO 2 * Sony Programmable I/O Control Device driver for VAIO
3 * 3 *
4 * Copyright (C) 2007 Mattia Dongili <malattia@linux.it>
5 *
4 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net> 6 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
5 * 7 *
6 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org> 8 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
@@ -95,6 +97,11 @@ module_param(useinput, int, 0444);
95MODULE_PARM_DESC(useinput, 97MODULE_PARM_DESC(useinput,
96 "set this if you would like sonypi to feed events to the input subsystem"); 98 "set this if you would like sonypi to feed events to the input subsystem");
97 99
100static int check_ioport = 1;
101module_param(check_ioport, int, 0444);
102MODULE_PARM_DESC(check_ioport,
103 "set this to 0 if you think the automatic ioport check for sony-laptop is wrong");
104
98#define SONYPI_DEVICE_MODEL_TYPE1 1 105#define SONYPI_DEVICE_MODEL_TYPE1 1
99#define SONYPI_DEVICE_MODEL_TYPE2 2 106#define SONYPI_DEVICE_MODEL_TYPE2 2
100#define SONYPI_DEVICE_MODEL_TYPE3 3 107#define SONYPI_DEVICE_MODEL_TYPE3 3
@@ -477,7 +484,7 @@ static struct sonypi_device {
477 u16 evtype_offset; 484 u16 evtype_offset;
478 int camera_power; 485 int camera_power;
479 int bluetooth_power; 486 int bluetooth_power;
480 struct semaphore lock; 487 struct mutex lock;
481 struct kfifo *fifo; 488 struct kfifo *fifo;
482 spinlock_t fifo_lock; 489 spinlock_t fifo_lock;
483 wait_queue_head_t fifo_proc_list; 490 wait_queue_head_t fifo_proc_list;
@@ -884,7 +891,7 @@ int sonypi_camera_command(int command, u8 value)
884 if (!camera) 891 if (!camera)
885 return -EIO; 892 return -EIO;
886 893
887 down(&sonypi_device.lock); 894 mutex_lock(&sonypi_device.lock);
888 895
889 switch (command) { 896 switch (command) {
890 case SONYPI_COMMAND_SETCAMERA: 897 case SONYPI_COMMAND_SETCAMERA:
@@ -919,7 +926,7 @@ int sonypi_camera_command(int command, u8 value)
919 command); 926 command);
920 break; 927 break;
921 } 928 }
922 up(&sonypi_device.lock); 929 mutex_unlock(&sonypi_device.lock);
923 return 0; 930 return 0;
924} 931}
925 932
@@ -938,20 +945,20 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
938static int sonypi_misc_release(struct inode *inode, struct file *file) 945static int sonypi_misc_release(struct inode *inode, struct file *file)
939{ 946{
940 sonypi_misc_fasync(-1, file, 0); 947 sonypi_misc_fasync(-1, file, 0);
941 down(&sonypi_device.lock); 948 mutex_lock(&sonypi_device.lock);
942 sonypi_device.open_count--; 949 sonypi_device.open_count--;
943 up(&sonypi_device.lock); 950 mutex_unlock(&sonypi_device.lock);
944 return 0; 951 return 0;
945} 952}
946 953
947static int sonypi_misc_open(struct inode *inode, struct file *file) 954static int sonypi_misc_open(struct inode *inode, struct file *file)
948{ 955{
949 down(&sonypi_device.lock); 956 mutex_lock(&sonypi_device.lock);
950 /* Flush input queue on first open */ 957 /* Flush input queue on first open */
951 if (!sonypi_device.open_count) 958 if (!sonypi_device.open_count)
952 kfifo_reset(sonypi_device.fifo); 959 kfifo_reset(sonypi_device.fifo);
953 sonypi_device.open_count++; 960 sonypi_device.open_count++;
954 up(&sonypi_device.lock); 961 mutex_unlock(&sonypi_device.lock);
955 return 0; 962 return 0;
956} 963}
957 964
@@ -1001,7 +1008,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1001 u8 val8; 1008 u8 val8;
1002 u16 val16; 1009 u16 val16;
1003 1010
1004 down(&sonypi_device.lock); 1011 mutex_lock(&sonypi_device.lock);
1005 switch (cmd) { 1012 switch (cmd) {
1006 case SONYPI_IOCGBRT: 1013 case SONYPI_IOCGBRT:
1007 if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) { 1014 if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) {
@@ -1101,7 +1108,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1101 default: 1108 default:
1102 ret = -EINVAL; 1109 ret = -EINVAL;
1103 } 1110 }
1104 up(&sonypi_device.lock); 1111 mutex_unlock(&sonypi_device.lock);
1105 return ret; 1112 return ret;
1106} 1113}
1107 1114
@@ -1260,6 +1267,28 @@ static int __devinit sonypi_create_input_devices(void)
1260static int __devinit sonypi_setup_ioports(struct sonypi_device *dev, 1267static int __devinit sonypi_setup_ioports(struct sonypi_device *dev,
1261 const struct sonypi_ioport_list *ioport_list) 1268 const struct sonypi_ioport_list *ioport_list)
1262{ 1269{
1270 /* try to detect if sony-laptop is being used and thus
1271 * has already requested one of the known ioports.
1272 * As in the deprecated check_region this is racy has we have
1273 * multiple ioports available and one of them can be requested
1274 * between this check and the subsequent request. Anyway, as an
1275 * attempt to be some more user-friendly as we currently are,
1276 * this is enough.
1277 */
1278 const struct sonypi_ioport_list *check = ioport_list;
1279 while (check_ioport && check->port1) {
1280 if (!request_region(check->port1,
1281 sonypi_device.region_size,
1282 "Sony Programable I/O Device Check")) {
1283 printk(KERN_ERR "sonypi: ioport 0x%.4x busy, using sony-laptop? "
1284 "if not use check_ioport=0\n",
1285 check->port1);
1286 return -EBUSY;
1287 }
1288 release_region(check->port1, sonypi_device.region_size);
1289 check++;
1290 }
1291
1263 while (ioport_list->port1) { 1292 while (ioport_list->port1) {
1264 1293
1265 if (request_region(ioport_list->port1, 1294 if (request_region(ioport_list->port1,
@@ -1321,6 +1350,10 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1321 struct pci_dev *pcidev; 1350 struct pci_dev *pcidev;
1322 int error; 1351 int error;
1323 1352
1353 printk(KERN_WARNING "sonypi: please try the sony-laptop module instead "
1354 "and report failures, see also "
1355 "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n");
1356
1324 spin_lock_init(&sonypi_device.fifo_lock); 1357 spin_lock_init(&sonypi_device.fifo_lock);
1325 sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, 1358 sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
1326 &sonypi_device.fifo_lock); 1359 &sonypi_device.fifo_lock);
@@ -1330,7 +1363,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1330 } 1363 }
1331 1364
1332 init_waitqueue_head(&sonypi_device.fifo_proc_list); 1365 init_waitqueue_head(&sonypi_device.fifo_proc_list);
1333 init_MUTEX(&sonypi_device.lock); 1366 mutex_init(&sonypi_device.lock);
1334 sonypi_device.bluetooth_power = -1; 1367 sonypi_device.bluetooth_power = -1;
1335 1368
1336 if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, 1369 if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 1fa2da8f4fbe..c9f2dd620e87 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -1039,10 +1039,22 @@ int vt_waitactive(int vt)
1039 1039
1040 add_wait_queue(&vt_activate_queue, &wait); 1040 add_wait_queue(&vt_activate_queue, &wait);
1041 for (;;) { 1041 for (;;) {
1042 set_current_state(TASK_INTERRUPTIBLE);
1043 retval = 0; 1042 retval = 0;
1044 if (vt == fg_console) 1043
1044 /*
1045 * Synchronize with redraw_screen(). By acquiring the console
1046 * semaphore we make sure that the console switch is completed
1047 * before we return. If we didn't wait for the semaphore, we
1048 * could return at a point where fg_console has already been
1049 * updated, but the console switch hasn't been completed.
1050 */
1051 acquire_console_sem();
1052 set_current_state(TASK_INTERRUPTIBLE);
1053 if (vt == fg_console) {
1054 release_console_sem();
1045 break; 1055 break;
1056 }
1057 release_console_sem();
1046 retval = -EINTR; 1058 retval = -EINTR;
1047 if (signal_pending(current)) 1059 if (signal_pending(current))
1048 break; 1060 break;
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index d42060ede930..5ac309ee7f05 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -90,7 +90,7 @@ __setup("acpi_pm_good", acpi_pm_good_setup);
90static inline void acpi_pm_need_workaround(void) 90static inline void acpi_pm_need_workaround(void)
91{ 91{
92 clocksource_acpi_pm.read = acpi_pm_read_slow; 92 clocksource_acpi_pm.read = acpi_pm_read_slow;
93 clocksource_acpi_pm.rating = 110; 93 clocksource_acpi_pm.rating = 120;
94} 94}
95 95
96/* 96/*
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f52facc570f5..3162010900c9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1015,6 +1015,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
1015{ 1015{
1016 unsigned int cpu = sys_dev->id; 1016 unsigned int cpu = sys_dev->id;
1017 int retval; 1017 int retval;
1018
1019 if (cpu_is_offline(cpu))
1020 return 0;
1021
1018 if (unlikely(lock_policy_rwsem_write(cpu))) 1022 if (unlikely(lock_policy_rwsem_write(cpu)))
1019 BUG(); 1023 BUG();
1020 1024
diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c
index 9e913629ef39..74edb1d0110f 100644
--- a/drivers/eisa/pci_eisa.c
+++ b/drivers/eisa/pci_eisa.c
@@ -19,8 +19,8 @@
19/* There is only *one* pci_eisa device per machine, right ? */ 19/* There is only *one* pci_eisa device per machine, right ? */
20static struct eisa_root_device pci_eisa_root; 20static struct eisa_root_device pci_eisa_root;
21 21
22static int __devinit pci_eisa_init (struct pci_dev *pdev, 22static int __init pci_eisa_init(struct pci_dev *pdev,
23 const struct pci_device_id *ent) 23 const struct pci_device_id *ent)
24{ 24{
25 int rc; 25 int rc;
26 26
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 67f3347afcf3..1cca32f46947 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -969,7 +969,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
969 969
970 if (size < rsize) { 970 if (size < rsize) {
971 dbg("report %d is too short, (%d < %d)", report->id, size, rsize); 971 dbg("report %d is too short, (%d < %d)", report->id, size, rsize);
972 return -1; 972 memset(data + size, 0, rsize - size);
973 } 973 }
974 974
975 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 975 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index da5828f2dfc2..30a76404f0af 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -121,9 +121,9 @@ superio_exit(void)
121 * ISA constants 121 * ISA constants
122 */ 122 */
123 123
124#define REGION_ALIGNMENT ~7 124#define IOREGION_ALIGNMENT ~7
125#define REGION_OFFSET 5 125#define IOREGION_OFFSET 5
126#define REGION_LENGTH 2 126#define IOREGION_LENGTH 2
127#define ADDR_REG_OFFSET 5 127#define ADDR_REG_OFFSET 5
128#define DATA_REG_OFFSET 6 128#define DATA_REG_OFFSET 6
129 129
@@ -407,7 +407,7 @@ static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
407 break; 407 break;
408 case 4: 408 case 4:
409 reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73) 409 reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73)
410 | ((data->fan_div[4] & 0x03) << 3) 410 | ((data->fan_div[4] & 0x03) << 2)
411 | ((data->fan_div[4] & 0x04) << 5); 411 | ((data->fan_div[4] & 0x04) << 5);
412 w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); 412 w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg);
413 break; 413 break;
@@ -471,9 +471,9 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
471 time */ 471 time */
472 if (data->fan[i] == 0xff 472 if (data->fan[i] == 0xff
473 && data->fan_div[i] < 0x07) { 473 && data->fan_div[i] < 0x07) {
474 dev_dbg(&client->dev, "Increasing fan %d " 474 dev_dbg(&client->dev, "Increasing fan%d "
475 "clock divider from %u to %u\n", 475 "clock divider from %u to %u\n",
476 i, div_from_reg(data->fan_div[i]), 476 i + 1, div_from_reg(data->fan_div[i]),
477 div_from_reg(data->fan_div[i] + 1)); 477 div_from_reg(data->fan_div[i] + 1));
478 data->fan_div[i]++; 478 data->fan_div[i]++;
479 w83627ehf_write_fan_div(client, i); 479 w83627ehf_write_fan_div(client, i);
@@ -1194,7 +1194,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
1194 u8 fan4pin, fan5pin; 1194 u8 fan4pin, fan5pin;
1195 int i, err = 0; 1195 int i, err = 0;
1196 1196
1197 if (!request_region(address + REGION_OFFSET, REGION_LENGTH, 1197 if (!request_region(address + IOREGION_OFFSET, IOREGION_LENGTH,
1198 w83627ehf_driver.driver.name)) { 1198 w83627ehf_driver.driver.name)) {
1199 err = -EBUSY; 1199 err = -EBUSY;
1200 goto exit; 1200 goto exit;
@@ -1322,7 +1322,7 @@ exit_remove:
1322exit_free: 1322exit_free:
1323 kfree(data); 1323 kfree(data);
1324exit_release: 1324exit_release:
1325 release_region(address + REGION_OFFSET, REGION_LENGTH); 1325 release_region(address + IOREGION_OFFSET, IOREGION_LENGTH);
1326exit: 1326exit:
1327 return err; 1327 return err;
1328} 1328}
@@ -1337,7 +1337,7 @@ static int w83627ehf_detach_client(struct i2c_client *client)
1337 1337
1338 if ((err = i2c_detach_client(client))) 1338 if ((err = i2c_detach_client(client)))
1339 return err; 1339 return err;
1340 release_region(client->addr + REGION_OFFSET, REGION_LENGTH); 1340 release_region(client->addr + IOREGION_OFFSET, IOREGION_LENGTH);
1341 kfree(data); 1341 kfree(data);
1342 1342
1343 return 0; 1343 return 0;
@@ -1380,7 +1380,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr)
1380 superio_select(W83627EHF_LD_HWM); 1380 superio_select(W83627EHF_LD_HWM);
1381 val = (superio_inb(SIO_REG_ADDR) << 8) 1381 val = (superio_inb(SIO_REG_ADDR) << 8)
1382 | superio_inb(SIO_REG_ADDR + 1); 1382 | superio_inb(SIO_REG_ADDR + 1);
1383 *addr = val & REGION_ALIGNMENT; 1383 *addr = val & IOREGION_ALIGNMENT;
1384 if (*addr == 0) { 1384 if (*addr == 0) {
1385 superio_exit(); 1385 superio_exit();
1386 return -ENODEV; 1386 return -ENODEV;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index fb19dbb31e42..ece31d2c6c64 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -344,8 +344,7 @@ config I2C_PARPORT_LIGHT
344 344
345config I2C_PASEMI 345config I2C_PASEMI
346 tristate "PA Semi SMBus interface" 346 tristate "PA Semi SMBus interface"
347# depends on PPC_PASEMI && I2C && PCI 347 depends on PPC_PASEMI && I2C && PCI
348 depends on I2C && PCI
349 help 348 help
350 Supports the PA Semi PWRficient on-chip SMBus interfaces. 349 Supports the PA Semi PWRficient on-chip SMBus interfaces.
351 350
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index f54fb5d65cc4..bf89eeef74e9 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -141,7 +141,7 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,
141 for (i = 0; i < msg->len - 1; i++) 141 for (i = 0; i < msg->len - 1; i++)
142 TXFIFO_WR(smbus, msg->buf[i]); 142 TXFIFO_WR(smbus, msg->buf[i]);
143 143
144 TXFIFO_WR(smbus, msg->buf[msg->len] | 144 TXFIFO_WR(smbus, msg->buf[msg->len-1] |
145 (stop ? MTXFIFO_STOP : 0)); 145 (stop ? MTXFIFO_STOP : 0));
146 } 146 }
147 147
@@ -226,7 +226,7 @@ static int pasemi_smb_xfer(struct i2c_adapter *adapter,
226 rd = RXFIFO_RD(smbus); 226 rd = RXFIFO_RD(smbus);
227 len = min_t(u8, (rd & MRXFIFO_DATA_M), 227 len = min_t(u8, (rd & MRXFIFO_DATA_M),
228 I2C_SMBUS_BLOCK_MAX); 228 I2C_SMBUS_BLOCK_MAX);
229 TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ | 229 TXFIFO_WR(smbus, len | MTXFIFO_READ |
230 MTXFIFO_STOP); 230 MTXFIFO_STOP);
231 } else { 231 } else {
232 len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX); 232 len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX);
@@ -258,7 +258,7 @@ static int pasemi_smb_xfer(struct i2c_adapter *adapter,
258 rd = RXFIFO_RD(smbus); 258 rd = RXFIFO_RD(smbus);
259 len = min_t(u8, (rd & MRXFIFO_DATA_M), 259 len = min_t(u8, (rd & MRXFIFO_DATA_M),
260 I2C_SMBUS_BLOCK_MAX - len); 260 I2C_SMBUS_BLOCK_MAX - len);
261 TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ | MTXFIFO_STOP); 261 TXFIFO_WR(smbus, len | MTXFIFO_READ | MTXFIFO_STOP);
262 break; 262 break;
263 263
264 default: 264 default:
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 8f1fd017679b..5bdf64b77913 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -57,6 +57,7 @@ if IDE
57config IDE_MAX_HWIFS 57config IDE_MAX_HWIFS
58 int "Max IDE interfaces" 58 int "Max IDE interfaces"
59 depends on ALPHA || SUPERH || IA64 || EMBEDDED 59 depends on ALPHA || SUPERH || IA64 || EMBEDDED
60 range 1 10
60 default 4 61 default 4
61 help 62 help
62 This is the maximum number of IDE hardware interfaces that will 63 This is the maximum number of IDE hardware interfaces that will
@@ -103,8 +104,10 @@ config BLK_DEV_IDE_SATA
103 ---help--- 104 ---help---
104 There are two drivers for Serial ATA controllers. 105 There are two drivers for Serial ATA controllers.
105 106
106 The main driver, "libata", exists inside the SCSI subsystem 107 The main driver, "libata", uses the SCSI subsystem
107 and supports most modern SATA controllers. 108 and supports most modern SATA controllers. In order to use it
109 you may take a look at "Serial ATA (prod) and Parallel ATA
110 (experimental) drivers".
108 111
109 The IDE driver (which you are currently configuring) supports 112 The IDE driver (which you are currently configuring) supports
110 a few first-generation SATA controllers. 113 a few first-generation SATA controllers.
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 45a928c058cf..638becda81c6 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -735,6 +735,15 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
735 cdrom_saw_media_change (drive); 735 cdrom_saw_media_change (drive);
736 /*printk("%s: media changed\n",drive->name);*/ 736 /*printk("%s: media changed\n",drive->name);*/
737 return 0; 737 return 0;
738 } else if ((sense_key == ILLEGAL_REQUEST) &&
739 (rq->cmd[0] == GPCMD_START_STOP_UNIT)) {
740 /*
741 * Don't print error message for this condition--
742 * SFF8090i indicates that 5/24/00 is the correct
743 * response to a request to close the tray if the
744 * drive doesn't have that capability.
745 * cdrom_log_sense() knows this!
746 */
738 } else if (!(rq->cmd_flags & REQ_QUIET)) { 747 } else if (!(rq->cmd_flags & REQ_QUIET)) {
739 /* Otherwise, print an error. */ 748 /* Otherwise, print an error. */
740 ide_dump_status(drive, "packet command error", stat); 749 ide_dump_status(drive, "packet command error", stat);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index c193553f6fe7..8670112f1d39 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -519,21 +519,24 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
519 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && hwif->err_stops_fifo == 0) 519 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && hwif->err_stops_fifo == 0)
520 try_to_flush_leftover_data(drive); 520 try_to_flush_leftover_data(drive);
521 521
522 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) {
523 ide_kill_rq(drive, rq);
524 return ide_stopped;
525 }
526
522 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 527 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
523 /* force an abort */ 528 rq->errors |= ERROR_RESET;
524 hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
525 529
526 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) 530 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
527 ide_kill_rq(drive, rq);
528 else {
529 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
530 ++rq->errors;
531 return ide_do_reset(drive);
532 }
533 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
534 drive->special.b.recalibrate = 1;
535 ++rq->errors; 531 ++rq->errors;
532 return ide_do_reset(drive);
536 } 533 }
534
535 if ((rq->errors & ERROR_RECAL) == ERROR_RECAL)
536 drive->special.b.recalibrate = 1;
537
538 ++rq->errors;
539
537 return ide_stopped; 540 return ide_stopped;
538} 541}
539 542
@@ -1025,6 +1028,13 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
1025 if (!drive->special.all) { 1028 if (!drive->special.all) {
1026 ide_driver_t *drv; 1029 ide_driver_t *drv;
1027 1030
1031 /*
1032 * We reset the drive so we need to issue a SETFEATURES.
1033 * Do it _after_ do_special() restored device parameters.
1034 */
1035 if (drive->current_speed == 0xff)
1036 ide_config_drive_speed(drive, drive->desired_speed);
1037
1028 if (rq->cmd_type == REQ_TYPE_ATA_CMD || 1038 if (rq->cmd_type == REQ_TYPE_ATA_CMD ||
1029 rq->cmd_type == REQ_TYPE_ATA_TASK || 1039 rq->cmd_type == REQ_TYPE_ATA_TASK ||
1030 rq->cmd_type == REQ_TYPE_ATA_TASKFILE) 1040 rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
@@ -1216,6 +1226,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1216#endif 1226#endif
1217 /* so that ide_timer_expiry knows what to do */ 1227 /* so that ide_timer_expiry knows what to do */
1218 hwgroup->sleeping = 1; 1228 hwgroup->sleeping = 1;
1229 hwgroup->req_gen_timer = hwgroup->req_gen;
1219 mod_timer(&hwgroup->timer, sleep); 1230 mod_timer(&hwgroup->timer, sleep);
1220 /* we purposely leave hwgroup->busy==1 1231 /* we purposely leave hwgroup->busy==1
1221 * while sleeping */ 1232 * while sleeping */
@@ -1401,7 +1412,8 @@ void ide_timer_expiry (unsigned long data)
1401 1412
1402 spin_lock_irqsave(&ide_lock, flags); 1413 spin_lock_irqsave(&ide_lock, flags);
1403 1414
1404 if ((handler = hwgroup->handler) == NULL) { 1415 if (((handler = hwgroup->handler) == NULL) ||
1416 (hwgroup->req_gen != hwgroup->req_gen_timer)) {
1405 /* 1417 /*
1406 * Either a marginal timeout occurred 1418 * Either a marginal timeout occurred
1407 * (got the interrupt just as timer expired), 1419 * (got the interrupt just as timer expired),
@@ -1429,6 +1441,7 @@ void ide_timer_expiry (unsigned long data)
1429 if ((wait = expiry(drive)) > 0) { 1441 if ((wait = expiry(drive)) > 0) {
1430 /* reset timer */ 1442 /* reset timer */
1431 hwgroup->timer.expires = jiffies + wait; 1443 hwgroup->timer.expires = jiffies + wait;
1444 hwgroup->req_gen_timer = hwgroup->req_gen;
1432 add_timer(&hwgroup->timer); 1445 add_timer(&hwgroup->timer);
1433 spin_unlock_irqrestore(&ide_lock, flags); 1446 spin_unlock_irqrestore(&ide_lock, flags);
1434 return; 1447 return;
@@ -1643,6 +1656,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1643 printk(KERN_ERR "%s: ide_intr: hwgroup->busy was 0 ??\n", drive->name); 1656 printk(KERN_ERR "%s: ide_intr: hwgroup->busy was 0 ??\n", drive->name);
1644 } 1657 }
1645 hwgroup->handler = NULL; 1658 hwgroup->handler = NULL;
1659 hwgroup->req_gen++;
1646 del_timer(&hwgroup->timer); 1660 del_timer(&hwgroup->timer);
1647 spin_unlock(&ide_lock); 1661 spin_unlock(&ide_lock);
1648 1662
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index bd513f5a2323..3caa176b3155 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -583,8 +583,12 @@ u8 eighty_ninty_three (ide_drive_t *drive)
583 if(!(drive->id->hw_config & 0x4000)) 583 if(!(drive->id->hw_config & 0x4000))
584 return 0; 584 return 0;
585#endif /* CONFIG_IDEDMA_IVB */ 585#endif /* CONFIG_IDEDMA_IVB */
586 if (!(drive->id->hw_config & 0x2000)) 586 /*
587 return 0; 587 * FIXME:
588 * - change master/slave IDENTIFY order
589 * - force bit13 (80c cable present) check
590 * (unless the slave device is pre-ATA3)
591 */
588 return 1; 592 return 1;
589} 593}
590 594
@@ -885,6 +889,7 @@ static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
885 hwgroup->handler = handler; 889 hwgroup->handler = handler;
886 hwgroup->expiry = expiry; 890 hwgroup->expiry = expiry;
887 hwgroup->timer.expires = jiffies + timeout; 891 hwgroup->timer.expires = jiffies + timeout;
892 hwgroup->req_gen_timer = hwgroup->req_gen;
888 add_timer(&hwgroup->timer); 893 add_timer(&hwgroup->timer);
889} 894}
890 895
@@ -925,6 +930,7 @@ void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *ha
925 hwgroup->handler = handler; 930 hwgroup->handler = handler;
926 hwgroup->expiry = expiry; 931 hwgroup->expiry = expiry;
927 hwgroup->timer.expires = jiffies + timeout; 932 hwgroup->timer.expires = jiffies + timeout;
933 hwgroup->req_gen_timer = hwgroup->req_gen;
928 add_timer(&hwgroup->timer); 934 add_timer(&hwgroup->timer);
929 hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); 935 hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG);
930 /* Drive takes 400nS to respond, we must avoid the IRQ being 936 /* Drive takes 400nS to respond, we must avoid the IRQ being
@@ -1090,6 +1096,9 @@ static void pre_reset(ide_drive_t *drive)
1090 if (HWIF(drive)->pre_reset != NULL) 1096 if (HWIF(drive)->pre_reset != NULL)
1091 HWIF(drive)->pre_reset(drive); 1097 HWIF(drive)->pre_reset(drive);
1092 1098
1099 if (drive->current_speed != 0xff)
1100 drive->desired_speed = drive->current_speed;
1101 drive->current_speed = 0xff;
1093} 1102}
1094 1103
1095/* 1104/*
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 695610f0e3e4..ae5bf2be6f52 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1124,17 +1124,40 @@ static int set_io_32bit(ide_drive_t *drive, int arg)
1124static int set_using_dma (ide_drive_t *drive, int arg) 1124static int set_using_dma (ide_drive_t *drive, int arg)
1125{ 1125{
1126#ifdef CONFIG_BLK_DEV_IDEDMA 1126#ifdef CONFIG_BLK_DEV_IDEDMA
1127 ide_hwif_t *hwif = drive->hwif;
1128 int err = -EPERM;
1129
1127 if (!drive->id || !(drive->id->capability & 1)) 1130 if (!drive->id || !(drive->id->capability & 1))
1128 return -EPERM; 1131 goto out;
1129 if (HWIF(drive)->ide_dma_check == NULL) 1132
1130 return -EPERM; 1133 if (hwif->ide_dma_check == NULL)
1134 goto out;
1135
1136 err = -EBUSY;
1137 if (ide_spin_wait_hwgroup(drive))
1138 goto out;
1139 /*
1140 * set ->busy flag, unlock and let it ride
1141 */
1142 hwif->hwgroup->busy = 1;
1143 spin_unlock_irq(&ide_lock);
1144
1145 err = 0;
1146
1131 if (arg) { 1147 if (arg) {
1132 if (ide_set_dma(drive)) 1148 if (ide_set_dma(drive) || hwif->ide_dma_on(drive))
1133 return -EIO; 1149 err = -EIO;
1134 if (HWIF(drive)->ide_dma_on(drive)) return -EIO;
1135 } else 1150 } else
1136 ide_dma_off(drive); 1151 ide_dma_off(drive);
1137 return 0; 1152
1153 /*
1154 * lock, clear ->busy flag and unlock before leaving
1155 */
1156 spin_lock_irq(&ide_lock);
1157 hwif->hwgroup->busy = 0;
1158 spin_unlock_irq(&ide_lock);
1159out:
1160 return err;
1138#else 1161#else
1139 return -EPERM; 1162 return -EPERM;
1140#endif 1163#endif
@@ -1939,6 +1962,8 @@ static char *media_string(ide_drive_t *drive)
1939 return "tape"; 1962 return "tape";
1940 case ide_floppy: 1963 case ide_floppy:
1941 return "floppy"; 1964 return "floppy";
1965 case ide_optical:
1966 return "optical";
1942 default: 1967 default:
1943 return "UNKNOWN"; 1968 return "UNKNOWN";
1944 } 1969 }
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index d4b753e70119..dd7ec37fdeab 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -108,6 +108,7 @@ delkin_cb_remove (struct pci_dev *dev)
108 108
109static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = { 109static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
110 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 110 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
111 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
111 { 0, }, 112 { 0, },
112}; 113};
113MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl); 114MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 60ecdc258c7c..ab6fa271aeb3 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 1.01 Dec 23, 2006 2 * linux/drivers/ide/pci/hpt366.c Version 1.02 Apr 18, 2007
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
6 * Portions Copyright (C) 2003 Red Hat Inc 6 * Portions Copyright (C) 2003 Red Hat Inc
7 * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. 7 * Portions Copyright (C) 2005-2007 MontaVista Software, Inc.
8 * 8 *
9 * Thanks to HighPoint Technologies for their assistance, and hardware. 9 * Thanks to HighPoint Technologies for their assistance, and hardware.
10 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his 10 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -494,6 +494,7 @@ static struct hpt_info hpt302n __devinitdata = {
494 .chip_type = HPT302N, 494 .chip_type = HPT302N,
495 .max_mode = HPT302_ALLOW_ATA133_6 ? 4 : 3, 495 .max_mode = HPT302_ALLOW_ATA133_6 ? 4 : 3,
496 .dpll_clk = 77, 496 .dpll_clk = 77,
497 .settings = hpt37x_settings
497}; 498};
498 499
499static struct hpt_info hpt371n __devinitdata = { 500static struct hpt_info hpt371n __devinitdata = {
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 6ceb25bc5a7b..ace98929cc3d 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -255,7 +255,7 @@ static int config_chipset_for_dma(ide_drive_t *drive)
255 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name); 255 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
256 } 256 }
257 257
258 if (drive->media != ide_disk) 258 if (drive->media != ide_disk && drive->media != ide_cdrom)
259 return 0; 259 return 0;
260 260
261 if (id->capability & 4) { 261 if (id->capability & 4) {
@@ -545,6 +545,7 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
545 545
546 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 546 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
547 547
548 hwif->atapi_dma = 1;
548 hwif->ultra_mask = 0x7f; 549 hwif->ultra_mask = 0x7f;
549 hwif->mwdma_mask = 0x07; 550 hwif->mwdma_mask = 0x07;
550 551
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig
index b8a47342cd2c..cd84a55ecf20 100644
--- a/drivers/ieee1394/Kconfig
+++ b/drivers/ieee1394/Kconfig
@@ -138,9 +138,9 @@ config IEEE1394_DV1394
138 tristate "OHCI-DV I/O support (deprecated)" 138 tristate "OHCI-DV I/O support (deprecated)"
139 depends on IEEE1394 && IEEE1394_OHCI1394 139 depends on IEEE1394 && IEEE1394_OHCI1394
140 help 140 help
141 The dv1394 driver will be removed from Linux in a future release. 141 The dv1394 driver is unsupported and may be removed from Linux in a
142 Its functionality is now provided by raw1394 together with libraries 142 future release. Its functionality is now provided by raw1394 together
143 such as libiec61883. 143 with libraries such as libiec61883.
144 144
145config IEEE1394_RAWIO 145config IEEE1394_RAWIO
146 tristate "Raw IEEE1394 I/O support" 146 tristate "Raw IEEE1394 I/O support"
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index dee9529aa8e7..026e38face5c 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2564,8 +2564,8 @@ static int __init dv1394_init_module(void)
2564 int ret; 2564 int ret;
2565 2565
2566 printk(KERN_WARNING 2566 printk(KERN_WARNING
2567 "WARNING: The dv1394 driver is unsupported and will be removed " 2567 "NOTE: The dv1394 driver is unsupported and may be removed in a "
2568 "from Linux soon. Use raw1394 instead.\n"); 2568 "future Linux release. Use raw1394 instead.\n");
2569 2569
2570 cdev_init(&dv1394_cdev, &dv1394_fops); 2570 cdev_init(&dv1394_cdev, &dv1394_fops);
2571 dv1394_cdev.owner = THIS_MODULE; 2571 dv1394_cdev.owner = THIS_MODULE;
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index 818cf1aee8c7..f5e9aeec6f6e 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -498,9 +498,9 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
498 u64 sge_cmd, ctx0, ctx1; 498 u64 sge_cmd, ctx0, ctx1;
499 u64 base_addr; 499 u64 base_addr;
500 struct t3_modify_qp_wr *wqe; 500 struct t3_modify_qp_wr *wqe;
501 struct sk_buff *skb = alloc_skb(sizeof(*wqe), GFP_KERNEL); 501 struct sk_buff *skb;
502
503 502
503 skb = alloc_skb(sizeof(*wqe), GFP_KERNEL);
504 if (!skb) { 504 if (!skb) {
505 PDBG("%s alloc_skb failed\n", __FUNCTION__); 505 PDBG("%s alloc_skb failed\n", __FUNCTION__);
506 return -ENOMEM; 506 return -ENOMEM;
@@ -508,7 +508,7 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
508 err = cxio_hal_init_ctrl_cq(rdev_p); 508 err = cxio_hal_init_ctrl_cq(rdev_p);
509 if (err) { 509 if (err) {
510 PDBG("%s err %d initializing ctrl_cq\n", __FUNCTION__, err); 510 PDBG("%s err %d initializing ctrl_cq\n", __FUNCTION__, err);
511 return err; 511 goto err;
512 } 512 }
513 rdev_p->ctrl_qp.workq = dma_alloc_coherent( 513 rdev_p->ctrl_qp.workq = dma_alloc_coherent(
514 &(rdev_p->rnic_info.pdev->dev), 514 &(rdev_p->rnic_info.pdev->dev),
@@ -518,7 +518,8 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
518 GFP_KERNEL); 518 GFP_KERNEL);
519 if (!rdev_p->ctrl_qp.workq) { 519 if (!rdev_p->ctrl_qp.workq) {
520 PDBG("%s dma_alloc_coherent failed\n", __FUNCTION__); 520 PDBG("%s dma_alloc_coherent failed\n", __FUNCTION__);
521 return -ENOMEM; 521 err = -ENOMEM;
522 goto err;
522 } 523 }
523 pci_unmap_addr_set(&rdev_p->ctrl_qp, mapping, 524 pci_unmap_addr_set(&rdev_p->ctrl_qp, mapping,
524 rdev_p->ctrl_qp.dma_addr); 525 rdev_p->ctrl_qp.dma_addr);
@@ -556,6 +557,9 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
556 rdev_p->ctrl_qp.workq, 1 << T3_CTRL_QP_SIZE_LOG2); 557 rdev_p->ctrl_qp.workq, 1 << T3_CTRL_QP_SIZE_LOG2);
557 skb->priority = CPL_PRIORITY_CONTROL; 558 skb->priority = CPL_PRIORITY_CONTROL;
558 return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb)); 559 return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb));
560err:
561 kfree_skb(skb);
562 return err;
559} 563}
560 564
561static int cxio_hal_destroy_ctrl_qp(struct cxio_rdev *rdev_p) 565static int cxio_hal_destroy_ctrl_qp(struct cxio_rdev *rdev_p)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index d0ed1d35ca3e..2d2de9b8b729 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -2026,6 +2026,17 @@ static int sched(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2026 return 0; 2026 return 0;
2027} 2027}
2028 2028
2029static int set_tcb_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
2030{
2031 struct cpl_set_tcb_rpl *rpl = cplhdr(skb);
2032
2033 if (rpl->status != CPL_ERR_NONE) {
2034 printk(KERN_ERR MOD "Unexpected SET_TCB_RPL status %u "
2035 "for tid %u\n", rpl->status, GET_TID(rpl));
2036 }
2037 return CPL_RET_BUF_DONE;
2038}
2039
2029int __init iwch_cm_init(void) 2040int __init iwch_cm_init(void)
2030{ 2041{
2031 skb_queue_head_init(&rxq); 2042 skb_queue_head_init(&rxq);
@@ -2053,6 +2064,7 @@ int __init iwch_cm_init(void)
2053 t3c_handlers[CPL_ABORT_REQ_RSS] = sched; 2064 t3c_handlers[CPL_ABORT_REQ_RSS] = sched;
2054 t3c_handlers[CPL_RDMA_TERMINATE] = sched; 2065 t3c_handlers[CPL_RDMA_TERMINATE] = sched;
2055 t3c_handlers[CPL_RDMA_EC_STATUS] = sched; 2066 t3c_handlers[CPL_RDMA_EC_STATUS] = sched;
2067 t3c_handlers[CPL_SET_TCB_RPL] = set_tcb_rpl;
2056 2068
2057 /* 2069 /*
2058 * These are the real handlers that are called from a 2070 * These are the real handlers that are called from a
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index 8e4846b5c641..ee561c569d5f 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -835,6 +835,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
835 835
836 key = arbel_key_to_hw_index(fmr->ibmr.lkey); 836 key = arbel_key_to_hw_index(fmr->ibmr.lkey);
837 key &= dev->limits.num_mpts - 1; 837 key &= dev->limits.num_mpts - 1;
838 key = adjust_key(dev, key);
838 fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key); 839 fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key);
839 840
840 fmr->maps = 0; 841 fmr->maps = 0;
@@ -881,8 +882,8 @@ int mthca_init_mr_table(struct mthca_dev *dev)
881 } 882 }
882 mpts = mtts = 1 << i; 883 mpts = mtts = 1 << i;
883 } else { 884 } else {
884 mpts = dev->limits.num_mtt_segs; 885 mtts = dev->limits.num_mtt_segs;
885 mtts = dev->limits.num_mpts; 886 mpts = dev->limits.num_mpts;
886 } 887 }
887 888
888 if (!mthca_is_memfree(dev) && 889 if (!mthca_is_memfree(dev) &&
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index e70492db74f6..2b242a4823f8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -131,7 +131,7 @@ static struct sk_buff *ipoib_cm_alloc_rx_skb(struct net_device *dev, int id, int
131 skb_fill_page_desc(skb, i, page, 0, PAGE_SIZE); 131 skb_fill_page_desc(skb, i, page, 0, PAGE_SIZE);
132 132
133 mapping[i + 1] = ib_dma_map_page(priv->ca, skb_shinfo(skb)->frags[i].page, 133 mapping[i + 1] = ib_dma_map_page(priv->ca, skb_shinfo(skb)->frags[i].page,
134 0, PAGE_SIZE, DMA_TO_DEVICE); 134 0, PAGE_SIZE, DMA_FROM_DEVICE);
135 if (unlikely(ib_dma_mapping_error(priv->ca, mapping[i + 1]))) 135 if (unlikely(ib_dma_mapping_error(priv->ca, mapping[i + 1])))
136 goto partial_error; 136 goto partial_error;
137 } 137 }
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 0741c6d1337c..f2a40ae8e7d0 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -814,7 +814,7 @@ static void ipoib_set_mcast_list(struct net_device *dev)
814 queue_work(ipoib_workqueue, &priv->restart_task); 814 queue_work(ipoib_workqueue, &priv->restart_task);
815} 815}
816 816
817static void ipoib_neigh_destructor(struct neighbour *n) 817static void ipoib_neigh_cleanup(struct neighbour *n)
818{ 818{
819 struct ipoib_neigh *neigh; 819 struct ipoib_neigh *neigh;
820 struct ipoib_dev_priv *priv = netdev_priv(n->dev); 820 struct ipoib_dev_priv *priv = netdev_priv(n->dev);
@@ -822,7 +822,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
822 struct ipoib_ah *ah = NULL; 822 struct ipoib_ah *ah = NULL;
823 823
824 ipoib_dbg(priv, 824 ipoib_dbg(priv,
825 "neigh_destructor for %06x " IPOIB_GID_FMT "\n", 825 "neigh_cleanup for %06x " IPOIB_GID_FMT "\n",
826 IPOIB_QPN(n->ha), 826 IPOIB_QPN(n->ha),
827 IPOIB_GID_RAW_ARG(n->ha + 4)); 827 IPOIB_GID_RAW_ARG(n->ha + 4));
828 828
@@ -874,7 +874,7 @@ void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
874 874
875static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms) 875static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms)
876{ 876{
877 parms->neigh_destructor = ipoib_neigh_destructor; 877 parms->neigh_cleanup = ipoib_neigh_cleanup;
878 878
879 return 0; 879 return 0;
880} 880}
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index cae8c96a55f8..8960196ffb0f 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -245,7 +245,6 @@ struct iser_conn {
245 wait_queue_head_t wait; /* waitq for conn/disconn */ 245 wait_queue_head_t wait; /* waitq for conn/disconn */
246 atomic_t post_recv_buf_count; /* posted rx count */ 246 atomic_t post_recv_buf_count; /* posted rx count */
247 atomic_t post_send_buf_count; /* posted tx count */ 247 atomic_t post_send_buf_count; /* posted tx count */
248 struct work_struct comperror_work; /* conn term sleepable ctx*/
249 char name[ISER_OBJECT_NAME_SIZE]; 248 char name[ISER_OBJECT_NAME_SIZE];
250 struct iser_page_vec *page_vec; /* represents SG to fmr maps* 249 struct iser_page_vec *page_vec; /* represents SG to fmr maps*
251 * maps serialized as tx is*/ 250 * maps serialized as tx is*/
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 89e37283c836..278fcbccc2d9 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -658,6 +658,7 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
658{ 658{
659 int deferred; 659 int deferred;
660 int is_rdma_aligned = 1; 660 int is_rdma_aligned = 1;
661 struct iser_regd_buf *regd;
661 662
662 /* if we were reading, copy back to unaligned sglist, 663 /* if we were reading, copy back to unaligned sglist,
663 * anyway dma_unmap and free the copy 664 * anyway dma_unmap and free the copy
@@ -672,20 +673,20 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
672 } 673 }
673 674
674 if (iser_ctask->dir[ISER_DIR_IN]) { 675 if (iser_ctask->dir[ISER_DIR_IN]) {
675 deferred = iser_regd_buff_release 676 regd = &iser_ctask->rdma_regd[ISER_DIR_IN];
676 (&iser_ctask->rdma_regd[ISER_DIR_IN]); 677 deferred = iser_regd_buff_release(regd);
677 if (deferred) { 678 if (deferred) {
678 iser_err("References remain for BUF-IN rdma reg\n"); 679 iser_err("%d references remain for BUF-IN rdma reg\n",
679 BUG(); 680 atomic_read(&regd->ref_count));
680 } 681 }
681 } 682 }
682 683
683 if (iser_ctask->dir[ISER_DIR_OUT]) { 684 if (iser_ctask->dir[ISER_DIR_OUT]) {
684 deferred = iser_regd_buff_release 685 regd = &iser_ctask->rdma_regd[ISER_DIR_OUT];
685 (&iser_ctask->rdma_regd[ISER_DIR_OUT]); 686 deferred = iser_regd_buff_release(regd);
686 if (deferred) { 687 if (deferred) {
687 iser_err("References remain for BUF-OUT rdma reg\n"); 688 iser_err("%d references remain for BUF-OUT rdma reg\n",
688 BUG(); 689 atomic_read(&regd->ref_count));
689 } 690 }
690 } 691 }
691 692
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 693b77002897..1fc967464a28 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -48,7 +48,6 @@
48 48
49static void iser_cq_tasklet_fn(unsigned long data); 49static void iser_cq_tasklet_fn(unsigned long data);
50static void iser_cq_callback(struct ib_cq *cq, void *cq_context); 50static void iser_cq_callback(struct ib_cq *cq, void *cq_context);
51static void iser_comp_error_worker(struct work_struct *work);
52 51
53static void iser_cq_event_callback(struct ib_event *cause, void *context) 52static void iser_cq_event_callback(struct ib_event *cause, void *context)
54{ 53{
@@ -480,7 +479,6 @@ int iser_conn_init(struct iser_conn **ibconn)
480 init_waitqueue_head(&ib_conn->wait); 479 init_waitqueue_head(&ib_conn->wait);
481 atomic_set(&ib_conn->post_recv_buf_count, 0); 480 atomic_set(&ib_conn->post_recv_buf_count, 0);
482 atomic_set(&ib_conn->post_send_buf_count, 0); 481 atomic_set(&ib_conn->post_send_buf_count, 0);
483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker);
484 INIT_LIST_HEAD(&ib_conn->conn_list); 482 INIT_LIST_HEAD(&ib_conn->conn_list);
485 spin_lock_init(&ib_conn->lock); 483 spin_lock_init(&ib_conn->lock);
486 484
@@ -753,26 +751,6 @@ int iser_post_send(struct iser_desc *tx_desc)
753 return ret_val; 751 return ret_val;
754} 752}
755 753
756static void iser_comp_error_worker(struct work_struct *work)
757{
758 struct iser_conn *ib_conn =
759 container_of(work, struct iser_conn, comperror_work);
760
761 /* getting here when the state is UP means that the conn is being *
762 * terminated asynchronously from the iSCSI layer's perspective. */
763 if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP,
764 ISER_CONN_TERMINATING))
765 iscsi_conn_failure(ib_conn->iser_conn->iscsi_conn,
766 ISCSI_ERR_CONN_FAILED);
767
768 /* complete the termination process if disconnect event was delivered *
769 * note there are no more non completed posts to the QP */
770 if (ib_conn->disc_evt_flag) {
771 ib_conn->state = ISER_CONN_DOWN;
772 wake_up_interruptible(&ib_conn->wait);
773 }
774}
775
776static void iser_handle_comp_error(struct iser_desc *desc) 754static void iser_handle_comp_error(struct iser_desc *desc)
777{ 755{
778 struct iser_dto *dto = &desc->dto; 756 struct iser_dto *dto = &desc->dto;
@@ -791,8 +769,22 @@ static void iser_handle_comp_error(struct iser_desc *desc)
791 } 769 }
792 770
793 if (atomic_read(&ib_conn->post_recv_buf_count) == 0 && 771 if (atomic_read(&ib_conn->post_recv_buf_count) == 0 &&
794 atomic_read(&ib_conn->post_send_buf_count) == 0) 772 atomic_read(&ib_conn->post_send_buf_count) == 0) {
795 schedule_work(&ib_conn->comperror_work); 773 /* getting here when the state is UP means that the conn is *
774 * being terminated asynchronously from the iSCSI layer's *
775 * perspective. */
776 if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP,
777 ISER_CONN_TERMINATING))
778 iscsi_conn_failure(ib_conn->iser_conn->iscsi_conn,
779 ISCSI_ERR_CONN_FAILED);
780
781 /* complete the termination process if disconnect event was delivered *
782 * note there are no more non completed posts to the QP */
783 if (ib_conn->disc_evt_flag) {
784 ib_conn->state = ISER_CONN_DOWN;
785 wake_up_interruptible(&ib_conn->wait);
786 }
787 }
796} 788}
797 789
798static void iser_cq_tasklet_fn(unsigned long data) 790static void iser_cq_tasklet_fn(unsigned long data)
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index c7db4032ef02..e8606c48c9c3 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -553,6 +553,7 @@ static int ucb1400_ts_remove(struct device *dev)
553} 553}
554 554
555static struct device_driver ucb1400_ts_driver = { 555static struct device_driver ucb1400_ts_driver = {
556 .name = "ucb1400_ts",
556 .owner = THIS_MODULE, 557 .owner = THIS_MODULE,
557 .bus = &ac97_bus_type, 558 .bus = &ac97_bus_type,
558 .probe = ucb1400_ts_probe, 559 .probe = ucb1400_ts_probe,
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 63e51dd6debe..00e31609a238 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -54,7 +54,7 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
54#define USB_SX353_PRODUCT_ID 0x0022 54#define USB_SX353_PRODUCT_ID 0x0022
55 55
56/* table of devices that work with this driver */ 56/* table of devices that work with this driver */
57static struct usb_device_id gigaset_table [] = { 57static const struct usb_device_id gigaset_table [] = {
58 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) }, 58 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) },
59 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) }, 59 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) },
60 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, 60 { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) },
@@ -2305,7 +2305,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
2305 gigaset_unassign(cs); 2305 gigaset_unassign(cs);
2306} 2306}
2307 2307
2308static struct gigaset_ops gigops = { 2308static const struct gigaset_ops gigops = {
2309 gigaset_write_cmd, 2309 gigaset_write_cmd,
2310 gigaset_write_room, 2310 gigaset_write_room,
2311 gigaset_chars_in_buffer, 2311 gigaset_chars_in_buffer,
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index b460a73a7c85..6df336bdd571 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -944,8 +944,8 @@ static DEFINE_SPINLOCK(driver_lock);
944struct cardstate *gigaset_get_cs_by_id(int id) 944struct cardstate *gigaset_get_cs_by_id(int id)
945{ 945{
946 unsigned long flags; 946 unsigned long flags;
947 static struct cardstate *ret = NULL; 947 struct cardstate *ret = NULL;
948 static struct cardstate *cs; 948 struct cardstate *cs;
949 struct gigaset_driver *drv; 949 struct gigaset_driver *drv;
950 unsigned i; 950 unsigned i;
951 951
@@ -999,7 +999,7 @@ void gigaset_debugdrivers(void)
999static struct cardstate *gigaset_get_cs_by_minor(unsigned minor) 999static struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
1000{ 1000{
1001 unsigned long flags; 1001 unsigned long flags;
1002 static struct cardstate *ret = NULL; 1002 struct cardstate *ret = NULL;
1003 struct gigaset_driver *drv; 1003 struct gigaset_driver *drv;
1004 unsigned index; 1004 unsigned index;
1005 1005
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index 4661e2c722bc..cec1ef342fcc 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -409,7 +409,7 @@ static struct reply_t tab_cid[] = /* no dle mode */ //FIXME
409}; 409};
410#endif 410#endif
411 411
412static struct resp_type_t resp_type[]= 412static const struct resp_type_t resp_type[] =
413{ 413{
414 /*{"", RSP_EMPTY, RT_NOTHING},*/ 414 /*{"", RSP_EMPTY, RT_NOTHING},*/
415 {"OK", RSP_OK, RT_NOTHING}, 415 {"OK", RSP_OK, RT_NOTHING},
@@ -511,7 +511,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
511 unsigned char *argv[MAX_REC_PARAMS + 1]; 511 unsigned char *argv[MAX_REC_PARAMS + 1];
512 int params; 512 int params;
513 int i, j; 513 int i, j;
514 struct resp_type_t *rt; 514 const struct resp_type_t *rt;
515 int curarg; 515 int curarg;
516 unsigned long flags; 516 unsigned long flags;
517 unsigned next, tail, head; 517 unsigned next, tail, head;
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index 8c0eb522dab1..e0505f238807 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -274,7 +274,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
274 * bit 12..10 = number of trailing '1' bits in result 274 * bit 12..10 = number of trailing '1' bits in result
275 * bit 14..13 = number of bits added by stuffing 275 * bit 14..13 = number of bits added by stuffing
276 */ 276 */
277static u16 stufftab[5 * 256] = { 277static const u16 stufftab[5 * 256] = {
278// previous 1s = 0: 278// previous 1s = 0:
279 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 279 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
280 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, 280 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f,
@@ -629,7 +629,7 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
629 * (replacing 8 by 7 to make it fit; the algorithm won't care) 629 * (replacing 8 by 7 to make it fit; the algorithm won't care)
630 * bit 7 set if there are 5 or more "interior" consecutive '1' bits 630 * bit 7 set if there are 5 or more "interior" consecutive '1' bits
631 */ 631 */
632static unsigned char bitcounts[256] = { 632static const unsigned char bitcounts[256] = {
633 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 633 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04,
634 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 634 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05,
635 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 635 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04,
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index c8b7db65e48f..ea44302e6e7e 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -459,7 +459,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
459 return -EINVAL; 459 return -EINVAL;
460} 460}
461 461
462static struct gigaset_ops ops = { 462static const struct gigaset_ops ops = {
463 gigaset_write_cmd, 463 gigaset_write_cmd,
464 gigaset_write_room, 464 gigaset_write_room,
465 gigaset_chars_in_buffer, 465 gigaset_chars_in_buffer,
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 04f2ad7ba8b0..2baef349c12d 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
50#define USB_M105_PRODUCT_ID 0x0009 50#define USB_M105_PRODUCT_ID 0x0009
51 51
52/* table of devices that work with this driver */ 52/* table of devices that work with this driver */
53static struct usb_device_id gigaset_table [] = { 53static const struct usb_device_id gigaset_table [] = {
54 { USB_DEVICE(USB_M105_VENDOR_ID, USB_M105_PRODUCT_ID) }, 54 { USB_DEVICE(USB_M105_VENDOR_ID, USB_M105_PRODUCT_ID) },
55 { } /* Terminating entry */ 55 { } /* Terminating entry */
56}; 56};
@@ -860,7 +860,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
860 gigaset_unassign(cs); 860 gigaset_unassign(cs);
861} 861}
862 862
863static struct gigaset_ops ops = { 863static const struct gigaset_ops ops = {
864 gigaset_write_cmd, 864 gigaset_write_cmd,
865 gigaset_write_room, 865 gigaset_write_room,
866 gigaset_chars_in_buffer, 866 gigaset_chars_in_buffer,
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 9df9e3548cf1..c547a6665052 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -440,7 +440,7 @@ isar_bh(struct work_struct *work)
440{ 440{
441 struct BCState *bcs = container_of(work, struct BCState, tqueue); 441 struct BCState *bcs = container_of(work, struct BCState, tqueue);
442 442
443 BChannel_bh(bcs); 443 BChannel_bh(work);
444 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event)) 444 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event))
445 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR); 445 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR);
446 if (test_and_clear_bit(B_LL_CONNECT, &bcs->event)) 446 if (test_and_clear_bit(B_LL_CONNECT, &bcs->event))
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index e85b4c7c36f7..cab26f301eab 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -1171,6 +1171,7 @@ void kvm_mmu_pre_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes)
1171 * and zap two pdes instead of one. 1171 * and zap two pdes instead of one.
1172 */ 1172 */
1173 if (level == PT32_ROOT_LEVEL) { 1173 if (level == PT32_ROOT_LEVEL) {
1174 page_offset &= ~7; /* kill rounding error */
1174 page_offset <<= 1; 1175 page_offset <<= 1;
1175 npte = 2; 1176 npte = 2;
1176 } 1177 }
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index bfa0ce42ea92..fbbf9d6b299f 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -618,7 +618,7 @@ static void fix_pmode_dataseg(int seg, struct kvm_save_segment *save)
618{ 618{
619 struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; 619 struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg];
620 620
621 if (vmcs_readl(sf->base) == save->base) { 621 if (vmcs_readl(sf->base) == save->base && (save->base & AR_S_MASK)) {
622 vmcs_write16(sf->selector, save->selector); 622 vmcs_write16(sf->selector, save->selector);
623 vmcs_writel(sf->base, save->base); 623 vmcs_writel(sf->base, save->base);
624 vmcs_write32(sf->limit, save->limit); 624 vmcs_write32(sf->limit, save->limit);
@@ -1888,6 +1888,27 @@ again:
1888 [cr2]"i"(offsetof(struct kvm_vcpu, cr2)) 1888 [cr2]"i"(offsetof(struct kvm_vcpu, cr2))
1889 : "cc", "memory" ); 1889 : "cc", "memory" );
1890 1890
1891 /*
1892 * Reload segment selectors ASAP. (it's needed for a functional
1893 * kernel: x86 relies on having __KERNEL_PDA in %fs and x86_64
1894 * relies on having 0 in %gs for the CPU PDA to work.)
1895 */
1896 if (fs_gs_ldt_reload_needed) {
1897 load_ldt(ldt_sel);
1898 load_fs(fs_sel);
1899 /*
1900 * If we have to reload gs, we must take care to
1901 * preserve our gs base.
1902 */
1903 local_irq_disable();
1904 load_gs(gs_sel);
1905#ifdef CONFIG_X86_64
1906 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
1907#endif
1908 local_irq_enable();
1909
1910 reload_tss();
1911 }
1891 ++kvm_stat.exits; 1912 ++kvm_stat.exits;
1892 1913
1893 save_msrs(vcpu->guest_msrs, NR_BAD_MSRS); 1914 save_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
@@ -1905,22 +1926,6 @@ again:
1905 kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR); 1926 kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR);
1906 r = 0; 1927 r = 0;
1907 } else { 1928 } else {
1908 if (fs_gs_ldt_reload_needed) {
1909 load_ldt(ldt_sel);
1910 load_fs(fs_sel);
1911 /*
1912 * If we have to reload gs, we must take care to
1913 * preserve our gs base.
1914 */
1915 local_irq_disable();
1916 load_gs(gs_sel);
1917#ifdef CONFIG_X86_64
1918 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
1919#endif
1920 local_irq_enable();
1921
1922 reload_tss();
1923 }
1924 /* 1929 /*
1925 * Profile KVM exit RIPs: 1930 * Profile KVM exit RIPs:
1926 */ 1931 */
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 3096836d8bd3..c9f3dc4fd3ee 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -1259,9 +1259,9 @@ static int smu_release(struct inode *inode, struct file *file)
1259 set_current_state(TASK_UNINTERRUPTIBLE); 1259 set_current_state(TASK_UNINTERRUPTIBLE);
1260 if (pp->cmd.status != 1) 1260 if (pp->cmd.status != 1)
1261 break; 1261 break;
1262 spin_lock_irqsave(&pp->lock, flags);
1263 schedule();
1264 spin_unlock_irqrestore(&pp->lock, flags); 1262 spin_unlock_irqrestore(&pp->lock, flags);
1263 schedule();
1264 spin_lock_irqsave(&pp->lock, flags);
1265 } 1265 }
1266 set_current_state(TASK_RUNNING); 1266 set_current_state(TASK_RUNNING);
1267 remove_wait_queue(&pp->wait, &wait); 1267 remove_wait_queue(&pp->wait, &wait);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5554adaa58f9..e61e0efe9ec7 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -863,9 +863,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
863 863
864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ 864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */
865 bitmap->filemap_attr = kzalloc( 865 bitmap->filemap_attr = kzalloc(
866 (((num_pages*4/8)+sizeof(unsigned long)-1) 866 roundup( DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)),
867 /sizeof(unsigned long))
868 *sizeof(unsigned long),
869 GFP_KERNEL); 867 GFP_KERNEL);
870 if (!bitmap->filemap_attr) 868 if (!bitmap->filemap_attr)
871 goto out; 869 goto out;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6c06e825cff5..509171ca7fa8 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1318,6 +1318,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1318 char b[BDEVNAME_SIZE]; 1318 char b[BDEVNAME_SIZE];
1319 struct kobject *ko; 1319 struct kobject *ko;
1320 char *s; 1320 char *s;
1321 int err;
1321 1322
1322 if (rdev->mddev) { 1323 if (rdev->mddev) {
1323 MD_BUG(); 1324 MD_BUG();
@@ -1352,20 +1353,35 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1352 while ( (s=strchr(rdev->kobj.k_name, '/')) != NULL) 1353 while ( (s=strchr(rdev->kobj.k_name, '/')) != NULL)
1353 *s = '!'; 1354 *s = '!';
1354 1355
1355 list_add(&rdev->same_set, &mddev->disks);
1356 rdev->mddev = mddev; 1356 rdev->mddev = mddev;
1357 printk(KERN_INFO "md: bind<%s>\n", b); 1357 printk(KERN_INFO "md: bind<%s>\n", b);
1358 1358
1359 rdev->kobj.parent = &mddev->kobj; 1359 rdev->kobj.parent = &mddev->kobj;
1360 kobject_add(&rdev->kobj); 1360 if ((err = kobject_add(&rdev->kobj)))
1361 goto fail;
1361 1362
1362 if (rdev->bdev->bd_part) 1363 if (rdev->bdev->bd_part)
1363 ko = &rdev->bdev->bd_part->kobj; 1364 ko = &rdev->bdev->bd_part->kobj;
1364 else 1365 else
1365 ko = &rdev->bdev->bd_disk->kobj; 1366 ko = &rdev->bdev->bd_disk->kobj;
1366 sysfs_create_link(&rdev->kobj, ko, "block"); 1367 if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) {
1368 kobject_del(&rdev->kobj);
1369 goto fail;
1370 }
1371 list_add(&rdev->same_set, &mddev->disks);
1367 bd_claim_by_disk(rdev->bdev, rdev, mddev->gendisk); 1372 bd_claim_by_disk(rdev->bdev, rdev, mddev->gendisk);
1368 return 0; 1373 return 0;
1374
1375 fail:
1376 printk(KERN_WARNING "md: failed to register dev-%s for %s\n",
1377 b, mdname(mddev));
1378 return err;
1379}
1380
1381static void delayed_delete(struct work_struct *ws)
1382{
1383 mdk_rdev_t *rdev = container_of(ws, mdk_rdev_t, del_work);
1384 kobject_del(&rdev->kobj);
1369} 1385}
1370 1386
1371static void unbind_rdev_from_array(mdk_rdev_t * rdev) 1387static void unbind_rdev_from_array(mdk_rdev_t * rdev)
@@ -1380,7 +1396,12 @@ static void unbind_rdev_from_array(mdk_rdev_t * rdev)
1380 printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); 1396 printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b));
1381 rdev->mddev = NULL; 1397 rdev->mddev = NULL;
1382 sysfs_remove_link(&rdev->kobj, "block"); 1398 sysfs_remove_link(&rdev->kobj, "block");
1383 kobject_del(&rdev->kobj); 1399
1400 /* We need to delay this, otherwise we can deadlock when
1401 * writing to 'remove' to "dev/state"
1402 */
1403 INIT_WORK(&rdev->del_work, delayed_delete);
1404 schedule_work(&rdev->del_work);
1384} 1405}
1385 1406
1386/* 1407/*
@@ -2966,7 +2987,9 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
2966 mddev->kobj.k_name = NULL; 2987 mddev->kobj.k_name = NULL;
2967 snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md"); 2988 snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");
2968 mddev->kobj.ktype = &md_ktype; 2989 mddev->kobj.ktype = &md_ktype;
2969 kobject_register(&mddev->kobj); 2990 if (kobject_register(&mddev->kobj))
2991 printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
2992 disk->disk_name);
2970 return NULL; 2993 return NULL;
2971} 2994}
2972 2995
@@ -3144,9 +3167,12 @@ static int do_md_run(mddev_t * mddev)
3144 bitmap_destroy(mddev); 3167 bitmap_destroy(mddev);
3145 return err; 3168 return err;
3146 } 3169 }
3147 if (mddev->pers->sync_request) 3170 if (mddev->pers->sync_request) {
3148 sysfs_create_group(&mddev->kobj, &md_redundancy_group); 3171 if (sysfs_create_group(&mddev->kobj, &md_redundancy_group))
3149 else if (mddev->ro == 2) /* auto-readonly not meaningful */ 3172 printk(KERN_WARNING
3173 "md: cannot register extra attributes for %s\n",
3174 mdname(mddev));
3175 } else if (mddev->ro == 2) /* auto-readonly not meaningful */
3150 mddev->ro = 0; 3176 mddev->ro = 0;
3151 3177
3152 atomic_set(&mddev->writes_pending,0); 3178 atomic_set(&mddev->writes_pending,0);
@@ -3160,7 +3186,9 @@ static int do_md_run(mddev_t * mddev)
3160 if (rdev->raid_disk >= 0) { 3186 if (rdev->raid_disk >= 0) {
3161 char nm[20]; 3187 char nm[20];
3162 sprintf(nm, "rd%d", rdev->raid_disk); 3188 sprintf(nm, "rd%d", rdev->raid_disk);
3163 sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); 3189 if (sysfs_create_link(&mddev->kobj, &rdev->kobj, nm))
3190 printk("md: cannot register %s for %s\n",
3191 nm, mdname(mddev));
3164 } 3192 }
3165 3193
3166 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3194 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
@@ -3325,6 +3353,7 @@ static int do_md_stop(mddev_t * mddev, int mode)
3325 mddev->queue->merge_bvec_fn = NULL; 3353 mddev->queue->merge_bvec_fn = NULL;
3326 mddev->queue->unplug_fn = NULL; 3354 mddev->queue->unplug_fn = NULL;
3327 mddev->queue->issue_flush_fn = NULL; 3355 mddev->queue->issue_flush_fn = NULL;
3356 mddev->queue->backing_dev_info.congested_fn = NULL;
3328 if (mddev->pers->sync_request) 3357 if (mddev->pers->sync_request)
3329 sysfs_remove_group(&mddev->kobj, &md_redundancy_group); 3358 sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
3330 3359
@@ -3371,6 +3400,9 @@ static int do_md_stop(mddev_t * mddev, int mode)
3371 sysfs_remove_link(&mddev->kobj, nm); 3400 sysfs_remove_link(&mddev->kobj, nm);
3372 } 3401 }
3373 3402
3403 /* make sure all delayed_delete calls have finished */
3404 flush_scheduled_work();
3405
3374 export_array(mddev); 3406 export_array(mddev);
3375 3407
3376 mddev->array_size = 0; 3408 mddev->array_size = 0;
@@ -5385,8 +5417,12 @@ static int remove_and_add_spares(mddev_t *mddev)
5385 if (mddev->pers->hot_add_disk(mddev,rdev)) { 5417 if (mddev->pers->hot_add_disk(mddev,rdev)) {
5386 char nm[20]; 5418 char nm[20];
5387 sprintf(nm, "rd%d", rdev->raid_disk); 5419 sprintf(nm, "rd%d", rdev->raid_disk);
5388 sysfs_create_link(&mddev->kobj, 5420 if (sysfs_create_link(&mddev->kobj,
5389 &rdev->kobj, nm); 5421 &rdev->kobj, nm))
5422 printk(KERN_WARNING
5423 "md: cannot register "
5424 "%s for %s\n",
5425 nm, mdname(mddev));
5390 spares++; 5426 spares++;
5391 md_new_event(mddev); 5427 md_new_event(mddev);
5392 } else 5428 } else
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 54a1ad5eef42..8d59914f2057 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3642,12 +3642,15 @@ static int run(mddev_t *mddev)
3642 } 3642 }
3643 3643
3644 /* Ok, everything is just fine now */ 3644 /* Ok, everything is just fine now */
3645 sysfs_create_group(&mddev->kobj, &raid5_attrs_group); 3645 if (sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
3646 printk(KERN_WARNING
3647 "raid5: failed to create sysfs attributes for %s\n",
3648 mdname(mddev));
3646 3649
3647 mddev->queue->unplug_fn = raid5_unplug_device; 3650 mddev->queue->unplug_fn = raid5_unplug_device;
3648 mddev->queue->issue_flush_fn = raid5_issue_flush; 3651 mddev->queue->issue_flush_fn = raid5_issue_flush;
3649 mddev->queue->backing_dev_info.congested_fn = raid5_congested;
3650 mddev->queue->backing_dev_info.congested_data = mddev; 3652 mddev->queue->backing_dev_info.congested_data = mddev;
3653 mddev->queue->backing_dev_info.congested_fn = raid5_congested;
3651 3654
3652 mddev->array_size = mddev->size * (conf->previous_raid_disks - 3655 mddev->array_size = mddev->size * (conf->previous_raid_disks -
3653 conf->max_degraded); 3656 conf->max_degraded);
@@ -3678,6 +3681,7 @@ static int stop(mddev_t *mddev)
3678 mddev->thread = NULL; 3681 mddev->thread = NULL;
3679 shrink_stripes(conf); 3682 shrink_stripes(conf);
3680 kfree(conf->stripe_hashtbl); 3683 kfree(conf->stripe_hashtbl);
3684 mddev->queue->backing_dev_info.congested_fn = NULL;
3681 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 3685 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
3682 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); 3686 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group);
3683 kfree(conf->disks); 3687 kfree(conf->disks);
@@ -3950,7 +3954,12 @@ static int raid5_start_reshape(mddev_t *mddev)
3950 added_devices++; 3954 added_devices++;
3951 rdev->recovery_offset = 0; 3955 rdev->recovery_offset = 0;
3952 sprintf(nm, "rd%d", rdev->raid_disk); 3956 sprintf(nm, "rd%d", rdev->raid_disk);
3953 sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); 3957 if (sysfs_create_link(&mddev->kobj,
3958 &rdev->kobj, nm))
3959 printk(KERN_WARNING
3960 "raid5: failed to create "
3961 " link %s for %s\n",
3962 nm, mdname(mddev));
3954 } else 3963 } else
3955 break; 3964 break;
3956 } 3965 }
@@ -4104,6 +4113,10 @@ static struct mdk_personality raid4_personality =
4104 .spare_active = raid5_spare_active, 4113 .spare_active = raid5_spare_active,
4105 .sync_request = sync_request, 4114 .sync_request = sync_request,
4106 .resize = raid5_resize, 4115 .resize = raid5_resize,
4116#ifdef CONFIG_MD_RAID5_RESHAPE
4117 .check_reshape = raid5_check_reshape,
4118 .start_reshape = raid5_start_reshape,
4119#endif
4107 .quiesce = raid5_quiesce, 4120 .quiesce = raid5_quiesce,
4108}; 4121};
4109 4122
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index cbf7c0564889..fcb194135627 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -310,13 +310,15 @@ void ir_rc5_timer_end(unsigned long data)
310 tv.tv_usec - ir->base_time.tv_usec; 310 tv.tv_usec - ir->base_time.tv_usec;
311 } 311 }
312 312
313 /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */ 313 /* signal we're ready to start a new code */
314 ir->active = 0;
315
316 /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
314 if (gap < 28000) { 317 if (gap < 28000) {
315 dprintk(1, "ir-common: spurious timer_end\n"); 318 dprintk(1, "ir-common: spurious timer_end\n");
316 return; 319 return;
317 } 320 }
318 321
319 ir->active = 0;
320 if (ir->last_bit < 20) { 322 if (ir->last_bit < 20) {
321 /* ignore spurious codes (caused by light/other remotes) */ 323 /* ignore spurious codes (caused by light/other remotes) */
322 dprintk(1, "ir-common: short code: %x\n", ir->code); 324 dprintk(1, "ir-common: short code: %x\n", ir->code);
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index fc77de45ca4d..a5c0e1a3e6d1 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -180,8 +180,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
180 struct dvb_device *dvbdev = file->private_data; 180 struct dvb_device *dvbdev = file->private_data;
181 struct dmxdev *dmxdev = dvbdev->priv; 181 struct dmxdev *dmxdev = dvbdev->priv;
182 182
183 if (mutex_lock_interruptible(&dmxdev->mutex)) 183 mutex_lock(&dmxdev->mutex);
184 return -ERESTARTSYS;
185 184
186 if ((file->f_flags & O_ACCMODE) == O_WRONLY) { 185 if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
187 dmxdev->demux->disconnect_frontend(dmxdev->demux); 186 dmxdev->demux->disconnect_frontend(dmxdev->demux);
@@ -673,13 +672,8 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
673static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, 672static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev,
674 struct dmxdev_filter *dmxdevfilter) 673 struct dmxdev_filter *dmxdevfilter)
675{ 674{
676 if (mutex_lock_interruptible(&dmxdev->mutex)) 675 mutex_lock(&dmxdev->mutex);
677 return -ERESTARTSYS; 676 mutex_lock(&dmxdevfilter->mutex);
678
679 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
680 mutex_unlock(&dmxdev->mutex);
681 return -ERESTARTSYS;
682 }
683 677
684 dvb_dmxdev_filter_stop(dmxdevfilter); 678 dvb_dmxdev_filter_stop(dmxdevfilter);
685 dvb_dmxdev_filter_reset(dmxdevfilter); 679 dvb_dmxdev_filter_reset(dmxdevfilter);
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index fcff5eab21a3..6d8d1c3df863 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -673,8 +673,7 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
673 struct dvb_demux *demux = feed->demux; 673 struct dvb_demux *demux = feed->demux;
674 int ret; 674 int ret;
675 675
676 if (mutex_lock_interruptible(&demux->mutex)) 676 mutex_lock(&demux->mutex);
677 return -ERESTARTSYS;
678 677
679 if (feed->state < DMX_STATE_GO) { 678 if (feed->state < DMX_STATE_GO) {
680 mutex_unlock(&demux->mutex); 679 mutex_unlock(&demux->mutex);
@@ -748,8 +747,7 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
748 struct dvb_demux *demux = (struct dvb_demux *)dmx; 747 struct dvb_demux *demux = (struct dvb_demux *)dmx;
749 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; 748 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
750 749
751 if (mutex_lock_interruptible(&demux->mutex)) 750 mutex_lock(&demux->mutex);
752 return -ERESTARTSYS;
753 751
754 if (feed->state == DMX_STATE_FREE) { 752 if (feed->state == DMX_STATE_FREE) {
755 mutex_unlock(&demux->mutex); 753 mutex_unlock(&demux->mutex);
@@ -916,8 +914,7 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
916 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 914 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
917 int ret; 915 int ret;
918 916
919 if (mutex_lock_interruptible(&dvbdmx->mutex)) 917 mutex_lock(&dvbdmx->mutex);
920 return -ERESTARTSYS;
921 918
922 if (!dvbdmx->stop_feed) { 919 if (!dvbdmx->stop_feed) {
923 mutex_unlock(&dvbdmx->mutex); 920 mutex_unlock(&dvbdmx->mutex);
@@ -942,8 +939,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
942 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; 939 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
943 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 940 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
944 941
945 if (mutex_lock_interruptible(&dvbdmx->mutex)) 942 mutex_lock(&dvbdmx->mutex);
946 return -ERESTARTSYS;
947 943
948 if (dvbdmxfilter->feed != dvbdmxfeed) { 944 if (dvbdmxfilter->feed != dvbdmxfeed) {
949 mutex_unlock(&dvbdmx->mutex); 945 mutex_unlock(&dvbdmx->mutex);
@@ -1016,8 +1012,7 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
1016 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; 1012 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
1017 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; 1013 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
1018 1014
1019 if (mutex_lock_interruptible(&dvbdmx->mutex)) 1015 mutex_lock(&dvbdmx->mutex);
1020 return -ERESTARTSYS;
1021 1016
1022 if (dvbdmxfeed->state == DMX_STATE_FREE) { 1017 if (dvbdmxfeed->state == DMX_STATE_FREE) {
1023 mutex_unlock(&dvbdmx->mutex); 1018 mutex_unlock(&dvbdmx->mutex);
@@ -1126,8 +1121,7 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux,
1126 if (demux->frontend) 1121 if (demux->frontend)
1127 return -EINVAL; 1122 return -EINVAL;
1128 1123
1129 if (mutex_lock_interruptible(&dvbdemux->mutex)) 1124 mutex_lock(&dvbdemux->mutex);
1130 return -ERESTARTSYS;
1131 1125
1132 demux->frontend = frontend; 1126 demux->frontend = frontend;
1133 mutex_unlock(&dvbdemux->mutex); 1127 mutex_unlock(&dvbdemux->mutex);
@@ -1138,8 +1132,7 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
1138{ 1132{
1139 struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; 1133 struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
1140 1134
1141 if (mutex_lock_interruptible(&dvbdemux->mutex)) 1135 mutex_lock(&dvbdemux->mutex);
1142 return -ERESTARTSYS;
1143 1136
1144 demux->frontend = NULL; 1137 demux->frontend = NULL;
1145 mutex_unlock(&dvbdemux->mutex); 1138 mutex_unlock(&dvbdemux->mutex);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 490337b5ee3e..14a372a0fe8b 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -203,8 +203,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
203 203
204 int id; 204 int id;
205 205
206 if (mutex_lock_interruptible(&dvbdev_register_lock)) 206 mutex_lock(&dvbdev_register_lock);
207 return -ERESTARTSYS;
208 207
209 if ((id = dvbdev_get_free_id (adap, type)) < 0){ 208 if ((id = dvbdev_get_free_id (adap, type)) < 0){
210 mutex_unlock(&dvbdev_register_lock); 209 mutex_unlock(&dvbdev_register_lock);
@@ -294,8 +293,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
294{ 293{
295 int num; 294 int num;
296 295
297 if (mutex_lock_interruptible(&dvbdev_register_lock)) 296 mutex_lock(&dvbdev_register_lock);
298 return -ERESTARTSYS;
299 297
300 if ((num = dvbdev_get_free_adapter_num ()) < 0) { 298 if ((num = dvbdev_get_free_adapter_num ()) < 0) {
301 mutex_unlock(&dvbdev_register_lock); 299 mutex_unlock(&dvbdev_register_lock);
@@ -323,8 +321,7 @@ EXPORT_SYMBOL(dvb_register_adapter);
323 321
324int dvb_unregister_adapter(struct dvb_adapter *adap) 322int dvb_unregister_adapter(struct dvb_adapter *adap)
325{ 323{
326 if (mutex_lock_interruptible(&dvbdev_register_lock)) 324 mutex_lock(&dvbdev_register_lock);
327 return -ERESTARTSYS;
328 list_del (&adap->list_head); 325 list_del (&adap->list_head);
329 mutex_unlock(&dvbdev_register_lock); 326 mutex_unlock(&dvbdev_register_lock);
330 return 0; 327 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 9511a31c8f50..68ed3a788083 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -107,8 +107,6 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
107 return -ENOMEM; 107 return -ENOMEM;
108 108
109 input_dev->evbit[0] = BIT(EV_KEY); 109 input_dev->evbit[0] = BIT(EV_KEY);
110 input_dev->keycodesize = sizeof(unsigned char);
111 input_dev->keycodemax = KEY_MAX;
112 input_dev->name = "IR-receiver inside an USB DVB receiver"; 110 input_dev->name = "IR-receiver inside an USB DVB receiver";
113 input_dev->phys = d->rc_phys; 111 input_dev->phys = d->rc_phys;
114 usb_to_input_id(d->udev, &input_dev->id); 112 usb_to_input_id(d->udev, &input_dev->id);
diff --git a/drivers/media/dvb/frontends/isl6421.c b/drivers/media/dvb/frontends/isl6421.c
index ef319369ec26..c967148a5945 100644
--- a/drivers/media/dvb/frontends/isl6421.c
+++ b/drivers/media/dvb/frontends/isl6421.c
@@ -122,6 +122,7 @@ struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter
122 /* detect if it is present or not */ 122 /* detect if it is present or not */
123 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) { 123 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) {
124 kfree(isl6421); 124 kfree(isl6421);
125 fe->sec_priv = NULL;
125 return NULL; 126 return NULL;
126 } 127 }
127 128
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index 4c27a2d90a38..ccc429cbbad0 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -212,7 +212,7 @@ static int tda10086_send_master_cmd (struct dvb_frontend* fe,
212 for(i=0; i< cmd->msg_len; i++) { 212 for(i=0; i< cmd->msg_len; i++) {
213 tda10086_write_byte(state, 0x48+i, cmd->msg[i]); 213 tda10086_write_byte(state, 0x48+i, cmd->msg[i]);
214 } 214 }
215 tda10086_write_byte(state, 0x36, 0x08 | ((cmd->msg_len + 1) << 4)); 215 tda10086_write_byte(state, 0x36, 0x08 | ((cmd->msg_len - 1) << 4));
216 216
217 tda10086_diseqc_wait(state); 217 tda10086_diseqc_wait(state);
218 218
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index ffda71dfdd65..058df5c10034 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -149,6 +149,15 @@ static inline void pluto_rw(struct pluto *pluto, u32 reg, u32 mask, u32 bits)
149 writel(val, &pluto->io_mem[reg]); 149 writel(val, &pluto->io_mem[reg]);
150} 150}
151 151
152static void pluto_write_tscr(struct pluto *pluto, u32 val)
153{
154 /* set the number of packets */
155 val &= ~TSCR_ADEF;
156 val |= TS_DMA_PACKETS / 2;
157
158 pluto_writereg(pluto, REG_TSCR, val);
159}
160
152static void pluto_setsda(void *data, int state) 161static void pluto_setsda(void *data, int state)
153{ 162{
154 struct pluto *pluto = data; 163 struct pluto *pluto = data;
@@ -213,11 +222,11 @@ static void pluto_reset_ts(struct pluto *pluto, int reenable)
213 222
214 if (val & TSCR_RSTN) { 223 if (val & TSCR_RSTN) {
215 val &= ~TSCR_RSTN; 224 val &= ~TSCR_RSTN;
216 pluto_writereg(pluto, REG_TSCR, val); 225 pluto_write_tscr(pluto, val);
217 } 226 }
218 if (reenable) { 227 if (reenable) {
219 val |= TSCR_RSTN; 228 val |= TSCR_RSTN;
220 pluto_writereg(pluto, REG_TSCR, val); 229 pluto_write_tscr(pluto, val);
221 } 230 }
222} 231}
223 232
@@ -339,7 +348,7 @@ static irqreturn_t pluto_irq(int irq, void *dev_id)
339 } 348 }
340 349
341 /* ACK the interrupt */ 350 /* ACK the interrupt */
342 pluto_writereg(pluto, REG_TSCR, tscr | TSCR_IACK); 351 pluto_write_tscr(pluto, tscr | TSCR_IACK);
343 352
344 return IRQ_HANDLED; 353 return IRQ_HANDLED;
345} 354}
@@ -348,9 +357,6 @@ static void __devinit pluto_enable_irqs(struct pluto *pluto)
348{ 357{
349 u32 val = pluto_readreg(pluto, REG_TSCR); 358 u32 val = pluto_readreg(pluto, REG_TSCR);
350 359
351 /* set the number of packets */
352 val &= ~TSCR_ADEF;
353 val |= TS_DMA_PACKETS / 2;
354 /* disable AFUL and LOCK interrupts */ 360 /* disable AFUL and LOCK interrupts */
355 val |= (TSCR_MSKA | TSCR_MSKL); 361 val |= (TSCR_MSKA | TSCR_MSKL);
356 /* enable DMA and OVERFLOW interrupts */ 362 /* enable DMA and OVERFLOW interrupts */
@@ -358,7 +364,7 @@ static void __devinit pluto_enable_irqs(struct pluto *pluto)
358 /* clear pending interrupts */ 364 /* clear pending interrupts */
359 val |= TSCR_IACK; 365 val |= TSCR_IACK;
360 366
361 pluto_writereg(pluto, REG_TSCR, val); 367 pluto_write_tscr(pluto, val);
362} 368}
363 369
364static void pluto_disable_irqs(struct pluto *pluto) 370static void pluto_disable_irqs(struct pluto *pluto)
@@ -370,7 +376,7 @@ static void pluto_disable_irqs(struct pluto *pluto)
370 /* clear pending interrupts */ 376 /* clear pending interrupts */
371 val |= TSCR_IACK; 377 val |= TSCR_IACK;
372 378
373 pluto_writereg(pluto, REG_TSCR, val); 379 pluto_write_tscr(pluto, val);
374} 380}
375 381
376static int __devinit pluto_hw_init(struct pluto *pluto) 382static int __devinit pluto_hw_init(struct pluto *pluto)
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 920b63f8cf05..af66a5d5ecd8 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5menu "Radio Adapters" 5menu "Radio Adapters"
6 depends on VIDEO_DEV!=n 6 depends on VIDEO_DEV
7 7
8config RADIO_CADET 8config RADIO_CADET
9 tristate "ADS Cadet AM/FM Tuner" 9 tristate "ADS Cadet AM/FM Tuner"
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 7a6105153f23..ff6aefde10df 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -577,14 +577,14 @@ config VIDEO_ZORAN_AVS6EYES
577 577
578config VIDEO_MEYE 578config VIDEO_MEYE
579 tristate "Sony Vaio Picturebook Motion Eye Video For Linux" 579 tristate "Sony Vaio Picturebook Motion Eye Video For Linux"
580 depends on PCI && SONYPI && VIDEO_V4L1 580 depends on PCI && SONY_LAPTOP && VIDEO_V4L1
581 ---help--- 581 ---help---
582 This is the video4linux driver for the Motion Eye camera found 582 This is the video4linux driver for the Motion Eye camera found
583 in the Vaio Picturebook laptops. Please read the material in 583 in the Vaio Picturebook laptops. Please read the material in
584 <file:Documentation/video4linux/meye.txt> for more information. 584 <file:Documentation/video4linux/meye.txt> for more information.
585 585
586 If you say Y or M here, you need to say Y or M to "Sony Programmable 586 If you say Y or M here, you need to say Y or M to "Sony Laptop
587 I/O Control Device" in the character device section. 587 Extras" in the misc device section.
588 588
589 To compile this driver as a module, choose M here: the 589 To compile this driver as a module, choose M here: the
590 module will be called meye. 590 module will be called meye.
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 98681da5e3b9..664aba8b4d85 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -925,13 +925,13 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
925 if (p->palette != VIDEO_PALETTE_YUV422 && p->palette != VIDEO_PALETTE_YUYV) 925 if (p->palette != VIDEO_PALETTE_YUV422 && p->palette != VIDEO_PALETTE_YUYV)
926 return -EINVAL; 926 return -EINVAL;
927 mutex_lock(&meye.lock); 927 mutex_lock(&meye.lock);
928 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 928 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERABRIGHTNESS,
929 p->brightness >> 10); 929 p->brightness >> 10);
930 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, 930 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAHUE,
931 p->hue >> 10); 931 p->hue >> 10);
932 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACOLOR, 932 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACOLOR,
933 p->colour >> 10); 933 p->colour >> 10);
934 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, 934 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACONTRAST,
935 p->contrast >> 10); 935 p->contrast >> 10);
936 meye.picture = *p; 936 meye.picture = *p;
937 mutex_unlock(&meye.lock); 937 mutex_unlock(&meye.lock);
@@ -1043,11 +1043,11 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1043 meye.params.quality != jp->quality) 1043 meye.params.quality != jp->quality)
1044 mchip_hic_stop(); /* need restart */ 1044 mchip_hic_stop(); /* need restart */
1045 meye.params = *jp; 1045 meye.params = *jp;
1046 sonypi_camera_command(SONYPI_COMMAND_SETCAMERASHARPNESS, 1046 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS,
1047 meye.params.sharpness); 1047 meye.params.sharpness);
1048 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAAGC, 1048 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC,
1049 meye.params.agc); 1049 meye.params.agc);
1050 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, 1050 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE,
1051 meye.params.picture); 1051 meye.params.picture);
1052 mutex_unlock(&meye.lock); 1052 mutex_unlock(&meye.lock);
1053 break; 1053 break;
@@ -1287,38 +1287,38 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1287 mutex_lock(&meye.lock); 1287 mutex_lock(&meye.lock);
1288 switch (c->id) { 1288 switch (c->id) {
1289 case V4L2_CID_BRIGHTNESS: 1289 case V4L2_CID_BRIGHTNESS:
1290 sonypi_camera_command( 1290 sony_pic_camera_command(
1291 SONYPI_COMMAND_SETCAMERABRIGHTNESS, c->value); 1291 SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value);
1292 meye.picture.brightness = c->value << 10; 1292 meye.picture.brightness = c->value << 10;
1293 break; 1293 break;
1294 case V4L2_CID_HUE: 1294 case V4L2_CID_HUE:
1295 sonypi_camera_command( 1295 sony_pic_camera_command(
1296 SONYPI_COMMAND_SETCAMERAHUE, c->value); 1296 SONY_PIC_COMMAND_SETCAMERAHUE, c->value);
1297 meye.picture.hue = c->value << 10; 1297 meye.picture.hue = c->value << 10;
1298 break; 1298 break;
1299 case V4L2_CID_CONTRAST: 1299 case V4L2_CID_CONTRAST:
1300 sonypi_camera_command( 1300 sony_pic_camera_command(
1301 SONYPI_COMMAND_SETCAMERACONTRAST, c->value); 1301 SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value);
1302 meye.picture.contrast = c->value << 10; 1302 meye.picture.contrast = c->value << 10;
1303 break; 1303 break;
1304 case V4L2_CID_SATURATION: 1304 case V4L2_CID_SATURATION:
1305 sonypi_camera_command( 1305 sony_pic_camera_command(
1306 SONYPI_COMMAND_SETCAMERACOLOR, c->value); 1306 SONY_PIC_COMMAND_SETCAMERACOLOR, c->value);
1307 meye.picture.colour = c->value << 10; 1307 meye.picture.colour = c->value << 10;
1308 break; 1308 break;
1309 case V4L2_CID_AGC: 1309 case V4L2_CID_AGC:
1310 sonypi_camera_command( 1310 sony_pic_camera_command(
1311 SONYPI_COMMAND_SETCAMERAAGC, c->value); 1311 SONY_PIC_COMMAND_SETCAMERAAGC, c->value);
1312 meye.params.agc = c->value; 1312 meye.params.agc = c->value;
1313 break; 1313 break;
1314 case V4L2_CID_SHARPNESS: 1314 case V4L2_CID_SHARPNESS:
1315 sonypi_camera_command( 1315 sony_pic_camera_command(
1316 SONYPI_COMMAND_SETCAMERASHARPNESS, c->value); 1316 SONY_PIC_COMMAND_SETCAMERASHARPNESS, c->value);
1317 meye.params.sharpness = c->value; 1317 meye.params.sharpness = c->value;
1318 break; 1318 break;
1319 case V4L2_CID_PICTURE: 1319 case V4L2_CID_PICTURE:
1320 sonypi_camera_command( 1320 sony_pic_camera_command(
1321 SONYPI_COMMAND_SETCAMERAPICTURE, c->value); 1321 SONY_PIC_COMMAND_SETCAMERAPICTURE, c->value);
1322 meye.params.picture = c->value; 1322 meye.params.picture = c->value;
1323 break; 1323 break;
1324 case V4L2_CID_JPEGQUAL: 1324 case V4L2_CID_JPEGQUAL:
@@ -1848,7 +1848,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1848 memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); 1848 memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
1849 meye.video_dev->dev = &meye.mchip_dev->dev; 1849 meye.video_dev->dev = &meye.mchip_dev->dev;
1850 1850
1851 if ((ret = sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1))) { 1851 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
1852 printk(KERN_ERR "meye: unable to power on the camera\n"); 1852 printk(KERN_ERR "meye: unable to power on the camera\n");
1853 printk(KERN_ERR "meye: did you enable the camera in " 1853 printk(KERN_ERR "meye: did you enable the camera in "
1854 "sonypi using the module options ?\n"); 1854 "sonypi using the module options ?\n");
@@ -1928,13 +1928,13 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1928 meye.params.picture = 0; 1928 meye.params.picture = 0;
1929 meye.params.framerate = 0; 1929 meye.params.framerate = 0;
1930 1930
1931 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 32); 1931 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, 32);
1932 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, 32); 1932 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAHUE, 32);
1933 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACOLOR, 32); 1933 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACOLOR, 32);
1934 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, 32); 1934 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACONTRAST, 32);
1935 sonypi_camera_command(SONYPI_COMMAND_SETCAMERASHARPNESS, 32); 1935 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS, 32);
1936 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, 0); 1936 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0);
1937 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAAGC, 48); 1937 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48);
1938 1938
1939 printk(KERN_INFO "meye: Motion Eye Camera Driver v%s.\n", 1939 printk(KERN_INFO "meye: Motion Eye Camera Driver v%s.\n",
1940 MEYE_DRIVER_VERSION); 1940 MEYE_DRIVER_VERSION);
@@ -1953,7 +1953,7 @@ outremap:
1953outregions: 1953outregions:
1954 pci_disable_device(meye.mchip_dev); 1954 pci_disable_device(meye.mchip_dev);
1955outenabledev: 1955outenabledev:
1956 sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0); 1956 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
1957outsonypienable: 1957outsonypienable:
1958 kfifo_free(meye.doneq); 1958 kfifo_free(meye.doneq);
1959outkfifoalloc2: 1959outkfifoalloc2:
@@ -1986,7 +1986,7 @@ static void __devexit meye_remove(struct pci_dev *pcidev)
1986 1986
1987 pci_disable_device(meye.mchip_dev); 1987 pci_disable_device(meye.mchip_dev);
1988 1988
1989 sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0); 1989 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
1990 1990
1991 kfifo_free(meye.doneq); 1991 kfifo_free(meye.doneq);
1992 kfifo_free(meye.grabq); 1992 kfifo_free(meye.grabq);
diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h
index ea107cb5c845..323d0074120d 100644
--- a/drivers/media/video/meye.h
+++ b/drivers/media/video/meye.h
@@ -255,7 +255,7 @@
255/****************************************************************************/ 255/****************************************************************************/
256 256
257/* Sony Programmable I/O Controller for accessing the camera commands */ 257/* Sony Programmable I/O Controller for accessing the camera commands */
258#include <linux/sonypi.h> 258#include <linux/sony-laptop.h>
259 259
260/* private API definitions */ 260/* private API definitions */
261#include <linux/meye.h> 261#include <linux/meye.h>
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 2fb9fe6a1ae7..ba1af3c8525e 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -780,18 +780,16 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
780 return 0; 780 return 0;
781} 781}
782 782
783static int msp_suspend(struct device * dev, pm_message_t state) 783static int msp_suspend(struct i2c_client *client, pm_message_t state)
784{ 784{
785 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
786 785
787 v4l_dbg(1, msp_debug, client, "suspend\n"); 786 v4l_dbg(1, msp_debug, client, "suspend\n");
788 msp_reset(client); 787 msp_reset(client);
789 return 0; 788 return 0;
790} 789}
791 790
792static int msp_resume(struct device * dev) 791static int msp_resume(struct i2c_client *client)
793{ 792{
794 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
795 793
796 v4l_dbg(1, msp_debug, client, "resume\n"); 794 v4l_dbg(1, msp_debug, client, "resume\n");
797 msp_wake_thread(client); 795 msp_wake_thread(client);
@@ -825,7 +823,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
825 if (msp_reset(client) == -1) { 823 if (msp_reset(client) == -1) {
826 v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); 824 v4l_dbg(1, msp_debug, client, "msp3400 not found\n");
827 kfree(client); 825 kfree(client);
828 return -1; 826 return 0;
829 } 827 }
830 828
831 state = kmalloc(sizeof(*state), GFP_KERNEL); 829 state = kmalloc(sizeof(*state), GFP_KERNEL);
@@ -859,7 +857,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
859 v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); 857 v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n");
860 kfree(state); 858 kfree(state);
861 kfree(client); 859 kfree(client);
862 return -1; 860 return 0;
863 } 861 }
864 862
865 msp_set_audio(client); 863 msp_set_audio(client);
@@ -996,11 +994,11 @@ static struct i2c_driver i2c_driver = {
996 .id = I2C_DRIVERID_MSP3400, 994 .id = I2C_DRIVERID_MSP3400,
997 .attach_adapter = msp_probe, 995 .attach_adapter = msp_probe,
998 .detach_client = msp_detach, 996 .detach_client = msp_detach,
997 .suspend = msp_suspend,
998 .resume = msp_resume,
999 .command = msp_command, 999 .command = msp_command,
1000 .driver = { 1000 .driver = {
1001 .name = "msp3400", 1001 .name = "msp3400",
1002 .suspend = msp_suspend,
1003 .resume = msp_resume,
1004 }, 1002 },
1005}; 1003};
1006 1004
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 7735b6758921..4d5bbd859de1 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -961,7 +961,7 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
961 reg |= 0x10; 961 reg |= 0x10;
962 } else if (std == V4L2_STD_NTSC_M_JP) { 962 } else if (std == V4L2_STD_NTSC_M_JP) {
963 reg |= 0x40; 963 reg |= 0x40;
964 } else if (std == V4L2_STD_SECAM) { 964 } else if (std & V4L2_STD_SECAM) {
965 reg |= 0x50; 965 reg |= 0x50;
966 } 966 }
967 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg); 967 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg);
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 7be73e3763de..15dbc6bf42a7 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -804,9 +804,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
804 return 0; 804 return 0;
805} 805}
806 806
807static int tuner_suspend(struct device *dev, pm_message_t state) 807static int tuner_suspend(struct i2c_client *c, pm_message_t state)
808{ 808{
809 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
810 struct tuner *t = i2c_get_clientdata (c); 809 struct tuner *t = i2c_get_clientdata (c);
811 810
812 tuner_dbg ("suspend\n"); 811 tuner_dbg ("suspend\n");
@@ -814,9 +813,8 @@ static int tuner_suspend(struct device *dev, pm_message_t state)
814 return 0; 813 return 0;
815} 814}
816 815
817static int tuner_resume(struct device *dev) 816static int tuner_resume(struct i2c_client *c)
818{ 817{
819 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
820 struct tuner *t = i2c_get_clientdata (c); 818 struct tuner *t = i2c_get_clientdata (c);
821 819
822 tuner_dbg ("resume\n"); 820 tuner_dbg ("resume\n");
@@ -837,10 +835,10 @@ static struct i2c_driver driver = {
837 .attach_adapter = tuner_probe, 835 .attach_adapter = tuner_probe,
838 .detach_client = tuner_detach, 836 .detach_client = tuner_detach,
839 .command = tuner_command, 837 .command = tuner_command,
838 .suspend = tuner_suspend,
839 .resume = tuner_resume,
840 .driver = { 840 .driver = {
841 .name = "tuner", 841 .name = "tuner",
842 .suspend = tuner_suspend,
843 .resume = tuner_resume,
844 }, 842 },
845}; 843};
846static struct i2c_client client_template = { 844static struct i2c_client client_template = {
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 404c014db1bd..1d2d03f77894 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -815,7 +815,7 @@ mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
815static int 815static int
816mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 816mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
817{ 817{
818 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 818 MPT_SCSI_HOST *hd;
819 struct mptsas_target_reset_event *target_reset_list, *n; 819 struct mptsas_target_reset_event *target_reset_list, *n;
820 int rc; 820 int rc;
821 821
@@ -827,7 +827,10 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
827 if (reset_phase != MPT_IOC_POST_RESET) 827 if (reset_phase != MPT_IOC_POST_RESET)
828 goto out; 828 goto out;
829 829
830 if (!hd || !hd->ioc) 830 if (!ioc->sh || !ioc->sh->hostdata)
831 goto out;
832 hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
833 if (!hd->ioc)
831 goto out; 834 goto out;
832 835
833 if (list_empty(&hd->target_reset_list)) 836 if (list_empty(&hd->target_reset_list))
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index da9859f2caf2..b17c4b2bc9ef 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -390,13 +390,6 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
390 return BLKPREP_KILL; 390 return BLKPREP_KILL;
391 } 391 }
392 392
393 /* request is already processed by us, so return */
394 if (blk_special_request(req)) {
395 osm_debug("REQ_SPECIAL already set!\n");
396 req->cmd_flags |= REQ_DONTPREP;
397 return BLKPREP_OK;
398 }
399
400 /* connect the i2o_block_request to the request */ 393 /* connect the i2o_block_request to the request */
401 if (!req->special) { 394 if (!req->special) {
402 ireq = i2o_block_request_alloc(); 395 ireq = i2o_block_request_alloc();
@@ -408,11 +401,8 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
408 ireq->i2o_blk_dev = i2o_blk_dev; 401 ireq->i2o_blk_dev = i2o_blk_dev;
409 req->special = ireq; 402 req->special = ireq;
410 ireq->req = req; 403 ireq->req = req;
411 } else 404 }
412 ireq = req->special;
413
414 /* do not come back here */ 405 /* do not come back here */
415 req->cmd_type = REQ_TYPE_SPECIAL;
416 req->cmd_flags |= REQ_DONTPREP; 406 req->cmd_flags |= REQ_DONTPREP;
417 407
418 return BLKPREP_OK; 408 return BLKPREP_OK;
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index c707c8ebc1a2..b0b4458ae90b 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -319,7 +319,7 @@ int sm501_unit_power(struct device *dev, unsigned int unit, unsigned int to)
319 319
320 mode &= 3; /* get current power mode */ 320 mode &= 3; /* get current power mode */
321 321
322 if (unit > ARRAY_SIZE(sm->unit_power)) { 322 if (unit >= ARRAY_SIZE(sm->unit_power)) {
323 dev_err(dev, "%s: bad unit %d\n", __FUNCTION__, unit); 323 dev_err(dev, "%s: bad unit %d\n", __FUNCTION__, unit);
324 goto already; 324 goto already;
325 } 325 }
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 445c4b10c41e..a3c525b2616a 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -112,16 +112,21 @@ config SONY_LAPTOP
112 depends on X86 && ACPI 112 depends on X86 && ACPI
113 select BACKLIGHT_CLASS_DEVICE 113 select BACKLIGHT_CLASS_DEVICE
114 ---help--- 114 ---help---
115 This mini-driver drives the SNC device present in the ACPI BIOS of 115 This mini-driver drives the SNC and SPIC devices present in the ACPI
116 the Sony Vaio laptops. 116 BIOS of the Sony Vaio laptops.
117 117
118 It gives access to some extra laptop functionalities. In its current 118 It gives access to some extra laptop functionalities like Bluetooth,
119 form, this driver let the user set or query the screen brightness 119 screen brightness control, Fn keys and allows powering on/off some
120 through the backlight subsystem and remove/apply power to some
121 devices. 120 devices.
122 121
123 Read <file:Documentation/sony-laptop.txt> for more information. 122 Read <file:Documentation/sony-laptop.txt> for more information.
124 123
124config SONY_LAPTOP_OLD
125 bool "Sonypi compatibility"
126 depends on SONY_LAPTOP
127 ---help---
128 Build the sonypi driver compatibility code into the sony-laptop driver.
129
125config THINKPAD_ACPI 130config THINKPAD_ACPI
126 tristate "ThinkPad ACPI Laptop Extras" 131 tristate "ThinkPad ACPI Laptop Extras"
127 depends on X86 && ACPI 132 depends on X86 && ACPI
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 4b232124a1ab..65c32a95e121 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * 4 *
5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor 5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
6 * Copyright (C) 2006 Corentin Chary 6 * Copyright (C) 2006-2007 Corentin Chary
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@
48#include <acpi/acpi_bus.h> 48#include <acpi/acpi_bus.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50 50
51#define ASUS_LAPTOP_VERSION "0.40" 51#define ASUS_LAPTOP_VERSION "0.41"
52 52
53#define ASUS_HOTK_NAME "Asus Laptop Support" 53#define ASUS_HOTK_NAME "Asus Laptop Support"
54#define ASUS_HOTK_CLASS "hotkey" 54#define ASUS_HOTK_CLASS "hotkey"
@@ -81,7 +81,8 @@
81#define TLED_ON 0x08 //touchpad LED 81#define TLED_ON 0x08 //touchpad LED
82#define RLED_ON 0x10 //Record LED 82#define RLED_ON 0x10 //Record LED
83#define PLED_ON 0x20 //Phone LED 83#define PLED_ON 0x20 //Phone LED
84#define LCD_ON 0x40 //LCD backlight 84#define GLED_ON 0x40 //Gaming LED
85#define LCD_ON 0x80 //LCD backlight
85 86
86#define ASUS_LOG ASUS_HOTK_FILE ": " 87#define ASUS_LOG ASUS_HOTK_FILE ": "
87#define ASUS_ERR KERN_ERR ASUS_LOG 88#define ASUS_ERR KERN_ERR ASUS_LOG
@@ -94,6 +95,19 @@ MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary");
94MODULE_DESCRIPTION(ASUS_HOTK_NAME); 95MODULE_DESCRIPTION(ASUS_HOTK_NAME);
95MODULE_LICENSE("GPL"); 96MODULE_LICENSE("GPL");
96 97
98/* WAPF defines the behavior of the Fn+Fx wlan key
99 * The significance of values is yet to be found, but
100 * most of the time:
101 * 0x0 will do nothing
102 * 0x1 will allow to control the device with Fn+Fx key.
103 * 0x4 will send an ACPI event (0x88) while pressing the Fn+Fx key
104 * 0x5 like 0x1 or 0x4
105 * So, if something doesn't work as you want, just try other values =)
106 */
107static uint wapf = 1;
108module_param(wapf, uint, 0644);
109MODULE_PARM_DESC(wapf, "WAPF value");
110
97#define ASUS_HANDLE(object, paths...) \ 111#define ASUS_HANDLE(object, paths...) \
98 static acpi_handle object##_handle = NULL; \ 112 static acpi_handle object##_handle = NULL; \
99 static char *object##_paths[] = { paths } 113 static char *object##_paths[] = { paths }
@@ -103,6 +117,7 @@ ASUS_HANDLE(mled_set, ASUS_HOTK_PREFIX "MLED");
103ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED"); 117ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED");
104ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */ 118ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */
105ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */ 119ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */
120ASUS_HANDLE(gled_set, ASUS_HOTK_PREFIX "GLED"); /* G1, G2 (probably) */
106 121
107/* LEDD */ 122/* LEDD */
108ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM"); 123ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM");
@@ -221,6 +236,7 @@ ASUS_LED(mled, "mail");
221ASUS_LED(tled, "touchpad"); 236ASUS_LED(tled, "touchpad");
222ASUS_LED(rled, "record"); 237ASUS_LED(rled, "record");
223ASUS_LED(pled, "phone"); 238ASUS_LED(pled, "phone");
239ASUS_LED(gled, "gaming");
224 240
225/* 241/*
226 * This function evaluates an ACPI method, given an int as parameter, the 242 * This function evaluates an ACPI method, given an int as parameter, the
@@ -245,32 +261,19 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
245 return (status == AE_OK); 261 return (status == AE_OK);
246} 262}
247 263
248static int read_acpi_int(acpi_handle handle, const char *method, int *val,
249 struct acpi_object_list *params)
250{
251 struct acpi_buffer output;
252 union acpi_object out_obj;
253 acpi_status status;
254
255 output.length = sizeof(out_obj);
256 output.pointer = &out_obj;
257
258 status = acpi_evaluate_object(handle, (char *)method, params, &output);
259 *val = out_obj.integer.value;
260 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
261}
262
263static int read_wireless_status(int mask) 264static int read_wireless_status(int mask)
264{ 265{
265 int status; 266 ulong status;
267 acpi_status rv = AE_OK;
266 268
267 if (!wireless_status_handle) 269 if (!wireless_status_handle)
268 return (hotk->status & mask) ? 1 : 0; 270 return (hotk->status & mask) ? 1 : 0;
269 271
270 if (read_acpi_int(wireless_status_handle, NULL, &status, NULL)) { 272 rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
271 return (status & mask) ? 1 : 0; 273 if (ACPI_FAILURE(rv))
272 } else
273 printk(ASUS_WARNING "Error reading Wireless status\n"); 274 printk(ASUS_WARNING "Error reading Wireless status\n");
275 else
276 return (status & mask) ? 1 : 0;
274 277
275 return (hotk->status & mask) ? 1 : 0; 278 return (hotk->status & mask) ? 1 : 0;
276} 279}
@@ -285,19 +288,28 @@ static int read_status(int mask)
285 return (hotk->status & mask) ? 1 : 0; 288 return (hotk->status & mask) ? 1 : 0;
286} 289}
287 290
288static void write_status(acpi_handle handle, int out, int mask, int invert) 291static void write_status(acpi_handle handle, int out, int mask)
289{ 292{
290 hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask); 293 hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask);
291 294
292 if (invert) /* invert target value */ 295 switch (mask) {
296 case MLED_ON:
293 out = !out & 0x1; 297 out = !out & 0x1;
298 break;
299 case GLED_ON:
300 out = (out & 0x1) + 1;
301 break;
302 default:
303 out &= 0x1;
304 break;
305 }
294 306
295 if (handle && !write_acpi_int(handle, NULL, out, NULL)) 307 if (handle && !write_acpi_int(handle, NULL, out, NULL))
296 printk(ASUS_WARNING " write failed\n"); 308 printk(ASUS_WARNING " write failed %x\n", mask);
297} 309}
298 310
299/* /sys/class/led handlers */ 311/* /sys/class/led handlers */
300#define ASUS_LED_HANDLER(object, mask, invert) \ 312#define ASUS_LED_HANDLER(object, mask) \
301 static void object##_led_set(struct led_classdev *led_cdev, \ 313 static void object##_led_set(struct led_classdev *led_cdev, \
302 enum led_brightness value) \ 314 enum led_brightness value) \
303 { \ 315 { \
@@ -307,13 +319,14 @@ static void write_status(acpi_handle handle, int out, int mask, int invert)
307 static void object##_led_update(struct work_struct *ignored) \ 319 static void object##_led_update(struct work_struct *ignored) \
308 { \ 320 { \
309 int value = object##_led_wk; \ 321 int value = object##_led_wk; \
310 write_status(object##_set_handle, value, (mask), (invert)); \ 322 write_status(object##_set_handle, value, (mask)); \
311 } 323 }
312 324
313ASUS_LED_HANDLER(mled, MLED_ON, 1); 325ASUS_LED_HANDLER(mled, MLED_ON);
314ASUS_LED_HANDLER(pled, PLED_ON, 0); 326ASUS_LED_HANDLER(pled, PLED_ON);
315ASUS_LED_HANDLER(rled, RLED_ON, 0); 327ASUS_LED_HANDLER(rled, RLED_ON);
316ASUS_LED_HANDLER(tled, TLED_ON, 0); 328ASUS_LED_HANDLER(tled, TLED_ON);
329ASUS_LED_HANDLER(gled, GLED_ON);
317 330
318static int get_lcd_state(void) 331static int get_lcd_state(void)
319{ 332{
@@ -338,7 +351,7 @@ static int set_lcd_state(int value)
338 printk(ASUS_WARNING "Error switching LCD\n"); 351 printk(ASUS_WARNING "Error switching LCD\n");
339 } 352 }
340 353
341 write_status(NULL, lcd, LCD_ON, 0); 354 write_status(NULL, lcd, LCD_ON);
342 return 0; 355 return 0;
343} 356}
344 357
@@ -354,9 +367,11 @@ static void lcd_blank(int blank)
354 367
355static int read_brightness(struct backlight_device *bd) 368static int read_brightness(struct backlight_device *bd)
356{ 369{
357 int value; 370 ulong value;
371 acpi_status rv = AE_OK;
358 372
359 if (!read_acpi_int(brightness_get_handle, NULL, &value, NULL)) 373 rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value);
374 if (ACPI_FAILURE(rv))
360 printk(ASUS_WARNING "Error reading brightness\n"); 375 printk(ASUS_WARNING "Error reading brightness\n");
361 376
362 return value; 377 return value;
@@ -403,8 +418,10 @@ static ssize_t show_infos(struct device *dev,
403 struct device_attribute *attr, char *page) 418 struct device_attribute *attr, char *page)
404{ 419{
405 int len = 0; 420 int len = 0;
406 int temp; 421 ulong temp;
407 char buf[16]; //enough for all info 422 char buf[16]; //enough for all info
423 acpi_status rv = AE_OK;
424
408 /* 425 /*
409 * We use the easy way, we don't care of off and count, so we don't set eof 426 * We use the easy way, we don't care of off and count, so we don't set eof
410 * to 1 427 * to 1
@@ -418,9 +435,10 @@ static ssize_t show_infos(struct device *dev,
418 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. 435 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
419 * The significance of others is yet to be found. 436 * The significance of others is yet to be found.
420 */ 437 */
421 if (read_acpi_int(hotk->handle, "SFUN", &temp, NULL)) 438 rv = acpi_evaluate_integer(hotk->handle, "SFUN", NULL, &temp);
422 len += 439 if (!ACPI_FAILURE(rv))
423 sprintf(page + len, "SFUN value : 0x%04x\n", temp); 440 len += sprintf(page + len, "SFUN value : 0x%04x\n",
441 (uint) temp);
424 /* 442 /*
425 * Another value for userspace: the ASYM method returns 0x02 for 443 * Another value for userspace: the ASYM method returns 0x02 for
426 * battery low and 0x04 for battery critical, its readings tend to be 444 * battery low and 0x04 for battery critical, its readings tend to be
@@ -428,9 +446,10 @@ static ssize_t show_infos(struct device *dev,
428 * Note: since not all the laptops provide this method, errors are 446 * Note: since not all the laptops provide this method, errors are
429 * silently ignored. 447 * silently ignored.
430 */ 448 */
431 if (read_acpi_int(hotk->handle, "ASYM", &temp, NULL)) 449 rv = acpi_evaluate_integer(hotk->handle, "ASYM", NULL, &temp);
432 len += 450 if (!ACPI_FAILURE(rv))
433 sprintf(page + len, "ASYM value : 0x%04x\n", temp); 451 len += sprintf(page + len, "ASYM value : 0x%04x\n",
452 (uint) temp);
434 if (asus_info) { 453 if (asus_info) {
435 snprintf(buf, 16, "%d", asus_info->length); 454 snprintf(buf, 16, "%d", asus_info->length);
436 len += sprintf(page + len, "DSDT length : %s\n", buf); 455 len += sprintf(page + len, "DSDT length : %s\n", buf);
@@ -465,7 +484,7 @@ static int parse_arg(const char *buf, unsigned long count, int *val)
465} 484}
466 485
467static ssize_t store_status(const char *buf, size_t count, 486static ssize_t store_status(const char *buf, size_t count,
468 acpi_handle handle, int mask, int invert) 487 acpi_handle handle, int mask)
469{ 488{
470 int rv, value; 489 int rv, value;
471 int out = 0; 490 int out = 0;
@@ -474,7 +493,7 @@ static ssize_t store_status(const char *buf, size_t count,
474 if (rv > 0) 493 if (rv > 0)
475 out = value ? 1 : 0; 494 out = value ? 1 : 0;
476 495
477 write_status(handle, out, mask, invert); 496 write_status(handle, out, mask);
478 497
479 return rv; 498 return rv;
480} 499}
@@ -515,7 +534,7 @@ static ssize_t show_wlan(struct device *dev,
515static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, 534static ssize_t store_wlan(struct device *dev, struct device_attribute *attr,
516 const char *buf, size_t count) 535 const char *buf, size_t count)
517{ 536{
518 return store_status(buf, count, wl_switch_handle, WL_ON, 0); 537 return store_status(buf, count, wl_switch_handle, WL_ON);
519} 538}
520 539
521/* 540/*
@@ -531,7 +550,7 @@ static ssize_t store_bluetooth(struct device *dev,
531 struct device_attribute *attr, const char *buf, 550 struct device_attribute *attr, const char *buf,
532 size_t count) 551 size_t count)
533{ 552{
534 return store_status(buf, count, bt_switch_handle, BT_ON, 0); 553 return store_status(buf, count, bt_switch_handle, BT_ON);
535} 554}
536 555
537/* 556/*
@@ -547,12 +566,15 @@ static void set_display(int value)
547 566
548static int read_display(void) 567static int read_display(void)
549{ 568{
550 int value = 0; 569 ulong value = 0;
570 acpi_status rv = AE_OK;
551 571
552 /* In most of the case, we know how to set the display, but sometime 572 /* In most of the case, we know how to set the display, but sometime
553 we can't read it */ 573 we can't read it */
554 if (display_get_handle) { 574 if (display_get_handle) {
555 if (!read_acpi_int(display_get_handle, NULL, &value, NULL)) 575 rv = acpi_evaluate_integer(display_get_handle, NULL,
576 NULL, &value);
577 if (ACPI_FAILURE(rv))
556 printk(ASUS_WARNING "Error reading display status\n"); 578 printk(ASUS_WARNING "Error reading display status\n");
557 } 579 }
558 580
@@ -656,10 +678,10 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
656 * switched 678 * switched
657 */ 679 */
658 if (event == ATKD_LCD_ON) { 680 if (event == ATKD_LCD_ON) {
659 write_status(NULL, 1, LCD_ON, 0); 681 write_status(NULL, 1, LCD_ON);
660 lcd_blank(FB_BLANK_UNBLANK); 682 lcd_blank(FB_BLANK_UNBLANK);
661 } else if (event == ATKD_LCD_OFF) { 683 } else if (event == ATKD_LCD_OFF) {
662 write_status(NULL, 0, LCD_ON, 0); 684 write_status(NULL, 0, LCD_ON);
663 lcd_blank(FB_BLANK_POWERDOWN); 685 lcd_blank(FB_BLANK_POWERDOWN);
664 } 686 }
665 687
@@ -771,7 +793,7 @@ static int asus_hotk_get_info(void)
771{ 793{
772 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 794 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
773 union acpi_object *model = NULL; 795 union acpi_object *model = NULL;
774 int bsts_result, hwrs_result; 796 ulong bsts_result, hwrs_result;
775 char *string = NULL; 797 char *string = NULL;
776 acpi_status status; 798 acpi_status status;
777 799
@@ -794,11 +816,16 @@ static int asus_hotk_get_info(void)
794 } 816 }
795 817
796 /* This needs to be called for some laptops to init properly */ 818 /* This needs to be called for some laptops to init properly */
797 if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result, NULL)) 819 status =
820 acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result);
821 if (ACPI_FAILURE(status))
798 printk(ASUS_WARNING "Error calling BSTS\n"); 822 printk(ASUS_WARNING "Error calling BSTS\n");
799 else if (bsts_result) 823 else if (bsts_result)
800 printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n", 824 printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n",
801 bsts_result); 825 (uint) bsts_result);
826
827 /* This too ... */
828 write_acpi_int(hotk->handle, "CWAP", wapf, NULL);
802 829
803 /* 830 /*
804 * Try to match the object returned by INIT to the specific model. 831 * Try to match the object returned by INIT to the specific model.
@@ -831,6 +858,7 @@ static int asus_hotk_get_info(void)
831 ASUS_HANDLE_INIT(tled_set); 858 ASUS_HANDLE_INIT(tled_set);
832 ASUS_HANDLE_INIT(rled_set); 859 ASUS_HANDLE_INIT(rled_set);
833 ASUS_HANDLE_INIT(pled_set); 860 ASUS_HANDLE_INIT(pled_set);
861 ASUS_HANDLE_INIT(gled_set);
834 862
835 ASUS_HANDLE_INIT(ledd_set); 863 ASUS_HANDLE_INIT(ledd_set);
836 864
@@ -840,7 +868,9 @@ static int asus_hotk_get_info(void)
840 * The significance of others is yet to be found. 868 * The significance of others is yet to be found.
841 * If we don't find the method, we assume the device are present. 869 * If we don't find the method, we assume the device are present.
842 */ 870 */
843 if (!read_acpi_int(hotk->handle, "HRWS", &hwrs_result, NULL)) 871 status =
872 acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &hwrs_result);
873 if (ACPI_FAILURE(status))
844 hwrs_result = WL_HWRS | BT_HWRS; 874 hwrs_result = WL_HWRS | BT_HWRS;
845 875
846 if (hwrs_result & WL_HWRS) 876 if (hwrs_result & WL_HWRS)
@@ -928,11 +958,15 @@ static int asus_hotk_add(struct acpi_device *device)
928 asus_hotk_found = 1; 958 asus_hotk_found = 1;
929 959
930 /* WLED and BLED are on by default */ 960 /* WLED and BLED are on by default */
931 write_status(bt_switch_handle, 1, BT_ON, 0); 961 write_status(bt_switch_handle, 1, BT_ON);
932 write_status(wl_switch_handle, 1, WL_ON, 0); 962 write_status(wl_switch_handle, 1, WL_ON);
963
964 /* If the h/w switch is off, we need to check the real status */
965 write_status(NULL, read_status(BT_ON), BT_ON);
966 write_status(NULL, read_status(WL_ON), WL_ON);
933 967
934 /* LCD Backlight is on by default */ 968 /* LCD Backlight is on by default */
935 write_status(NULL, 1, LCD_ON, 0); 969 write_status(NULL, 1, LCD_ON);
936 970
937 /* LED display is off by default */ 971 /* LED display is off by default */
938 hotk->ledd_status = 0xFFF; 972 hotk->ledd_status = 0xFFF;
@@ -991,6 +1025,7 @@ static void asus_led_exit(void)
991 ASUS_LED_UNREGISTER(tled); 1025 ASUS_LED_UNREGISTER(tled);
992 ASUS_LED_UNREGISTER(pled); 1026 ASUS_LED_UNREGISTER(pled);
993 ASUS_LED_UNREGISTER(rled); 1027 ASUS_LED_UNREGISTER(rled);
1028 ASUS_LED_UNREGISTER(gled);
994 1029
995 destroy_workqueue(led_workqueue); 1030 destroy_workqueue(led_workqueue);
996} 1031}
@@ -1062,6 +1097,10 @@ static int asus_led_init(struct device *dev)
1062 if (rv) 1097 if (rv)
1063 return rv; 1098 return rv;
1064 1099
1100 rv = ASUS_LED_REGISTER(gled, dev);
1101 if (rv)
1102 return rv;
1103
1065 led_workqueue = create_singlethread_workqueue("led_workqueue"); 1104 led_workqueue = create_singlethread_workqueue("led_workqueue");
1066 if (!led_workqueue) 1105 if (!led_workqueue)
1067 return -ENOMEM; 1106 return -ENOMEM;
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index ac708bc2f9f3..c15c1f61bd1b 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ACPI Sony Notebook Control Driver (SNC) 2 * ACPI Sony Notebook Control Driver (SNC and SPIC)
3 * 3 *
4 * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net> 4 * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net>
5 * Copyright (C) 2007 Mattia Dongili <malattia@linux.it> 5 * Copyright (C) 2007 Mattia Dongili <malattia@linux.it>
@@ -7,6 +7,25 @@
7 * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c 7 * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c
8 * which are copyrighted by their respective authors. 8 * which are copyrighted by their respective authors.
9 * 9 *
10 * The SNY6001 driver part is based on the sonypi driver which includes
11 * material from:
12 *
13 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
14 *
15 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
16 *
17 * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
18 *
19 * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
20 *
21 * Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
22 *
23 * Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
24 *
25 * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
26 *
27 * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
28 *
10 * This program is free software; you can redistribute it and/or modify 29 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 30 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 31 * the Free Software Foundation; either version 2 of the License, or
@@ -31,40 +50,404 @@
31#include <linux/backlight.h> 50#include <linux/backlight.h>
32#include <linux/platform_device.h> 51#include <linux/platform_device.h>
33#include <linux/err.h> 52#include <linux/err.h>
53#include <linux/dmi.h>
54#include <linux/pci.h>
55#include <linux/interrupt.h>
56#include <linux/delay.h>
57#include <linux/input.h>
58#include <linux/kfifo.h>
59#include <linux/workqueue.h>
60#include <linux/acpi.h>
34#include <acpi/acpi_drivers.h> 61#include <acpi/acpi_drivers.h>
35#include <acpi/acpi_bus.h> 62#include <acpi/acpi_bus.h>
36#include <asm/uaccess.h> 63#include <asm/uaccess.h>
64#include <linux/sonypi.h>
65#include <linux/sony-laptop.h>
66#ifdef CONFIG_SONY_LAPTOP_OLD
67#include <linux/poll.h>
68#include <linux/miscdevice.h>
69#endif
37 70
38#define ACPI_SNC_CLASS "sony" 71#define DRV_PFX "sony-laptop: "
39#define ACPI_SNC_HID "SNY5001" 72#define dprintk(msg...) do { \
40#define ACPI_SNC_DRIVER_NAME "ACPI Sony Notebook Control Driver v0.4" 73 if (debug) printk(KERN_WARNING DRV_PFX msg); \
74} while (0)
41 75
42/* the device uses 1-based values, while the backlight subsystem uses 76#define SONY_LAPTOP_DRIVER_VERSION "0.5"
43 0-based values */ 77
44#define SONY_MAX_BRIGHTNESS 8 78#define SONY_NC_CLASS "sony-nc"
79#define SONY_NC_HID "SNY5001"
80#define SONY_NC_DRIVER_NAME "Sony Notebook Control Driver"
45 81
46#define LOG_PFX KERN_WARNING "sony-laptop: " 82#define SONY_PIC_CLASS "sony-pic"
83#define SONY_PIC_HID "SNY6001"
84#define SONY_PIC_DRIVER_NAME "Sony Programmable IO Control Driver"
47 85
48MODULE_AUTHOR("Stelian Pop, Mattia Dongili"); 86MODULE_AUTHOR("Stelian Pop, Mattia Dongili");
49MODULE_DESCRIPTION(ACPI_SNC_DRIVER_NAME); 87MODULE_DESCRIPTION("Sony laptop extras driver (SPIC and SNC ACPI device)");
50MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
89MODULE_VERSION(SONY_LAPTOP_DRIVER_VERSION);
51 90
52static int debug; 91static int debug;
53module_param(debug, int, 0); 92module_param(debug, int, 0);
54MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " 93MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
55 "the development of this driver"); 94 "the development of this driver");
56 95
57static ssize_t sony_acpi_show(struct device *, struct device_attribute *, 96static int no_spic; /* = 0 */
97module_param(no_spic, int, 0444);
98MODULE_PARM_DESC(no_spic,
99 "set this if you don't want to enable the SPIC device");
100
101static int compat; /* = 0 */
102module_param(compat, int, 0444);
103MODULE_PARM_DESC(compat,
104 "set this if you want to enable backward compatibility mode");
105
106static unsigned long mask = 0xffffffff;
107module_param(mask, ulong, 0644);
108MODULE_PARM_DESC(mask,
109 "set this to the mask of event you want to enable (see doc)");
110
111static int camera; /* = 0 */
112module_param(camera, int, 0444);
113MODULE_PARM_DESC(camera,
114 "set this to 1 to enable Motion Eye camera controls "
115 "(only use it if you have a C1VE or C1VN model)");
116
117#ifdef CONFIG_SONY_LAPTOP_OLD
118static int minor = -1;
119module_param(minor, int, 0);
120MODULE_PARM_DESC(minor,
121 "minor number of the misc device for the SPIC compatibility code, "
122 "default is -1 (automatic)");
123#endif
124
125/*********** Input Devices ***********/
126
127#define SONY_LAPTOP_BUF_SIZE 128
128struct sony_laptop_input_s {
129 atomic_t users;
130 struct input_dev *jog_dev;
131 struct input_dev *key_dev;
132 struct kfifo *fifo;
133 spinlock_t fifo_lock;
134 struct workqueue_struct *wq;
135};
136static struct sony_laptop_input_s sony_laptop_input = {
137 .users = ATOMIC_INIT(0),
138};
139
140struct sony_laptop_keypress {
141 struct input_dev *dev;
142 int key;
143};
144
145/* Correspondance table between sonypi events and input layer events */
146static struct {
147 int sonypiev;
148 int inputev;
149} sony_laptop_inputkeys[] = {
150 { SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA },
151 { SONYPI_EVENT_FNKEY_ONLY, KEY_FN },
152 { SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC },
153 { SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 },
154 { SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 },
155 { SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 },
156 { SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 },
157 { SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 },
158 { SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 },
159 { SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 },
160 { SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 },
161 { SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 },
162 { SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 },
163 { SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 },
164 { SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 },
165 { SONYPI_EVENT_FNKEY_1, KEY_FN_1 },
166 { SONYPI_EVENT_FNKEY_2, KEY_FN_2 },
167 { SONYPI_EVENT_FNKEY_D, KEY_FN_D },
168 { SONYPI_EVENT_FNKEY_E, KEY_FN_E },
169 { SONYPI_EVENT_FNKEY_F, KEY_FN_F },
170 { SONYPI_EVENT_FNKEY_S, KEY_FN_S },
171 { SONYPI_EVENT_FNKEY_B, KEY_FN_B },
172 { SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE },
173 { SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE },
174 { SONYPI_EVENT_PKEY_P1, KEY_PROG1 },
175 { SONYPI_EVENT_PKEY_P2, KEY_PROG2 },
176 { SONYPI_EVENT_PKEY_P3, KEY_PROG3 },
177 { SONYPI_EVENT_BACK_PRESSED, KEY_BACK },
178 { SONYPI_EVENT_HELP_PRESSED, KEY_HELP },
179 { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM },
180 { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB },
181 { 0, 0 },
182};
183
184/* release buttons after a short delay if pressed */
185static void do_sony_laptop_release_key(struct work_struct *work)
186{
187 struct sony_laptop_keypress kp;
188
189 while (kfifo_get(sony_laptop_input.fifo, (unsigned char *)&kp,
190 sizeof(kp)) == sizeof(kp)) {
191 msleep(10);
192 input_report_key(kp.dev, kp.key, 0);
193 input_sync(kp.dev);
194 }
195}
196static DECLARE_WORK(sony_laptop_release_key_work,
197 do_sony_laptop_release_key);
198
199/* forward event to the input subsytem */
200static void sony_laptop_report_input_event(u8 event)
201{
202 struct input_dev *jog_dev = sony_laptop_input.jog_dev;
203 struct input_dev *key_dev = sony_laptop_input.key_dev;
204 struct sony_laptop_keypress kp = { NULL };
205 int i;
206
207 if (event == SONYPI_EVENT_FNKEY_RELEASED) {
208 /* Nothing, not all VAIOs generate this event */
209 return;
210 }
211
212 /* report events */
213 switch (event) {
214 /* jog_dev events */
215 case SONYPI_EVENT_JOGDIAL_UP:
216 case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
217 input_report_rel(jog_dev, REL_WHEEL, 1);
218 input_sync(jog_dev);
219 return;
220
221 case SONYPI_EVENT_JOGDIAL_DOWN:
222 case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
223 input_report_rel(jog_dev, REL_WHEEL, -1);
224 input_sync(jog_dev);
225 return;
226
227 /* key_dev events */
228 case SONYPI_EVENT_JOGDIAL_PRESSED:
229 kp.key = BTN_MIDDLE;
230 kp.dev = jog_dev;
231 break;
232
233 default:
234 for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
235 if (event == sony_laptop_inputkeys[i].sonypiev) {
236 kp.dev = key_dev;
237 kp.key = sony_laptop_inputkeys[i].inputev;
238 break;
239 }
240 break;
241 }
242
243 if (kp.dev) {
244 input_report_key(kp.dev, kp.key, 1);
245 input_sync(kp.dev);
246 kfifo_put(sony_laptop_input.fifo,
247 (unsigned char *)&kp, sizeof(kp));
248
249 if (!work_pending(&sony_laptop_release_key_work))
250 queue_work(sony_laptop_input.wq,
251 &sony_laptop_release_key_work);
252 } else
253 dprintk("unknown input event %.2x\n", event);
254}
255
256static int sony_laptop_setup_input(void)
257{
258 struct input_dev *jog_dev;
259 struct input_dev *key_dev;
260 int i;
261 int error;
262
263 /* don't run again if already initialized */
264 if (atomic_add_return(1, &sony_laptop_input.users) > 1)
265 return 0;
266
267 /* kfifo */
268 spin_lock_init(&sony_laptop_input.fifo_lock);
269 sony_laptop_input.fifo =
270 kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
271 &sony_laptop_input.fifo_lock);
272 if (IS_ERR(sony_laptop_input.fifo)) {
273 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
274 error = PTR_ERR(sony_laptop_input.fifo);
275 goto err_dec_users;
276 }
277
278 /* init workqueue */
279 sony_laptop_input.wq = create_singlethread_workqueue("sony-laptop");
280 if (!sony_laptop_input.wq) {
281 printk(KERN_ERR DRV_PFX
282 "Unabe to create workqueue.\n");
283 error = -ENXIO;
284 goto err_free_kfifo;
285 }
286
287 /* input keys */
288 key_dev = input_allocate_device();
289 if (!key_dev) {
290 error = -ENOMEM;
291 goto err_destroy_wq;
292 }
293
294 key_dev->name = "Sony Vaio Keys";
295 key_dev->id.bustype = BUS_ISA;
296 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
297
298 /* Initialize the Input Drivers: special keys */
299 key_dev->evbit[0] = BIT(EV_KEY);
300 for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
301 if (sony_laptop_inputkeys[i].inputev)
302 set_bit(sony_laptop_inputkeys[i].inputev,
303 key_dev->keybit);
304
305 error = input_register_device(key_dev);
306 if (error)
307 goto err_free_keydev;
308
309 sony_laptop_input.key_dev = key_dev;
310
311 /* jogdial */
312 jog_dev = input_allocate_device();
313 if (!jog_dev) {
314 error = -ENOMEM;
315 goto err_unregister_keydev;
316 }
317
318 jog_dev->name = "Sony Vaio Jogdial";
319 jog_dev->id.bustype = BUS_ISA;
320 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
321
322 jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
323 jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
324 jog_dev->relbit[0] = BIT(REL_WHEEL);
325
326 error = input_register_device(jog_dev);
327 if (error)
328 goto err_free_jogdev;
329
330 sony_laptop_input.jog_dev = jog_dev;
331
332 return 0;
333
334err_free_jogdev:
335 input_free_device(jog_dev);
336
337err_unregister_keydev:
338 input_unregister_device(key_dev);
339 /* to avoid kref underflow below at input_free_device */
340 key_dev = NULL;
341
342err_free_keydev:
343 input_free_device(key_dev);
344
345err_destroy_wq:
346 destroy_workqueue(sony_laptop_input.wq);
347
348err_free_kfifo:
349 kfifo_free(sony_laptop_input.fifo);
350
351err_dec_users:
352 atomic_dec(&sony_laptop_input.users);
353 return error;
354}
355
356static void sony_laptop_remove_input(void)
357{
358 /* cleanup only after the last user has gone */
359 if (!atomic_dec_and_test(&sony_laptop_input.users))
360 return;
361
362 /* flush workqueue first */
363 flush_workqueue(sony_laptop_input.wq);
364
365 /* destroy input devs */
366 input_unregister_device(sony_laptop_input.key_dev);
367 sony_laptop_input.key_dev = NULL;
368
369 if (sony_laptop_input.jog_dev) {
370 input_unregister_device(sony_laptop_input.jog_dev);
371 sony_laptop_input.jog_dev = NULL;
372 }
373
374 destroy_workqueue(sony_laptop_input.wq);
375 kfifo_free(sony_laptop_input.fifo);
376}
377
378/*********** Platform Device ***********/
379
380static atomic_t sony_pf_users = ATOMIC_INIT(0);
381static struct platform_driver sony_pf_driver = {
382 .driver = {
383 .name = "sony-laptop",
384 .owner = THIS_MODULE,
385 }
386};
387static struct platform_device *sony_pf_device;
388
389static int sony_pf_add(void)
390{
391 int ret = 0;
392
393 /* don't run again if already initialized */
394 if (atomic_add_return(1, &sony_pf_users) > 1)
395 return 0;
396
397 ret = platform_driver_register(&sony_pf_driver);
398 if (ret)
399 goto out;
400
401 sony_pf_device = platform_device_alloc("sony-laptop", -1);
402 if (!sony_pf_device) {
403 ret = -ENOMEM;
404 goto out_platform_registered;
405 }
406
407 ret = platform_device_add(sony_pf_device);
408 if (ret)
409 goto out_platform_alloced;
410
411 return 0;
412
413 out_platform_alloced:
414 platform_device_put(sony_pf_device);
415 sony_pf_device = NULL;
416 out_platform_registered:
417 platform_driver_unregister(&sony_pf_driver);
418 out:
419 atomic_dec(&sony_pf_users);
420 return ret;
421}
422
423static void sony_pf_remove(void)
424{
425 /* deregister only after the last user has gone */
426 if (!atomic_dec_and_test(&sony_pf_users))
427 return;
428
429 platform_device_del(sony_pf_device);
430 platform_device_put(sony_pf_device);
431 platform_driver_unregister(&sony_pf_driver);
432}
433
434/*********** SNC (SNY5001) Device ***********/
435
436/* the device uses 1-based values, while the backlight subsystem uses
437 0-based values */
438#define SONY_MAX_BRIGHTNESS 8
439
440#define SNC_VALIDATE_IN 0
441#define SNC_VALIDATE_OUT 1
442
443static ssize_t sony_nc_sysfs_show(struct device *, struct device_attribute *,
58 char *); 444 char *);
59static ssize_t sony_acpi_store(struct device *, struct device_attribute *, 445static ssize_t sony_nc_sysfs_store(struct device *, struct device_attribute *,
60 const char *, size_t); 446 const char *, size_t);
61static int boolean_validate(const int, const int); 447static int boolean_validate(const int, const int);
62static int brightness_default_validate(const int, const int); 448static int brightness_default_validate(const int, const int);
63 449
64#define SNC_VALIDATE_IN 0 450struct sony_nc_value {
65#define SNC_VALIDATE_OUT 1
66
67struct sony_acpi_value {
68 char *name; /* name of the entry */ 451 char *name; /* name of the entry */
69 char **acpiget; /* names of the ACPI get function */ 452 char **acpiget; /* names of the ACPI get function */
70 char **acpiset; /* names of the ACPI set function */ 453 char **acpiset; /* names of the ACPI set function */
@@ -75,65 +458,65 @@ struct sony_acpi_value {
75 struct device_attribute devattr; /* sysfs atribute */ 458 struct device_attribute devattr; /* sysfs atribute */
76}; 459};
77 460
78#define HANDLE_NAMES(_name, _values...) \ 461#define SNC_HANDLE_NAMES(_name, _values...) \
79 static char *snc_##_name[] = { _values, NULL } 462 static char *snc_##_name[] = { _values, NULL }
80 463
81#define SONY_ACPI_VALUE(_name, _getters, _setters, _validate, _debug) \ 464#define SNC_HANDLE(_name, _getters, _setters, _validate, _debug) \
82 { \ 465 { \
83 .name = __stringify(_name), \ 466 .name = __stringify(_name), \
84 .acpiget = _getters, \ 467 .acpiget = _getters, \
85 .acpiset = _setters, \ 468 .acpiset = _setters, \
86 .validate = _validate, \ 469 .validate = _validate, \
87 .debug = _debug, \ 470 .debug = _debug, \
88 .devattr = __ATTR(_name, 0, sony_acpi_show, sony_acpi_store), \ 471 .devattr = __ATTR(_name, 0, sony_nc_sysfs_show, sony_nc_sysfs_store), \
89 } 472 }
90 473
91#define SONY_ACPI_VALUE_NULL { .name = NULL } 474#define SNC_HANDLE_NULL { .name = NULL }
92 475
93HANDLE_NAMES(fnkey_get, "GHKE"); 476SNC_HANDLE_NAMES(fnkey_get, "GHKE");
94 477
95HANDLE_NAMES(brightness_def_get, "GPBR"); 478SNC_HANDLE_NAMES(brightness_def_get, "GPBR");
96HANDLE_NAMES(brightness_def_set, "SPBR"); 479SNC_HANDLE_NAMES(brightness_def_set, "SPBR");
97 480
98HANDLE_NAMES(cdpower_get, "GCDP"); 481SNC_HANDLE_NAMES(cdpower_get, "GCDP");
99HANDLE_NAMES(cdpower_set, "SCDP", "CDPW"); 482SNC_HANDLE_NAMES(cdpower_set, "SCDP", "CDPW");
100 483
101HANDLE_NAMES(audiopower_get, "GAZP"); 484SNC_HANDLE_NAMES(audiopower_get, "GAZP");
102HANDLE_NAMES(audiopower_set, "AZPW"); 485SNC_HANDLE_NAMES(audiopower_set, "AZPW");
103 486
104HANDLE_NAMES(lanpower_get, "GLNP"); 487SNC_HANDLE_NAMES(lanpower_get, "GLNP");
105HANDLE_NAMES(lanpower_set, "LNPW"); 488SNC_HANDLE_NAMES(lanpower_set, "LNPW");
106 489
107HANDLE_NAMES(PID_get, "GPID"); 490SNC_HANDLE_NAMES(PID_get, "GPID");
108 491
109HANDLE_NAMES(CTR_get, "GCTR"); 492SNC_HANDLE_NAMES(CTR_get, "GCTR");
110HANDLE_NAMES(CTR_set, "SCTR"); 493SNC_HANDLE_NAMES(CTR_set, "SCTR");
111 494
112HANDLE_NAMES(PCR_get, "GPCR"); 495SNC_HANDLE_NAMES(PCR_get, "GPCR");
113HANDLE_NAMES(PCR_set, "SPCR"); 496SNC_HANDLE_NAMES(PCR_set, "SPCR");
114 497
115HANDLE_NAMES(CMI_get, "GCMI"); 498SNC_HANDLE_NAMES(CMI_get, "GCMI");
116HANDLE_NAMES(CMI_set, "SCMI"); 499SNC_HANDLE_NAMES(CMI_set, "SCMI");
117 500
118static struct sony_acpi_value sony_acpi_values[] = { 501static struct sony_nc_value sony_nc_values[] = {
119 SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get, 502 SNC_HANDLE(brightness_default, snc_brightness_def_get,
120 snc_brightness_def_set, brightness_default_validate, 0), 503 snc_brightness_def_set, brightness_default_validate, 0),
121 SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, NULL, 0), 504 SNC_HANDLE(fnkey, snc_fnkey_get, NULL, NULL, 0),
122 SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, boolean_validate, 0), 505 SNC_HANDLE(cdpower, snc_cdpower_get, snc_cdpower_set, boolean_validate, 0),
123 SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, 506 SNC_HANDLE(audiopower, snc_audiopower_get, snc_audiopower_set,
124 boolean_validate, 0), 507 boolean_validate, 0),
125 SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, 508 SNC_HANDLE(lanpower, snc_lanpower_get, snc_lanpower_set,
126 boolean_validate, 1), 509 boolean_validate, 1),
127 /* unknown methods */ 510 /* unknown methods */
128 SONY_ACPI_VALUE(PID, snc_PID_get, NULL, NULL, 1), 511 SNC_HANDLE(PID, snc_PID_get, NULL, NULL, 1),
129 SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1), 512 SNC_HANDLE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1),
130 SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, NULL, 1), 513 SNC_HANDLE(PCR, snc_PCR_get, snc_PCR_set, NULL, 1),
131 SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, NULL, 1), 514 SNC_HANDLE(CMI, snc_CMI_get, snc_CMI_set, NULL, 1),
132 SONY_ACPI_VALUE_NULL 515 SNC_HANDLE_NULL
133}; 516};
134 517
135static acpi_handle sony_acpi_handle; 518static acpi_handle sony_nc_acpi_handle;
136static struct acpi_device *sony_acpi_acpi_device = NULL; 519static struct acpi_device *sony_nc_acpi_device = NULL;
137 520
138/* 521/*
139 * acpi_evaluate_object wrappers 522 * acpi_evaluate_object wrappers
@@ -153,7 +536,7 @@ static int acpi_callgetfunc(acpi_handle handle, char *name, int *result)
153 return 0; 536 return 0;
154 } 537 }
155 538
156 printk(LOG_PFX "acpi_callreadfunc failed\n"); 539 printk(KERN_WARNING DRV_PFX "acpi_callreadfunc failed\n");
157 540
158 return -1; 541 return -1;
159} 542}
@@ -179,7 +562,7 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
179 if (status == AE_OK) { 562 if (status == AE_OK) {
180 if (result != NULL) { 563 if (result != NULL) {
181 if (out_obj.type != ACPI_TYPE_INTEGER) { 564 if (out_obj.type != ACPI_TYPE_INTEGER) {
182 printk(LOG_PFX "acpi_evaluate_object bad " 565 printk(KERN_WARNING DRV_PFX "acpi_evaluate_object bad "
183 "return type\n"); 566 "return type\n");
184 return -1; 567 return -1;
185 } 568 }
@@ -188,13 +571,13 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
188 return 0; 571 return 0;
189 } 572 }
190 573
191 printk(LOG_PFX "acpi_evaluate_object failed\n"); 574 printk(KERN_WARNING DRV_PFX "acpi_evaluate_object failed\n");
192 575
193 return -1; 576 return -1;
194} 577}
195 578
196/* 579/*
197 * sony_acpi_values input/output validate functions 580 * sony_nc_values input/output validate functions
198 */ 581 */
199 582
200/* brightness_default_validate: 583/* brightness_default_validate:
@@ -229,19 +612,19 @@ static int boolean_validate(const int direction, const int value)
229} 612}
230 613
231/* 614/*
232 * Sysfs show/store common to all sony_acpi_values 615 * Sysfs show/store common to all sony_nc_values
233 */ 616 */
234static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr, 617static ssize_t sony_nc_sysfs_show(struct device *dev, struct device_attribute *attr,
235 char *buffer) 618 char *buffer)
236{ 619{
237 int value; 620 int value;
238 struct sony_acpi_value *item = 621 struct sony_nc_value *item =
239 container_of(attr, struct sony_acpi_value, devattr); 622 container_of(attr, struct sony_nc_value, devattr);
240 623
241 if (!*item->acpiget) 624 if (!*item->acpiget)
242 return -EIO; 625 return -EIO;
243 626
244 if (acpi_callgetfunc(sony_acpi_handle, *item->acpiget, &value) < 0) 627 if (acpi_callgetfunc(sony_nc_acpi_handle, *item->acpiget, &value) < 0)
245 return -EIO; 628 return -EIO;
246 629
247 if (item->validate) 630 if (item->validate)
@@ -250,13 +633,13 @@ static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
250 return snprintf(buffer, PAGE_SIZE, "%d\n", value); 633 return snprintf(buffer, PAGE_SIZE, "%d\n", value);
251} 634}
252 635
253static ssize_t sony_acpi_store(struct device *dev, 636static ssize_t sony_nc_sysfs_store(struct device *dev,
254 struct device_attribute *attr, 637 struct device_attribute *attr,
255 const char *buffer, size_t count) 638 const char *buffer, size_t count)
256{ 639{
257 int value; 640 int value;
258 struct sony_acpi_value *item = 641 struct sony_nc_value *item =
259 container_of(attr, struct sony_acpi_value, devattr); 642 container_of(attr, struct sony_nc_value, devattr);
260 643
261 if (!item->acpiset) 644 if (!item->acpiset)
262 return -EIO; 645 return -EIO;
@@ -272,118 +655,20 @@ static ssize_t sony_acpi_store(struct device *dev,
272 if (value < 0) 655 if (value < 0)
273 return value; 656 return value;
274 657
275 if (acpi_callsetfunc(sony_acpi_handle, *item->acpiset, value, NULL) < 0) 658 if (acpi_callsetfunc(sony_nc_acpi_handle, *item->acpiset, value, NULL) < 0)
276 return -EIO; 659 return -EIO;
277 item->value = value; 660 item->value = value;
278 item->valid = 1; 661 item->valid = 1;
279 return count; 662 return count;
280} 663}
281 664
282/*
283 * Platform device
284 */
285static struct platform_driver sncpf_driver = {
286 .driver = {
287 .name = "sony-laptop",
288 .owner = THIS_MODULE,
289 }
290};
291static struct platform_device *sncpf_device;
292
293static int sony_snc_pf_add(void)
294{
295 acpi_handle handle;
296 struct sony_acpi_value *item;
297 int ret = 0;
298
299 ret = platform_driver_register(&sncpf_driver);
300 if (ret)
301 goto out;
302
303 sncpf_device = platform_device_alloc("sony-laptop", -1);
304 if (!sncpf_device) {
305 ret = -ENOMEM;
306 goto out_platform_registered;
307 }
308
309 ret = platform_device_add(sncpf_device);
310 if (ret)
311 goto out_platform_alloced;
312
313 for (item = sony_acpi_values; item->name; ++item) {
314
315 if (!debug && item->debug)
316 continue;
317
318 /* find the available acpiget as described in the DSDT */
319 for (; item->acpiget && *item->acpiget; ++item->acpiget) {
320 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
321 *item->acpiget,
322 &handle))) {
323 if (debug)
324 printk(LOG_PFX "Found %s getter: %s\n",
325 item->name, *item->acpiget);
326 item->devattr.attr.mode |= S_IRUGO;
327 break;
328 }
329 }
330
331 /* find the available acpiset as described in the DSDT */
332 for (; item->acpiset && *item->acpiset; ++item->acpiset) {
333 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
334 *item->acpiset,
335 &handle))) {
336 if (debug)
337 printk(LOG_PFX "Found %s setter: %s\n",
338 item->name, *item->acpiset);
339 item->devattr.attr.mode |= S_IWUSR;
340 break;
341 }
342 }
343
344 if (item->devattr.attr.mode != 0) {
345 ret =
346 device_create_file(&sncpf_device->dev,
347 &item->devattr);
348 if (ret)
349 goto out_sysfs;
350 }
351 }
352
353 return 0;
354
355 out_sysfs:
356 for (item = sony_acpi_values; item->name; ++item) {
357 device_remove_file(&sncpf_device->dev, &item->devattr);
358 }
359 platform_device_del(sncpf_device);
360 out_platform_alloced:
361 platform_device_put(sncpf_device);
362 out_platform_registered:
363 platform_driver_unregister(&sncpf_driver);
364 out:
365 return ret;
366}
367
368static void sony_snc_pf_remove(void)
369{
370 struct sony_acpi_value *item;
371
372 for (item = sony_acpi_values; item->name; ++item) {
373 device_remove_file(&sncpf_device->dev, &item->devattr);
374 }
375
376 platform_device_del(sncpf_device);
377 platform_device_put(sncpf_device);
378 platform_driver_unregister(&sncpf_driver);
379}
380 665
381/* 666/*
382 * Backlight device 667 * Backlight device
383 */ 668 */
384static int sony_backlight_update_status(struct backlight_device *bd) 669static int sony_backlight_update_status(struct backlight_device *bd)
385{ 670{
386 return acpi_callsetfunc(sony_acpi_handle, "SBRT", 671 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT",
387 bd->props.brightness + 1, NULL); 672 bd->props.brightness + 1, NULL);
388} 673}
389 674
@@ -391,7 +676,7 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
391{ 676{
392 int value; 677 int value;
393 678
394 if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value)) 679 if (acpi_callgetfunc(sony_nc_acpi_handle, "GBRT", &value))
395 return 0; 680 return 0;
396 /* brightness levels are 1-based, while backlight ones are 0-based */ 681 /* brightness levels are 1-based, while backlight ones are 0-based */
397 return value - 1; 682 return value - 1;
@@ -408,9 +693,9 @@ static struct backlight_ops sony_backlight_ops = {
408 */ 693 */
409static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) 694static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
410{ 695{
411 if (debug) 696 dprintk("sony_acpi_notify, event: %d\n", event);
412 printk(LOG_PFX "sony_acpi_notify, event: %d\n", event); 697 sony_laptop_report_input_event(event);
413 acpi_bus_generate_event(sony_acpi_acpi_device, 1, event); 698 acpi_bus_generate_event(sony_nc_acpi_device, 1, event);
414} 699}
415 700
416static acpi_status sony_walk_callback(acpi_handle handle, u32 level, 701static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -422,7 +707,7 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
422 node = (struct acpi_namespace_node *)handle; 707 node = (struct acpi_namespace_node *)handle;
423 operand = (union acpi_operand_object *)node->object; 708 operand = (union acpi_operand_object *)node->object;
424 709
425 printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii, 710 printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii,
426 (u32) operand->method.param_count); 711 (u32) operand->method.param_count);
427 712
428 return AE_OK; 713 return AE_OK;
@@ -431,16 +716,16 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
431/* 716/*
432 * ACPI device 717 * ACPI device
433 */ 718 */
434static int sony_acpi_resume(struct acpi_device *device) 719static int sony_nc_resume(struct acpi_device *device)
435{ 720{
436 struct sony_acpi_value *item; 721 struct sony_nc_value *item;
437 722
438 for (item = sony_acpi_values; item->name; item++) { 723 for (item = sony_nc_values; item->name; item++) {
439 int ret; 724 int ret;
440 725
441 if (!item->valid) 726 if (!item->valid)
442 continue; 727 continue;
443 ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset, 728 ret = acpi_callsetfunc(sony_nc_acpi_handle, *item->acpiset,
444 item->value, NULL); 729 item->value, NULL);
445 if (ret < 0) { 730 if (ret < 0) {
446 printk("%s: %d\n", __FUNCTION__, ret); 731 printk("%s: %d\n", __FUNCTION__, ret);
@@ -450,42 +735,55 @@ static int sony_acpi_resume(struct acpi_device *device)
450 return 0; 735 return 0;
451} 736}
452 737
453static int sony_acpi_add(struct acpi_device *device) 738static int sony_nc_add(struct acpi_device *device)
454{ 739{
455 acpi_status status; 740 acpi_status status;
456 int result = 0; 741 int result = 0;
457 acpi_handle handle; 742 acpi_handle handle;
743 struct sony_nc_value *item;
744
745 printk(KERN_INFO DRV_PFX "%s v%s.\n",
746 SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
458 747
459 sony_acpi_acpi_device = device; 748 sony_nc_acpi_device = device;
749 strcpy(acpi_device_class(device), "sony/hotkey");
460 750
461 sony_acpi_handle = device->handle; 751 sony_nc_acpi_handle = device->handle;
462 752
463 if (debug) { 753 if (debug) {
464 status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_acpi_handle, 754 status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_nc_acpi_handle,
465 1, sony_walk_callback, NULL, NULL); 755 1, sony_walk_callback, NULL, NULL);
466 if (ACPI_FAILURE(status)) { 756 if (ACPI_FAILURE(status)) {
467 printk(LOG_PFX "unable to walk acpi resources\n"); 757 printk(KERN_WARNING DRV_PFX "unable to walk acpi resources\n");
468 result = -ENODEV; 758 result = -ENODEV;
469 goto outwalk; 759 goto outwalk;
470 } 760 }
471 } 761 }
472 762
473 status = acpi_install_notify_handler(sony_acpi_handle, 763 /* setup input devices and helper fifo */
764 result = sony_laptop_setup_input();
765 if (result) {
766 printk(KERN_ERR DRV_PFX
767 "Unabe to create input devices.\n");
768 goto outwalk;
769 }
770
771 status = acpi_install_notify_handler(sony_nc_acpi_handle,
474 ACPI_DEVICE_NOTIFY, 772 ACPI_DEVICE_NOTIFY,
475 sony_acpi_notify, NULL); 773 sony_acpi_notify, NULL);
476 if (ACPI_FAILURE(status)) { 774 if (ACPI_FAILURE(status)) {
477 printk(LOG_PFX "unable to install notify handler\n"); 775 printk(KERN_WARNING DRV_PFX "unable to install notify handler\n");
478 result = -ENODEV; 776 result = -ENODEV;
479 goto outwalk; 777 goto outinput;
480 } 778 }
481 779
482 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) { 780 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", &handle))) {
483 sony_backlight_device = backlight_device_register("sony", NULL, 781 sony_backlight_device = backlight_device_register("sony", NULL,
484 NULL, 782 NULL,
485 &sony_backlight_ops); 783 &sony_backlight_ops);
486 784
487 if (IS_ERR(sony_backlight_device)) { 785 if (IS_ERR(sony_backlight_device)) {
488 printk(LOG_PFX "unable to register backlight device\n"); 786 printk(KERN_WARNING DRV_PFX "unable to register backlight device\n");
489 sony_backlight_device = NULL; 787 sony_backlight_device = NULL;
490 } else { 788 } else {
491 sony_backlight_device->props.brightness = 789 sony_backlight_device->props.brightness =
@@ -497,68 +795,1497 @@ static int sony_acpi_add(struct acpi_device *device)
497 795
498 } 796 }
499 797
500 if (sony_snc_pf_add()) 798 result = sony_pf_add();
799 if (result)
501 goto outbacklight; 800 goto outbacklight;
502 801
503 printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully installed\n"); 802 /* create sony_pf sysfs attributes related to the SNC device */
803 for (item = sony_nc_values; item->name; ++item) {
804
805 if (!debug && item->debug)
806 continue;
807
808 /* find the available acpiget as described in the DSDT */
809 for (; item->acpiget && *item->acpiget; ++item->acpiget) {
810 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle,
811 *item->acpiget,
812 &handle))) {
813 dprintk("Found %s getter: %s\n",
814 item->name, *item->acpiget);
815 item->devattr.attr.mode |= S_IRUGO;
816 break;
817 }
818 }
819
820 /* find the available acpiset as described in the DSDT */
821 for (; item->acpiset && *item->acpiset; ++item->acpiset) {
822 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle,
823 *item->acpiset,
824 &handle))) {
825 dprintk("Found %s setter: %s\n",
826 item->name, *item->acpiset);
827 item->devattr.attr.mode |= S_IWUSR;
828 break;
829 }
830 }
831
832 if (item->devattr.attr.mode != 0) {
833 result =
834 device_create_file(&sony_pf_device->dev,
835 &item->devattr);
836 if (result)
837 goto out_sysfs;
838 }
839 }
504 840
505 return 0; 841 return 0;
506 842
843 out_sysfs:
844 for (item = sony_nc_values; item->name; ++item) {
845 device_remove_file(&sony_pf_device->dev, &item->devattr);
846 }
847 sony_pf_remove();
848
507 outbacklight: 849 outbacklight:
508 if (sony_backlight_device) 850 if (sony_backlight_device)
509 backlight_device_unregister(sony_backlight_device); 851 backlight_device_unregister(sony_backlight_device);
510 852
511 status = acpi_remove_notify_handler(sony_acpi_handle, 853 status = acpi_remove_notify_handler(sony_nc_acpi_handle,
512 ACPI_DEVICE_NOTIFY, 854 ACPI_DEVICE_NOTIFY,
513 sony_acpi_notify); 855 sony_acpi_notify);
514 if (ACPI_FAILURE(status)) 856 if (ACPI_FAILURE(status))
515 printk(LOG_PFX "unable to remove notify handler\n"); 857 printk(KERN_WARNING DRV_PFX "unable to remove notify handler\n");
858
859 outinput:
860 sony_laptop_remove_input();
861
516 outwalk: 862 outwalk:
517 return result; 863 return result;
518} 864}
519 865
520static int sony_acpi_remove(struct acpi_device *device, int type) 866static int sony_nc_remove(struct acpi_device *device, int type)
521{ 867{
522 acpi_status status; 868 acpi_status status;
869 struct sony_nc_value *item;
523 870
524 if (sony_backlight_device) 871 if (sony_backlight_device)
525 backlight_device_unregister(sony_backlight_device); 872 backlight_device_unregister(sony_backlight_device);
526 873
527 sony_acpi_acpi_device = NULL; 874 sony_nc_acpi_device = NULL;
528 875
529 status = acpi_remove_notify_handler(sony_acpi_handle, 876 status = acpi_remove_notify_handler(sony_nc_acpi_handle,
530 ACPI_DEVICE_NOTIFY, 877 ACPI_DEVICE_NOTIFY,
531 sony_acpi_notify); 878 sony_acpi_notify);
532 if (ACPI_FAILURE(status)) 879 if (ACPI_FAILURE(status))
533 printk(LOG_PFX "unable to remove notify handler\n"); 880 printk(KERN_WARNING DRV_PFX "unable to remove notify handler\n");
534 881
535 sony_snc_pf_remove(); 882 for (item = sony_nc_values; item->name; ++item) {
883 device_remove_file(&sony_pf_device->dev, &item->devattr);
884 }
536 885
537 printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully removed\n"); 886 sony_pf_remove();
887 sony_laptop_remove_input();
888 dprintk(SONY_NC_DRIVER_NAME " removed.\n");
538 889
539 return 0; 890 return 0;
540} 891}
541 892
542static struct acpi_driver sony_acpi_driver = { 893static struct acpi_driver sony_nc_driver = {
543 .name = ACPI_SNC_DRIVER_NAME, 894 .name = SONY_NC_DRIVER_NAME,
544 .class = ACPI_SNC_CLASS, 895 .class = SONY_NC_CLASS,
545 .ids = ACPI_SNC_HID, 896 .ids = SONY_NC_HID,
897 .owner = THIS_MODULE,
546 .ops = { 898 .ops = {
547 .add = sony_acpi_add, 899 .add = sony_nc_add,
548 .remove = sony_acpi_remove, 900 .remove = sony_nc_remove,
549 .resume = sony_acpi_resume, 901 .resume = sony_nc_resume,
550 }, 902 },
551}; 903};
552 904
553static int __init sony_acpi_init(void) 905/*********** SPIC (SNY6001) Device ***********/
906
907#define SONYPI_DEVICE_TYPE1 0x00000001
908#define SONYPI_DEVICE_TYPE2 0x00000002
909#define SONYPI_DEVICE_TYPE3 0x00000004
910
911#define SONY_PIC_EV_MASK 0xff
912
913struct sony_pic_ioport {
914 struct acpi_resource_io io;
915 struct list_head list;
916};
917
918struct sony_pic_irq {
919 struct acpi_resource_irq irq;
920 struct list_head list;
921};
922
923struct sony_pic_dev {
924 int model;
925 u8 camera_power;
926 u8 bluetooth_power;
927 u8 wwan_power;
928 struct acpi_device *acpi_dev;
929 struct sony_pic_irq *cur_irq;
930 struct sony_pic_ioport *cur_ioport;
931 struct list_head interrupts;
932 struct list_head ioports;
933 struct mutex lock;
934};
935
936static struct sony_pic_dev spic_dev = {
937 .interrupts = LIST_HEAD_INIT(spic_dev.interrupts),
938 .ioports = LIST_HEAD_INIT(spic_dev.ioports),
939};
940
941/* Event masks */
942#define SONYPI_JOGGER_MASK 0x00000001
943#define SONYPI_CAPTURE_MASK 0x00000002
944#define SONYPI_FNKEY_MASK 0x00000004
945#define SONYPI_BLUETOOTH_MASK 0x00000008
946#define SONYPI_PKEY_MASK 0x00000010
947#define SONYPI_BACK_MASK 0x00000020
948#define SONYPI_HELP_MASK 0x00000040
949#define SONYPI_LID_MASK 0x00000080
950#define SONYPI_ZOOM_MASK 0x00000100
951#define SONYPI_THUMBPHRASE_MASK 0x00000200
952#define SONYPI_MEYE_MASK 0x00000400
953#define SONYPI_MEMORYSTICK_MASK 0x00000800
954#define SONYPI_BATTERY_MASK 0x00001000
955#define SONYPI_WIRELESS_MASK 0x00002000
956
957struct sonypi_event {
958 u8 data;
959 u8 event;
960};
961
962/* The set of possible button release events */
963static struct sonypi_event sonypi_releaseev[] = {
964 { 0x00, SONYPI_EVENT_ANYBUTTON_RELEASED },
965 { 0, 0 }
966};
967
968/* The set of possible jogger events */
969static struct sonypi_event sonypi_joggerev[] = {
970 { 0x1f, SONYPI_EVENT_JOGDIAL_UP },
971 { 0x01, SONYPI_EVENT_JOGDIAL_DOWN },
972 { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED },
973 { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED },
974 { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP },
975 { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN },
976 { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED },
977 { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED },
978 { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP },
979 { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN },
980 { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED },
981 { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED },
982 { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED },
983 { 0, 0 }
984};
985
986/* The set of possible capture button events */
987static struct sonypi_event sonypi_captureev[] = {
988 { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED },
989 { 0x07, SONYPI_EVENT_CAPTURE_PRESSED },
990 { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED },
991 { 0, 0 }
992};
993
994/* The set of possible fnkeys events */
995static struct sonypi_event sonypi_fnkeyev[] = {
996 { 0x10, SONYPI_EVENT_FNKEY_ESC },
997 { 0x11, SONYPI_EVENT_FNKEY_F1 },
998 { 0x12, SONYPI_EVENT_FNKEY_F2 },
999 { 0x13, SONYPI_EVENT_FNKEY_F3 },
1000 { 0x14, SONYPI_EVENT_FNKEY_F4 },
1001 { 0x15, SONYPI_EVENT_FNKEY_F5 },
1002 { 0x16, SONYPI_EVENT_FNKEY_F6 },
1003 { 0x17, SONYPI_EVENT_FNKEY_F7 },
1004 { 0x18, SONYPI_EVENT_FNKEY_F8 },
1005 { 0x19, SONYPI_EVENT_FNKEY_F9 },
1006 { 0x1a, SONYPI_EVENT_FNKEY_F10 },
1007 { 0x1b, SONYPI_EVENT_FNKEY_F11 },
1008 { 0x1c, SONYPI_EVENT_FNKEY_F12 },
1009 { 0x1f, SONYPI_EVENT_FNKEY_RELEASED },
1010 { 0x21, SONYPI_EVENT_FNKEY_1 },
1011 { 0x22, SONYPI_EVENT_FNKEY_2 },
1012 { 0x31, SONYPI_EVENT_FNKEY_D },
1013 { 0x32, SONYPI_EVENT_FNKEY_E },
1014 { 0x33, SONYPI_EVENT_FNKEY_F },
1015 { 0x34, SONYPI_EVENT_FNKEY_S },
1016 { 0x35, SONYPI_EVENT_FNKEY_B },
1017 { 0x36, SONYPI_EVENT_FNKEY_ONLY },
1018 { 0, 0 }
1019};
1020
1021/* The set of possible program key events */
1022static struct sonypi_event sonypi_pkeyev[] = {
1023 { 0x01, SONYPI_EVENT_PKEY_P1 },
1024 { 0x02, SONYPI_EVENT_PKEY_P2 },
1025 { 0x04, SONYPI_EVENT_PKEY_P3 },
1026 { 0x5c, SONYPI_EVENT_PKEY_P1 },
1027 { 0, 0 }
1028};
1029
1030/* The set of possible bluetooth events */
1031static struct sonypi_event sonypi_blueev[] = {
1032 { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED },
1033 { 0x59, SONYPI_EVENT_BLUETOOTH_ON },
1034 { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF },
1035 { 0, 0 }
1036};
1037
1038/* The set of possible wireless events */
1039static struct sonypi_event sonypi_wlessev[] = {
1040 { 0x59, SONYPI_EVENT_WIRELESS_ON },
1041 { 0x5a, SONYPI_EVENT_WIRELESS_OFF },
1042 { 0, 0 }
1043};
1044
1045/* The set of possible back button events */
1046static struct sonypi_event sonypi_backev[] = {
1047 { 0x20, SONYPI_EVENT_BACK_PRESSED },
1048 { 0, 0 }
1049};
1050
1051/* The set of possible help button events */
1052static struct sonypi_event sonypi_helpev[] = {
1053 { 0x3b, SONYPI_EVENT_HELP_PRESSED },
1054 { 0, 0 }
1055};
1056
1057
1058/* The set of possible lid events */
1059static struct sonypi_event sonypi_lidev[] = {
1060 { 0x51, SONYPI_EVENT_LID_CLOSED },
1061 { 0x50, SONYPI_EVENT_LID_OPENED },
1062 { 0, 0 }
1063};
1064
1065/* The set of possible zoom events */
1066static struct sonypi_event sonypi_zoomev[] = {
1067 { 0x39, SONYPI_EVENT_ZOOM_PRESSED },
1068 { 0, 0 }
1069};
1070
1071/* The set of possible thumbphrase events */
1072static struct sonypi_event sonypi_thumbphraseev[] = {
1073 { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED },
1074 { 0, 0 }
1075};
1076
1077/* The set of possible motioneye camera events */
1078static struct sonypi_event sonypi_meyeev[] = {
1079 { 0x00, SONYPI_EVENT_MEYE_FACE },
1080 { 0x01, SONYPI_EVENT_MEYE_OPPOSITE },
1081 { 0, 0 }
1082};
1083
1084/* The set of possible memorystick events */
1085static struct sonypi_event sonypi_memorystickev[] = {
1086 { 0x53, SONYPI_EVENT_MEMORYSTICK_INSERT },
1087 { 0x54, SONYPI_EVENT_MEMORYSTICK_EJECT },
1088 { 0, 0 }
1089};
1090
1091/* The set of possible battery events */
1092static struct sonypi_event sonypi_batteryev[] = {
1093 { 0x20, SONYPI_EVENT_BATTERY_INSERT },
1094 { 0x30, SONYPI_EVENT_BATTERY_REMOVE },
1095 { 0, 0 }
1096};
1097
1098static struct sonypi_eventtypes {
1099 int model;
1100 u8 data;
1101 unsigned long mask;
1102 struct sonypi_event * events;
1103} sony_pic_eventtypes[] = {
1104 { SONYPI_DEVICE_TYPE1, 0, 0xffffffff, sonypi_releaseev },
1105 { SONYPI_DEVICE_TYPE1, 0x70, SONYPI_MEYE_MASK, sonypi_meyeev },
1106 { SONYPI_DEVICE_TYPE1, 0x30, SONYPI_LID_MASK, sonypi_lidev },
1107 { SONYPI_DEVICE_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev },
1108 { SONYPI_DEVICE_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev },
1109 { SONYPI_DEVICE_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
1110 { SONYPI_DEVICE_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
1111 { SONYPI_DEVICE_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev },
1112 { SONYPI_DEVICE_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
1113 { SONYPI_DEVICE_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev },
1114
1115 { SONYPI_DEVICE_TYPE2, 0, 0xffffffff, sonypi_releaseev },
1116 { SONYPI_DEVICE_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev },
1117 { SONYPI_DEVICE_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev },
1118 { SONYPI_DEVICE_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev },
1119 { SONYPI_DEVICE_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
1120 { SONYPI_DEVICE_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
1121 { SONYPI_DEVICE_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev },
1122 { SONYPI_DEVICE_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev },
1123 { SONYPI_DEVICE_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev },
1124 { SONYPI_DEVICE_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev },
1125 { SONYPI_DEVICE_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev },
1126 { SONYPI_DEVICE_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
1127 { SONYPI_DEVICE_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
1128 { SONYPI_DEVICE_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev },
1129
1130 { SONYPI_DEVICE_TYPE3, 0, 0xffffffff, sonypi_releaseev },
1131 { SONYPI_DEVICE_TYPE3, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
1132 { SONYPI_DEVICE_TYPE3, 0x31, SONYPI_WIRELESS_MASK, sonypi_wlessev },
1133 { SONYPI_DEVICE_TYPE3, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
1134 { SONYPI_DEVICE_TYPE3, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
1135 { SONYPI_DEVICE_TYPE3, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev },
1136 { 0 }
1137};
1138
1139static int sony_pic_detect_device_type(void)
1140{
1141 struct pci_dev *pcidev;
1142 int model = 0;
1143
1144 if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
1145 PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
1146 model = SONYPI_DEVICE_TYPE1;
1147
1148 else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
1149 PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
1150 model = SONYPI_DEVICE_TYPE3;
1151
1152 else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
1153 PCI_DEVICE_ID_INTEL_ICH7_1, NULL)))
1154 model = SONYPI_DEVICE_TYPE3;
1155
1156 else
1157 model = SONYPI_DEVICE_TYPE2;
1158
1159 if (pcidev)
1160 pci_dev_put(pcidev);
1161
1162 printk(KERN_INFO DRV_PFX "detected Type%d model\n",
1163 model == SONYPI_DEVICE_TYPE1 ? 1 :
1164 model == SONYPI_DEVICE_TYPE2 ? 2 : 3);
1165 return model;
1166}
1167
1168#define ITERATIONS_LONG 10000
1169#define ITERATIONS_SHORT 10
1170#define wait_on_command(command, iterations) { \
1171 unsigned int n = iterations; \
1172 while (--n && (command)) \
1173 udelay(1); \
1174 if (!n) \
1175 dprintk("command failed at %s : %s (line %d)\n", \
1176 __FILE__, __FUNCTION__, __LINE__); \
1177}
1178
1179static u8 sony_pic_call1(u8 dev)
1180{
1181 u8 v1, v2;
1182
1183 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
1184 ITERATIONS_LONG);
1185 outb(dev, spic_dev.cur_ioport->io.minimum + 4);
1186 v1 = inb_p(spic_dev.cur_ioport->io.minimum + 4);
1187 v2 = inb_p(spic_dev.cur_ioport->io.minimum);
1188 dprintk("sony_pic_call1: 0x%.4x\n", (v2 << 8) | v1);
1189 return v2;
1190}
1191
1192static u8 sony_pic_call2(u8 dev, u8 fn)
1193{
1194 u8 v1;
1195
1196 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
1197 ITERATIONS_LONG);
1198 outb(dev, spic_dev.cur_ioport->io.minimum + 4);
1199 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
1200 ITERATIONS_LONG);
1201 outb(fn, spic_dev.cur_ioport->io.minimum);
1202 v1 = inb_p(spic_dev.cur_ioport->io.minimum);
1203 dprintk("sony_pic_call2: 0x%.4x\n", v1);
1204 return v1;
1205}
1206
1207static u8 sony_pic_call3(u8 dev, u8 fn, u8 v)
1208{
1209 u8 v1;
1210
1211 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
1212 outb(dev, spic_dev.cur_ioport->io.minimum + 4);
1213 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
1214 outb(fn, spic_dev.cur_ioport->io.minimum);
1215 wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
1216 outb(v, spic_dev.cur_ioport->io.minimum);
1217 v1 = inb_p(spic_dev.cur_ioport->io.minimum);
1218 dprintk("sony_pic_call3: 0x%.4x\n", v1);
1219 return v1;
1220}
1221
1222/* camera tests and poweron/poweroff */
1223#define SONYPI_CAMERA_PICTURE 5
1224#define SONYPI_CAMERA_CONTROL 0x10
1225
1226#define SONYPI_CAMERA_BRIGHTNESS 0
1227#define SONYPI_CAMERA_CONTRAST 1
1228#define SONYPI_CAMERA_HUE 2
1229#define SONYPI_CAMERA_COLOR 3
1230#define SONYPI_CAMERA_SHARPNESS 4
1231
1232#define SONYPI_CAMERA_EXPOSURE_MASK 0xC
1233#define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3
1234#define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30
1235#define SONYPI_CAMERA_MUTE_MASK 0x40
1236
1237/* the rest don't need a loop until not 0xff */
1238#define SONYPI_CAMERA_AGC 6
1239#define SONYPI_CAMERA_AGC_MASK 0x30
1240#define SONYPI_CAMERA_SHUTTER_MASK 0x7
1241
1242#define SONYPI_CAMERA_SHUTDOWN_REQUEST 7
1243#define SONYPI_CAMERA_CONTROL 0x10
1244
1245#define SONYPI_CAMERA_STATUS 7
1246#define SONYPI_CAMERA_STATUS_READY 0x2
1247#define SONYPI_CAMERA_STATUS_POSITION 0x4
1248
1249#define SONYPI_DIRECTION_BACKWARDS 0x4
1250
1251#define SONYPI_CAMERA_REVISION 8
1252#define SONYPI_CAMERA_ROMVERSION 9
1253
1254static int __sony_pic_camera_ready(void)
1255{
1256 u8 v;
1257
1258 v = sony_pic_call2(0x8f, SONYPI_CAMERA_STATUS);
1259 return (v != 0xff && (v & SONYPI_CAMERA_STATUS_READY));
1260}
1261
1262static int __sony_pic_camera_off(void)
1263{
1264 if (!camera) {
1265 printk(KERN_WARNING DRV_PFX "camera control not enabled\n");
1266 return -ENODEV;
1267 }
1268
1269 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE,
1270 SONYPI_CAMERA_MUTE_MASK),
1271 ITERATIONS_SHORT);
1272
1273 if (spic_dev.camera_power) {
1274 sony_pic_call2(0x91, 0);
1275 spic_dev.camera_power = 0;
1276 }
1277 return 0;
1278}
1279
1280static int __sony_pic_camera_on(void)
554{ 1281{
555 return acpi_bus_register_driver(&sony_acpi_driver); 1282 int i, j, x;
1283
1284 if (!camera) {
1285 printk(KERN_WARNING DRV_PFX "camera control not enabled\n");
1286 return -ENODEV;
1287 }
1288
1289 if (spic_dev.camera_power)
1290 return 0;
1291
1292 for (j = 5; j > 0; j--) {
1293
1294 for (x = 0; x < 100 && sony_pic_call2(0x91, 0x1); x++)
1295 msleep(10);
1296 sony_pic_call1(0x93);
1297
1298 for (i = 400; i > 0; i--) {
1299 if (__sony_pic_camera_ready())
1300 break;
1301 msleep(10);
1302 }
1303 if (i)
1304 break;
1305 }
1306
1307 if (j == 0) {
1308 printk(KERN_WARNING DRV_PFX "failed to power on camera\n");
1309 return -ENODEV;
1310 }
1311
1312 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTROL,
1313 0x5a),
1314 ITERATIONS_SHORT);
1315
1316 spic_dev.camera_power = 1;
1317 return 0;
1318}
1319
1320/* External camera command (exported to the motion eye v4l driver) */
1321int sony_pic_camera_command(int command, u8 value)
1322{
1323 if (!camera)
1324 return -EIO;
1325
1326 mutex_lock(&spic_dev.lock);
1327
1328 switch (command) {
1329 case SONY_PIC_COMMAND_SETCAMERA:
1330 if (value)
1331 __sony_pic_camera_on();
1332 else
1333 __sony_pic_camera_off();
1334 break;
1335 case SONY_PIC_COMMAND_SETCAMERABRIGHTNESS:
1336 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_BRIGHTNESS, value),
1337 ITERATIONS_SHORT);
1338 break;
1339 case SONY_PIC_COMMAND_SETCAMERACONTRAST:
1340 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTRAST, value),
1341 ITERATIONS_SHORT);
1342 break;
1343 case SONY_PIC_COMMAND_SETCAMERAHUE:
1344 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_HUE, value),
1345 ITERATIONS_SHORT);
1346 break;
1347 case SONY_PIC_COMMAND_SETCAMERACOLOR:
1348 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_COLOR, value),
1349 ITERATIONS_SHORT);
1350 break;
1351 case SONY_PIC_COMMAND_SETCAMERASHARPNESS:
1352 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_SHARPNESS, value),
1353 ITERATIONS_SHORT);
1354 break;
1355 case SONY_PIC_COMMAND_SETCAMERAPICTURE:
1356 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE, value),
1357 ITERATIONS_SHORT);
1358 break;
1359 case SONY_PIC_COMMAND_SETCAMERAAGC:
1360 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_AGC, value),
1361 ITERATIONS_SHORT);
1362 break;
1363 default:
1364 printk(KERN_ERR DRV_PFX "sony_pic_camera_command invalid: %d\n",
1365 command);
1366 break;
1367 }
1368 mutex_unlock(&spic_dev.lock);
1369 return 0;
1370}
1371EXPORT_SYMBOL(sony_pic_camera_command);
1372
1373/* gprs/edge modem (SZ460N and SZ210P), thanks to Joshua Wise */
1374static void sony_pic_set_wwanpower(u8 state)
1375{
1376 state = !!state;
1377 mutex_lock(&spic_dev.lock);
1378 if (spic_dev.wwan_power == state) {
1379 mutex_unlock(&spic_dev.lock);
1380 return;
1381 }
1382 sony_pic_call2(0xB0, state);
1383 spic_dev.wwan_power = state;
1384 mutex_unlock(&spic_dev.lock);
1385}
1386
1387static ssize_t sony_pic_wwanpower_store(struct device *dev,
1388 struct device_attribute *attr,
1389 const char *buffer, size_t count)
1390{
1391 unsigned long value;
1392 if (count > 31)
1393 return -EINVAL;
1394
1395 value = simple_strtoul(buffer, NULL, 10);
1396 sony_pic_set_wwanpower(value);
1397
1398 return count;
1399}
1400
1401static ssize_t sony_pic_wwanpower_show(struct device *dev,
1402 struct device_attribute *attr, char *buffer)
1403{
1404 ssize_t count;
1405 mutex_lock(&spic_dev.lock);
1406 count = snprintf(buffer, PAGE_SIZE, "%d\n", spic_dev.wwan_power);
1407 mutex_unlock(&spic_dev.lock);
1408 return count;
1409}
1410
1411/* bluetooth subsystem power state */
1412static void __sony_pic_set_bluetoothpower(u8 state)
1413{
1414 state = !!state;
1415 if (spic_dev.bluetooth_power == state)
1416 return;
1417 sony_pic_call2(0x96, state);
1418 sony_pic_call1(0x82);
1419 spic_dev.bluetooth_power = state;
1420}
1421
1422static ssize_t sony_pic_bluetoothpower_store(struct device *dev,
1423 struct device_attribute *attr,
1424 const char *buffer, size_t count)
1425{
1426 unsigned long value;
1427 if (count > 31)
1428 return -EINVAL;
1429
1430 value = simple_strtoul(buffer, NULL, 10);
1431 mutex_lock(&spic_dev.lock);
1432 __sony_pic_set_bluetoothpower(value);
1433 mutex_unlock(&spic_dev.lock);
1434
1435 return count;
1436}
1437
1438static ssize_t sony_pic_bluetoothpower_show(struct device *dev,
1439 struct device_attribute *attr, char *buffer)
1440{
1441 ssize_t count = 0;
1442 mutex_lock(&spic_dev.lock);
1443 count = snprintf(buffer, PAGE_SIZE, "%d\n", spic_dev.bluetooth_power);
1444 mutex_unlock(&spic_dev.lock);
1445 return count;
1446}
1447
1448/* fan speed */
1449/* FAN0 information (reverse engineered from ACPI tables) */
1450#define SONY_PIC_FAN0_STATUS 0x93
1451static int sony_pic_set_fanspeed(unsigned long value)
1452{
1453 return ec_write(SONY_PIC_FAN0_STATUS, value);
1454}
1455
1456static int sony_pic_get_fanspeed(u8 *value)
1457{
1458 return ec_read(SONY_PIC_FAN0_STATUS, value);
1459}
1460
1461static ssize_t sony_pic_fanspeed_store(struct device *dev,
1462 struct device_attribute *attr,
1463 const char *buffer, size_t count)
1464{
1465 unsigned long value;
1466 if (count > 31)
1467 return -EINVAL;
1468
1469 value = simple_strtoul(buffer, NULL, 10);
1470 if (sony_pic_set_fanspeed(value))
1471 return -EIO;
1472
1473 return count;
1474}
1475
1476static ssize_t sony_pic_fanspeed_show(struct device *dev,
1477 struct device_attribute *attr, char *buffer)
1478{
1479 u8 value = 0;
1480 if (sony_pic_get_fanspeed(&value))
1481 return -EIO;
1482
1483 return snprintf(buffer, PAGE_SIZE, "%d\n", value);
1484}
1485
1486#define SPIC_ATTR(_name, _mode) \
1487struct device_attribute spic_attr_##_name = __ATTR(_name, \
1488 _mode, sony_pic_## _name ##_show, \
1489 sony_pic_## _name ##_store)
1490
1491static SPIC_ATTR(bluetoothpower, 0644);
1492static SPIC_ATTR(wwanpower, 0644);
1493static SPIC_ATTR(fanspeed, 0644);
1494
1495static struct attribute *spic_attributes[] = {
1496 &spic_attr_bluetoothpower.attr,
1497 &spic_attr_wwanpower.attr,
1498 &spic_attr_fanspeed.attr,
1499 NULL
1500};
1501
1502static struct attribute_group spic_attribute_group = {
1503 .attrs = spic_attributes
1504};
1505
1506/******** SONYPI compatibility **********/
1507#ifdef CONFIG_SONY_LAPTOP_OLD
1508
1509/* battery / brightness / temperature addresses */
1510#define SONYPI_BAT_FLAGS 0x81
1511#define SONYPI_LCD_LIGHT 0x96
1512#define SONYPI_BAT1_PCTRM 0xa0
1513#define SONYPI_BAT1_LEFT 0xa2
1514#define SONYPI_BAT1_MAXRT 0xa4
1515#define SONYPI_BAT2_PCTRM 0xa8
1516#define SONYPI_BAT2_LEFT 0xaa
1517#define SONYPI_BAT2_MAXRT 0xac
1518#define SONYPI_BAT1_MAXTK 0xb0
1519#define SONYPI_BAT1_FULL 0xb2
1520#define SONYPI_BAT2_MAXTK 0xb8
1521#define SONYPI_BAT2_FULL 0xba
1522#define SONYPI_TEMP_STATUS 0xC1
1523
1524struct sonypi_compat_s {
1525 struct fasync_struct *fifo_async;
1526 struct kfifo *fifo;
1527 spinlock_t fifo_lock;
1528 wait_queue_head_t fifo_proc_list;
1529 atomic_t open_count;
1530};
1531static struct sonypi_compat_s sonypi_compat = {
1532 .open_count = ATOMIC_INIT(0),
1533};
1534
1535static int sonypi_misc_fasync(int fd, struct file *filp, int on)
1536{
1537 int retval;
1538
1539 retval = fasync_helper(fd, filp, on, &sonypi_compat.fifo_async);
1540 if (retval < 0)
1541 return retval;
1542 return 0;
1543}
1544
1545static int sonypi_misc_release(struct inode *inode, struct file *file)
1546{
1547 sonypi_misc_fasync(-1, file, 0);
1548 atomic_dec(&sonypi_compat.open_count);
1549 return 0;
1550}
1551
1552static int sonypi_misc_open(struct inode *inode, struct file *file)
1553{
1554 /* Flush input queue on first open */
1555 if (atomic_inc_return(&sonypi_compat.open_count) == 1)
1556 kfifo_reset(sonypi_compat.fifo);
1557 return 0;
1558}
1559
1560static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
1561 size_t count, loff_t *pos)
1562{
1563 ssize_t ret;
1564 unsigned char c;
1565
1566 if ((kfifo_len(sonypi_compat.fifo) == 0) &&
1567 (file->f_flags & O_NONBLOCK))
1568 return -EAGAIN;
1569
1570 ret = wait_event_interruptible(sonypi_compat.fifo_proc_list,
1571 kfifo_len(sonypi_compat.fifo) != 0);
1572 if (ret)
1573 return ret;
1574
1575 while (ret < count &&
1576 (kfifo_get(sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) {
1577 if (put_user(c, buf++))
1578 return -EFAULT;
1579 ret++;
1580 }
1581
1582 if (ret > 0) {
1583 struct inode *inode = file->f_path.dentry->d_inode;
1584 inode->i_atime = current_fs_time(inode->i_sb);
1585 }
1586
1587 return ret;
1588}
1589
1590static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
1591{
1592 poll_wait(file, &sonypi_compat.fifo_proc_list, wait);
1593 if (kfifo_len(sonypi_compat.fifo))
1594 return POLLIN | POLLRDNORM;
1595 return 0;
1596}
1597
1598static int ec_read16(u8 addr, u16 *value)
1599{
1600 u8 val_lb, val_hb;
1601 if (ec_read(addr, &val_lb))
1602 return -1;
1603 if (ec_read(addr + 1, &val_hb))
1604 return -1;
1605 *value = val_lb | (val_hb << 8);
1606 return 0;
1607}
1608
1609static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1610 unsigned int cmd, unsigned long arg)
1611{
1612 int ret = 0;
1613 void __user *argp = (void __user *)arg;
1614 u8 val8;
1615 u16 val16;
1616 int value;
1617
1618 mutex_lock(&spic_dev.lock);
1619 switch (cmd) {
1620 case SONYPI_IOCGBRT:
1621 if (sony_backlight_device == NULL) {
1622 ret = -EIO;
1623 break;
1624 }
1625 if (acpi_callgetfunc(sony_nc_acpi_handle, "GBRT", &value)) {
1626 ret = -EIO;
1627 break;
1628 }
1629 val8 = ((value & 0xff) - 1) << 5;
1630 if (copy_to_user(argp, &val8, sizeof(val8)))
1631 ret = -EFAULT;
1632 break;
1633 case SONYPI_IOCSBRT:
1634 if (sony_backlight_device == NULL) {
1635 ret = -EIO;
1636 break;
1637 }
1638 if (copy_from_user(&val8, argp, sizeof(val8))) {
1639 ret = -EFAULT;
1640 break;
1641 }
1642 if (acpi_callsetfunc(sony_nc_acpi_handle, "SBRT",
1643 (val8 >> 5) + 1, NULL)) {
1644 ret = -EIO;
1645 break;
1646 }
1647 /* sync the backlight device status */
1648 sony_backlight_device->props.brightness =
1649 sony_backlight_get_brightness(sony_backlight_device);
1650 break;
1651 case SONYPI_IOCGBAT1CAP:
1652 if (ec_read16(SONYPI_BAT1_FULL, &val16)) {
1653 ret = -EIO;
1654 break;
1655 }
1656 if (copy_to_user(argp, &val16, sizeof(val16)))
1657 ret = -EFAULT;
1658 break;
1659 case SONYPI_IOCGBAT1REM:
1660 if (ec_read16(SONYPI_BAT1_LEFT, &val16)) {
1661 ret = -EIO;
1662 break;
1663 }
1664 if (copy_to_user(argp, &val16, sizeof(val16)))
1665 ret = -EFAULT;
1666 break;
1667 case SONYPI_IOCGBAT2CAP:
1668 if (ec_read16(SONYPI_BAT2_FULL, &val16)) {
1669 ret = -EIO;
1670 break;
1671 }
1672 if (copy_to_user(argp, &val16, sizeof(val16)))
1673 ret = -EFAULT;
1674 break;
1675 case SONYPI_IOCGBAT2REM:
1676 if (ec_read16(SONYPI_BAT2_LEFT, &val16)) {
1677 ret = -EIO;
1678 break;
1679 }
1680 if (copy_to_user(argp, &val16, sizeof(val16)))
1681 ret = -EFAULT;
1682 break;
1683 case SONYPI_IOCGBATFLAGS:
1684 if (ec_read(SONYPI_BAT_FLAGS, &val8)) {
1685 ret = -EIO;
1686 break;
1687 }
1688 val8 &= 0x07;
1689 if (copy_to_user(argp, &val8, sizeof(val8)))
1690 ret = -EFAULT;
1691 break;
1692 case SONYPI_IOCGBLUE:
1693 val8 = spic_dev.bluetooth_power;
1694 if (copy_to_user(argp, &val8, sizeof(val8)))
1695 ret = -EFAULT;
1696 break;
1697 case SONYPI_IOCSBLUE:
1698 if (copy_from_user(&val8, argp, sizeof(val8))) {
1699 ret = -EFAULT;
1700 break;
1701 }
1702 __sony_pic_set_bluetoothpower(val8);
1703 break;
1704 /* FAN Controls */
1705 case SONYPI_IOCGFAN:
1706 if (sony_pic_get_fanspeed(&val8)) {
1707 ret = -EIO;
1708 break;
1709 }
1710 if (copy_to_user(argp, &val8, sizeof(val8)))
1711 ret = -EFAULT;
1712 break;
1713 case SONYPI_IOCSFAN:
1714 if (copy_from_user(&val8, argp, sizeof(val8))) {
1715 ret = -EFAULT;
1716 break;
1717 }
1718 if (sony_pic_set_fanspeed(val8))
1719 ret = -EIO;
1720 break;
1721 /* GET Temperature (useful under APM) */
1722 case SONYPI_IOCGTEMP:
1723 if (ec_read(SONYPI_TEMP_STATUS, &val8)) {
1724 ret = -EIO;
1725 break;
1726 }
1727 if (copy_to_user(argp, &val8, sizeof(val8)))
1728 ret = -EFAULT;
1729 break;
1730 default:
1731 ret = -EINVAL;
1732 }
1733 mutex_unlock(&spic_dev.lock);
1734 return ret;
1735}
1736
1737static const struct file_operations sonypi_misc_fops = {
1738 .owner = THIS_MODULE,
1739 .read = sonypi_misc_read,
1740 .poll = sonypi_misc_poll,
1741 .open = sonypi_misc_open,
1742 .release = sonypi_misc_release,
1743 .fasync = sonypi_misc_fasync,
1744 .ioctl = sonypi_misc_ioctl,
1745};
1746
1747static struct miscdevice sonypi_misc_device = {
1748 .minor = MISC_DYNAMIC_MINOR,
1749 .name = "sonypi",
1750 .fops = &sonypi_misc_fops,
1751};
1752
1753static void sonypi_compat_report_event(u8 event)
1754{
1755 kfifo_put(sonypi_compat.fifo, (unsigned char *)&event, sizeof(event));
1756 kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
1757 wake_up_interruptible(&sonypi_compat.fifo_proc_list);
1758}
1759
1760static int sonypi_compat_init(void)
1761{
1762 int error;
1763
1764 spin_lock_init(&sonypi_compat.fifo_lock);
1765 sonypi_compat.fifo = kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
1766 &sonypi_compat.fifo_lock);
1767 if (IS_ERR(sonypi_compat.fifo)) {
1768 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
1769 return PTR_ERR(sonypi_compat.fifo);
1770 }
1771
1772 init_waitqueue_head(&sonypi_compat.fifo_proc_list);
1773
1774 if (minor != -1)
1775 sonypi_misc_device.minor = minor;
1776 error = misc_register(&sonypi_misc_device);
1777 if (error) {
1778 printk(KERN_ERR DRV_PFX "misc_register failed\n");
1779 goto err_free_kfifo;
1780 }
1781 if (minor == -1)
1782 printk(KERN_INFO DRV_PFX "device allocated minor is %d\n",
1783 sonypi_misc_device.minor);
1784
1785 return 0;
1786
1787err_free_kfifo:
1788 kfifo_free(sonypi_compat.fifo);
1789 return error;
1790}
1791
1792static void sonypi_compat_exit(void)
1793{
1794 misc_deregister(&sonypi_misc_device);
1795 kfifo_free(sonypi_compat.fifo);
1796}
1797#else
1798static int sonypi_compat_init(void) { return 0; }
1799static void sonypi_compat_exit(void) { }
1800static void sonypi_compat_report_event(u8 event) { }
1801#endif /* CONFIG_SONY_LAPTOP_OLD */
1802
1803/*
1804 * ACPI callbacks
1805 */
1806static acpi_status
1807sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
1808{
1809 u32 i;
1810 struct sony_pic_dev *dev = (struct sony_pic_dev *)context;
1811
1812 switch (resource->type) {
1813 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
1814 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
1815 return AE_OK;
1816
1817 case ACPI_RESOURCE_TYPE_IRQ:
1818 {
1819 struct acpi_resource_irq *p = &resource->data.irq;
1820 struct sony_pic_irq *interrupt = NULL;
1821 if (!p || !p->interrupt_count) {
1822 /*
1823 * IRQ descriptors may have no IRQ# bits set,
1824 * particularly those those w/ _STA disabled
1825 */
1826 dprintk("Blank IRQ resource\n");
1827 return AE_OK;
1828 }
1829 for (i = 0; i < p->interrupt_count; i++) {
1830 if (!p->interrupts[i]) {
1831 printk(KERN_WARNING DRV_PFX
1832 "Invalid IRQ %d\n",
1833 p->interrupts[i]);
1834 continue;
1835 }
1836 interrupt = kzalloc(sizeof(*interrupt),
1837 GFP_KERNEL);
1838 if (!interrupt)
1839 return AE_ERROR;
1840
1841 list_add_tail(&interrupt->list, &dev->interrupts);
1842 interrupt->irq.triggering = p->triggering;
1843 interrupt->irq.polarity = p->polarity;
1844 interrupt->irq.sharable = p->sharable;
1845 interrupt->irq.interrupt_count = 1;
1846 interrupt->irq.interrupts[0] = p->interrupts[i];
1847 }
1848 return AE_OK;
1849 }
1850 case ACPI_RESOURCE_TYPE_IO:
1851 {
1852 struct acpi_resource_io *io = &resource->data.io;
1853 struct sony_pic_ioport *ioport = NULL;
1854 if (!io) {
1855 dprintk("Blank IO resource\n");
1856 return AE_OK;
1857 }
1858
1859 ioport = kzalloc(sizeof(*ioport), GFP_KERNEL);
1860 if (!ioport)
1861 return AE_ERROR;
1862
1863 list_add_tail(&ioport->list, &dev->ioports);
1864 memcpy(&ioport->io, io, sizeof(*io));
1865 return AE_OK;
1866 }
1867 default:
1868 dprintk("Resource %d isn't an IRQ nor an IO port\n",
1869 resource->type);
1870
1871 case ACPI_RESOURCE_TYPE_END_TAG:
1872 return AE_OK;
1873 }
1874 return AE_CTRL_TERMINATE;
1875}
1876
1877static int sony_pic_possible_resources(struct acpi_device *device)
1878{
1879 int result = 0;
1880 acpi_status status = AE_OK;
1881
1882 if (!device)
1883 return -EINVAL;
1884
1885 /* get device status */
1886 /* see acpi_pci_link_get_current acpi_pci_link_get_possible */
1887 dprintk("Evaluating _STA\n");
1888 result = acpi_bus_get_status(device);
1889 if (result) {
1890 printk(KERN_WARNING DRV_PFX "Unable to read status\n");
1891 goto end;
1892 }
1893
1894 if (!device->status.enabled)
1895 dprintk("Device disabled\n");
1896 else
1897 dprintk("Device enabled\n");
1898
1899 /*
1900 * Query and parse 'method'
1901 */
1902 dprintk("Evaluating %s\n", METHOD_NAME__PRS);
1903 status = acpi_walk_resources(device->handle, METHOD_NAME__PRS,
1904 sony_pic_read_possible_resource, &spic_dev);
1905 if (ACPI_FAILURE(status)) {
1906 printk(KERN_WARNING DRV_PFX
1907 "Failure evaluating %s\n",
1908 METHOD_NAME__PRS);
1909 result = -ENODEV;
1910 }
1911end:
1912 return result;
1913}
1914
1915/*
1916 * Disable the spic device by calling its _DIS method
1917 */
1918static int sony_pic_disable(struct acpi_device *device)
1919{
1920 if (ACPI_FAILURE(acpi_evaluate_object(device->handle, "_DIS", 0, NULL)))
1921 return -ENXIO;
1922
1923 dprintk("Device disabled\n");
1924 return 0;
1925}
1926
1927
1928/*
1929 * Based on drivers/acpi/pci_link.c:acpi_pci_link_set
1930 *
1931 * Call _SRS to set current resources
1932 */
1933static int sony_pic_enable(struct acpi_device *device,
1934 struct sony_pic_ioport *ioport, struct sony_pic_irq *irq)
1935{
1936 acpi_status status;
1937 int result = 0;
1938 struct {
1939 struct acpi_resource io_res;
1940 struct acpi_resource irq_res;
1941 struct acpi_resource end;
1942 } *resource;
1943 struct acpi_buffer buffer = { 0, NULL };
1944
1945 if (!ioport || !irq)
1946 return -EINVAL;
1947
1948 /* init acpi_buffer */
1949 resource = kzalloc(sizeof(*resource) + 1, GFP_KERNEL);
1950 if (!resource)
1951 return -ENOMEM;
1952
1953 buffer.length = sizeof(*resource) + 1;
1954 buffer.pointer = resource;
1955
1956 /* setup io resource */
1957 resource->io_res.type = ACPI_RESOURCE_TYPE_IO;
1958 resource->io_res.length = sizeof(struct acpi_resource);
1959 memcpy(&resource->io_res.data.io, &ioport->io,
1960 sizeof(struct acpi_resource_io));
1961
1962 /* setup irq resource */
1963 resource->irq_res.type = ACPI_RESOURCE_TYPE_IRQ;
1964 resource->irq_res.length = sizeof(struct acpi_resource);
1965 memcpy(&resource->irq_res.data.irq, &irq->irq,
1966 sizeof(struct acpi_resource_irq));
1967 /* we requested a shared irq */
1968 resource->irq_res.data.irq.sharable = ACPI_SHARED;
1969
1970 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
1971
1972 /* Attempt to set the resource */
1973 dprintk("Evaluating _SRS\n");
1974 status = acpi_set_current_resources(device->handle, &buffer);
1975
1976 /* check for total failure */
1977 if (ACPI_FAILURE(status)) {
1978 printk(KERN_ERR DRV_PFX "Error evaluating _SRS");
1979 result = -ENODEV;
1980 goto end;
1981 }
1982
1983 /* Necessary device initializations calls (from sonypi) */
1984 sony_pic_call1(0x82);
1985 sony_pic_call2(0x81, 0xff);
1986 sony_pic_call1(compat ? 0x92 : 0x82);
1987
1988end:
1989 kfree(resource);
1990 return result;
1991}
1992
1993/*****************
1994 *
1995 * ISR: some event is available
1996 *
1997 *****************/
1998static irqreturn_t sony_pic_irq(int irq, void *dev_id)
1999{
2000 int i, j;
2001 u32 port_val = 0;
2002 u8 ev = 0;
2003 u8 data_mask = 0;
2004 u8 device_event = 0;
2005
2006 struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id;
2007
2008 acpi_os_read_port(dev->cur_ioport->io.minimum, &port_val,
2009 dev->cur_ioport->io.address_length);
2010 ev = port_val & SONY_PIC_EV_MASK;
2011 data_mask = 0xff & (port_val >> (dev->cur_ioport->io.address_length - 8));
2012
2013 dprintk("event (0x%.8x [%.2x] [%.2x]) at port 0x%.4x\n",
2014 port_val, ev, data_mask, dev->cur_ioport->io.minimum);
2015
2016 if (ev == 0x00 || ev == 0xff)
2017 return IRQ_HANDLED;
2018
2019 for (i = 0; sony_pic_eventtypes[i].model; i++) {
2020
2021 if (spic_dev.model != sony_pic_eventtypes[i].model)
2022 continue;
2023
2024 if ((data_mask & sony_pic_eventtypes[i].data) !=
2025 sony_pic_eventtypes[i].data)
2026 continue;
2027
2028 if (!(mask & sony_pic_eventtypes[i].mask))
2029 continue;
2030
2031 for (j = 0; sony_pic_eventtypes[i].events[j].event; j++) {
2032 if (ev == sony_pic_eventtypes[i].events[j].data) {
2033 device_event =
2034 sony_pic_eventtypes[i].events[j].event;
2035 goto found;
2036 }
2037 }
2038 }
2039 return IRQ_HANDLED;
2040
2041found:
2042 sony_laptop_report_input_event(device_event);
2043 acpi_bus_generate_event(spic_dev.acpi_dev, 1, device_event);
2044 sonypi_compat_report_event(device_event);
2045
2046 return IRQ_HANDLED;
2047}
2048
2049/*****************
2050 *
2051 * ACPI driver
2052 *
2053 *****************/
2054static int sony_pic_remove(struct acpi_device *device, int type)
2055{
2056 struct sony_pic_ioport *io, *tmp_io;
2057 struct sony_pic_irq *irq, *tmp_irq;
2058
2059 sonypi_compat_exit();
2060
2061 if (sony_pic_disable(device)) {
2062 printk(KERN_ERR DRV_PFX "Couldn't disable device.\n");
2063 return -ENXIO;
2064 }
2065
2066 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
2067 release_region(spic_dev.cur_ioport->io.minimum,
2068 spic_dev.cur_ioport->io.address_length);
2069
2070 sony_laptop_remove_input();
2071
2072 /* pf attrs */
2073 sysfs_remove_group(&sony_pf_device->dev.kobj, &spic_attribute_group);
2074 sony_pf_remove();
2075
2076 list_for_each_entry_safe(io, tmp_io, &spic_dev.ioports, list) {
2077 list_del(&io->list);
2078 kfree(io);
2079 }
2080 list_for_each_entry_safe(irq, tmp_irq, &spic_dev.interrupts, list) {
2081 list_del(&irq->list);
2082 kfree(irq);
2083 }
2084 spic_dev.cur_ioport = NULL;
2085 spic_dev.cur_irq = NULL;
2086
2087 dprintk(SONY_PIC_DRIVER_NAME " removed.\n");
2088 return 0;
2089}
2090
2091static int sony_pic_add(struct acpi_device *device)
2092{
2093 int result;
2094 struct sony_pic_ioport *io, *tmp_io;
2095 struct sony_pic_irq *irq, *tmp_irq;
2096
2097 printk(KERN_INFO DRV_PFX "%s v%s.\n",
2098 SONY_PIC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
2099
2100 spic_dev.acpi_dev = device;
2101 strcpy(acpi_device_class(device), "sony/hotkey");
2102 spic_dev.model = sony_pic_detect_device_type();
2103 mutex_init(&spic_dev.lock);
2104
2105 /* read _PRS resources */
2106 result = sony_pic_possible_resources(device);
2107 if (result) {
2108 printk(KERN_ERR DRV_PFX
2109 "Unabe to read possible resources.\n");
2110 goto err_free_resources;
2111 }
2112
2113 /* setup input devices and helper fifo */
2114 result = sony_laptop_setup_input();
2115 if (result) {
2116 printk(KERN_ERR DRV_PFX
2117 "Unabe to create input devices.\n");
2118 goto err_free_resources;
2119 }
2120
2121 /* request io port */
2122 list_for_each_entry(io, &spic_dev.ioports, list) {
2123 if (request_region(io->io.minimum, io->io.address_length,
2124 "Sony Programable I/O Device")) {
2125 dprintk("I/O port: 0x%.4x (0x%.4x) + 0x%.2x\n",
2126 io->io.minimum, io->io.maximum,
2127 io->io.address_length);
2128 spic_dev.cur_ioport = io;
2129 break;
2130 }
2131 }
2132 if (!spic_dev.cur_ioport) {
2133 printk(KERN_ERR DRV_PFX "Failed to request_region.\n");
2134 result = -ENODEV;
2135 goto err_remove_input;
2136 }
2137
2138 /* request IRQ */
2139 list_for_each_entry(irq, &spic_dev.interrupts, list) {
2140 if (!request_irq(irq->irq.interrupts[0], sony_pic_irq,
2141 IRQF_SHARED, "sony-laptop", &spic_dev)) {
2142 dprintk("IRQ: %d - triggering: %d - "
2143 "polarity: %d - shr: %d\n",
2144 irq->irq.interrupts[0],
2145 irq->irq.triggering,
2146 irq->irq.polarity,
2147 irq->irq.sharable);
2148 spic_dev.cur_irq = irq;
2149 break;
2150 }
2151 }
2152 if (!spic_dev.cur_irq) {
2153 printk(KERN_ERR DRV_PFX "Failed to request_irq.\n");
2154 result = -ENODEV;
2155 goto err_release_region;
2156 }
2157
2158 /* set resource status _SRS */
2159 result = sony_pic_enable(device, spic_dev.cur_ioport, spic_dev.cur_irq);
2160 if (result) {
2161 printk(KERN_ERR DRV_PFX "Couldn't enable device.\n");
2162 goto err_free_irq;
2163 }
2164
2165 spic_dev.bluetooth_power = -1;
2166 /* create device attributes */
2167 result = sony_pf_add();
2168 if (result)
2169 goto err_disable_device;
2170
2171 result = sysfs_create_group(&sony_pf_device->dev.kobj, &spic_attribute_group);
2172 if (result)
2173 goto err_remove_pf;
2174
2175 if (sonypi_compat_init())
2176 goto err_remove_pf;
2177
2178 return 0;
2179
2180err_remove_pf:
2181 sony_pf_remove();
2182
2183err_disable_device:
2184 sony_pic_disable(device);
2185
2186err_free_irq:
2187 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
2188
2189err_release_region:
2190 release_region(spic_dev.cur_ioport->io.minimum,
2191 spic_dev.cur_ioport->io.address_length);
2192
2193err_remove_input:
2194 sony_laptop_remove_input();
2195
2196err_free_resources:
2197 list_for_each_entry_safe(io, tmp_io, &spic_dev.ioports, list) {
2198 list_del(&io->list);
2199 kfree(io);
2200 }
2201 list_for_each_entry_safe(irq, tmp_irq, &spic_dev.interrupts, list) {
2202 list_del(&irq->list);
2203 kfree(irq);
2204 }
2205 spic_dev.cur_ioport = NULL;
2206 spic_dev.cur_irq = NULL;
2207
2208 return result;
2209}
2210
2211static int sony_pic_suspend(struct acpi_device *device, pm_message_t state)
2212{
2213 if (sony_pic_disable(device))
2214 return -ENXIO;
2215 return 0;
2216}
2217
2218static int sony_pic_resume(struct acpi_device *device)
2219{
2220 sony_pic_enable(device, spic_dev.cur_ioport, spic_dev.cur_irq);
2221 return 0;
2222}
2223
2224static struct acpi_driver sony_pic_driver = {
2225 .name = SONY_PIC_DRIVER_NAME,
2226 .class = SONY_PIC_CLASS,
2227 .ids = SONY_PIC_HID,
2228 .owner = THIS_MODULE,
2229 .ops = {
2230 .add = sony_pic_add,
2231 .remove = sony_pic_remove,
2232 .suspend = sony_pic_suspend,
2233 .resume = sony_pic_resume,
2234 },
2235};
2236
2237static struct dmi_system_id __initdata sonypi_dmi_table[] = {
2238 {
2239 .ident = "Sony Vaio",
2240 .matches = {
2241 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
2242 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
2243 },
2244 },
2245 {
2246 .ident = "Sony Vaio",
2247 .matches = {
2248 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
2249 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),
2250 },
2251 },
2252 { }
2253};
2254
2255static int __init sony_laptop_init(void)
2256{
2257 int result;
2258
2259 if (!no_spic && dmi_check_system(sonypi_dmi_table)) {
2260 result = acpi_bus_register_driver(&sony_pic_driver);
2261 if (result) {
2262 printk(KERN_ERR DRV_PFX
2263 "Unable to register SPIC driver.");
2264 goto out;
2265 }
2266 }
2267
2268 result = acpi_bus_register_driver(&sony_nc_driver);
2269 if (result) {
2270 printk(KERN_ERR DRV_PFX "Unable to register SNC driver.");
2271 goto out_unregister_pic;
2272 }
2273
2274 return 0;
2275
2276out_unregister_pic:
2277 if (!no_spic)
2278 acpi_bus_unregister_driver(&sony_pic_driver);
2279out:
2280 return result;
556} 2281}
557 2282
558static void __exit sony_acpi_exit(void) 2283static void __exit sony_laptop_exit(void)
559{ 2284{
560 acpi_bus_unregister_driver(&sony_acpi_driver); 2285 acpi_bus_unregister_driver(&sony_nc_driver);
2286 if (!no_spic)
2287 acpi_bus_unregister_driver(&sony_pic_driver);
561} 2288}
562 2289
563module_init(sony_acpi_init); 2290module_init(sony_laptop_init);
564module_exit(sony_acpi_exit); 2291module_exit(sony_laptop_exit);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index c3f9f599f134..a3d46ea37126 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2263,6 +2263,7 @@ config GIANFAR
2263 tristate "Gianfar Ethernet" 2263 tristate "Gianfar Ethernet"
2264 depends on 85xx || 83xx || PPC_86xx 2264 depends on 85xx || 83xx || PPC_86xx
2265 select PHYLIB 2265 select PHYLIB
2266 select CRC32
2266 help 2267 help
2267 This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx, 2268 This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
2268 and MPC86xx family of chips, and the FEC on the 8540. 2269 and MPC86xx family of chips, and the FEC on the 8540.
diff --git a/drivers/net/atl1/atl1_hw.c b/drivers/net/atl1/atl1_hw.c
index 314dbaabb642..69482e0d849b 100644
--- a/drivers/net/atl1/atl1_hw.c
+++ b/drivers/net/atl1/atl1_hw.c
@@ -334,7 +334,6 @@ u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
334 int i; 334 int i;
335 335
336 crc32 = ether_crc_le(6, mc_addr); 336 crc32 = ether_crc_le(6, mc_addr);
337 crc32 = ~crc32;
338 for (i = 0; i < 32; i++) 337 for (i = 0; i < 32; i++)
339 value |= (((crc32 >> i) & 1) << (31 - i)); 338 value |= (((crc32 >> i) & 1) << (31 - i));
340 339
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
index dee3638ad744..8606eac5bec8 100644
--- a/drivers/net/atl1/atl1_main.c
+++ b/drivers/net/atl1/atl1_main.c
@@ -2320,6 +2320,16 @@ static void __devexit atl1_remove(struct pci_dev *pdev)
2320 return; 2320 return;
2321 2321
2322 adapter = netdev_priv(netdev); 2322 adapter = netdev_priv(netdev);
2323
2324 /* Some atl1 boards lack persistent storage for their MAC, and get it
2325 * from the BIOS during POST. If we've been messing with the MAC
2326 * address, we need to save the permanent one.
2327 */
2328 if (memcmp(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN)) {
2329 memcpy(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN);
2330 atl1_set_mac_addr(&adapter->hw);
2331 }
2332
2323 iowrite16(0, adapter->hw.hw_addr + REG_GPHY_ENABLE); 2333 iowrite16(0, adapter->hw.hw_addr + REG_GPHY_ENABLE);
2324 unregister_netdev(netdev); 2334 unregister_netdev(netdev);
2325 pci_iounmap(pdev, adapter->hw.hw_addr); 2335 pci_iounmap(pdev, adapter->hw.hw_addr);
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index aaada572732a..d742bfe24471 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1709,7 +1709,7 @@ static void __b44_set_rx_mode(struct net_device *dev)
1709 bw32(bp, B44_RXCONFIG, val); 1709 bw32(bp, B44_RXCONFIG, val);
1710 } else { 1710 } else {
1711 unsigned char zero[6] = {0, 0, 0, 0, 0, 0}; 1711 unsigned char zero[6] = {0, 0, 0, 0, 0, 0};
1712 int i = 0; 1712 int i = 1;
1713 1713
1714 __b44_set_mac_addr(bp); 1714 __b44_set_mac_addr(bp);
1715 1715
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index c12e5ea61819..e85f5ec48f96 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -54,8 +54,8 @@
54 54
55#define DRV_MODULE_NAME "bnx2" 55#define DRV_MODULE_NAME "bnx2"
56#define PFX DRV_MODULE_NAME ": " 56#define PFX DRV_MODULE_NAME ": "
57#define DRV_MODULE_VERSION "1.5.5" 57#define DRV_MODULE_VERSION "1.5.8"
58#define DRV_MODULE_RELDATE "February 1, 2007" 58#define DRV_MODULE_RELDATE "April 24, 2007"
59 59
60#define RUN_AT(x) (jiffies + (x)) 60#define RUN_AT(x) (jiffies + (x))
61 61
@@ -2033,8 +2033,8 @@ bnx2_has_work(struct bnx2 *bp)
2033 (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)) 2033 (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons))
2034 return 1; 2034 return 1;
2035 2035
2036 if (((sblk->status_attn_bits & STATUS_ATTN_BITS_LINK_STATE) != 0) != 2036 if ((sblk->status_attn_bits & STATUS_ATTN_BITS_LINK_STATE) !=
2037 bp->link_up) 2037 (sblk->status_attn_bits_ack & STATUS_ATTN_BITS_LINK_STATE))
2038 return 1; 2038 return 1;
2039 2039
2040 return 0; 2040 return 0;
@@ -3099,20 +3099,18 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
3099 3099
3100 if ((align_start = (offset32 & 3))) { 3100 if ((align_start = (offset32 & 3))) {
3101 offset32 &= ~3; 3101 offset32 &= ~3;
3102 len32 += (4 - align_start); 3102 len32 += align_start;
3103 if (len32 < 4)
3104 len32 = 4;
3103 if ((rc = bnx2_nvram_read(bp, offset32, start, 4))) 3105 if ((rc = bnx2_nvram_read(bp, offset32, start, 4)))
3104 return rc; 3106 return rc;
3105 } 3107 }
3106 3108
3107 if (len32 & 3) { 3109 if (len32 & 3) {
3108 if ((len32 > 4) || !align_start) { 3110 align_end = 4 - (len32 & 3);
3109 align_end = 4 - (len32 & 3); 3111 len32 += align_end;
3110 len32 += align_end; 3112 if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4, end, 4)))
3111 if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4, 3113 return rc;
3112 end, 4))) {
3113 return rc;
3114 }
3115 }
3116 } 3114 }
3117 3115
3118 if (align_start || align_end) { 3116 if (align_start || align_end) {
@@ -3187,17 +3185,17 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
3187 if ((rc = bnx2_enable_nvram_write(bp)) != 0) 3185 if ((rc = bnx2_enable_nvram_write(bp)) != 0)
3188 goto nvram_write_end; 3186 goto nvram_write_end;
3189 3187
3190 /* Erase the page */
3191 if ((rc = bnx2_nvram_erase_page(bp, page_start)) != 0)
3192 goto nvram_write_end;
3193
3194 /* Re-enable the write again for the actual write */
3195 bnx2_enable_nvram_write(bp);
3196
3197 /* Loop to write back the buffer data from page_start to 3188 /* Loop to write back the buffer data from page_start to
3198 * data_start */ 3189 * data_start */
3199 i = 0; 3190 i = 0;
3200 if (bp->flash_info->buffered == 0) { 3191 if (bp->flash_info->buffered == 0) {
3192 /* Erase the page */
3193 if ((rc = bnx2_nvram_erase_page(bp, page_start)) != 0)
3194 goto nvram_write_end;
3195
3196 /* Re-enable the write again for the actual write */
3197 bnx2_enable_nvram_write(bp);
3198
3201 for (addr = page_start; addr < data_start; 3199 for (addr = page_start; addr < data_start;
3202 addr += 4, i += 4) { 3200 addr += 4, i += 4) {
3203 3201
@@ -3423,6 +3421,9 @@ bnx2_init_chip(struct bnx2 *bp)
3423 val = REG_RD(bp, BNX2_MQ_CONFIG); 3421 val = REG_RD(bp, BNX2_MQ_CONFIG);
3424 val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE; 3422 val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE;
3425 val |= BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256; 3423 val |= BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256;
3424 if (CHIP_ID(bp) == CHIP_ID_5709_A0 || CHIP_ID(bp) == CHIP_ID_5709_A1)
3425 val |= BNX2_MQ_CONFIG_HALT_DIS;
3426
3426 REG_WR(bp, BNX2_MQ_CONFIG, val); 3427 REG_WR(bp, BNX2_MQ_CONFIG, val);
3427 3428
3428 val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE); 3429 val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index ccbdf81c6599..878eee58f12a 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6518,6 +6518,7 @@ struct bnx2 {
6518#define CHIP_ID_5708_B0 0x57081000 6518#define CHIP_ID_5708_B0 0x57081000
6519#define CHIP_ID_5708_B1 0x57081010 6519#define CHIP_ID_5708_B1 0x57081010
6520#define CHIP_ID_5709_A0 0x57090000 6520#define CHIP_ID_5709_A0 0x57090000
6521#define CHIP_ID_5709_A1 0x57090010
6521 6522
6522#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf) 6523#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf)
6523 6524
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 85e5543cfb57..8d1379633698 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -112,8 +112,7 @@ enum {
112}; 112};
113 113
114enum { 114enum {
115 SUPPORTED_OFFLOAD = 1 << 24, 115 SUPPORTED_IRQ = 1 << 24
116 SUPPORTED_IRQ = 1 << 25
117}; 116};
118 117
119enum { /* adapter interrupt-maintained statistics */ 118enum { /* adapter interrupt-maintained statistics */
@@ -358,6 +357,9 @@ enum {
358 MC5_MODE_72_BIT = 2 357 MC5_MODE_72_BIT = 2
359}; 358};
360 359
360/* MC5 min active region size */
361enum { MC5_MIN_TIDS = 16 };
362
361struct vpd_params { 363struct vpd_params {
362 unsigned int cclk; 364 unsigned int cclk;
363 unsigned int mclk; 365 unsigned int mclk;
@@ -402,6 +404,7 @@ struct adapter_params {
402 unsigned int stats_update_period; /* MAC stats accumulation period */ 404 unsigned int stats_update_period; /* MAC stats accumulation period */
403 unsigned int linkpoll_period; /* link poll period in 0.1s */ 405 unsigned int linkpoll_period; /* link poll period in 0.1s */
404 unsigned int rev; /* chip revision */ 406 unsigned int rev; /* chip revision */
407 unsigned int offload;
405}; 408};
406 409
407enum { /* chip revisions */ 410enum { /* chip revisions */
@@ -475,8 +478,11 @@ struct cmac {
475 struct adapter *adapter; 478 struct adapter *adapter;
476 unsigned int offset; 479 unsigned int offset;
477 unsigned int nucast; /* # of address filters for unicast MACs */ 480 unsigned int nucast; /* # of address filters for unicast MACs */
478 unsigned int tcnt; 481 unsigned int tx_tcnt;
479 unsigned int xcnt; 482 unsigned int tx_xcnt;
483 u64 tx_mcnt;
484 unsigned int rx_xcnt;
485 u64 rx_mcnt;
480 unsigned int toggle_cnt; 486 unsigned int toggle_cnt;
481 unsigned int txen; 487 unsigned int txen;
482 struct mac_stats stats; 488 struct mac_stats stats;
@@ -602,7 +608,7 @@ static inline int is_10G(const struct adapter *adap)
602 608
603static inline int is_offload(const struct adapter *adap) 609static inline int is_offload(const struct adapter *adap)
604{ 610{
605 return adapter_info(adap)->caps & SUPPORTED_OFFLOAD; 611 return adap->params.offload;
606} 612}
607 613
608static inline unsigned int core_ticks_per_usec(const struct adapter *adap) 614static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
diff --git a/drivers/net/cxgb3/cxgb3_defs.h b/drivers/net/cxgb3/cxgb3_defs.h
index e14862b43d17..483a594210a7 100644
--- a/drivers/net/cxgb3/cxgb3_defs.h
+++ b/drivers/net/cxgb3/cxgb3_defs.h
@@ -67,7 +67,10 @@ static inline union listen_entry *stid2entry(const struct tid_info *t,
67static inline struct t3c_tid_entry *lookup_tid(const struct tid_info *t, 67static inline struct t3c_tid_entry *lookup_tid(const struct tid_info *t,
68 unsigned int tid) 68 unsigned int tid)
69{ 69{
70 return tid < t->ntids ? &(t->tid_tab[tid]) : NULL; 70 struct t3c_tid_entry *t3c_tid = tid < t->ntids ?
71 &(t->tid_tab[tid]) : NULL;
72
73 return (t3c_tid && t3c_tid->client) ? t3c_tid : NULL;
71} 74}
72 75
73/* 76/*
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index d55383610559..67b4b219d927 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -185,16 +185,24 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat,
185 int speed, int duplex, int pause) 185 int speed, int duplex, int pause)
186{ 186{
187 struct net_device *dev = adapter->port[port_id]; 187 struct net_device *dev = adapter->port[port_id];
188 struct port_info *pi = netdev_priv(dev);
189 struct cmac *mac = &pi->mac;
188 190
189 /* Skip changes from disabled ports. */ 191 /* Skip changes from disabled ports. */
190 if (!netif_running(dev)) 192 if (!netif_running(dev))
191 return; 193 return;
192 194
193 if (link_stat != netif_carrier_ok(dev)) { 195 if (link_stat != netif_carrier_ok(dev)) {
194 if (link_stat) 196 if (link_stat) {
197 t3_mac_enable(mac, MAC_DIRECTION_RX);
195 netif_carrier_on(dev); 198 netif_carrier_on(dev);
196 else 199 } else {
197 netif_carrier_off(dev); 200 netif_carrier_off(dev);
201 pi->phy.ops->power_down(&pi->phy, 1);
202 t3_mac_disable(mac, MAC_DIRECTION_RX);
203 t3_link_start(&pi->phy, mac, &pi->link_config);
204 }
205
198 link_report(dev); 206 link_report(dev);
199 } 207 }
200} 208}
@@ -407,7 +415,7 @@ static void quiesce_rx(struct adapter *adap)
407static int setup_sge_qsets(struct adapter *adap) 415static int setup_sge_qsets(struct adapter *adap)
408{ 416{
409 int i, j, err, irq_idx = 0, qset_idx = 0, dummy_dev_idx = 0; 417 int i, j, err, irq_idx = 0, qset_idx = 0, dummy_dev_idx = 0;
410 unsigned int ntxq = is_offload(adap) ? SGE_TXQ_PER_SET : 1; 418 unsigned int ntxq = SGE_TXQ_PER_SET;
411 419
412 if (adap->params.rev > 0 && !(adap->flags & USING_MSI)) 420 if (adap->params.rev > 0 && !(adap->flags & USING_MSI))
413 irq_idx = -1; 421 irq_idx = -1;
@@ -485,12 +493,14 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \
485static ssize_t set_nfilters(struct net_device *dev, unsigned int val) 493static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
486{ 494{
487 struct adapter *adap = dev->priv; 495 struct adapter *adap = dev->priv;
496 int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0;
488 497
489 if (adap->flags & FULL_INIT_DONE) 498 if (adap->flags & FULL_INIT_DONE)
490 return -EBUSY; 499 return -EBUSY;
491 if (val && adap->params.rev == 0) 500 if (val && adap->params.rev == 0)
492 return -EINVAL; 501 return -EINVAL;
493 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers) 502 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers -
503 min_tids)
494 return -EINVAL; 504 return -EINVAL;
495 adap->params.mc5.nfilters = val; 505 adap->params.mc5.nfilters = val;
496 return 0; 506 return 0;
@@ -508,7 +518,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val)
508 518
509 if (adap->flags & FULL_INIT_DONE) 519 if (adap->flags & FULL_INIT_DONE)
510 return -EBUSY; 520 return -EBUSY;
511 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters) 521 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters -
522 MC5_MIN_TIDS)
512 return -EINVAL; 523 return -EINVAL;
513 adap->params.mc5.nservers = val; 524 adap->params.mc5.nservers = val;
514 return 0; 525 return 0;
@@ -708,7 +719,7 @@ static void bind_qsets(struct adapter *adap)
708 } 719 }
709} 720}
710 721
711#define FW_FNAME "t3fw-%d.%d.bin" 722#define FW_FNAME "t3fw-%d.%d.%d.bin"
712 723
713static int upgrade_fw(struct adapter *adap) 724static int upgrade_fw(struct adapter *adap)
714{ 725{
@@ -718,7 +729,7 @@ static int upgrade_fw(struct adapter *adap)
718 struct device *dev = &adap->pdev->dev; 729 struct device *dev = &adap->pdev->dev;
719 730
720 snprintf(buf, sizeof(buf), FW_FNAME, FW_VERSION_MAJOR, 731 snprintf(buf, sizeof(buf), FW_FNAME, FW_VERSION_MAJOR,
721 FW_VERSION_MINOR); 732 FW_VERSION_MINOR, FW_VERSION_MICRO);
722 ret = request_firmware(&fw, buf, dev); 733 ret = request_firmware(&fw, buf, dev);
723 if (ret < 0) { 734 if (ret < 0) {
724 dev_err(dev, "could not upgrade firmware: unable to load %s\n", 735 dev_err(dev, "could not upgrade firmware: unable to load %s\n",
@@ -759,6 +770,8 @@ static int cxgb_up(struct adapter *adap)
759 if (err) 770 if (err)
760 goto out; 771 goto out;
761 772
773 t3_write_reg(adap, A_ULPRX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12));
774
762 err = setup_sge_qsets(adap); 775 err = setup_sge_qsets(adap);
763 if (err) 776 if (err)
764 goto out; 777 goto out;
@@ -919,7 +932,7 @@ static int cxgb_open(struct net_device *dev)
919 return err; 932 return err;
920 933
921 set_bit(pi->port_id, &adapter->open_device_map); 934 set_bit(pi->port_id, &adapter->open_device_map);
922 if (!ofld_disable) { 935 if (is_offload(adapter) && !ofld_disable) {
923 err = offload_open(dev); 936 err = offload_open(dev);
924 if (err) 937 if (err)
925 printk(KERN_WARNING 938 printk(KERN_WARNING
@@ -2106,7 +2119,9 @@ static void check_t3b2_mac(struct adapter *adapter)
2106{ 2119{
2107 int i; 2120 int i;
2108 2121
2109 rtnl_lock(); /* synchronize with ifdown */ 2122 if (!rtnl_trylock()) /* synchronize with ifdown */
2123 return;
2124
2110 for_each_port(adapter, i) { 2125 for_each_port(adapter, i) {
2111 struct net_device *dev = adapter->port[i]; 2126 struct net_device *dev = adapter->port[i];
2112 struct port_info *p = netdev_priv(dev); 2127 struct port_info *p = netdev_priv(dev);
@@ -2116,7 +2131,7 @@ static void check_t3b2_mac(struct adapter *adapter)
2116 continue; 2131 continue;
2117 2132
2118 status = 0; 2133 status = 0;
2119 if (netif_running(dev)) 2134 if (netif_running(dev) && netif_carrier_ok(dev))
2120 status = t3b2_mac_watchdog_task(&p->mac); 2135 status = t3b2_mac_watchdog_task(&p->mac);
2121 if (status == 1) 2136 if (status == 1)
2122 p->mac.stats.num_toggled++; 2137 p->mac.stats.num_toggled++;
@@ -2267,9 +2282,9 @@ static void __devinit print_port_info(struct adapter *adap,
2267 2282
2268 if (!test_bit(i, &adap->registered_device_map)) 2283 if (!test_bit(i, &adap->registered_device_map))
2269 continue; 2284 continue;
2270 printk(KERN_INFO "%s: %s %s RNIC (rev %d) %s%s\n", 2285 printk(KERN_INFO "%s: %s %s %sNIC (rev %d) %s%s\n",
2271 dev->name, ai->desc, pi->port_type->desc, 2286 dev->name, ai->desc, pi->port_type->desc,
2272 adap->params.rev, buf, 2287 is_offload(adap) ? "R" : "", adap->params.rev, buf,
2273 (adap->flags & USING_MSIX) ? " MSI-X" : 2288 (adap->flags & USING_MSIX) ? " MSI-X" :
2274 (adap->flags & USING_MSI) ? " MSI" : ""); 2289 (adap->flags & USING_MSI) ? " MSI" : "");
2275 if (adap->name == dev->name && adap->params.vpd.mclk) 2290 if (adap->name == dev->name && adap->params.vpd.mclk)
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index f6ed033efb56..199e5066acf3 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -508,6 +508,7 @@ void cxgb3_queue_tid_release(struct t3cdev *tdev, unsigned int tid)
508 508
509 spin_lock_bh(&td->tid_release_lock); 509 spin_lock_bh(&td->tid_release_lock);
510 p->ctx = (void *)td->tid_release_list; 510 p->ctx = (void *)td->tid_release_list;
511 p->client = NULL;
511 td->tid_release_list = p; 512 td->tid_release_list = p;
512 if (!p->ctx) 513 if (!p->ctx)
513 schedule_work(&td->tid_release_task); 514 schedule_work(&td->tid_release_task);
@@ -553,7 +554,9 @@ int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client,
553 struct tid_info *t = &(T3C_DATA(tdev))->tid_maps; 554 struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
554 555
555 spin_lock_bh(&t->atid_lock); 556 spin_lock_bh(&t->atid_lock);
556 if (t->afree) { 557 if (t->afree &&
558 t->atids_in_use + atomic_read(&t->tids_in_use) + MC5_MIN_TIDS <=
559 t->ntids) {
557 union active_open_entry *p = t->afree; 560 union active_open_entry *p = t->afree;
558 561
559 atid = (p - t->atid_tab) + t->atid_base; 562 atid = (p - t->atid_tab) + t->atid_base;
@@ -621,7 +624,8 @@ static int do_act_open_rpl(struct t3cdev *dev, struct sk_buff *skb)
621 struct t3c_tid_entry *t3c_tid; 624 struct t3c_tid_entry *t3c_tid;
622 625
623 t3c_tid = lookup_atid(&(T3C_DATA(dev))->tid_maps, atid); 626 t3c_tid = lookup_atid(&(T3C_DATA(dev))->tid_maps, atid);
624 if (t3c_tid->ctx && t3c_tid->client && t3c_tid->client->handlers && 627 if (t3c_tid && t3c_tid->ctx && t3c_tid->client &&
628 t3c_tid->client->handlers &&
625 t3c_tid->client->handlers[CPL_ACT_OPEN_RPL]) { 629 t3c_tid->client->handlers[CPL_ACT_OPEN_RPL]) {
626 return t3c_tid->client->handlers[CPL_ACT_OPEN_RPL] (dev, skb, 630 return t3c_tid->client->handlers[CPL_ACT_OPEN_RPL] (dev, skb,
627 t3c_tid-> 631 t3c_tid->
@@ -640,7 +644,7 @@ static int do_stid_rpl(struct t3cdev *dev, struct sk_buff *skb)
640 struct t3c_tid_entry *t3c_tid; 644 struct t3c_tid_entry *t3c_tid;
641 645
642 t3c_tid = lookup_stid(&(T3C_DATA(dev))->tid_maps, stid); 646 t3c_tid = lookup_stid(&(T3C_DATA(dev))->tid_maps, stid);
643 if (t3c_tid->ctx && t3c_tid->client->handlers && 647 if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers &&
644 t3c_tid->client->handlers[p->opcode]) { 648 t3c_tid->client->handlers[p->opcode]) {
645 return t3c_tid->client->handlers[p->opcode] (dev, skb, 649 return t3c_tid->client->handlers[p->opcode] (dev, skb,
646 t3c_tid->ctx); 650 t3c_tid->ctx);
@@ -658,7 +662,7 @@ static int do_hwtid_rpl(struct t3cdev *dev, struct sk_buff *skb)
658 struct t3c_tid_entry *t3c_tid; 662 struct t3c_tid_entry *t3c_tid;
659 663
660 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid); 664 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid);
661 if (t3c_tid->ctx && t3c_tid->client->handlers && 665 if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers &&
662 t3c_tid->client->handlers[p->opcode]) { 666 t3c_tid->client->handlers[p->opcode]) {
663 return t3c_tid->client->handlers[p->opcode] 667 return t3c_tid->client->handlers[p->opcode]
664 (dev, skb, t3c_tid->ctx); 668 (dev, skb, t3c_tid->ctx);
@@ -687,6 +691,28 @@ static int do_cr(struct t3cdev *dev, struct sk_buff *skb)
687 } 691 }
688} 692}
689 693
694/*
695 * Returns an sk_buff for a reply CPL message of size len. If the input
696 * sk_buff has no other users it is trimmed and reused, otherwise a new buffer
697 * is allocated. The input skb must be of size at least len. Note that this
698 * operation does not destroy the original skb data even if it decides to reuse
699 * the buffer.
700 */
701static struct sk_buff *cxgb3_get_cpl_reply_skb(struct sk_buff *skb, size_t len,
702 int gfp)
703{
704 if (likely(!skb_cloned(skb))) {
705 BUG_ON(skb->len < len);
706 __skb_trim(skb, len);
707 skb_get(skb);
708 } else {
709 skb = alloc_skb(len, gfp);
710 if (skb)
711 __skb_put(skb, len);
712 }
713 return skb;
714}
715
690static int do_abort_req_rss(struct t3cdev *dev, struct sk_buff *skb) 716static int do_abort_req_rss(struct t3cdev *dev, struct sk_buff *skb)
691{ 717{
692 union opcode_tid *p = cplhdr(skb); 718 union opcode_tid *p = cplhdr(skb);
@@ -694,30 +720,39 @@ static int do_abort_req_rss(struct t3cdev *dev, struct sk_buff *skb)
694 struct t3c_tid_entry *t3c_tid; 720 struct t3c_tid_entry *t3c_tid;
695 721
696 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid); 722 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid);
697 if (t3c_tid->ctx && t3c_tid->client->handlers && 723 if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers &&
698 t3c_tid->client->handlers[p->opcode]) { 724 t3c_tid->client->handlers[p->opcode]) {
699 return t3c_tid->client->handlers[p->opcode] 725 return t3c_tid->client->handlers[p->opcode]
700 (dev, skb, t3c_tid->ctx); 726 (dev, skb, t3c_tid->ctx);
701 } else { 727 } else {
702 struct cpl_abort_req_rss *req = cplhdr(skb); 728 struct cpl_abort_req_rss *req = cplhdr(skb);
703 struct cpl_abort_rpl *rpl; 729 struct cpl_abort_rpl *rpl;
730 struct sk_buff *reply_skb;
731 unsigned int tid = GET_TID(req);
732 u8 cmd = req->status;
733
734 if (req->status == CPL_ERR_RTX_NEG_ADVICE ||
735 req->status == CPL_ERR_PERSIST_NEG_ADVICE)
736 goto out;
704 737
705 struct sk_buff *skb = 738 reply_skb = cxgb3_get_cpl_reply_skb(skb,
706 alloc_skb(sizeof(struct cpl_abort_rpl), GFP_ATOMIC); 739 sizeof(struct
707 if (!skb) { 740 cpl_abort_rpl),
741 GFP_ATOMIC);
742
743 if (!reply_skb) {
708 printk("do_abort_req_rss: couldn't get skb!\n"); 744 printk("do_abort_req_rss: couldn't get skb!\n");
709 goto out; 745 goto out;
710 } 746 }
711 skb->priority = CPL_PRIORITY_DATA; 747 reply_skb->priority = CPL_PRIORITY_DATA;
712 __skb_put(skb, sizeof(struct cpl_abort_rpl)); 748 __skb_put(reply_skb, sizeof(struct cpl_abort_rpl));
713 rpl = cplhdr(skb); 749 rpl = cplhdr(reply_skb);
714 rpl->wr.wr_hi = 750 rpl->wr.wr_hi =
715 htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_RPL)); 751 htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_RPL));
716 rpl->wr.wr_lo = htonl(V_WR_TID(GET_TID(req))); 752 rpl->wr.wr_lo = htonl(V_WR_TID(tid));
717 OPCODE_TID(rpl) = 753 OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, tid));
718 htonl(MK_OPCODE_TID(CPL_ABORT_RPL, GET_TID(req))); 754 rpl->cmd = cmd;
719 rpl->cmd = req->status; 755 cxgb3_ofld_send(dev, reply_skb);
720 cxgb3_ofld_send(dev, skb);
721out: 756out:
722 return CPL_RET_BUF_DONE; 757 return CPL_RET_BUF_DONE;
723 } 758 }
@@ -730,7 +765,7 @@ static int do_act_establish(struct t3cdev *dev, struct sk_buff *skb)
730 struct t3c_tid_entry *t3c_tid; 765 struct t3c_tid_entry *t3c_tid;
731 766
732 t3c_tid = lookup_atid(&(T3C_DATA(dev))->tid_maps, atid); 767 t3c_tid = lookup_atid(&(T3C_DATA(dev))->tid_maps, atid);
733 if (t3c_tid->ctx && t3c_tid->client->handlers && 768 if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers &&
734 t3c_tid->client->handlers[CPL_ACT_ESTABLISH]) { 769 t3c_tid->client->handlers[CPL_ACT_ESTABLISH]) {
735 return t3c_tid->client->handlers[CPL_ACT_ESTABLISH] 770 return t3c_tid->client->handlers[CPL_ACT_ESTABLISH]
736 (dev, skb, t3c_tid->ctx); 771 (dev, skb, t3c_tid->ctx);
@@ -741,17 +776,6 @@ static int do_act_establish(struct t3cdev *dev, struct sk_buff *skb)
741 } 776 }
742} 777}
743 778
744static int do_set_tcb_rpl(struct t3cdev *dev, struct sk_buff *skb)
745{
746 struct cpl_set_tcb_rpl *rpl = cplhdr(skb);
747
748 if (rpl->status != CPL_ERR_NONE)
749 printk(KERN_ERR
750 "Unexpected SET_TCB_RPL status %u for tid %u\n",
751 rpl->status, GET_TID(rpl));
752 return CPL_RET_BUF_DONE;
753}
754
755static int do_trace(struct t3cdev *dev, struct sk_buff *skb) 779static int do_trace(struct t3cdev *dev, struct sk_buff *skb)
756{ 780{
757 struct cpl_trace_pkt *p = cplhdr(skb); 781 struct cpl_trace_pkt *p = cplhdr(skb);
@@ -771,7 +795,7 @@ static int do_term(struct t3cdev *dev, struct sk_buff *skb)
771 struct t3c_tid_entry *t3c_tid; 795 struct t3c_tid_entry *t3c_tid;
772 796
773 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid); 797 t3c_tid = lookup_tid(&(T3C_DATA(dev))->tid_maps, hwtid);
774 if (t3c_tid->ctx && t3c_tid->client->handlers && 798 if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers &&
775 t3c_tid->client->handlers[opcode]) { 799 t3c_tid->client->handlers[opcode]) {
776 return t3c_tid->client->handlers[opcode] (dev, skb, 800 return t3c_tid->client->handlers[opcode] (dev, skb,
777 t3c_tid->ctx); 801 t3c_tid->ctx);
@@ -970,7 +994,7 @@ void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
970 for (tid = 0; tid < ti->ntids; tid++) { 994 for (tid = 0; tid < ti->ntids; tid++) {
971 te = lookup_tid(ti, tid); 995 te = lookup_tid(ti, tid);
972 BUG_ON(!te); 996 BUG_ON(!te);
973 if (te->ctx && te->client && te->client->redirect) { 997 if (te && te->ctx && te->client && te->client->redirect) {
974 update_tcb = te->client->redirect(te->ctx, old, new, e); 998 update_tcb = te->client->redirect(te->ctx, old, new, e);
975 if (update_tcb) { 999 if (update_tcb) {
976 l2t_hold(L2DATA(tdev), e); 1000 l2t_hold(L2DATA(tdev), e);
@@ -1213,7 +1237,8 @@ void __init cxgb3_offload_init(void)
1213 t3_register_cpl_handler(CPL_CLOSE_CON_RPL, do_hwtid_rpl); 1237 t3_register_cpl_handler(CPL_CLOSE_CON_RPL, do_hwtid_rpl);
1214 t3_register_cpl_handler(CPL_ABORT_REQ_RSS, do_abort_req_rss); 1238 t3_register_cpl_handler(CPL_ABORT_REQ_RSS, do_abort_req_rss);
1215 t3_register_cpl_handler(CPL_ACT_ESTABLISH, do_act_establish); 1239 t3_register_cpl_handler(CPL_ACT_ESTABLISH, do_act_establish);
1216 t3_register_cpl_handler(CPL_SET_TCB_RPL, do_set_tcb_rpl); 1240 t3_register_cpl_handler(CPL_SET_TCB_RPL, do_hwtid_rpl);
1241 t3_register_cpl_handler(CPL_GET_TCB_RPL, do_hwtid_rpl);
1217 t3_register_cpl_handler(CPL_RDMA_TERMINATE, do_term); 1242 t3_register_cpl_handler(CPL_RDMA_TERMINATE, do_term);
1218 t3_register_cpl_handler(CPL_RDMA_EC_STATUS, do_hwtid_rpl); 1243 t3_register_cpl_handler(CPL_RDMA_EC_STATUS, do_hwtid_rpl);
1219 t3_register_cpl_handler(CPL_TRACE_PKT, do_trace); 1244 t3_register_cpl_handler(CPL_TRACE_PKT, do_trace);
diff --git a/drivers/net/cxgb3/mc5.c b/drivers/net/cxgb3/mc5.c
index 644d62ea86a6..84c1ffa8e2d3 100644
--- a/drivers/net/cxgb3/mc5.c
+++ b/drivers/net/cxgb3/mc5.c
@@ -328,6 +328,9 @@ int t3_mc5_init(struct mc5 *mc5, unsigned int nservers, unsigned int nfilters,
328 unsigned int tcam_size = mc5->tcam_size; 328 unsigned int tcam_size = mc5->tcam_size;
329 struct adapter *adap = mc5->adapter; 329 struct adapter *adap = mc5->adapter;
330 330
331 if (!tcam_size)
332 return 0;
333
331 if (nroutes > MAX_ROUTES || nroutes + nservers + nfilters > tcam_size) 334 if (nroutes > MAX_ROUTES || nroutes + nservers + nfilters > tcam_size)
332 return -EINVAL; 335 return -EINVAL;
333 336
diff --git a/drivers/net/cxgb3/regs.h b/drivers/net/cxgb3/regs.h
index b38629a244d0..e5a553410e24 100644
--- a/drivers/net/cxgb3/regs.h
+++ b/drivers/net/cxgb3/regs.h
@@ -1234,9 +1234,15 @@
1234 1234
1235#define A_ULPRX_ISCSI_TAGMASK 0x514 1235#define A_ULPRX_ISCSI_TAGMASK 0x514
1236 1236
1237#define S_HPZ0 0
1238#define M_HPZ0 0xf
1239#define V_HPZ0(x) ((x) << S_HPZ0)
1240#define G_HPZ0(x) (((x) >> S_HPZ0) & M_HPZ0)
1241
1237#define A_ULPRX_TDDP_LLIMIT 0x51c 1242#define A_ULPRX_TDDP_LLIMIT 0x51c
1238 1243
1239#define A_ULPRX_TDDP_ULIMIT 0x520 1244#define A_ULPRX_TDDP_ULIMIT 0x520
1245#define A_ULPRX_TDDP_PSZ 0x528
1240 1246
1241#define A_ULPRX_STAG_LLIMIT 0x52c 1247#define A_ULPRX_STAG_LLIMIT 0x52c
1242 1248
@@ -1940,6 +1946,10 @@
1940 1946
1941#define V_TXFIFOTHRESH(x) ((x) << S_TXFIFOTHRESH) 1947#define V_TXFIFOTHRESH(x) ((x) << S_TXFIFOTHRESH)
1942 1948
1949#define S_ENDROPPKT 21
1950#define V_ENDROPPKT(x) ((x) << S_ENDROPPKT)
1951#define F_ENDROPPKT V_ENDROPPKT(1U)
1952
1943#define A_XGM_SERDES_CTRL 0x890 1953#define A_XGM_SERDES_CTRL 0x890
1944#define A_XGM_SERDES_CTRL0 0x8e0 1954#define A_XGM_SERDES_CTRL0 0x8e0
1945 1955
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index c23783432e51..027ab2c3825c 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -2631,7 +2631,7 @@ int t3_sge_alloc_qset(struct adapter *adapter, unsigned int id, int nports,
2631 q->txq[TXQ_ETH].stop_thres = nports * 2631 q->txq[TXQ_ETH].stop_thres = nports *
2632 flits_to_desc(sgl_len(MAX_SKB_FRAGS + 1) + 3); 2632 flits_to_desc(sgl_len(MAX_SKB_FRAGS + 1) + 3);
2633 2633
2634 if (ntxq == 1) { 2634 if (!is_offload(adapter)) {
2635#ifdef USE_RX_PAGE 2635#ifdef USE_RX_PAGE
2636 q->fl[0].buf_size = RX_PAGE_SIZE; 2636 q->fl[0].buf_size = RX_PAGE_SIZE;
2637#else 2637#else
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 791ed6dc1943..fb485d0a43d8 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -438,23 +438,23 @@ static const struct adapter_info t3_adap_info[] = {
438 {2, 0, 0, 0, 438 {2, 0, 0, 0,
439 F_GPIO2_OEN | F_GPIO4_OEN | 439 F_GPIO2_OEN | F_GPIO4_OEN |
440 F_GPIO2_OUT_VAL | F_GPIO4_OUT_VAL, F_GPIO3 | F_GPIO5, 440 F_GPIO2_OUT_VAL | F_GPIO4_OUT_VAL, F_GPIO3 | F_GPIO5,
441 SUPPORTED_OFFLOAD, 441 0,
442 &mi1_mdio_ops, "Chelsio PE9000"}, 442 &mi1_mdio_ops, "Chelsio PE9000"},
443 {2, 0, 0, 0, 443 {2, 0, 0, 0,
444 F_GPIO2_OEN | F_GPIO4_OEN | 444 F_GPIO2_OEN | F_GPIO4_OEN |
445 F_GPIO2_OUT_VAL | F_GPIO4_OUT_VAL, F_GPIO3 | F_GPIO5, 445 F_GPIO2_OUT_VAL | F_GPIO4_OUT_VAL, F_GPIO3 | F_GPIO5,
446 SUPPORTED_OFFLOAD, 446 0,
447 &mi1_mdio_ops, "Chelsio T302"}, 447 &mi1_mdio_ops, "Chelsio T302"},
448 {1, 0, 0, 0, 448 {1, 0, 0, 0,
449 F_GPIO1_OEN | F_GPIO6_OEN | F_GPIO7_OEN | F_GPIO10_OEN | 449 F_GPIO1_OEN | F_GPIO6_OEN | F_GPIO7_OEN | F_GPIO10_OEN |
450 F_GPIO1_OUT_VAL | F_GPIO6_OUT_VAL | F_GPIO10_OUT_VAL, 0, 450 F_GPIO1_OUT_VAL | F_GPIO6_OUT_VAL | F_GPIO10_OUT_VAL, 0,
451 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_OFFLOAD, 451 SUPPORTED_10000baseT_Full | SUPPORTED_AUI,
452 &mi1_mdio_ext_ops, "Chelsio T310"}, 452 &mi1_mdio_ext_ops, "Chelsio T310"},
453 {2, 0, 0, 0, 453 {2, 0, 0, 0,
454 F_GPIO1_OEN | F_GPIO2_OEN | F_GPIO4_OEN | F_GPIO5_OEN | F_GPIO6_OEN | 454 F_GPIO1_OEN | F_GPIO2_OEN | F_GPIO4_OEN | F_GPIO5_OEN | F_GPIO6_OEN |
455 F_GPIO7_OEN | F_GPIO10_OEN | F_GPIO11_OEN | F_GPIO1_OUT_VAL | 455 F_GPIO7_OEN | F_GPIO10_OEN | F_GPIO11_OEN | F_GPIO1_OUT_VAL |
456 F_GPIO5_OUT_VAL | F_GPIO6_OUT_VAL | F_GPIO10_OUT_VAL, 0, 456 F_GPIO5_OUT_VAL | F_GPIO6_OUT_VAL | F_GPIO10_OUT_VAL, 0,
457 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_OFFLOAD, 457 SUPPORTED_10000baseT_Full | SUPPORTED_AUI,
458 &mi1_mdio_ext_ops, "Chelsio T320"}, 458 &mi1_mdio_ext_ops, "Chelsio T320"},
459}; 459};
460 460
@@ -1523,19 +1523,25 @@ static int mac_intr_handler(struct adapter *adap, unsigned int idx)
1523 */ 1523 */
1524int t3_phy_intr_handler(struct adapter *adapter) 1524int t3_phy_intr_handler(struct adapter *adapter)
1525{ 1525{
1526 static const int intr_gpio_bits[] = { 8, 0x20 }; 1526 u32 mask, gpi = adapter_info(adapter)->gpio_intr;
1527
1528 u32 i, cause = t3_read_reg(adapter, A_T3DBG_INT_CAUSE); 1527 u32 i, cause = t3_read_reg(adapter, A_T3DBG_INT_CAUSE);
1529 1528
1530 for_each_port(adapter, i) { 1529 for_each_port(adapter, i) {
1531 if (cause & intr_gpio_bits[i]) { 1530 struct port_info *p = adap2pinfo(adapter, i);
1532 struct cphy *phy = &adap2pinfo(adapter, i)->phy; 1531
1533 int phy_cause = phy->ops->intr_handler(phy); 1532 mask = gpi - (gpi & (gpi - 1));
1533 gpi -= mask;
1534
1535 if (!(p->port_type->caps & SUPPORTED_IRQ))
1536 continue;
1537
1538 if (cause & mask) {
1539 int phy_cause = p->phy.ops->intr_handler(&p->phy);
1534 1540
1535 if (phy_cause & cphy_cause_link_change) 1541 if (phy_cause & cphy_cause_link_change)
1536 t3_link_changed(adapter, i); 1542 t3_link_changed(adapter, i);
1537 if (phy_cause & cphy_cause_fifo_error) 1543 if (phy_cause & cphy_cause_fifo_error)
1538 phy->fifo_errors++; 1544 p->phy.fifo_errors++;
1539 } 1545 }
1540 } 1546 }
1541 1547
@@ -2900,6 +2906,9 @@ static int mc7_init(struct mc7 *mc7, unsigned int mc7_clock, int mem_type)
2900 struct adapter *adapter = mc7->adapter; 2906 struct adapter *adapter = mc7->adapter;
2901 const struct mc7_timing_params *p = &mc7_timings[mem_type]; 2907 const struct mc7_timing_params *p = &mc7_timings[mem_type];
2902 2908
2909 if (!mc7->size)
2910 return 0;
2911
2903 val = t3_read_reg(adapter, mc7->offset + A_MC7_CFG); 2912 val = t3_read_reg(adapter, mc7->offset + A_MC7_CFG);
2904 slow = val & F_SLOW; 2913 slow = val & F_SLOW;
2905 width = G_WIDTH(val); 2914 width = G_WIDTH(val);
@@ -3100,8 +3109,10 @@ int t3_init_hw(struct adapter *adapter, u32 fw_params)
3100 do { /* wait for uP to initialize */ 3109 do { /* wait for uP to initialize */
3101 msleep(20); 3110 msleep(20);
3102 } while (t3_read_reg(adapter, A_CIM_HOST_ACC_DATA) && --attempts); 3111 } while (t3_read_reg(adapter, A_CIM_HOST_ACC_DATA) && --attempts);
3103 if (!attempts) 3112 if (!attempts) {
3113 CH_ERR(adapter, "uP initialization timed out\n");
3104 goto out_err; 3114 goto out_err;
3115 }
3105 3116
3106 err = 0; 3117 err = 0;
3107out_err: 3118out_err:
@@ -3201,7 +3212,7 @@ static void __devinit mc7_prep(struct adapter *adapter, struct mc7 *mc7,
3201 mc7->name = name; 3212 mc7->name = name;
3202 mc7->offset = base_addr - MC7_PMRX_BASE_ADDR; 3213 mc7->offset = base_addr - MC7_PMRX_BASE_ADDR;
3203 cfg = t3_read_reg(adapter, mc7->offset + A_MC7_CFG); 3214 cfg = t3_read_reg(adapter, mc7->offset + A_MC7_CFG);
3204 mc7->size = mc7_calc_size(cfg); 3215 mc7->size = mc7->size = G_DEN(cfg) == M_DEN ? 0 : mc7_calc_size(cfg);
3205 mc7->width = G_WIDTH(cfg); 3216 mc7->width = G_WIDTH(cfg);
3206} 3217}
3207 3218
@@ -3228,6 +3239,7 @@ void early_hw_init(struct adapter *adapter, const struct adapter_info *ai)
3228 V_I2C_CLKDIV(adapter->params.vpd.cclk / 80 - 1)); 3239 V_I2C_CLKDIV(adapter->params.vpd.cclk / 80 - 1));
3229 t3_write_reg(adapter, A_T3DBG_GPIO_EN, 3240 t3_write_reg(adapter, A_T3DBG_GPIO_EN,
3230 ai->gpio_out | F_GPIO0_OEN | F_GPIO0_OUT_VAL); 3241 ai->gpio_out | F_GPIO0_OEN | F_GPIO0_OUT_VAL);
3242 t3_write_reg(adapter, A_MC5_DB_SERVER_INDEX, 0);
3231 3243
3232 if (adapter->params.rev == 0 || !uses_xaui(adapter)) 3244 if (adapter->params.rev == 0 || !uses_xaui(adapter))
3233 val |= F_ENRGMII; 3245 val |= F_ENRGMII;
@@ -3326,7 +3338,13 @@ int __devinit t3_prep_adapter(struct adapter *adapter,
3326 p->tx_num_pgs = pm_num_pages(p->chan_tx_size, p->tx_pg_size); 3338 p->tx_num_pgs = pm_num_pages(p->chan_tx_size, p->tx_pg_size);
3327 p->ntimer_qs = p->cm_size >= (128 << 20) || 3339 p->ntimer_qs = p->cm_size >= (128 << 20) ||
3328 adapter->params.rev > 0 ? 12 : 6; 3340 adapter->params.rev > 0 ? 12 : 6;
3341 }
3342
3343 adapter->params.offload = t3_mc7_size(&adapter->pmrx) &&
3344 t3_mc7_size(&adapter->pmtx) &&
3345 t3_mc7_size(&adapter->cm);
3329 3346
3347 if (is_offload(adapter)) {
3330 adapter->params.mc5.nservers = DEFAULT_NSERVERS; 3348 adapter->params.mc5.nservers = DEFAULT_NSERVERS;
3331 adapter->params.mc5.nfilters = adapter->params.rev > 0 ? 3349 adapter->params.mc5.nfilters = adapter->params.rev > 0 ?
3332 DEFAULT_NFILTERS : 0; 3350 DEFAULT_NFILTERS : 0;
diff --git a/drivers/net/cxgb3/version.h b/drivers/net/cxgb3/version.h
index 82278f850259..042e27e291cd 100644
--- a/drivers/net/cxgb3/version.h
+++ b/drivers/net/cxgb3/version.h
@@ -36,6 +36,9 @@
36#define DRV_NAME "cxgb3" 36#define DRV_NAME "cxgb3"
37/* Driver version */ 37/* Driver version */
38#define DRV_VERSION "1.0-ko" 38#define DRV_VERSION "1.0-ko"
39
40/* Firmware version */
39#define FW_VERSION_MAJOR 3 41#define FW_VERSION_MAJOR 3
40#define FW_VERSION_MINOR 2 42#define FW_VERSION_MINOR 3
43#define FW_VERSION_MICRO 0
41#endif /* __CHELSIO_VERSION_H */ 44#endif /* __CHELSIO_VERSION_H */
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index 2b42c13ba8e0..a506792f9575 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -367,7 +367,8 @@ int t3_mac_enable(struct cmac *mac, int which)
367 int idx = macidx(mac); 367 int idx = macidx(mac);
368 struct adapter *adap = mac->adapter; 368 struct adapter *adap = mac->adapter;
369 unsigned int oft = mac->offset; 369 unsigned int oft = mac->offset;
370 370 struct mac_stats *s = &mac->stats;
371
371 if (which & MAC_DIRECTION_TX) { 372 if (which & MAC_DIRECTION_TX) {
372 t3_write_reg(adap, A_XGM_TX_CTRL + oft, F_TXEN); 373 t3_write_reg(adap, A_XGM_TX_CTRL + oft, F_TXEN);
373 t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CFG_CH0 + idx); 374 t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CFG_CH0 + idx);
@@ -376,10 +377,16 @@ int t3_mac_enable(struct cmac *mac, int which)
376 t3_set_reg_field(adap, A_TP_PIO_DATA, 1 << idx, 1 << idx); 377 t3_set_reg_field(adap, A_TP_PIO_DATA, 1 << idx, 1 << idx);
377 378
378 t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CNT_CH0 + idx); 379 t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CNT_CH0 + idx);
379 mac->tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap, 380 mac->tx_mcnt = s->tx_frames;
380 A_TP_PIO_DATA))); 381 mac->tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
381 mac->xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, 382 A_TP_PIO_DATA)));
382 A_XGM_TX_SPI4_SOP_EOP_CNT))); 383 mac->tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
384 A_XGM_TX_SPI4_SOP_EOP_CNT +
385 oft)));
386 mac->rx_mcnt = s->rx_frames;
387 mac->rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
388 A_XGM_RX_SPI4_SOP_EOP_CNT +
389 oft)));
383 mac->txen = F_TXEN; 390 mac->txen = F_TXEN;
384 mac->toggle_cnt = 0; 391 mac->toggle_cnt = 0;
385 } 392 }
@@ -392,6 +399,7 @@ int t3_mac_disable(struct cmac *mac, int which)
392{ 399{
393 int idx = macidx(mac); 400 int idx = macidx(mac);
394 struct adapter *adap = mac->adapter; 401 struct adapter *adap = mac->adapter;
402 int val;
395 403
396 if (which & MAC_DIRECTION_TX) { 404 if (which & MAC_DIRECTION_TX) {
397 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0); 405 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0);
@@ -401,44 +409,89 @@ int t3_mac_disable(struct cmac *mac, int which)
401 t3_set_reg_field(adap, A_TP_PIO_DATA, 1 << idx, 1 << idx); 409 t3_set_reg_field(adap, A_TP_PIO_DATA, 1 << idx, 1 << idx);
402 mac->txen = 0; 410 mac->txen = 0;
403 } 411 }
404 if (which & MAC_DIRECTION_RX) 412 if (which & MAC_DIRECTION_RX) {
413 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset,
414 F_PCS_RESET_, 0);
415 msleep(100);
405 t3_write_reg(adap, A_XGM_RX_CTRL + mac->offset, 0); 416 t3_write_reg(adap, A_XGM_RX_CTRL + mac->offset, 0);
417 val = F_MAC_RESET_;
418 if (is_10G(adap))
419 val |= F_PCS_RESET_;
420 else if (uses_xaui(adap))
421 val |= F_PCS_RESET_ | F_XG2G_RESET_;
422 else
423 val |= F_RGMII_RESET_ | F_XG2G_RESET_;
424 t3_write_reg(mac->adapter, A_XGM_RESET_CTRL + mac->offset, val);
425 }
406 return 0; 426 return 0;
407} 427}
408 428
409int t3b2_mac_watchdog_task(struct cmac *mac) 429int t3b2_mac_watchdog_task(struct cmac *mac)
410{ 430{
411 struct adapter *adap = mac->adapter; 431 struct adapter *adap = mac->adapter;
412 unsigned int tcnt, xcnt; 432 struct mac_stats *s = &mac->stats;
433 unsigned int tx_tcnt, tx_xcnt;
434 unsigned int tx_mcnt = s->tx_frames;
435 unsigned int rx_mcnt = s->rx_frames;
436 unsigned int rx_xcnt;
413 int status; 437 int status;
414 438
415 t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CNT_CH0 + macidx(mac)); 439 if (tx_mcnt == mac->tx_mcnt) {
416 tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap, A_TP_PIO_DATA))); 440 tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
417 xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, 441 A_XGM_TX_SPI4_SOP_EOP_CNT +
418 A_XGM_TX_SPI4_SOP_EOP_CNT + 442 mac->offset)));
419 mac->offset))); 443 if (tx_xcnt == 0) {
420 444 t3_write_reg(adap, A_TP_PIO_ADDR,
421 if (tcnt != mac->tcnt && xcnt == 0 && mac->xcnt == 0) { 445 A_TP_TX_DROP_CNT_CH0 + macidx(mac));
422 if (mac->toggle_cnt > 4) { 446 tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
423 t3b2_mac_reset(mac); 447 A_TP_PIO_DATA)));
448 } else {
424 mac->toggle_cnt = 0; 449 mac->toggle_cnt = 0;
450 return 0;
451 }
452 } else {
453 mac->toggle_cnt = 0;
454 return 0;
455 }
456
457 if (((tx_tcnt != mac->tx_tcnt) &&
458 (tx_xcnt == 0) && (mac->tx_xcnt == 0)) ||
459 ((mac->tx_mcnt == tx_mcnt) &&
460 (tx_xcnt != 0) && (mac->tx_xcnt != 0))) {
461 if (mac->toggle_cnt > 4)
425 status = 2; 462 status = 2;
426 } else { 463 else
427 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0);
428 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset);
429 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset,
430 mac->txen);
431 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset);
432 mac->toggle_cnt++;
433 status = 1; 464 status = 1;
434 }
435 } else { 465 } else {
436 mac->toggle_cnt = 0; 466 mac->toggle_cnt = 0;
437 status = 0; 467 return 0;
438 } 468 }
439 mac->tcnt = tcnt;
440 mac->xcnt = xcnt;
441 469
470 if (rx_mcnt != mac->rx_mcnt)
471 rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
472 A_XGM_RX_SPI4_SOP_EOP_CNT +
473 mac->offset)));
474 else
475 return 0;
476
477 if (mac->rx_mcnt != s->rx_frames && rx_xcnt == 0 && mac->rx_xcnt == 0)
478 status = 2;
479
480 mac->tx_tcnt = tx_tcnt;
481 mac->tx_xcnt = tx_xcnt;
482 mac->tx_mcnt = s->tx_frames;
483 mac->rx_xcnt = rx_xcnt;
484 mac->rx_mcnt = s->rx_frames;
485 if (status == 1) {
486 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0);
487 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */
488 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, mac->txen);
489 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */
490 mac->toggle_cnt++;
491 } else if (status == 2) {
492 t3b2_mac_reset(mac);
493 mac->toggle_cnt = 0;
494 }
442 return status; 495 return status;
443} 496}
444 497
@@ -471,7 +524,6 @@ const struct mac_stats *t3_mac_update_stats(struct cmac *mac)
471 RMON_UPDATE(mac, rx_symbol_errs, RX_SYM_CODE_ERR_FRAMES); 524 RMON_UPDATE(mac, rx_symbol_errs, RX_SYM_CODE_ERR_FRAMES);
472 525
473 RMON_UPDATE(mac, rx_too_long, RX_OVERSIZE_FRAMES); 526 RMON_UPDATE(mac, rx_too_long, RX_OVERSIZE_FRAMES);
474 mac->stats.rx_too_long += RMON_READ(mac, A_XGM_RX_MAX_PKT_SIZE_ERR_CNT);
475 527
476 v = RMON_READ(mac, A_XGM_RX_MAX_PKT_SIZE_ERR_CNT); 528 v = RMON_READ(mac, A_XGM_RX_MAX_PKT_SIZE_ERR_CNT);
477 if (mac->adapter->params.rev == T3_REV_B2) 529 if (mac->adapter->params.rev == T3_REV_B2)
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 5113eef755b9..f3807aaf10aa 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1491,8 +1491,9 @@ static void __init depca_platform_probe (void)
1491 depca_io_ports[i].device = pldev; 1491 depca_io_ports[i].device = pldev;
1492 1492
1493 if (platform_device_add(pldev)) { 1493 if (platform_device_add(pldev)) {
1494 platform_device_put(pldev);
1495 depca_io_ports[i].device = NULL; 1494 depca_io_ports[i].device = NULL;
1495 pldev->dev.platform_data = NULL;
1496 platform_device_put(pldev);
1496 continue; 1497 continue;
1497 } 1498 }
1498 1499
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 1d08e937af82..b28a915bd980 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3796,7 +3796,7 @@ e1000_intr_msi(int irq, void *data)
3796 3796
3797 for (i = 0; i < E1000_MAX_INTR; i++) 3797 for (i = 0; i < E1000_MAX_INTR; i++)
3798 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) & 3798 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3799 e1000_clean_tx_irq(adapter, adapter->tx_ring))) 3799 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3800 break; 3800 break;
3801 3801
3802 if (likely(adapter->itr_setting & 3)) 3802 if (likely(adapter->itr_setting & 3))
@@ -3899,7 +3899,7 @@ e1000_intr(int irq, void *data)
3899 3899
3900 for (i = 0; i < E1000_MAX_INTR; i++) 3900 for (i = 0; i < E1000_MAX_INTR; i++)
3901 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) & 3901 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3902 e1000_clean_tx_irq(adapter, adapter->tx_ring))) 3902 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3903 break; 3903 break;
3904 3904
3905 if (likely(adapter->itr_setting & 3)) 3905 if (likely(adapter->itr_setting & 3))
@@ -3949,7 +3949,7 @@ e1000_clean(struct net_device *poll_dev, int *budget)
3949 poll_dev->quota -= work_done; 3949 poll_dev->quota -= work_done;
3950 3950
3951 /* If no Tx and not enough Rx work done, exit the polling mode */ 3951 /* If no Tx and not enough Rx work done, exit the polling mode */
3952 if ((tx_cleaned && (work_done < work_to_do)) || 3952 if ((!tx_cleaned && (work_done == 0)) ||
3953 !netif_running(poll_dev)) { 3953 !netif_running(poll_dev)) {
3954quit_polling: 3954quit_polling:
3955 if (likely(adapter->itr_setting & 3)) 3955 if (likely(adapter->itr_setting & 3))
@@ -3979,7 +3979,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3979#ifdef CONFIG_E1000_NAPI 3979#ifdef CONFIG_E1000_NAPI
3980 unsigned int count = 0; 3980 unsigned int count = 0;
3981#endif 3981#endif
3982 boolean_t cleaned = TRUE; 3982 boolean_t cleaned = FALSE;
3983 unsigned int total_tx_bytes=0, total_tx_packets=0; 3983 unsigned int total_tx_bytes=0, total_tx_packets=0;
3984 3984
3985 i = tx_ring->next_to_clean; 3985 i = tx_ring->next_to_clean;
@@ -4013,10 +4013,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
4013#ifdef CONFIG_E1000_NAPI 4013#ifdef CONFIG_E1000_NAPI
4014#define E1000_TX_WEIGHT 64 4014#define E1000_TX_WEIGHT 64
4015 /* weight of a sort for tx, to avoid endless transmit cleanup */ 4015 /* weight of a sort for tx, to avoid endless transmit cleanup */
4016 if (count++ == E1000_TX_WEIGHT) { 4016 if (count++ == E1000_TX_WEIGHT) break;
4017 cleaned = FALSE;
4018 break;
4019 }
4020#endif 4017#endif
4021 } 4018 }
4022 4019
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 46e1697d9cfd..d04214e4e581 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -2050,9 +2050,10 @@ static void nv_tx_timeout(struct net_device *dev)
2050 nv_drain_tx(dev); 2050 nv_drain_tx(dev);
2051 nv_init_tx(dev); 2051 nv_init_tx(dev);
2052 setup_hw_rings(dev, NV_SETUP_TX_RING); 2052 setup_hw_rings(dev, NV_SETUP_TX_RING);
2053 netif_wake_queue(dev);
2054 } 2053 }
2055 2054
2055 netif_wake_queue(dev);
2056
2056 /* 4) restart tx engine */ 2057 /* 4) restart tx engine */
2057 nv_start_tx(dev); 2058 nv_start_tx(dev);
2058 spin_unlock_irq(&np->lock); 2059 spin_unlock_irq(&np->lock);
@@ -3536,7 +3537,10 @@ static void nv_do_nic_poll(unsigned long data)
3536 pci_push(base); 3537 pci_push(base);
3537 3538
3538 if (!using_multi_irqs(dev)) { 3539 if (!using_multi_irqs(dev)) {
3539 nv_nic_irq(0, dev); 3540 if (np->desc_ver == DESC_VER_3)
3541 nv_nic_irq_optimized(0, dev);
3542 else
3543 nv_nic_irq(0, dev);
3540 if (np->msi_flags & NV_MSI_X_ENABLED) 3544 if (np->msi_flags & NV_MSI_X_ENABLED)
3541 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 3545 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
3542 else 3546 else
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 59214e74b9cf..30baf6ecfc63 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -75,12 +75,14 @@
75#include <linux/ioport.h> 75#include <linux/ioport.h>
76#include <linux/string.h> 76#include <linux/string.h>
77#include <linux/init.h> 77#include <linux/init.h>
78#include <asm/uaccess.h>
79#include <asm/io.h>
80#include <linux/hdlcdrv.h> 78#include <linux/hdlcdrv.h>
81#include <linux/baycom.h> 79#include <linux/baycom.h>
82#include <linux/jiffies.h> 80#include <linux/jiffies.h>
83 81
82#include <asm/uaccess.h>
83#include <asm/io.h>
84#include <asm/irq.h>
85
84/* --------------------------------------------------------------------- */ 86/* --------------------------------------------------------------------- */
85 87
86#define BAYCOM_DEBUG 88#define BAYCOM_DEBUG
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ca2b21f9d444..07b4c0d7a75c 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -96,17 +96,24 @@ static void ri_tasklet(unsigned long dev)
96 skb->tc_verd = SET_TC_NCLS(skb->tc_verd); 96 skb->tc_verd = SET_TC_NCLS(skb->tc_verd);
97 stats->tx_packets++; 97 stats->tx_packets++;
98 stats->tx_bytes +=skb->len; 98 stats->tx_bytes +=skb->len;
99
100 skb->dev = __dev_get_by_index(skb->iif);
101 if (!skb->dev) {
102 dev_kfree_skb(skb);
103 stats->tx_dropped++;
104 break;
105 }
106 skb->iif = _dev->ifindex;
107
99 if (from & AT_EGRESS) { 108 if (from & AT_EGRESS) {
100 dp->st_rx_frm_egr++; 109 dp->st_rx_frm_egr++;
101 dev_queue_xmit(skb); 110 dev_queue_xmit(skb);
102 } else if (from & AT_INGRESS) { 111 } else if (from & AT_INGRESS) {
103
104 dp->st_rx_frm_ing++; 112 dp->st_rx_frm_ing++;
113 skb_pull(skb, skb->dev->hard_header_len);
105 netif_rx(skb); 114 netif_rx(skb);
106 } else { 115 } else
107 dev_kfree_skb(skb); 116 BUG();
108 stats->tx_dropped++;
109 }
110 } 117 }
111 118
112 if (netif_tx_trylock(_dev)) { 119 if (netif_tx_trylock(_dev)) {
@@ -157,26 +164,10 @@ static int ifb_xmit(struct sk_buff *skb, struct net_device *dev)
157 stats->rx_packets++; 164 stats->rx_packets++;
158 stats->rx_bytes+=skb->len; 165 stats->rx_bytes+=skb->len;
159 166
160 if (!from || !skb->input_dev) { 167 if (!(from & (AT_INGRESS|AT_EGRESS)) || !skb->iif) {
161dropped:
162 dev_kfree_skb(skb); 168 dev_kfree_skb(skb);
163 stats->rx_dropped++; 169 stats->rx_dropped++;
164 return ret; 170 return ret;
165 } else {
166 /*
167 * note we could be going
168 * ingress -> egress or
169 * egress -> ingress
170 */
171 skb->dev = skb->input_dev;
172 skb->input_dev = dev;
173 if (from & AT_INGRESS) {
174 skb_pull(skb, skb->dev->hard_header_len);
175 } else {
176 if (!(from & AT_EGRESS)) {
177 goto dropped;
178 }
179 }
180 } 171 }
181 172
182 if (skb_queue_len(&dp->rq) >= dev->tx_queue_len) { 173 if (skb_queue_len(&dp->rq) >= dev->tx_queue_len) {
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 9137e239fac2..2272156af31e 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -321,15 +321,22 @@ static void pxa_irda_fir_dma_tx_irq(int channel, void *data)
321 pxa_irda_set_speed(si, si->newspeed); 321 pxa_irda_set_speed(si, si->newspeed);
322 si->newspeed = 0; 322 si->newspeed = 0;
323 } else { 323 } else {
324 int i = 64;
325
324 ICCR0 = 0; 326 ICCR0 = 0;
325 pxa_irda_fir_dma_rx_start(si); 327 pxa_irda_fir_dma_rx_start(si);
328 while ((ICSR1 & ICSR1_RNE) && i--)
329 (void)ICDR;
326 ICCR0 = ICCR0_ITR | ICCR0_RXE; 330 ICCR0 = ICCR0_ITR | ICCR0_RXE;
331
332 if (i < 0)
333 printk(KERN_ERR "pxa_ir: cannot clear Rx FIFO!\n");
327 } 334 }
328 netif_wake_queue(dev); 335 netif_wake_queue(dev);
329} 336}
330 337
331/* EIF(Error in FIFO/End in Frame) handler for FIR */ 338/* EIF(Error in FIFO/End in Frame) handler for FIR */
332static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev) 339static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, int icsr0)
333{ 340{
334 unsigned int len, stat, data; 341 unsigned int len, stat, data;
335 342
@@ -350,7 +357,7 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev)
350 } 357 }
351 if (stat & ICSR1_ROR) { 358 if (stat & ICSR1_ROR) {
352 printk(KERN_DEBUG "pxa_ir: fir receive overrun\n"); 359 printk(KERN_DEBUG "pxa_ir: fir receive overrun\n");
353 si->stats.rx_frame_errors++; 360 si->stats.rx_over_errors++;
354 } 361 }
355 } else { 362 } else {
356 si->dma_rx_buff[len++] = data; 363 si->dma_rx_buff[len++] = data;
@@ -362,7 +369,15 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev)
362 369
363 if (stat & ICSR1_EOF) { 370 if (stat & ICSR1_EOF) {
364 /* end of frame. */ 371 /* end of frame. */
365 struct sk_buff *skb = alloc_skb(len+1,GFP_ATOMIC); 372 struct sk_buff *skb;
373
374 if (icsr0 & ICSR0_FRE) {
375 printk(KERN_ERR "pxa_ir: dropping erroneous frame\n");
376 si->stats.rx_dropped++;
377 return;
378 }
379
380 skb = alloc_skb(len+1,GFP_ATOMIC);
366 if (!skb) { 381 if (!skb) {
367 printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n"); 382 printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n");
368 si->stats.rx_dropped++; 383 si->stats.rx_dropped++;
@@ -392,7 +407,7 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
392{ 407{
393 struct net_device *dev = dev_id; 408 struct net_device *dev = dev_id;
394 struct pxa_irda *si = netdev_priv(dev); 409 struct pxa_irda *si = netdev_priv(dev);
395 int icsr0; 410 int icsr0, i = 64;
396 411
397 /* stop RX DMA */ 412 /* stop RX DMA */
398 DCSR(si->rxdma) &= ~DCSR_RUN; 413 DCSR(si->rxdma) &= ~DCSR_RUN;
@@ -412,13 +427,18 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
412 427
413 if (icsr0 & ICSR0_EIF) { 428 if (icsr0 & ICSR0_EIF) {
414 /* An error in FIFO occured, or there is a end of frame */ 429 /* An error in FIFO occured, or there is a end of frame */
415 pxa_irda_fir_irq_eif(si, dev); 430 pxa_irda_fir_irq_eif(si, dev, icsr0);
416 } 431 }
417 432
418 ICCR0 = 0; 433 ICCR0 = 0;
419 pxa_irda_fir_dma_rx_start(si); 434 pxa_irda_fir_dma_rx_start(si);
435 while ((ICSR1 & ICSR1_RNE) && i--)
436 (void)ICDR;
420 ICCR0 = ICCR0_ITR | ICCR0_RXE; 437 ICCR0 = ICCR0_ITR | ICCR0_RXE;
421 438
439 if (i < 0)
440 printk(KERN_ERR "pxa_ir: cannot clear Rx FIFO!\n");
441
422 return IRQ_HANDLED; 442 return IRQ_HANDLED;
423} 443}
424 444
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c9f55bc57edb..8015a7c5b0c9 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1379,7 +1379,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1379 1379
1380 spin_lock_init(&mp->lock); 1380 spin_lock_init(&mp->lock);
1381 1381
1382 port_num = pd->port_number; 1382 port_num = mp->port_num = pd->port_number;
1383 1383
1384 /* set default config values */ 1384 /* set default config values */
1385 eth_port_uc_addr_get(dev, dev->dev_addr); 1385 eth_port_uc_addr_get(dev, dev->dev_addr);
@@ -1411,8 +1411,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1411 duplex = pd->duplex; 1411 duplex = pd->duplex;
1412 speed = pd->speed; 1412 speed = pd->speed;
1413 1413
1414 mp->port_num = port_num;
1415
1416 /* Hook up MII support for ethtool */ 1414 /* Hook up MII support for ethtool */
1417 mp->mii.dev = dev; 1415 mp->mii.dev = dev;
1418 mp->mii.mdio_read = mv643xx_mdio_read; 1416 mp->mii.mdio_read = mv643xx_mdio_read;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index b05b20ef8c0a..f8efe0e70a6b 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -71,7 +71,7 @@
71#include "myri10ge_mcp.h" 71#include "myri10ge_mcp.h"
72#include "myri10ge_mcp_gen_header.h" 72#include "myri10ge_mcp_gen_header.h"
73 73
74#define MYRI10GE_VERSION_STR "1.3.0-1.226" 74#define MYRI10GE_VERSION_STR "1.3.0-1.233"
75 75
76MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 76MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
77MODULE_AUTHOR("Maintainer: help@myri.com"); 77MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -900,19 +900,9 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
900 /* try to refill entire ring */ 900 /* try to refill entire ring */
901 while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) { 901 while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) {
902 idx = rx->fill_cnt & rx->mask; 902 idx = rx->fill_cnt & rx->mask;
903 903 if (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE) {
904 if ((bytes < MYRI10GE_ALLOC_SIZE / 2) &&
905 (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE)) {
906 /* we can use part of previous page */ 904 /* we can use part of previous page */
907 get_page(rx->page); 905 get_page(rx->page);
908#if MYRI10GE_ALLOC_SIZE > 4096
909 /* Firmware cannot cross 4K boundary.. */
910 if ((rx->page_offset >> 12) !=
911 ((rx->page_offset + bytes - 1) >> 12)) {
912 rx->page_offset =
913 (rx->page_offset + bytes) & ~4095;
914 }
915#endif
916 } else { 906 } else {
917 /* we need a new page */ 907 /* we need a new page */
918 page = 908 page =
@@ -941,6 +931,13 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
941 931
942 /* start next packet on a cacheline boundary */ 932 /* start next packet on a cacheline boundary */
943 rx->page_offset += SKB_DATA_ALIGN(bytes); 933 rx->page_offset += SKB_DATA_ALIGN(bytes);
934
935#if MYRI10GE_ALLOC_SIZE > 4096
936 /* don't cross a 4KB boundary */
937 if ((rx->page_offset >> 12) !=
938 ((rx->page_offset + bytes - 1) >> 12))
939 rx->page_offset = (rx->page_offset + 4096) & ~4095;
940#endif
944 rx->fill_cnt++; 941 rx->fill_cnt++;
945 942
946 /* copy 8 descriptors to the firmware at a time */ 943 /* copy 8 descriptors to the firmware at a time */
@@ -2015,10 +2012,9 @@ again:
2015 mss = 0; 2012 mss = 0;
2016 max_segments = MXGEFW_MAX_SEND_DESC; 2013 max_segments = MXGEFW_MAX_SEND_DESC;
2017 2014
2018 if (skb->len > (dev->mtu + ETH_HLEN)) { 2015 if (skb_is_gso(skb)) {
2019 mss = skb_shinfo(skb)->gso_size; 2016 mss = skb_shinfo(skb)->gso_size;
2020 if (mss != 0) 2017 max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
2021 max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
2022 } 2018 }
2023 2019
2024 if ((unlikely(avail < max_segments))) { 2020 if ((unlikely(avail < max_segments))) {
@@ -2491,6 +2487,10 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2491 2487
2492#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7 2488#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
2493#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa 2489#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
2490#define PCI_DEVICE_ID_INTEL_6300ESB_PCIEE1 0x3510
2491#define PCI_DEVICE_ID_INTEL_6300ESB_PCIEE4 0x351b
2492#define PCI_DEVICE_ID_INTEL_E3000_PCIE 0x2779
2493#define PCI_DEVICE_ID_INTEL_E3010_PCIE 0x277a
2494#define PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_FIRST 0x140 2494#define PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_FIRST 0x140
2495#define PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_LAST 0x142 2495#define PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_LAST 0x142
2496 2496
@@ -2530,6 +2530,18 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2530 PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_FIRST 2530 PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_FIRST
2531 && bridge->device <= 2531 && bridge->device <=
2532 PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_LAST) 2532 PCI_DEVICE_ID_SERVERWORKS_HT2100_PCIE_LAST)
2533 /* All Intel E3000/E3010 PCIE ports */
2534 || (bridge->vendor == PCI_VENDOR_ID_INTEL
2535 && (bridge->device ==
2536 PCI_DEVICE_ID_INTEL_E3000_PCIE
2537 || bridge->device ==
2538 PCI_DEVICE_ID_INTEL_E3010_PCIE))
2539 /* All Intel 6310/6311/6321ESB PCIE ports */
2540 || (bridge->vendor == PCI_VENDOR_ID_INTEL
2541 && bridge->device >=
2542 PCI_DEVICE_ID_INTEL_6300ESB_PCIEE1
2543 && bridge->device <=
2544 PCI_DEVICE_ID_INTEL_6300ESB_PCIEE4)
2533 /* All Intel E5000 PCIE ports */ 2545 /* All Intel E5000 PCIE ports */
2534 || (bridge->vendor == PCI_VENDOR_ID_INTEL 2546 || (bridge->vendor == PCI_VENDOR_ID_INTEL
2535 && bridge->device >= 2547 && bridge->device >=
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 229aa1c4fb79..eff965dc5fff 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -438,6 +438,7 @@ do_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
438 438
439 for (addridx = addr; addridx < (addr + size); addridx += 4) { 439 for (addridx = addr; addridx < (addr + size); addridx += 4) {
440 ret = do_rom_fast_read(adapter, addridx, (int *)bytes); 440 ret = do_rom_fast_read(adapter, addridx, (int *)bytes);
441 *(int *)bytes = cpu_to_le32(*(int *)bytes);
441 if (ret != 0) 442 if (ret != 0)
442 break; 443 break;
443 bytes += 4; 444 bytes += 4;
@@ -497,7 +498,7 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter,
497 int timeout = 0; 498 int timeout = 0;
498 int data; 499 int data;
499 500
500 data = *(u32*)bytes; 501 data = le32_to_cpu((*(u32*)bytes));
501 502
502 ret = do_rom_fast_write(adapter, addridx, data); 503 ret = do_rom_fast_write(adapter, addridx, data);
503 if (ret < 0) 504 if (ret < 0)
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 933e2f3c77aa..caabbc408c34 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -802,9 +802,9 @@ process_input_packet(struct asyncppp *ap)
802 802
803 /* check for address/control and protocol compression */ 803 /* check for address/control and protocol compression */
804 p = skb->data; 804 p = skb->data;
805 if (p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) { 805 if (p[0] == PPP_ALLSTATIONS) {
806 /* chop off address/control */ 806 /* chop off address/control */
807 if (skb->len < 3) 807 if (p[1] != PPP_UI || skb->len < 3)
808 goto err; 808 goto err;
809 p = skb_pull(skb, 2); 809 p = skb_pull(skb, 2);
810 } 810 }
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 11b575f89856..ef58e4128782 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2544,6 +2544,9 @@ static void ppp_destroy_interface(struct ppp *ppp)
2544 ppp->active_filter = NULL; 2544 ppp->active_filter = NULL;
2545#endif /* CONFIG_PPP_FILTER */ 2545#endif /* CONFIG_PPP_FILTER */
2546 2546
2547 if (ppp->xmit_pending)
2548 kfree_skb(ppp->xmit_pending);
2549
2547 kfree(ppp); 2550 kfree(ppp);
2548} 2551}
2549 2552
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index d3f65dab306c..a8246eb2f8d9 100755
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -1691,6 +1691,27 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
1691/* 1691/*
1692 * Caller holds hw_lock. 1692 * Caller holds hw_lock.
1693 */ 1693 */
1694static void ql_update_small_bufq_prod_index(struct ql3_adapter *qdev)
1695{
1696 struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
1697 if (qdev->small_buf_release_cnt >= 16) {
1698 while (qdev->small_buf_release_cnt >= 16) {
1699 qdev->small_buf_q_producer_index++;
1700
1701 if (qdev->small_buf_q_producer_index ==
1702 NUM_SBUFQ_ENTRIES)
1703 qdev->small_buf_q_producer_index = 0;
1704 qdev->small_buf_release_cnt -= 8;
1705 }
1706 wmb();
1707 writel(qdev->small_buf_q_producer_index,
1708 &port_regs->CommonRegs.rxSmallQProducerIndex);
1709 }
1710}
1711
1712/*
1713 * Caller holds hw_lock.
1714 */
1694static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev) 1715static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
1695{ 1716{
1696 struct bufq_addr_element *lrg_buf_q_ele; 1717 struct bufq_addr_element *lrg_buf_q_ele;
@@ -1732,13 +1753,10 @@ static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
1732 lrg_buf_q_ele = qdev->lrg_buf_q_virt_addr; 1753 lrg_buf_q_ele = qdev->lrg_buf_q_virt_addr;
1733 } 1754 }
1734 } 1755 }
1735 1756 wmb();
1736 qdev->lrg_buf_next_free = lrg_buf_q_ele; 1757 qdev->lrg_buf_next_free = lrg_buf_q_ele;
1737 1758 writel(qdev->lrg_buf_q_producer_index,
1738 ql_write_common_reg(qdev, 1759 &port_regs->CommonRegs.rxLargeQProducerIndex);
1739 &port_regs->CommonRegs.
1740 rxLargeQProducerIndex,
1741 qdev->lrg_buf_q_producer_index);
1742 } 1760 }
1743} 1761}
1744 1762
@@ -1915,17 +1933,18 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
1915 u16 checksum = le16_to_cpu(ib_ip_rsp_ptr->checksum); 1933 u16 checksum = le16_to_cpu(ib_ip_rsp_ptr->checksum);
1916 if (checksum & 1934 if (checksum &
1917 (IB_IP_IOCB_RSP_3032_ICE | 1935 (IB_IP_IOCB_RSP_3032_ICE |
1918 IB_IP_IOCB_RSP_3032_CE | 1936 IB_IP_IOCB_RSP_3032_CE)) {
1919 IB_IP_IOCB_RSP_3032_NUC)) {
1920 printk(KERN_ERR 1937 printk(KERN_ERR
1921 "%s: Bad checksum for this %s packet, checksum = %x.\n", 1938 "%s: Bad checksum for this %s packet, checksum = %x.\n",
1922 __func__, 1939 __func__,
1923 ((checksum & 1940 ((checksum &
1924 IB_IP_IOCB_RSP_3032_TCP) ? "TCP" : 1941 IB_IP_IOCB_RSP_3032_TCP) ? "TCP" :
1925 "UDP"),checksum); 1942 "UDP"),checksum);
1926 } else if (checksum & IB_IP_IOCB_RSP_3032_TCP) { 1943 } else if ((checksum & IB_IP_IOCB_RSP_3032_TCP) ||
1944 (checksum & IB_IP_IOCB_RSP_3032_UDP &&
1945 !(checksum & IB_IP_IOCB_RSP_3032_NUC))) {
1927 skb2->ip_summed = CHECKSUM_UNNECESSARY; 1946 skb2->ip_summed = CHECKSUM_UNNECESSARY;
1928 } 1947 }
1929 } 1948 }
1930 skb2->dev = qdev->ndev; 1949 skb2->dev = qdev->ndev;
1931 skb2->protocol = eth_type_trans(skb2, qdev->ndev); 1950 skb2->protocol = eth_type_trans(skb2, qdev->ndev);
@@ -1944,16 +1963,12 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
1944static int ql_tx_rx_clean(struct ql3_adapter *qdev, 1963static int ql_tx_rx_clean(struct ql3_adapter *qdev,
1945 int *tx_cleaned, int *rx_cleaned, int work_to_do) 1964 int *tx_cleaned, int *rx_cleaned, int work_to_do)
1946{ 1965{
1947 struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
1948 struct net_rsp_iocb *net_rsp; 1966 struct net_rsp_iocb *net_rsp;
1949 struct net_device *ndev = qdev->ndev; 1967 struct net_device *ndev = qdev->ndev;
1950 unsigned long hw_flags;
1951 int work_done = 0; 1968 int work_done = 0;
1952 1969
1953 u32 rsp_producer_index = le32_to_cpu(*(qdev->prsp_producer_index));
1954
1955 /* While there are entries in the completion queue. */ 1970 /* While there are entries in the completion queue. */
1956 while ((rsp_producer_index != 1971 while ((le32_to_cpu(*(qdev->prsp_producer_index)) !=
1957 qdev->rsp_consumer_index) && (work_done < work_to_do)) { 1972 qdev->rsp_consumer_index) && (work_done < work_to_do)) {
1958 1973
1959 net_rsp = qdev->rsp_current; 1974 net_rsp = qdev->rsp_current;
@@ -2009,33 +2024,7 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
2009 work_done = *tx_cleaned + *rx_cleaned; 2024 work_done = *tx_cleaned + *rx_cleaned;
2010 } 2025 }
2011 2026
2012 if(work_done) { 2027 return work_done;
2013 spin_lock_irqsave(&qdev->hw_lock, hw_flags);
2014
2015 ql_update_lrg_bufq_prod_index(qdev);
2016
2017 if (qdev->small_buf_release_cnt >= 16) {
2018 while (qdev->small_buf_release_cnt >= 16) {
2019 qdev->small_buf_q_producer_index++;
2020
2021 if (qdev->small_buf_q_producer_index ==
2022 NUM_SBUFQ_ENTRIES)
2023 qdev->small_buf_q_producer_index = 0;
2024 qdev->small_buf_release_cnt -= 8;
2025 }
2026
2027 wmb();
2028 ql_write_common_reg(qdev,
2029 &port_regs->CommonRegs.
2030 rxSmallQProducerIndex,
2031 qdev->small_buf_q_producer_index);
2032
2033 }
2034
2035 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
2036 }
2037
2038 return *tx_cleaned + *rx_cleaned;
2039} 2028}
2040 2029
2041static int ql_poll(struct net_device *ndev, int *budget) 2030static int ql_poll(struct net_device *ndev, int *budget)
@@ -2059,9 +2048,10 @@ quit_polling:
2059 netif_rx_complete(ndev); 2048 netif_rx_complete(ndev);
2060 2049
2061 spin_lock_irqsave(&qdev->hw_lock, hw_flags); 2050 spin_lock_irqsave(&qdev->hw_lock, hw_flags);
2062 ql_write_common_reg(qdev, 2051 ql_update_small_bufq_prod_index(qdev);
2063 &port_regs->CommonRegs.rspQConsumerIndex, 2052 ql_update_lrg_bufq_prod_index(qdev);
2064 qdev->rsp_consumer_index); 2053 writel(qdev->rsp_consumer_index,
2054 &port_regs->CommonRegs.rspQConsumerIndex);
2065 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); 2055 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
2066 2056
2067 ql_enable_interrupts(qdev); 2057 ql_enable_interrupts(qdev);
@@ -2217,12 +2207,7 @@ static int ql_send_map(struct ql3_adapter *qdev,
2217 int seg_cnt, seg = 0; 2207 int seg_cnt, seg = 0;
2218 int frag_cnt = (int)skb_shinfo(skb)->nr_frags; 2208 int frag_cnt = (int)skb_shinfo(skb)->nr_frags;
2219 2209
2220 seg_cnt = tx_cb->seg_count = ql_get_seg_count(qdev, 2210 seg_cnt = tx_cb->seg_count;
2221 (skb_shinfo(skb)->nr_frags));
2222 if(seg_cnt == -1) {
2223 printk(KERN_ERR PFX"%s: invalid segment count!\n",__func__);
2224 return NETDEV_TX_BUSY;
2225 }
2226 /* 2211 /*
2227 * Map the skb buffer first. 2212 * Map the skb buffer first.
2228 */ 2213 */
@@ -2278,7 +2263,7 @@ static int ql_send_map(struct ql3_adapter *qdev,
2278 pci_unmap_addr_set(&tx_cb->map[seg], mapaddr, 2263 pci_unmap_addr_set(&tx_cb->map[seg], mapaddr,
2279 map); 2264 map);
2280 pci_unmap_len_set(&tx_cb->map[seg], maplen, 2265 pci_unmap_len_set(&tx_cb->map[seg], maplen,
2281 len); 2266 sizeof(struct oal));
2282 oal_entry = (struct oal_entry *)oal; 2267 oal_entry = (struct oal_entry *)oal;
2283 oal++; 2268 oal++;
2284 seg++; 2269 seg++;
@@ -2380,6 +2365,7 @@ static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
2380 } 2365 }
2381 2366
2382 mac_iocb_ptr = tx_cb->queue_entry; 2367 mac_iocb_ptr = tx_cb->queue_entry;
2368 memset((void *)mac_iocb_ptr, 0, sizeof(struct ob_mac_iocb_req));
2383 mac_iocb_ptr->opcode = qdev->mac_ob_opcode; 2369 mac_iocb_ptr->opcode = qdev->mac_ob_opcode;
2384 mac_iocb_ptr->flags = OB_MAC_IOCB_REQ_X; 2370 mac_iocb_ptr->flags = OB_MAC_IOCB_REQ_X;
2385 mac_iocb_ptr->flags |= qdev->mb_bit_mask; 2371 mac_iocb_ptr->flags |= qdev->mb_bit_mask;
@@ -3054,15 +3040,6 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
3054 goto out; 3040 goto out;
3055 } 3041 }
3056 3042
3057 if (qdev->mac_index)
3058 ql_write_page0_reg(qdev,
3059 &port_regs->mac1MaxFrameLengthReg,
3060 qdev->max_frame_size);
3061 else
3062 ql_write_page0_reg(qdev,
3063 &port_regs->mac0MaxFrameLengthReg,
3064 qdev->max_frame_size);
3065
3066 value = qdev->nvram_data.tcpMaxWindowSize; 3043 value = qdev->nvram_data.tcpMaxWindowSize;
3067 ql_write_page0_reg(qdev, &port_regs->tcpMaxWindow, value); 3044 ql_write_page0_reg(qdev, &port_regs->tcpMaxWindow, value);
3068 3045
@@ -3082,6 +3059,14 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
3082 ql_sem_unlock(qdev, QL_FLASH_SEM_MASK); 3059 ql_sem_unlock(qdev, QL_FLASH_SEM_MASK);
3083 } 3060 }
3084 3061
3062 if (qdev->mac_index)
3063 ql_write_page0_reg(qdev,
3064 &port_regs->mac1MaxFrameLengthReg,
3065 qdev->max_frame_size);
3066 else
3067 ql_write_page0_reg(qdev,
3068 &port_regs->mac0MaxFrameLengthReg,
3069 qdev->max_frame_size);
3085 3070
3086 if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK, 3071 if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
3087 (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) * 3072 (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
@@ -3152,7 +3137,8 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
3152 if (qdev->device_id == QL3032_DEVICE_ID) { 3137 if (qdev->device_id == QL3032_DEVICE_ID) {
3153 value = 3138 value =
3154 (QL3032_PORT_CONTROL_EF | QL3032_PORT_CONTROL_KIE | 3139 (QL3032_PORT_CONTROL_EF | QL3032_PORT_CONTROL_KIE |
3155 QL3032_PORT_CONTROL_EIv6 | QL3032_PORT_CONTROL_EIv4); 3140 QL3032_PORT_CONTROL_EIv6 | QL3032_PORT_CONTROL_EIv4 |
3141 QL3032_PORT_CONTROL_ET);
3156 ql_write_page0_reg(qdev, &port_regs->functionControl, 3142 ql_write_page0_reg(qdev, &port_regs->functionControl,
3157 ((value << 16) | value)); 3143 ((value << 16) | value));
3158 } else { 3144 } else {
diff --git a/drivers/net/qla3xxx.h b/drivers/net/qla3xxx.h
index 34cd6580fd07..0203f88f0544 100755
--- a/drivers/net/qla3xxx.h
+++ b/drivers/net/qla3xxx.h
@@ -1014,8 +1014,7 @@ struct eeprom_data {
1014 1014
1015/* Transmit and Receive Buffers */ 1015/* Transmit and Receive Buffers */
1016#define NUM_LBUFQ_ENTRIES 128 1016#define NUM_LBUFQ_ENTRIES 128
1017#define JUMBO_NUM_LBUFQ_ENTRIES \ 1017#define JUMBO_NUM_LBUFQ_ENTRIES 32
1018(NUM_LBUFQ_ENTRIES/(JUMBO_MTU_SIZE/NORMAL_MTU_SIZE))
1019#define NUM_SBUFQ_ENTRIES 64 1018#define NUM_SBUFQ_ENTRIES 64
1020#define QL_SMALL_BUFFER_SIZE 32 1019#define QL_SMALL_BUFFER_SIZE 32
1021#define QL_ADDR_ELE_PER_BUFQ_ENTRY \ 1020#define QL_ADDR_ELE_PER_BUFQ_ENTRY \
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 521b5f0618a4..6a77b8a92245 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -66,6 +66,7 @@ VERSION 2.2LK <2005/01/25>
66#include <linux/init.h> 66#include <linux/init.h>
67#include <linux/dma-mapping.h> 67#include <linux/dma-mapping.h>
68 68
69#include <asm/system.h>
69#include <asm/io.h> 70#include <asm/io.h>
70#include <asm/irq.h> 71#include <asm/irq.h>
71 72
@@ -486,6 +487,7 @@ static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *,
486 void __iomem *); 487 void __iomem *);
487static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); 488static int rtl8169_change_mtu(struct net_device *dev, int new_mtu);
488static void rtl8169_down(struct net_device *dev); 489static void rtl8169_down(struct net_device *dev);
490static void rtl8169_rx_clear(struct rtl8169_private *tp);
489 491
490#ifdef CONFIG_R8169_NAPI 492#ifdef CONFIG_R8169_NAPI
491static int rtl8169_poll(struct net_device *dev, int *budget); 493static int rtl8169_poll(struct net_device *dev, int *budget);
@@ -1751,16 +1753,10 @@ static int rtl8169_open(struct net_device *dev)
1751{ 1753{
1752 struct rtl8169_private *tp = netdev_priv(dev); 1754 struct rtl8169_private *tp = netdev_priv(dev);
1753 struct pci_dev *pdev = tp->pci_dev; 1755 struct pci_dev *pdev = tp->pci_dev;
1754 int retval; 1756 int retval = -ENOMEM;
1755 1757
1756 rtl8169_set_rxbufsize(tp, dev);
1757
1758 retval =
1759 request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED, dev->name, dev);
1760 if (retval < 0)
1761 goto out;
1762 1758
1763 retval = -ENOMEM; 1759 rtl8169_set_rxbufsize(tp, dev);
1764 1760
1765 /* 1761 /*
1766 * Rx and Tx desscriptors needs 256 bytes alignment. 1762 * Rx and Tx desscriptors needs 256 bytes alignment.
@@ -1769,19 +1765,26 @@ static int rtl8169_open(struct net_device *dev)
1769 tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES, 1765 tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES,
1770 &tp->TxPhyAddr); 1766 &tp->TxPhyAddr);
1771 if (!tp->TxDescArray) 1767 if (!tp->TxDescArray)
1772 goto err_free_irq; 1768 goto out;
1773 1769
1774 tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES, 1770 tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES,
1775 &tp->RxPhyAddr); 1771 &tp->RxPhyAddr);
1776 if (!tp->RxDescArray) 1772 if (!tp->RxDescArray)
1777 goto err_free_tx; 1773 goto err_free_tx_0;
1778 1774
1779 retval = rtl8169_init_ring(dev); 1775 retval = rtl8169_init_ring(dev);
1780 if (retval < 0) 1776 if (retval < 0)
1781 goto err_free_rx; 1777 goto err_free_rx_1;
1782 1778
1783 INIT_DELAYED_WORK(&tp->task, NULL); 1779 INIT_DELAYED_WORK(&tp->task, NULL);
1784 1780
1781 smp_mb();
1782
1783 retval = request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED,
1784 dev->name, dev);
1785 if (retval < 0)
1786 goto err_release_ring_2;
1787
1785 rtl8169_hw_start(dev); 1788 rtl8169_hw_start(dev);
1786 1789
1787 rtl8169_request_timer(dev); 1790 rtl8169_request_timer(dev);
@@ -1790,14 +1793,14 @@ static int rtl8169_open(struct net_device *dev)
1790out: 1793out:
1791 return retval; 1794 return retval;
1792 1795
1793err_free_rx: 1796err_release_ring_2:
1797 rtl8169_rx_clear(tp);
1798err_free_rx_1:
1794 pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray, 1799 pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray,
1795 tp->RxPhyAddr); 1800 tp->RxPhyAddr);
1796err_free_tx: 1801err_free_tx_0:
1797 pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray, 1802 pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray,
1798 tp->TxPhyAddr); 1803 tp->TxPhyAddr);
1799err_free_irq:
1800 free_irq(dev->irq, dev);
1801 goto out; 1804 goto out;
1802} 1805}
1803 1806
@@ -2887,7 +2890,7 @@ static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
2887 void __iomem *ioaddr = tp->mmio_addr; 2890 void __iomem *ioaddr = tp->mmio_addr;
2888 2891
2889 if (!netif_running(dev)) 2892 if (!netif_running(dev))
2890 goto out; 2893 goto out_pci_suspend;
2891 2894
2892 netif_device_detach(dev); 2895 netif_device_detach(dev);
2893 netif_stop_queue(dev); 2896 netif_stop_queue(dev);
@@ -2901,10 +2904,11 @@ static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state)
2901 2904
2902 spin_unlock_irq(&tp->lock); 2905 spin_unlock_irq(&tp->lock);
2903 2906
2907out_pci_suspend:
2904 pci_save_state(pdev); 2908 pci_save_state(pdev);
2905 pci_enable_wake(pdev, pci_choose_state(pdev, state), tp->wol_enabled); 2909 pci_enable_wake(pdev, pci_choose_state(pdev, state), tp->wol_enabled);
2906 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2910 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2907out: 2911
2908 return 0; 2912 return 0;
2909} 2913}
2910 2914
@@ -2912,15 +2916,15 @@ static int rtl8169_resume(struct pci_dev *pdev)
2912{ 2916{
2913 struct net_device *dev = pci_get_drvdata(pdev); 2917 struct net_device *dev = pci_get_drvdata(pdev);
2914 2918
2919 pci_set_power_state(pdev, PCI_D0);
2920 pci_restore_state(pdev);
2921 pci_enable_wake(pdev, PCI_D0, 0);
2922
2915 if (!netif_running(dev)) 2923 if (!netif_running(dev))
2916 goto out; 2924 goto out;
2917 2925
2918 netif_device_attach(dev); 2926 netif_device_attach(dev);
2919 2927
2920 pci_set_power_state(pdev, PCI_D0);
2921 pci_restore_state(pdev);
2922 pci_enable_wake(pdev, PCI_D0, 0);
2923
2924 rtl8169_schedule_work(dev, rtl8169_reset_task); 2928 rtl8169_schedule_work(dev, rtl8169_reset_task);
2925out: 2929out:
2926 return 0; 2930 return 0;
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 4a926f20b6ea..c32c21af3fdd 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -964,7 +964,7 @@ static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev)
964 goto out; 964 goto out;
965 } 965 }
966 966
967 spin_lock_bh(&priv->lock); 967 spin_lock(&priv->lock);
968 968
969 if (unlikely(!netif_carrier_ok(dev))) { 969 if (unlikely(!netif_carrier_ok(dev))) {
970 err = -ENOLINK; 970 err = -ENOLINK;
@@ -1005,7 +1005,7 @@ static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev)
1005 netif_stop_queue(dev); 1005 netif_stop_queue(dev);
1006 1006
1007out_unlock: 1007out_unlock:
1008 spin_unlock_bh(&priv->lock); 1008 spin_unlock(&priv->lock);
1009 1009
1010out: 1010out:
1011 dev_kfree_skb(skb); 1011 dev_kfree_skb(skb);
@@ -1042,12 +1042,12 @@ static int sc92031_open(struct net_device *dev)
1042 priv->pm_config = 0; 1042 priv->pm_config = 0;
1043 1043
1044 /* Interrupts already disabled by sc92031_stop or sc92031_probe */ 1044 /* Interrupts already disabled by sc92031_stop or sc92031_probe */
1045 spin_lock(&priv->lock); 1045 spin_lock_bh(&priv->lock);
1046 1046
1047 _sc92031_reset(dev); 1047 _sc92031_reset(dev);
1048 mmiowb(); 1048 mmiowb();
1049 1049
1050 spin_unlock(&priv->lock); 1050 spin_unlock_bh(&priv->lock);
1051 sc92031_enable_interrupts(dev); 1051 sc92031_enable_interrupts(dev);
1052 1052
1053 if (netif_carrier_ok(dev)) 1053 if (netif_carrier_ok(dev))
@@ -1077,13 +1077,13 @@ static int sc92031_stop(struct net_device *dev)
1077 /* Disable interrupts, stop Tx and Rx. */ 1077 /* Disable interrupts, stop Tx and Rx. */
1078 sc92031_disable_interrupts(dev); 1078 sc92031_disable_interrupts(dev);
1079 1079
1080 spin_lock(&priv->lock); 1080 spin_lock_bh(&priv->lock);
1081 1081
1082 _sc92031_disable_tx_rx(dev); 1082 _sc92031_disable_tx_rx(dev);
1083 _sc92031_tx_clear(dev); 1083 _sc92031_tx_clear(dev);
1084 mmiowb(); 1084 mmiowb();
1085 1085
1086 spin_unlock(&priv->lock); 1086 spin_unlock_bh(&priv->lock);
1087 1087
1088 free_irq(pdev->irq, dev); 1088 free_irq(pdev->irq, dev);
1089 pci_free_consistent(pdev, TX_BUF_TOT_LEN, priv->tx_bufs, 1089 pci_free_consistent(pdev, TX_BUF_TOT_LEN, priv->tx_bufs,
@@ -1539,13 +1539,13 @@ static int sc92031_suspend(struct pci_dev *pdev, pm_message_t state)
1539 /* Disable interrupts, stop Tx and Rx. */ 1539 /* Disable interrupts, stop Tx and Rx. */
1540 sc92031_disable_interrupts(dev); 1540 sc92031_disable_interrupts(dev);
1541 1541
1542 spin_lock(&priv->lock); 1542 spin_lock_bh(&priv->lock);
1543 1543
1544 _sc92031_disable_tx_rx(dev); 1544 _sc92031_disable_tx_rx(dev);
1545 _sc92031_tx_clear(dev); 1545 _sc92031_tx_clear(dev);
1546 mmiowb(); 1546 mmiowb();
1547 1547
1548 spin_unlock(&priv->lock); 1548 spin_unlock_bh(&priv->lock);
1549 1549
1550out: 1550out:
1551 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1551 pci_set_power_state(pdev, pci_choose_state(pdev, state));
@@ -1565,12 +1565,12 @@ static int sc92031_resume(struct pci_dev *pdev)
1565 goto out; 1565 goto out;
1566 1566
1567 /* Interrupts already disabled by sc92031_suspend */ 1567 /* Interrupts already disabled by sc92031_suspend */
1568 spin_lock(&priv->lock); 1568 spin_lock_bh(&priv->lock);
1569 1569
1570 _sc92031_reset(dev); 1570 _sc92031_reset(dev);
1571 mmiowb(); 1571 mmiowb();
1572 1572
1573 spin_unlock(&priv->lock); 1573 spin_unlock_bh(&priv->lock);
1574 sc92031_enable_interrupts(dev); 1574 sc92031_enable_interrupts(dev);
1575 1575
1576 netif_device_attach(dev); 1576 netif_device_attach(dev);
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index b08508b35833..34463ce6f132 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -324,6 +324,7 @@ static struct mii_chip_info {
324 u32 feature; 324 u32 feature;
325} mii_chip_table[] = { 325} mii_chip_table[] = {
326 { "Broadcom PHY BCM5461", { 0x0020, 0x60c0 }, LAN, F_PHY_BCM5461 }, 326 { "Broadcom PHY BCM5461", { 0x0020, 0x60c0 }, LAN, F_PHY_BCM5461 },
327 { "Broadcom PHY AC131", { 0x0143, 0xbc70 }, LAN, 0 },
327 { "Agere PHY ET1101B", { 0x0282, 0xf010 }, LAN, 0 }, 328 { "Agere PHY ET1101B", { 0x0282, 0xf010 }, LAN, 0 },
328 { "Marvell PHY 88E1111", { 0x0141, 0x0cc0 }, LAN, F_PHY_88E1111 }, 329 { "Marvell PHY 88E1111", { 0x0141, 0x0cc0 }, LAN, F_PHY_88E1111 },
329 { "Realtek PHY RTL8201", { 0x0000, 0x8200 }, LAN, 0 }, 330 { "Realtek PHY RTL8201", { 0x0000, 0x8200 }, LAN, 0 },
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index b3750f284279..b2a3b19d773a 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1755,6 +1755,24 @@ static int sis900_rx(struct net_device *net_dev)
1755 } else { 1755 } else {
1756 struct sk_buff * skb; 1756 struct sk_buff * skb;
1757 1757
1758 pci_unmap_single(sis_priv->pci_dev,
1759 sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
1760 PCI_DMA_FROMDEVICE);
1761
1762 /* refill the Rx buffer, what if there is not enought
1763 * memory for new socket buffer ?? */
1764 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
1765 /*
1766 * Not enough memory to refill the buffer
1767 * so we need to recycle the old one so
1768 * as to avoid creating a memory hole
1769 * in the rx ring
1770 */
1771 skb = sis_priv->rx_skbuff[entry];
1772 sis_priv->stats.rx_dropped++;
1773 goto refill_rx_ring;
1774 }
1775
1758 /* This situation should never happen, but due to 1776 /* This situation should never happen, but due to
1759 some unknow bugs, it is possible that 1777 some unknow bugs, it is possible that
1760 we are working on NULL sk_buff :-( */ 1778 we are working on NULL sk_buff :-( */
@@ -1768,9 +1786,6 @@ static int sis900_rx(struct net_device *net_dev)
1768 break; 1786 break;
1769 } 1787 }
1770 1788
1771 pci_unmap_single(sis_priv->pci_dev,
1772 sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
1773 PCI_DMA_FROMDEVICE);
1774 /* give the socket buffer to upper layers */ 1789 /* give the socket buffer to upper layers */
1775 skb = sis_priv->rx_skbuff[entry]; 1790 skb = sis_priv->rx_skbuff[entry];
1776 skb_put(skb, rx_size); 1791 skb_put(skb, rx_size);
@@ -1783,33 +1798,14 @@ static int sis900_rx(struct net_device *net_dev)
1783 net_dev->last_rx = jiffies; 1798 net_dev->last_rx = jiffies;
1784 sis_priv->stats.rx_bytes += rx_size; 1799 sis_priv->stats.rx_bytes += rx_size;
1785 sis_priv->stats.rx_packets++; 1800 sis_priv->stats.rx_packets++;
1786 1801 sis_priv->dirty_rx++;
1787 /* refill the Rx buffer, what if there is not enought 1802refill_rx_ring:
1788 * memory for new socket buffer ?? */
1789 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
1790 /* not enough memory for skbuff, this makes a
1791 * "hole" on the buffer ring, it is not clear
1792 * how the hardware will react to this kind
1793 * of degenerated buffer */
1794 if (netif_msg_rx_status(sis_priv))
1795 printk(KERN_INFO "%s: Memory squeeze,"
1796 "deferring packet.\n",
1797 net_dev->name);
1798 sis_priv->rx_skbuff[entry] = NULL;
1799 /* reset buffer descriptor state */
1800 sis_priv->rx_ring[entry].cmdsts = 0;
1801 sis_priv->rx_ring[entry].bufptr = 0;
1802 sis_priv->stats.rx_dropped++;
1803 sis_priv->cur_rx++;
1804 break;
1805 }
1806 skb->dev = net_dev; 1803 skb->dev = net_dev;
1807 sis_priv->rx_skbuff[entry] = skb; 1804 sis_priv->rx_skbuff[entry] = skb;
1808 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1805 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1809 sis_priv->rx_ring[entry].bufptr = 1806 sis_priv->rx_ring[entry].bufptr =
1810 pci_map_single(sis_priv->pci_dev, skb->data, 1807 pci_map_single(sis_priv->pci_dev, skb->data,
1811 RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1808 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1812 sis_priv->dirty_rx++;
1813 } 1809 }
1814 sis_priv->cur_rx++; 1810 sis_priv->cur_rx++;
1815 entry = sis_priv->cur_rx % NUM_RX_DESC; 1811 entry = sis_priv->cur_rx % NUM_RX_DESC;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 39c6677dff5e..d476a3cc2e94 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -163,27 +163,46 @@ static void skge_wol_init(struct skge_port *skge)
163{ 163{
164 struct skge_hw *hw = skge->hw; 164 struct skge_hw *hw = skge->hw;
165 int port = skge->port; 165 int port = skge->port;
166 enum pause_control save_mode; 166 u16 ctrl;
167 u32 ctrl;
168 167
169 /* Bring hardware out of reset */
170 skge_write16(hw, B0_CTST, CS_RST_CLR); 168 skge_write16(hw, B0_CTST, CS_RST_CLR);
171 skge_write16(hw, SK_REG(port, GMAC_LINK_CTRL), GMLC_RST_CLR); 169 skge_write16(hw, SK_REG(port, GMAC_LINK_CTRL), GMLC_RST_CLR);
172 170
173 skge_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); 171 /* Turn on Vaux */
174 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); 172 skge_write8(hw, B0_POWER_CTRL,
173 PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF);
175 174
176 /* Force to 10/100 skge_reset will re-enable on resume */ 175 /* WA code for COMA mode -- clear PHY reset */
177 save_mode = skge->flow_control; 176 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
178 skge->flow_control = FLOW_MODE_SYMMETRIC; 177 hw->chip_rev >= CHIP_REV_YU_LITE_A3) {
178 u32 reg = skge_read32(hw, B2_GP_IO);
179 reg |= GP_DIR_9;
180 reg &= ~GP_IO_9;
181 skge_write32(hw, B2_GP_IO, reg);
182 }
179 183
180 ctrl = skge->advertising; 184 skge_write32(hw, SK_REG(port, GPHY_CTRL),
181 skge->advertising &= ~(ADVERTISED_1000baseT_Half|ADVERTISED_1000baseT_Full); 185 GPC_DIS_SLEEP |
186 GPC_HWCFG_M_3 | GPC_HWCFG_M_2 | GPC_HWCFG_M_1 | GPC_HWCFG_M_0 |
187 GPC_ANEG_1 | GPC_RST_SET);
182 188
183 skge_phy_reset(skge); 189 skge_write32(hw, SK_REG(port, GPHY_CTRL),
190 GPC_DIS_SLEEP |
191 GPC_HWCFG_M_3 | GPC_HWCFG_M_2 | GPC_HWCFG_M_1 | GPC_HWCFG_M_0 |
192 GPC_ANEG_1 | GPC_RST_CLR);
193
194 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
195
196 /* Force to 10/100 skge_reset will re-enable on resume */
197 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
198 PHY_AN_100FULL | PHY_AN_100HALF |
199 PHY_AN_10FULL | PHY_AN_10HALF| PHY_AN_CSMA);
200 /* no 1000 HD/FD */
201 gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, 0);
202 gm_phy_write(hw, port, PHY_MARV_CTRL,
203 PHY_CT_RESET | PHY_CT_SPS_LSB | PHY_CT_ANE |
204 PHY_CT_RE_CFG | PHY_CT_DUP_MD);
184 205
185 skge->flow_control = save_mode;
186 skge->advertising = ctrl;
187 206
188 /* Set GMAC to no flow control and auto update for speed/duplex */ 207 /* Set GMAC to no flow control and auto update for speed/duplex */
189 gma_write16(hw, port, GM_GP_CTRL, 208 gma_write16(hw, port, GM_GP_CTRL,
@@ -227,12 +246,10 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
227 struct skge_port *skge = netdev_priv(dev); 246 struct skge_port *skge = netdev_priv(dev);
228 struct skge_hw *hw = skge->hw; 247 struct skge_hw *hw = skge->hw;
229 248
230 if (wol->wolopts & wol_supported(hw)) 249 if (wol->wolopts & ~wol_supported(hw))
231 return -EOPNOTSUPP; 250 return -EOPNOTSUPP;
232 251
233 skge->wol = wol->wolopts; 252 skge->wol = wol->wolopts;
234 if (!netif_running(dev))
235 skge_wol_init(skge);
236 return 0; 253 return 0;
237} 254}
238 255
@@ -2535,10 +2552,12 @@ static int skge_down(struct net_device *dev)
2535 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 2552 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
2536 2553
2537 netif_stop_queue(dev); 2554 netif_stop_queue(dev);
2555
2538 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC) 2556 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
2539 del_timer_sync(&skge->link_timer); 2557 del_timer_sync(&skge->link_timer);
2540 2558
2541 netif_poll_disable(dev); 2559 netif_poll_disable(dev);
2560 netif_carrier_off(dev);
2542 2561
2543 spin_lock_irq(&hw->hw_lock); 2562 spin_lock_irq(&hw->hw_lock);
2544 hw->intr_mask &= ~portmask[port]; 2563 hw->intr_mask &= ~portmask[port];
@@ -3765,21 +3784,6 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3765} 3784}
3766 3785
3767#ifdef CONFIG_PM 3786#ifdef CONFIG_PM
3768static int vaux_avail(struct pci_dev *pdev)
3769{
3770 int pm_cap;
3771
3772 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
3773 if (pm_cap) {
3774 u16 ctl;
3775 pci_read_config_word(pdev, pm_cap + PCI_PM_PMC, &ctl);
3776 if (ctl & PCI_PM_CAP_AUX_POWER)
3777 return 1;
3778 }
3779 return 0;
3780}
3781
3782
3783static int skge_suspend(struct pci_dev *pdev, pm_message_t state) 3787static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3784{ 3788{
3785 struct skge_hw *hw = pci_get_drvdata(pdev); 3789 struct skge_hw *hw = pci_get_drvdata(pdev);
@@ -3801,10 +3805,6 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3801 wol |= skge->wol; 3805 wol |= skge->wol;
3802 } 3806 }
3803 3807
3804 if (wol && vaux_avail(pdev))
3805 skge_write8(hw, B0_POWER_CTRL,
3806 PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF);
3807
3808 skge_write32(hw, B0_IMSK, 0); 3808 skge_write32(hw, B0_IMSK, 0);
3809 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); 3809 pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
3810 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3810 pci_set_power_state(pdev, pci_choose_state(pdev, state));
@@ -3850,6 +3850,28 @@ out:
3850} 3850}
3851#endif 3851#endif
3852 3852
3853static void skge_shutdown(struct pci_dev *pdev)
3854{
3855 struct skge_hw *hw = pci_get_drvdata(pdev);
3856 int i, wol = 0;
3857
3858 for (i = 0; i < hw->ports; i++) {
3859 struct net_device *dev = hw->dev[i];
3860 struct skge_port *skge = netdev_priv(dev);
3861
3862 if (skge->wol)
3863 skge_wol_init(skge);
3864 wol |= skge->wol;
3865 }
3866
3867 pci_enable_wake(pdev, PCI_D3hot, wol);
3868 pci_enable_wake(pdev, PCI_D3cold, wol);
3869
3870 pci_disable_device(pdev);
3871 pci_set_power_state(pdev, PCI_D3hot);
3872
3873}
3874
3853static struct pci_driver skge_driver = { 3875static struct pci_driver skge_driver = {
3854 .name = DRV_NAME, 3876 .name = DRV_NAME,
3855 .id_table = skge_id_table, 3877 .id_table = skge_id_table,
@@ -3859,6 +3881,7 @@ static struct pci_driver skge_driver = {
3859 .suspend = skge_suspend, 3881 .suspend = skge_suspend,
3860 .resume = skge_resume, 3882 .resume = skge_resume,
3861#endif 3883#endif
3884 .shutdown = skge_shutdown,
3862}; 3885};
3863 3886
3864static int __init skge_init_module(void) 3887static int __init skge_init_module(void)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index ab0ab92583fe..ac36152c68bf 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -49,7 +49,7 @@
49#include "sky2.h" 49#include "sky2.h"
50 50
51#define DRV_NAME "sky2" 51#define DRV_NAME "sky2"
52#define DRV_VERSION "1.13" 52#define DRV_VERSION "1.14"
53#define PFX DRV_NAME " " 53#define PFX DRV_NAME " "
54 54
55/* 55/*
@@ -123,7 +123,10 @@ static const struct pci_device_id sky2_id_table[] = {
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */ 123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */ 124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */
125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */ 125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */
126#ifdef broken
127 /* This device causes data corruption problems that are not resolved */
126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */ 128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */
129#endif
127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */ 130 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */ 131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
129 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ 132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
@@ -510,9 +513,9 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
510 ledover &= ~PHY_M_LED_MO_RX; 513 ledover &= ~PHY_M_LED_MO_RX;
511 } 514 }
512 515
513 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { 516 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
517 hw->chip_rev == CHIP_REV_YU_EC_U_A1) {
514 /* apply fixes in PHY AFE */ 518 /* apply fixes in PHY AFE */
515 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
516 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 255); 519 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 255);
517 520
518 /* increase differential signal amplitude in 10BASE-T */ 521 /* increase differential signal amplitude in 10BASE-T */
@@ -524,7 +527,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
524 gm_phy_write(hw, port, 0x17, 0x2002); 527 gm_phy_write(hw, port, 0x17, 0x2002);
525 528
526 /* set page register to 0 */ 529 /* set page register to 0 */
527 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 530 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0);
528 } else if (hw->chip_id != CHIP_ID_YUKON_EX) { 531 } else if (hw->chip_id != CHIP_ID_YUKON_EX) {
529 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); 532 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
530 533
@@ -740,12 +743,17 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
740 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) { 743 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
741 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8); 744 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
742 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 745 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
743 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 746
744 /* set Tx GMAC FIFO Almost Empty Threshold */ 747 /* set Tx GMAC FIFO Almost Empty Threshold */
745 sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR), 0x180); 748 sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR),
746 /* Disable Store & Forward mode for TX */ 749 (ECU_JUMBO_WM << 16) | ECU_AE_THR);
747 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS); 750
748 } 751 if (hw->dev[port]->mtu > ETH_DATA_LEN)
752 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
753 TX_JUMBO_ENA | TX_STFW_DIS);
754 else
755 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
756 TX_JUMBO_DIS | TX_STFW_ENA);
749 } 757 }
750 758
751} 759}
@@ -1278,7 +1286,7 @@ static int sky2_up(struct net_device *dev)
1278 /* Set almost empty threshold */ 1286 /* Set almost empty threshold */
1279 if (hw->chip_id == CHIP_ID_YUKON_EC_U 1287 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1280 && hw->chip_rev == CHIP_REV_YU_EC_U_A0) 1288 && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
1281 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0); 1289 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), ECU_TXFF_LEV);
1282 1290
1283 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, 1291 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
1284 TX_RING_SIZE - 1); 1292 TX_RING_SIZE - 1);
@@ -1561,6 +1569,7 @@ static int sky2_down(struct net_device *dev)
1561 1569
1562 /* Stop more packets from being queued */ 1570 /* Stop more packets from being queued */
1563 netif_stop_queue(dev); 1571 netif_stop_queue(dev);
1572 netif_carrier_off(dev);
1564 1573
1565 /* Disable port IRQ */ 1574 /* Disable port IRQ */
1566 imask = sky2_read32(hw, B0_IMSK); 1575 imask = sky2_read32(hw, B0_IMSK);
@@ -1583,13 +1592,6 @@ static int sky2_down(struct net_device *dev)
1583 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), 1592 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
1584 RB_RST_SET | RB_DIS_OP_MD); 1593 RB_RST_SET | RB_DIS_OP_MD);
1585 1594
1586 /* WA for dev. #4.209 */
1587 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1588 && (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1589 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1590 sky2->speed != SPEED_1000 ?
1591 TX_STFW_ENA : TX_STFW_DIS);
1592
1593 ctrl = gma_read16(hw, port, GM_GP_CTRL); 1595 ctrl = gma_read16(hw, port, GM_GP_CTRL);
1594 ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA); 1596 ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA);
1595 gma_write16(hw, port, GM_GP_CTRL, ctrl); 1597 gma_write16(hw, port, GM_GP_CTRL, ctrl);
@@ -1889,6 +1891,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1889{ 1891{
1890 struct sky2_port *sky2 = netdev_priv(dev); 1892 struct sky2_port *sky2 = netdev_priv(dev);
1891 struct sky2_hw *hw = sky2->hw; 1893 struct sky2_hw *hw = sky2->hw;
1894 unsigned port = sky2->port;
1892 int err; 1895 int err;
1893 u16 ctl, mode; 1896 u16 ctl, mode;
1894 u32 imask; 1897 u32 imask;
@@ -1896,9 +1899,8 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1896 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 1899 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
1897 return -EINVAL; 1900 return -EINVAL;
1898 1901
1899 /* TSO on Yukon Ultra and MTU > 1500 not supported */ 1902 if (new_mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_FE)
1900 if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN) 1903 return -EINVAL;
1901 dev->features &= ~NETIF_F_TSO;
1902 1904
1903 if (!netif_running(dev)) { 1905 if (!netif_running(dev)) {
1904 dev->mtu = new_mtu; 1906 dev->mtu = new_mtu;
@@ -1914,8 +1916,18 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1914 1916
1915 synchronize_irq(hw->pdev->irq); 1917 synchronize_irq(hw->pdev->irq);
1916 1918
1917 ctl = gma_read16(hw, sky2->port, GM_GP_CTRL); 1919 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
1918 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA); 1920 if (new_mtu > ETH_DATA_LEN) {
1921 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1922 TX_JUMBO_ENA | TX_STFW_DIS);
1923 dev->features &= NETIF_F_TSO | NETIF_F_SG | NETIF_F_IP_CSUM;
1924 } else
1925 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1926 TX_JUMBO_DIS | TX_STFW_ENA);
1927 }
1928
1929 ctl = gma_read16(hw, port, GM_GP_CTRL);
1930 gma_write16(hw, port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
1919 sky2_rx_stop(sky2); 1931 sky2_rx_stop(sky2);
1920 sky2_rx_clean(sky2); 1932 sky2_rx_clean(sky2);
1921 1933
@@ -1927,9 +1939,9 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1927 if (dev->mtu > ETH_DATA_LEN) 1939 if (dev->mtu > ETH_DATA_LEN)
1928 mode |= GM_SMOD_JUMBO_ENA; 1940 mode |= GM_SMOD_JUMBO_ENA;
1929 1941
1930 gma_write16(hw, sky2->port, GM_SERIAL_MODE, mode); 1942 gma_write16(hw, port, GM_SERIAL_MODE, mode);
1931 1943
1932 sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD); 1944 sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_ENA_OP_MD);
1933 1945
1934 err = sky2_rx_start(sky2); 1946 err = sky2_rx_start(sky2);
1935 sky2_write32(hw, B0_IMSK, imask); 1947 sky2_write32(hw, B0_IMSK, imask);
@@ -1937,7 +1949,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1937 if (err) 1949 if (err)
1938 dev_close(dev); 1950 dev_close(dev);
1939 else { 1951 else {
1940 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); 1952 gma_write16(hw, port, GM_GP_CTRL, ctl);
1941 1953
1942 netif_poll_enable(hw->dev[0]); 1954 netif_poll_enable(hw->dev[0]);
1943 netif_wake_queue(dev); 1955 netif_wake_queue(dev);
@@ -2339,26 +2351,22 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
2339 } 2351 }
2340} 2352}
2341 2353
2342/* This should never happen it is a fatal situation */ 2354/* This should never happen it is a bug. */
2343static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port, 2355static void sky2_le_error(struct sky2_hw *hw, unsigned port,
2344 const char *rxtx, u32 mask) 2356 u16 q, unsigned ring_size)
2345{ 2357{
2346 struct net_device *dev = hw->dev[port]; 2358 struct net_device *dev = hw->dev[port];
2347 struct sky2_port *sky2 = netdev_priv(dev); 2359 struct sky2_port *sky2 = netdev_priv(dev);
2348 u32 imask; 2360 unsigned idx;
2349 2361 const u64 *le = (q == Q_R1 || q == Q_R2)
2350 printk(KERN_ERR PFX "%s: %s descriptor error (hardware problem)\n", 2362 ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
2351 dev ? dev->name : "<not registered>", rxtx);
2352 2363
2353 imask = sky2_read32(hw, B0_IMSK); 2364 idx = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX));
2354 imask &= ~mask; 2365 printk(KERN_ERR PFX "%s: descriptor error q=%#x get=%u [%llx] put=%u\n",
2355 sky2_write32(hw, B0_IMSK, imask); 2366 dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
2367 (unsigned) sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX)));
2356 2368
2357 if (dev) { 2369 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK);
2358 spin_lock(&sky2->phy_lock);
2359 sky2_link_down(sky2);
2360 spin_unlock(&sky2->phy_lock);
2361 }
2362} 2370}
2363 2371
2364/* If idle then force a fake soft NAPI poll once a second 2372/* If idle then force a fake soft NAPI poll once a second
@@ -2382,23 +2390,15 @@ static void sky2_idle(unsigned long arg)
2382 mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout)); 2390 mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout));
2383} 2391}
2384 2392
2385 2393/* Hardware/software error handling */
2386static int sky2_poll(struct net_device *dev0, int *budget) 2394static void sky2_err_intr(struct sky2_hw *hw, u32 status)
2387{ 2395{
2388 struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw; 2396 if (net_ratelimit())
2389 int work_limit = min(dev0->quota, *budget); 2397 dev_warn(&hw->pdev->dev, "error interrupt status=%#x\n", status);
2390 int work_done = 0;
2391 u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
2392 2398
2393 if (status & Y2_IS_HW_ERR) 2399 if (status & Y2_IS_HW_ERR)
2394 sky2_hw_intr(hw); 2400 sky2_hw_intr(hw);
2395 2401
2396 if (status & Y2_IS_IRQ_PHY1)
2397 sky2_phy_intr(hw, 0);
2398
2399 if (status & Y2_IS_IRQ_PHY2)
2400 sky2_phy_intr(hw, 1);
2401
2402 if (status & Y2_IS_IRQ_MAC1) 2402 if (status & Y2_IS_IRQ_MAC1)
2403 sky2_mac_intr(hw, 0); 2403 sky2_mac_intr(hw, 0);
2404 2404
@@ -2406,16 +2406,33 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2406 sky2_mac_intr(hw, 1); 2406 sky2_mac_intr(hw, 1);
2407 2407
2408 if (status & Y2_IS_CHK_RX1) 2408 if (status & Y2_IS_CHK_RX1)
2409 sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); 2409 sky2_le_error(hw, 0, Q_R1, RX_LE_SIZE);
2410 2410
2411 if (status & Y2_IS_CHK_RX2) 2411 if (status & Y2_IS_CHK_RX2)
2412 sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); 2412 sky2_le_error(hw, 1, Q_R2, RX_LE_SIZE);
2413 2413
2414 if (status & Y2_IS_CHK_TXA1) 2414 if (status & Y2_IS_CHK_TXA1)
2415 sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); 2415 sky2_le_error(hw, 0, Q_XA1, TX_RING_SIZE);
2416 2416
2417 if (status & Y2_IS_CHK_TXA2) 2417 if (status & Y2_IS_CHK_TXA2)
2418 sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); 2418 sky2_le_error(hw, 1, Q_XA2, TX_RING_SIZE);
2419}
2420
2421static int sky2_poll(struct net_device *dev0, int *budget)
2422{
2423 struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
2424 int work_limit = min(dev0->quota, *budget);
2425 int work_done = 0;
2426 u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
2427
2428 if (unlikely(status & Y2_IS_ERROR))
2429 sky2_err_intr(hw, status);
2430
2431 if (status & Y2_IS_IRQ_PHY1)
2432 sky2_phy_intr(hw, 0);
2433
2434 if (status & Y2_IS_IRQ_PHY2)
2435 sky2_phy_intr(hw, 1);
2419 2436
2420 work_done = sky2_status_intr(hw, work_limit); 2437 work_done = sky2_status_intr(hw, work_limit);
2421 if (work_done < work_limit) { 2438 if (work_done < work_limit) {
@@ -2533,16 +2550,14 @@ static void sky2_reset(struct sky2_hw *hw)
2533 int i; 2550 int i;
2534 2551
2535 /* disable ASF */ 2552 /* disable ASF */
2536 if (hw->chip_id <= CHIP_ID_YUKON_EC) { 2553 if (hw->chip_id == CHIP_ID_YUKON_EX) {
2537 if (hw->chip_id == CHIP_ID_YUKON_EX) { 2554 status = sky2_read16(hw, HCU_CCSR);
2538 status = sky2_read16(hw, HCU_CCSR); 2555 status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE |
2539 status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE | 2556 HCU_CCSR_UC_STATE_MSK);
2540 HCU_CCSR_UC_STATE_MSK); 2557 sky2_write16(hw, HCU_CCSR, status);
2541 sky2_write16(hw, HCU_CCSR, status); 2558 } else
2542 } else 2559 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
2543 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); 2560 sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
2544 sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
2545 }
2546 2561
2547 /* do a SW reset */ 2562 /* do a SW reset */
2548 sky2_write8(hw, B0_CTST, CS_RST_SET); 2563 sky2_write8(hw, B0_CTST, CS_RST_SET);
@@ -3327,6 +3342,36 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
3327 regs->len - B3_RI_WTO_R1); 3342 regs->len - B3_RI_WTO_R1);
3328} 3343}
3329 3344
3345/* In order to do Jumbo packets on these chips, need to turn off the
3346 * transmit store/forward. Therefore checksum offload won't work.
3347 */
3348static int no_tx_offload(struct net_device *dev)
3349{
3350 const struct sky2_port *sky2 = netdev_priv(dev);
3351 const struct sky2_hw *hw = sky2->hw;
3352
3353 return dev->mtu > ETH_DATA_LEN &&
3354 (hw->chip_id == CHIP_ID_YUKON_EX
3355 || hw->chip_id == CHIP_ID_YUKON_EC_U);
3356}
3357
3358static int sky2_set_tx_csum(struct net_device *dev, u32 data)
3359{
3360 if (data && no_tx_offload(dev))
3361 return -EINVAL;
3362
3363 return ethtool_op_set_tx_csum(dev, data);
3364}
3365
3366
3367static int sky2_set_tso(struct net_device *dev, u32 data)
3368{
3369 if (data && no_tx_offload(dev))
3370 return -EINVAL;
3371
3372 return ethtool_op_set_tso(dev, data);
3373}
3374
3330static const struct ethtool_ops sky2_ethtool_ops = { 3375static const struct ethtool_ops sky2_ethtool_ops = {
3331 .get_settings = sky2_get_settings, 3376 .get_settings = sky2_get_settings,
3332 .set_settings = sky2_set_settings, 3377 .set_settings = sky2_set_settings,
@@ -3342,9 +3387,9 @@ static const struct ethtool_ops sky2_ethtool_ops = {
3342 .get_sg = ethtool_op_get_sg, 3387 .get_sg = ethtool_op_get_sg,
3343 .set_sg = ethtool_op_set_sg, 3388 .set_sg = ethtool_op_set_sg,
3344 .get_tx_csum = ethtool_op_get_tx_csum, 3389 .get_tx_csum = ethtool_op_get_tx_csum,
3345 .set_tx_csum = ethtool_op_set_tx_csum, 3390 .set_tx_csum = sky2_set_tx_csum,
3346 .get_tso = ethtool_op_get_tso, 3391 .get_tso = ethtool_op_get_tso,
3347 .set_tso = ethtool_op_set_tso, 3392 .set_tso = sky2_set_tso,
3348 .get_rx_csum = sky2_get_rx_csum, 3393 .get_rx_csum = sky2_get_rx_csum,
3349 .set_rx_csum = sky2_set_rx_csum, 3394 .set_rx_csum = sky2_set_rx_csum,
3350 .get_strings = sky2_get_strings, 3395 .get_strings = sky2_get_strings,
@@ -3769,6 +3814,11 @@ static int sky2_resume(struct pci_dev *pdev)
3769 goto out; 3814 goto out;
3770 3815
3771 pci_enable_wake(pdev, PCI_D0, 0); 3816 pci_enable_wake(pdev, PCI_D0, 0);
3817
3818 /* Re-enable all clocks */
3819 if (hw->chip_id == CHIP_ID_YUKON_EX || hw->chip_id == CHIP_ID_YUKON_EC_U)
3820 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
3821
3772 sky2_reset(hw); 3822 sky2_reset(hw);
3773 3823
3774 sky2_write32(hw, B0_IMSK, Y2_IS_BASE); 3824 sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index ac24bdc42976..5efb5afc45ba 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -288,6 +288,9 @@ enum {
288 | Y2_IS_CHK_TXA1 | Y2_IS_CHK_RX1, 288 | Y2_IS_CHK_TXA1 | Y2_IS_CHK_RX1,
289 Y2_IS_PORT_2 = Y2_IS_IRQ_PHY2 | Y2_IS_IRQ_MAC2 289 Y2_IS_PORT_2 = Y2_IS_IRQ_PHY2 | Y2_IS_IRQ_MAC2
290 | Y2_IS_CHK_TXA2 | Y2_IS_CHK_RX2, 290 | Y2_IS_CHK_TXA2 | Y2_IS_CHK_RX2,
291 Y2_IS_ERROR = Y2_IS_HW_ERR |
292 Y2_IS_IRQ_MAC1 | Y2_IS_CHK_TXA1 | Y2_IS_CHK_RX1 |
293 Y2_IS_IRQ_MAC2 | Y2_IS_CHK_TXA2 | Y2_IS_CHK_RX2,
291}; 294};
292 295
293/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */ 296/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */
@@ -738,6 +741,11 @@ enum {
738 TX_GMF_RP = 0x0d70,/* 32 bit Tx GMAC FIFO Read Pointer */ 741 TX_GMF_RP = 0x0d70,/* 32 bit Tx GMAC FIFO Read Pointer */
739 TX_GMF_RSTP = 0x0d74,/* 32 bit Tx GMAC FIFO Restart Pointer */ 742 TX_GMF_RSTP = 0x0d74,/* 32 bit Tx GMAC FIFO Restart Pointer */
740 TX_GMF_RLEV = 0x0d78,/* 32 bit Tx GMAC FIFO Read Level */ 743 TX_GMF_RLEV = 0x0d78,/* 32 bit Tx GMAC FIFO Read Level */
744
745 /* Threshold values for Yukon-EC Ultra and Extreme */
746 ECU_AE_THR = 0x0070, /* Almost Empty Threshold */
747 ECU_TXFF_LEV = 0x01a0, /* Tx BMU FIFO Level */
748 ECU_JUMBO_WM = 0x0080, /* Jumbo Mode Watermark */
741}; 749};
742 750
743/* Descriptor Poll Timer Registers */ 751/* Descriptor Poll Timer Registers */
@@ -1631,6 +1639,9 @@ enum {
1631 TX_VLAN_TAG_ON = 1<<25,/* enable VLAN tagging */ 1639 TX_VLAN_TAG_ON = 1<<25,/* enable VLAN tagging */
1632 TX_VLAN_TAG_OFF = 1<<24,/* disable VLAN tagging */ 1640 TX_VLAN_TAG_OFF = 1<<24,/* disable VLAN tagging */
1633 1641
1642 TX_JUMBO_ENA = 1<<23,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */
1643 TX_JUMBO_DIS = 1<<22,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */
1644
1634 GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ 1645 GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */
1635 GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ 1646 GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */
1636 GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ 1647 GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 3b91af89e4c7..e3019d52c30f 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -719,7 +719,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
719 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS; 719 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
720 spin_unlock_irqrestore(&chain->lock, flags); 720 spin_unlock_irqrestore(&chain->lock, flags);
721 721
722 if (skb->protocol == htons(ETH_P_IP)) 722 if (skb->protocol == htons(ETH_P_IP) && skb->ip_summed == CHECKSUM_PARTIAL)
723 switch (skb->nh.iph->protocol) { 723 switch (skb->nh.iph->protocol) {
724 case IPPROTO_TCP: 724 case IPPROTO_TCP:
725 hwdescr->dmac_cmd_status |= SPIDER_NET_DMAC_TCP; 725 hwdescr->dmac_cmd_status |= SPIDER_NET_DMAC_TCP;
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index c62e85d89f41..7bee45b42a2c 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -336,13 +336,27 @@ static int __init lance_probe( struct net_device *dev)
336 336
337 /* XXX - leak? */ 337 /* XXX - leak? */
338 MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000); 338 MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
339 if (MEM == NULL) {
340#ifdef CONFIG_SUN3
341 iounmap((void __iomem *)ioaddr);
342#endif
343 printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA memory\n");
344 return 0;
345 }
339 346
340 lp->iobase = (volatile unsigned short *)ioaddr; 347 lp->iobase = (volatile unsigned short *)ioaddr;
341 dev->base_addr = (unsigned long)ioaddr; /* informational only */ 348 dev->base_addr = (unsigned long)ioaddr; /* informational only */
342 349
343 REGA(CSR0) = CSR0_STOP; 350 REGA(CSR0) = CSR0_STOP;
344 351
345 request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev); 352 if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) {
353#ifdef CONFIG_SUN3
354 iounmap((void __iomem *)ioaddr);
355#endif
356 dvma_free((void *)MEM);
357 printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
358 return 0;
359 }
346 dev->irq = (unsigned short)LANCE_IRQ; 360 dev->irq = (unsigned short)LANCE_IRQ;
347 361
348 362
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 616be8d0fa85..08ea61db46fe 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2530,6 +2530,35 @@ static struct net_device_stats *gem_get_stats(struct net_device *dev)
2530 return &gp->net_stats; 2530 return &gp->net_stats;
2531} 2531}
2532 2532
2533static int gem_set_mac_address(struct net_device *dev, void *addr)
2534{
2535 struct sockaddr *macaddr = (struct sockaddr *) addr;
2536 struct gem *gp = dev->priv;
2537 unsigned char *e = &dev->dev_addr[0];
2538
2539 if (!is_valid_ether_addr(macaddr->sa_data))
2540 return -EADDRNOTAVAIL;
2541
2542 if (!netif_running(dev) || !netif_device_present(dev)) {
2543 /* We'll just catch it later when the
2544 * device is up'd or resumed.
2545 */
2546 memcpy(dev->dev_addr, macaddr->sa_data, dev->addr_len);
2547 return 0;
2548 }
2549
2550 mutex_lock(&gp->pm_mutex);
2551 memcpy(dev->dev_addr, macaddr->sa_data, dev->addr_len);
2552 if (gp->running) {
2553 writel((e[4] << 8) | e[5], gp->regs + MAC_ADDR0);
2554 writel((e[2] << 8) | e[3], gp->regs + MAC_ADDR1);
2555 writel((e[0] << 8) | e[1], gp->regs + MAC_ADDR2);
2556 }
2557 mutex_unlock(&gp->pm_mutex);
2558
2559 return 0;
2560}
2561
2533static void gem_set_multicast(struct net_device *dev) 2562static void gem_set_multicast(struct net_device *dev)
2534{ 2563{
2535 struct gem *gp = dev->priv; 2564 struct gem *gp = dev->priv;
@@ -3122,6 +3151,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3122 dev->change_mtu = gem_change_mtu; 3151 dev->change_mtu = gem_change_mtu;
3123 dev->irq = pdev->irq; 3152 dev->irq = pdev->irq;
3124 dev->dma = 0; 3153 dev->dma = 0;
3154 dev->set_mac_address = gem_set_mac_address;
3125#ifdef CONFIG_NET_POLL_CONTROLLER 3155#ifdef CONFIG_NET_POLL_CONTROLLER
3126 dev->poll_controller = gem_poll_controller; 3156 dev->poll_controller = gem_poll_controller;
3127#endif 3157#endif
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index ef671739cfea..192bbc91c731 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -3314,7 +3314,7 @@ static int __devexit hme_sbus_remove(struct of_device *dev)
3314 struct happy_meal *hp = dev_get_drvdata(&dev->dev); 3314 struct happy_meal *hp = dev_get_drvdata(&dev->dev);
3315 struct net_device *net_dev = hp->dev; 3315 struct net_device *net_dev = hp->dev;
3316 3316
3317 unregister_netdevice(net_dev); 3317 unregister_netdev(net_dev);
3318 3318
3319 /* XXX qfe parent interrupt... */ 3319 /* XXX qfe parent interrupt... */
3320 3320
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 5b00d79b5573..b0929a457b60 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -1550,7 +1550,7 @@ static int __exit sunlance_sun4_remove(void)
1550 struct lance_private *lp = dev_get_drvdata(&sun4_sdev.ofdev.dev); 1550 struct lance_private *lp = dev_get_drvdata(&sun4_sdev.ofdev.dev);
1551 struct net_device *net_dev = lp->dev; 1551 struct net_device *net_dev = lp->dev;
1552 1552
1553 unregister_netdevice(net_dev); 1553 unregister_netdev(net_dev);
1554 1554
1555 lance_free_hwresources(lp); 1555 lance_free_hwresources(lp);
1556 1556
@@ -1590,7 +1590,7 @@ static int __devexit sunlance_sbus_remove(struct of_device *dev)
1590 struct lance_private *lp = dev_get_drvdata(&dev->dev); 1590 struct lance_private *lp = dev_get_drvdata(&dev->dev);
1591 struct net_device *net_dev = lp->dev; 1591 struct net_device *net_dev = lp->dev;
1592 1592
1593 unregister_netdevice(net_dev); 1593 unregister_netdev(net_dev);
1594 1594
1595 lance_free_hwresources(lp); 1595 lance_free_hwresources(lp);
1596 1596
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index 7874eb1ef043..f3bad56d476a 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -845,6 +845,8 @@ static int __init qec_ether_init(struct sbus_dev *sdev)
845 if (!dev) 845 if (!dev)
846 return -ENOMEM; 846 return -ENOMEM;
847 847
848 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
849
848 qe = netdev_priv(dev); 850 qe = netdev_priv(dev);
849 851
850 i = of_getintprop_default(sdev->ofdev.node, "channel#", -1); 852 i = of_getintprop_default(sdev->ofdev.node, "channel#", -1);
@@ -960,7 +962,7 @@ static int __devexit qec_sbus_remove(struct of_device *dev)
960 struct sunqe *qp = dev_get_drvdata(&dev->dev); 962 struct sunqe *qp = dev_get_drvdata(&dev->dev);
961 struct net_device *net_dev = qp->dev; 963 struct net_device *net_dev = qp->dev;
962 964
963 unregister_netdevice(net_dev); 965 unregister_netdev(net_dev);
964 966
965 sbus_iounmap(qp->qcregs, CREG_REG_SIZE); 967 sbus_iounmap(qp->qcregs, CREG_REG_SIZE);
966 sbus_iounmap(qp->mregs, MREGS_REG_SIZE); 968 sbus_iounmap(qp->mregs, MREGS_REG_SIZE);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8c8f9f4d47a5..256969e1300c 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.74" 67#define DRV_MODULE_VERSION "3.75"
68#define DRV_MODULE_RELDATE "February 20, 2007" 68#define DRV_MODULE_RELDATE "March 23, 2007"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -3568,32 +3568,34 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id)
3568 * Reading the PCI State register will confirm whether the 3568 * Reading the PCI State register will confirm whether the
3569 * interrupt is ours and will flush the status block. 3569 * interrupt is ours and will flush the status block.
3570 */ 3570 */
3571 if ((sblk->status & SD_STATUS_UPDATED) || 3571 if (unlikely(!(sblk->status & SD_STATUS_UPDATED))) {
3572 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) { 3572 if ((tp->tg3_flags & TG3_FLAG_CHIP_RESETTING) ||
3573 /* 3573 (tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
3574 * Writing any value to intr-mbox-0 clears PCI INTA# and 3574 handled = 0;
3575 * chip-internal interrupt pending events.
3576 * Writing non-zero to intr-mbox-0 additional tells the
3577 * NIC to stop sending us irqs, engaging "in-intr-handler"
3578 * event coalescing.
3579 */
3580 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3581 0x00000001);
3582 if (tg3_irq_sync(tp))
3583 goto out; 3575 goto out;
3584 sblk->status &= ~SD_STATUS_UPDATED;
3585 if (likely(tg3_has_work(tp))) {
3586 prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
3587 netif_rx_schedule(dev); /* schedule NAPI poll */
3588 } else {
3589 /* No work, shared interrupt perhaps? re-enable
3590 * interrupts, and flush that PCI write
3591 */
3592 tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3593 0x00000000);
3594 } 3576 }
3595 } else { /* shared interrupt */ 3577 }
3596 handled = 0; 3578
3579 /*
3580 * Writing any value to intr-mbox-0 clears PCI INTA# and
3581 * chip-internal interrupt pending events.
3582 * Writing non-zero to intr-mbox-0 additional tells the
3583 * NIC to stop sending us irqs, engaging "in-intr-handler"
3584 * event coalescing.
3585 */
3586 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
3587 if (tg3_irq_sync(tp))
3588 goto out;
3589 sblk->status &= ~SD_STATUS_UPDATED;
3590 if (likely(tg3_has_work(tp))) {
3591 prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
3592 netif_rx_schedule(dev); /* schedule NAPI poll */
3593 } else {
3594 /* No work, shared interrupt perhaps? re-enable
3595 * interrupts, and flush that PCI write
3596 */
3597 tw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3598 0x00000000);
3597 } 3599 }
3598out: 3600out:
3599 return IRQ_RETVAL(handled); 3601 return IRQ_RETVAL(handled);
@@ -3611,31 +3613,33 @@ static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id)
3611 * Reading the PCI State register will confirm whether the 3613 * Reading the PCI State register will confirm whether the
3612 * interrupt is ours and will flush the status block. 3614 * interrupt is ours and will flush the status block.
3613 */ 3615 */
3614 if ((sblk->status_tag != tp->last_tag) || 3616 if (unlikely(sblk->status_tag == tp->last_tag)) {
3615 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) { 3617 if ((tp->tg3_flags & TG3_FLAG_CHIP_RESETTING) ||
3616 /* 3618 (tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
3617 * writing any value to intr-mbox-0 clears PCI INTA# and 3619 handled = 0;
3618 * chip-internal interrupt pending events.
3619 * writing non-zero to intr-mbox-0 additional tells the
3620 * NIC to stop sending us irqs, engaging "in-intr-handler"
3621 * event coalescing.
3622 */
3623 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3624 0x00000001);
3625 if (tg3_irq_sync(tp))
3626 goto out; 3620 goto out;
3627 if (netif_rx_schedule_prep(dev)) {
3628 prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
3629 /* Update last_tag to mark that this status has been
3630 * seen. Because interrupt may be shared, we may be
3631 * racing with tg3_poll(), so only update last_tag
3632 * if tg3_poll() is not scheduled.
3633 */
3634 tp->last_tag = sblk->status_tag;
3635 __netif_rx_schedule(dev);
3636 } 3621 }
3637 } else { /* shared interrupt */ 3622 }
3638 handled = 0; 3623
3624 /*
3625 * writing any value to intr-mbox-0 clears PCI INTA# and
3626 * chip-internal interrupt pending events.
3627 * writing non-zero to intr-mbox-0 additional tells the
3628 * NIC to stop sending us irqs, engaging "in-intr-handler"
3629 * event coalescing.
3630 */
3631 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
3632 if (tg3_irq_sync(tp))
3633 goto out;
3634 if (netif_rx_schedule_prep(dev)) {
3635 prefetch(&tp->rx_rcb[tp->rx_rcb_ptr]);
3636 /* Update last_tag to mark that this status has been
3637 * seen. Because interrupt may be shared, we may be
3638 * racing with tg3_poll(), so only update last_tag
3639 * if tg3_poll() is not scheduled.
3640 */
3641 tp->last_tag = sblk->status_tag;
3642 __netif_rx_schedule(dev);
3639 } 3643 }
3640out: 3644out:
3641 return IRQ_RETVAL(handled); 3645 return IRQ_RETVAL(handled);
@@ -4823,6 +4827,21 @@ static int tg3_chip_reset(struct tg3 *tp)
4823 if (write_op == tg3_write_flush_reg32) 4827 if (write_op == tg3_write_flush_reg32)
4824 tp->write32 = tg3_write32; 4828 tp->write32 = tg3_write32;
4825 4829
4830 /* Prevent the irq handler from reading or writing PCI registers
4831 * during chip reset when the memory enable bit in the PCI command
4832 * register may be cleared. The chip does not generate interrupt
4833 * at this time, but the irq handler may still be called due to irq
4834 * sharing or irqpoll.
4835 */
4836 tp->tg3_flags |= TG3_FLAG_CHIP_RESETTING;
4837 if (tp->hw_status) {
4838 tp->hw_status->status = 0;
4839 tp->hw_status->status_tag = 0;
4840 }
4841 tp->last_tag = 0;
4842 smp_mb();
4843 synchronize_irq(tp->pdev->irq);
4844
4826 /* do the reset */ 4845 /* do the reset */
4827 val = GRC_MISC_CFG_CORECLK_RESET; 4846 val = GRC_MISC_CFG_CORECLK_RESET;
4828 4847
@@ -4904,6 +4923,8 @@ static int tg3_chip_reset(struct tg3 *tp)
4904 4923
4905 pci_restore_state(tp->pdev); 4924 pci_restore_state(tp->pdev);
4906 4925
4926 tp->tg3_flags &= ~TG3_FLAG_CHIP_RESETTING;
4927
4907 /* Make sure PCI-X relaxed ordering bit is clear. */ 4928 /* Make sure PCI-X relaxed ordering bit is clear. */
4908 pci_read_config_dword(tp->pdev, TG3PCI_X_CAPS, &val); 4929 pci_read_config_dword(tp->pdev, TG3PCI_X_CAPS, &val);
4909 val &= ~PCIX_CAPS_RELAXED_ORDERING; 4930 val &= ~PCIX_CAPS_RELAXED_ORDERING;
@@ -6321,8 +6342,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6321 RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB | 6342 RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
6322 RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB | 6343 RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
6323 RDMAC_MODE_LNGREAD_ENAB); 6344 RDMAC_MODE_LNGREAD_ENAB);
6324 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
6325 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
6326 6345
6327 /* If statement applies to 5705 and 5750 PCI devices only */ 6346 /* If statement applies to 5705 and 5750 PCI devices only */
6328 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 6347 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
@@ -6495,9 +6514,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6495 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 6514 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
6496 val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK); 6515 val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
6497 val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT); 6516 val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
6498 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
6499 val |= (tp->split_mode_max_reqs <<
6500 PCIX_CAPS_SPLIT_SHIFT);
6501 } 6517 }
6502 tw32(TG3PCI_X_CAPS, val); 6518 tw32(TG3PCI_X_CAPS, val);
6503 } 6519 }
@@ -10863,14 +10879,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10863 grc_misc_cfg = tr32(GRC_MISC_CFG); 10879 grc_misc_cfg = tr32(GRC_MISC_CFG);
10864 grc_misc_cfg &= GRC_MISC_CFG_BOARD_ID_MASK; 10880 grc_misc_cfg &= GRC_MISC_CFG_BOARD_ID_MASK;
10865 10881
10866 /* Broadcom's driver says that CIOBE multisplit has a bug */
10867#if 0
10868 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
10869 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5704CIOBE) {
10870 tp->tg3_flags |= TG3_FLAG_SPLIT_MODE;
10871 tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
10872 }
10873#endif
10874 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 10882 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
10875 (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 || 10883 (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
10876 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M)) 10884 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
@@ -11968,14 +11976,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11968 i == 5 ? '\n' : ':'); 11976 i == 5 ? '\n' : ':');
11969 11977
11970 printk(KERN_INFO "%s: RXcsums[%d] LinkChgREG[%d] " 11978 printk(KERN_INFO "%s: RXcsums[%d] LinkChgREG[%d] "
11971 "MIirq[%d] ASF[%d] Split[%d] WireSpeed[%d] " 11979 "MIirq[%d] ASF[%d] WireSpeed[%d] TSOcap[%d]\n",
11972 "TSOcap[%d] \n",
11973 dev->name, 11980 dev->name,
11974 (tp->tg3_flags & TG3_FLAG_RX_CHECKSUMS) != 0, 11981 (tp->tg3_flags & TG3_FLAG_RX_CHECKSUMS) != 0,
11975 (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) != 0, 11982 (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) != 0,
11976 (tp->tg3_flags & TG3_FLAG_USE_MI_INTERRUPT) != 0, 11983 (tp->tg3_flags & TG3_FLAG_USE_MI_INTERRUPT) != 0,
11977 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0, 11984 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0,
11978 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0,
11979 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0, 11985 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0,
11980 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0); 11986 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0);
11981 printk(KERN_INFO "%s: dma_rwctrl[%08x] dma_mask[%d-bit]\n", 11987 printk(KERN_INFO "%s: dma_rwctrl[%08x] dma_mask[%d-bit]\n",
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 086892d8c1f1..d515ed23841b 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2223,7 +2223,7 @@ struct tg3 {
2223#define TG3_FLAG_40BIT_DMA_BUG 0x08000000 2223#define TG3_FLAG_40BIT_DMA_BUG 0x08000000
2224#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 2224#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
2225#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000 2225#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000
2226#define TG3_FLAG_SPLIT_MODE 0x40000000 2226#define TG3_FLAG_CHIP_RESETTING 0x40000000
2227#define TG3_FLAG_INIT_COMPLETE 0x80000000 2227#define TG3_FLAG_INIT_COMPLETE 0x80000000
2228 u32 tg3_flags2; 2228 u32 tg3_flags2;
2229#define TG3_FLG2_RESTART_TIMER 0x00000001 2229#define TG3_FLG2_RESTART_TIMER 0x00000001
@@ -2262,9 +2262,6 @@ struct tg3 {
2262#define TG3_FLG2_NO_FWARE_REPORTED 0x40000000 2262#define TG3_FLG2_NO_FWARE_REPORTED 0x40000000
2263#define TG3_FLG2_PHY_ADJUST_TRIM 0x80000000 2263#define TG3_FLG2_PHY_ADJUST_TRIM 0x80000000
2264 2264
2265 u32 split_mode_max_reqs;
2266#define SPLIT_MODE_5704_MAX_REQ 3
2267
2268 struct timer_list timer; 2265 struct timer_list timer;
2269 u16 timer_counter; 2266 u16 timer_counter;
2270 u16 timer_multiplier; 2267 u16 timer_multiplier;
diff --git a/drivers/net/wan/lmc/lmc_media.h b/drivers/net/wan/lmc/lmc_media.h
deleted file mode 100644
index ddcc00403563..000000000000
--- a/drivers/net/wan/lmc/lmc_media.h
+++ /dev/null
@@ -1,65 +0,0 @@
1#ifndef _LMC_MEDIA_H_
2#define _LMC_MEDIA_H_
3
4lmc_media_t lmc_ds3_media = {
5 lmc_ds3_init, /* special media init stuff */
6 lmc_ds3_default, /* reset to default state */
7 lmc_ds3_set_status, /* reset status to state provided */
8 lmc_dummy_set_1, /* set clock source */
9 lmc_dummy_set2_1, /* set line speed */
10 lmc_ds3_set_100ft, /* set cable length */
11 lmc_ds3_set_scram, /* set scrambler */
12 lmc_ds3_get_link_status, /* get link status */
13 lmc_dummy_set_1, /* set link status */
14 lmc_ds3_set_crc_length, /* set CRC length */
15 lmc_dummy_set_1, /* set T1 or E1 circuit type */
16 lmc_ds3_watchdog
17};
18
19lmc_media_t lmc_hssi_media = {
20 lmc_hssi_init, /* special media init stuff */
21 lmc_hssi_default, /* reset to default state */
22 lmc_hssi_set_status, /* reset status to state provided */
23 lmc_hssi_set_clock, /* set clock source */
24 lmc_dummy_set2_1, /* set line speed */
25 lmc_dummy_set_1, /* set cable length */
26 lmc_dummy_set_1, /* set scrambler */
27 lmc_hssi_get_link_status, /* get link status */
28 lmc_hssi_set_link_status, /* set link status */
29 lmc_hssi_set_crc_length, /* set CRC length */
30 lmc_dummy_set_1, /* set T1 or E1 circuit type */
31 lmc_hssi_watchdog
32};
33
34lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
35 lmc_ssi_default, /* reset to default state */
36 lmc_ssi_set_status, /* reset status to state provided */
37 lmc_ssi_set_clock, /* set clock source */
38 lmc_ssi_set_speed, /* set line speed */
39 lmc_dummy_set_1, /* set cable length */
40 lmc_dummy_set_1, /* set scrambler */
41 lmc_ssi_get_link_status, /* get link status */
42 lmc_ssi_set_link_status, /* set link status */
43 lmc_ssi_set_crc_length, /* set CRC length */
44 lmc_dummy_set_1, /* set T1 or E1 circuit type */
45 lmc_ssi_watchdog
46};
47
48lmc_media_t lmc_t1_media = {
49 lmc_t1_init, /* special media init stuff */
50 lmc_t1_default, /* reset to default state */
51 lmc_t1_set_status, /* reset status to state provided */
52 lmc_t1_set_clock, /* set clock source */
53 lmc_dummy_set2_1, /* set line speed */
54 lmc_dummy_set_1, /* set cable length */
55 lmc_dummy_set_1, /* set scrambler */
56 lmc_t1_get_link_status, /* get link status */
57 lmc_dummy_set_1, /* set link status */
58 lmc_t1_set_crc_length, /* set CRC length */
59 lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
60 lmc_t1_watchdog
61};
62
63
64#endif
65
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 80cb88eb98c6..a38e7eec0e62 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -946,6 +946,7 @@ static int bcm43xx_geo_init(struct bcm43xx_private *bcm)
946 u8 channel; 946 u8 channel;
947 struct bcm43xx_phyinfo *phy; 947 struct bcm43xx_phyinfo *phy;
948 const char *iso_country; 948 const char *iso_country;
949 u8 max_bg_channel;
949 950
950 geo = kzalloc(sizeof(*geo), GFP_KERNEL); 951 geo = kzalloc(sizeof(*geo), GFP_KERNEL);
951 if (!geo) 952 if (!geo)
@@ -967,6 +968,23 @@ static int bcm43xx_geo_init(struct bcm43xx_private *bcm)
967 } 968 }
968 iso_country = bcm43xx_locale_iso(bcm->sprom.locale); 969 iso_country = bcm43xx_locale_iso(bcm->sprom.locale);
969 970
971/* set the maximum channel based on locale set in sprom or witle locale option */
972 switch (bcm->sprom.locale) {
973 case BCM43xx_LOCALE_THAILAND:
974 case BCM43xx_LOCALE_ISRAEL:
975 case BCM43xx_LOCALE_JORDAN:
976 case BCM43xx_LOCALE_USA_CANADA_ANZ:
977 case BCM43xx_LOCALE_USA_LOW:
978 max_bg_channel = 11;
979 break;
980 case BCM43xx_LOCALE_JAPAN:
981 case BCM43xx_LOCALE_JAPAN_HIGH:
982 max_bg_channel = 14;
983 break;
984 default:
985 max_bg_channel = 13;
986 }
987
970 if (have_a) { 988 if (have_a) {
971 for (i = 0, channel = IEEE80211_52GHZ_MIN_CHANNEL; 989 for (i = 0, channel = IEEE80211_52GHZ_MIN_CHANNEL;
972 channel <= IEEE80211_52GHZ_MAX_CHANNEL; channel++) { 990 channel <= IEEE80211_52GHZ_MAX_CHANNEL; channel++) {
@@ -978,7 +996,7 @@ static int bcm43xx_geo_init(struct bcm43xx_private *bcm)
978 } 996 }
979 if (have_bg) { 997 if (have_bg) {
980 for (i = 0, channel = IEEE80211_24GHZ_MIN_CHANNEL; 998 for (i = 0, channel = IEEE80211_24GHZ_MIN_CHANNEL;
981 channel <= IEEE80211_24GHZ_MAX_CHANNEL; channel++) { 999 channel <= max_bg_channel; channel++) {
982 chan = &geo->bg[i++]; 1000 chan = &geo->bg[i++];
983 chan->freq = bcm43xx_channel_to_freq_bg(channel); 1001 chan->freq = bcm43xx_channel_to_freq_bg(channel);
984 chan->channel = channel; 1002 chan->channel = channel;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index cae89258a640..72529a440f15 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -757,7 +757,7 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
757 if (radio->version == 0x2050) 757 if (radio->version == 0x2050)
758 bcm43xx_phy_write(bcm, 0x0038, 0x0667); 758 bcm43xx_phy_write(bcm, 0x0038, 0x0667);
759 759
760 if (phy->type == BCM43xx_PHYTYPE_G) { 760 if (phy->connected) {
761 if (radio->version == 0x2050) { 761 if (radio->version == 0x2050) {
762 bcm43xx_radio_write16(bcm, 0x007A, 762 bcm43xx_radio_write16(bcm, 0x007A,
763 bcm43xx_radio_read16(bcm, 0x007A) 763 bcm43xx_radio_read16(bcm, 0x007A)
@@ -978,7 +978,7 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
978{ 978{
979 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 979 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
980 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); 980 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
981 u16 backup_phy[15]; 981 u16 backup_phy[15] = {0};
982 u16 backup_radio[3]; 982 u16 backup_radio[3];
983 u16 backup_bband; 983 u16 backup_bband;
984 u16 i; 984 u16 i;
@@ -989,8 +989,10 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
989 backup_phy[1] = bcm43xx_phy_read(bcm, 0x0001); 989 backup_phy[1] = bcm43xx_phy_read(bcm, 0x0001);
990 backup_phy[2] = bcm43xx_phy_read(bcm, 0x0811); 990 backup_phy[2] = bcm43xx_phy_read(bcm, 0x0811);
991 backup_phy[3] = bcm43xx_phy_read(bcm, 0x0812); 991 backup_phy[3] = bcm43xx_phy_read(bcm, 0x0812);
992 backup_phy[4] = bcm43xx_phy_read(bcm, 0x0814); 992 if (phy->rev != 1) {
993 backup_phy[5] = bcm43xx_phy_read(bcm, 0x0815); 993 backup_phy[4] = bcm43xx_phy_read(bcm, 0x0814);
994 backup_phy[5] = bcm43xx_phy_read(bcm, 0x0815);
995 }
994 backup_phy[6] = bcm43xx_phy_read(bcm, 0x005A); 996 backup_phy[6] = bcm43xx_phy_read(bcm, 0x005A);
995 backup_phy[7] = bcm43xx_phy_read(bcm, 0x0059); 997 backup_phy[7] = bcm43xx_phy_read(bcm, 0x0059);
996 backup_phy[8] = bcm43xx_phy_read(bcm, 0x0058); 998 backup_phy[8] = bcm43xx_phy_read(bcm, 0x0058);
@@ -1018,14 +1020,16 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
1018 bcm43xx_phy_read(bcm, 0x0811) | 0x0001); 1020 bcm43xx_phy_read(bcm, 0x0811) | 0x0001);
1019 bcm43xx_phy_write(bcm, 0x0812, 1021 bcm43xx_phy_write(bcm, 0x0812,
1020 bcm43xx_phy_read(bcm, 0x0812) & 0xFFFE); 1022 bcm43xx_phy_read(bcm, 0x0812) & 0xFFFE);
1021 bcm43xx_phy_write(bcm, 0x0814, 1023 if (phy->rev != 1) {
1022 bcm43xx_phy_read(bcm, 0x0814) | 0x0001); 1024 bcm43xx_phy_write(bcm, 0x0814,
1023 bcm43xx_phy_write(bcm, 0x0815, 1025 bcm43xx_phy_read(bcm, 0x0814) | 0x0001);
1024 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFE); 1026 bcm43xx_phy_write(bcm, 0x0815,
1025 bcm43xx_phy_write(bcm, 0x0814, 1027 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFE);
1026 bcm43xx_phy_read(bcm, 0x0814) | 0x0002); 1028 bcm43xx_phy_write(bcm, 0x0814,
1027 bcm43xx_phy_write(bcm, 0x0815, 1029 bcm43xx_phy_read(bcm, 0x0814) | 0x0002);
1028 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFD); 1030 bcm43xx_phy_write(bcm, 0x0815,
1031 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFD);
1032 }
1029 bcm43xx_phy_write(bcm, 0x0811, 1033 bcm43xx_phy_write(bcm, 0x0811,
1030 bcm43xx_phy_read(bcm, 0x0811) | 0x000C); 1034 bcm43xx_phy_read(bcm, 0x0811) | 0x000C);
1031 bcm43xx_phy_write(bcm, 0x0812, 1035 bcm43xx_phy_write(bcm, 0x0812,
@@ -1048,10 +1052,12 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
1048 bcm43xx_phy_read(bcm, 0x000A) 1052 bcm43xx_phy_read(bcm, 0x000A)
1049 | 0x2000); 1053 | 0x2000);
1050 } 1054 }
1051 bcm43xx_phy_write(bcm, 0x0814, 1055 if (phy->rev != 1) {
1052 bcm43xx_phy_read(bcm, 0x0814) | 0x0004); 1056 bcm43xx_phy_write(bcm, 0x0814,
1053 bcm43xx_phy_write(bcm, 0x0815, 1057 bcm43xx_phy_read(bcm, 0x0814) | 0x0004);
1054 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFB); 1058 bcm43xx_phy_write(bcm, 0x0815,
1059 bcm43xx_phy_read(bcm, 0x0815) & 0xFFFB);
1060 }
1055 bcm43xx_phy_write(bcm, 0x0003, 1061 bcm43xx_phy_write(bcm, 0x0003,
1056 (bcm43xx_phy_read(bcm, 0x0003) 1062 (bcm43xx_phy_read(bcm, 0x0003)
1057 & 0xFF9F) | 0x0040); 1063 & 0xFF9F) | 0x0040);
@@ -1138,8 +1144,10 @@ static void bcm43xx_calc_loopback_gain(struct bcm43xx_private *bcm)
1138 } 1144 }
1139 } 1145 }
1140 1146
1141 bcm43xx_phy_write(bcm, 0x0814, backup_phy[4]); 1147 if (phy->rev != 1) {
1142 bcm43xx_phy_write(bcm, 0x0815, backup_phy[5]); 1148 bcm43xx_phy_write(bcm, 0x0814, backup_phy[4]);
1149 bcm43xx_phy_write(bcm, 0x0815, backup_phy[5]);
1150 }
1143 bcm43xx_phy_write(bcm, 0x005A, backup_phy[6]); 1151 bcm43xx_phy_write(bcm, 0x005A, backup_phy[6]);
1144 bcm43xx_phy_write(bcm, 0x0059, backup_phy[7]); 1152 bcm43xx_phy_write(bcm, 0x0059, backup_phy[7]);
1145 bcm43xx_phy_write(bcm, 0x0058, backup_phy[8]); 1153 bcm43xx_phy_write(bcm, 0x0058, backup_phy[8]);
@@ -1188,24 +1196,23 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1188 bcm43xx_phy_write(bcm, 0x0811, 0x0000); 1196 bcm43xx_phy_write(bcm, 0x0811, 0x0000);
1189 bcm43xx_phy_write(bcm, 0x0015, 0x00C0); 1197 bcm43xx_phy_write(bcm, 0x0015, 0x00C0);
1190 } 1198 }
1191 if (phy->rev >= 3) { 1199 if (phy->rev > 5) {
1192 bcm43xx_phy_write(bcm, 0x0811, 0x0400); 1200 bcm43xx_phy_write(bcm, 0x0811, 0x0400);
1193 bcm43xx_phy_write(bcm, 0x0015, 0x00C0); 1201 bcm43xx_phy_write(bcm, 0x0015, 0x00C0);
1194 } 1202 }
1195 if (phy->connected) { 1203 if (phy->rev >= 2 && phy->connected) {
1196 tmp = bcm43xx_phy_read(bcm, 0x0400) & 0xFF; 1204 tmp = bcm43xx_phy_read(bcm, 0x0400) & 0xFF;
1197 if (tmp < 6) { 1205 if (tmp ==3 || tmp == 5) {
1198 bcm43xx_phy_write(bcm, 0x04C2, 0x1816); 1206 bcm43xx_phy_write(bcm, 0x04C2, 0x1816);
1199 bcm43xx_phy_write(bcm, 0x04C3, 0x8006); 1207 bcm43xx_phy_write(bcm, 0x04C3, 0x8006);
1200 if (tmp != 3) { 1208 if (tmp == 5) {
1201 bcm43xx_phy_write(bcm, 0x04CC, 1209 bcm43xx_phy_write(bcm, 0x04CC,
1202 (bcm43xx_phy_read(bcm, 0x04CC) 1210 (bcm43xx_phy_read(bcm, 0x04CC)
1203 & 0x00FF) | 0x1F00); 1211 & 0x00FF) | 0x1F00);
1204 } 1212 }
1205 } 1213 }
1206 }
1207 if (phy->rev < 3 && phy->connected)
1208 bcm43xx_phy_write(bcm, 0x047E, 0x0078); 1214 bcm43xx_phy_write(bcm, 0x047E, 0x0078);
1215 }
1209 if (radio->revision == 8) { 1216 if (radio->revision == 8) {
1210 bcm43xx_phy_write(bcm, 0x0801, bcm43xx_phy_read(bcm, 0x0801) | 0x0080); 1217 bcm43xx_phy_write(bcm, 0x0801, bcm43xx_phy_read(bcm, 0x0801) | 0x0080);
1211 bcm43xx_phy_write(bcm, 0x043E, bcm43xx_phy_read(bcm, 0x043E) | 0x0004); 1218 bcm43xx_phy_write(bcm, 0x043E, bcm43xx_phy_read(bcm, 0x043E) | 0x0004);
@@ -1232,7 +1239,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1232 if (phy->rev >= 6) { 1239 if (phy->rev >= 6) {
1233 bcm43xx_phy_write(bcm, 0x0036, 1240 bcm43xx_phy_write(bcm, 0x0036,
1234 (bcm43xx_phy_read(bcm, 0x0036) 1241 (bcm43xx_phy_read(bcm, 0x0036)
1235 & 0xF000) | (radio->txctl2 << 12)); 1242 & 0x0FFF) | (radio->txctl2 << 12));
1236 } 1243 }
1237 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) 1244 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL)
1238 bcm43xx_phy_write(bcm, 0x002E, 0x8075); 1245 bcm43xx_phy_write(bcm, 0x002E, 0x8075);
@@ -1243,7 +1250,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1243 else 1250 else
1244 bcm43xx_phy_write(bcm, 0x002F, 0x0202); 1251 bcm43xx_phy_write(bcm, 0x002F, 0x0202);
1245 } 1252 }
1246 if (phy->connected) { 1253 if (phy->connected || phy->rev >= 2) {
1247 bcm43xx_phy_lo_adjust(bcm, 0); 1254 bcm43xx_phy_lo_adjust(bcm, 0);
1248 bcm43xx_phy_write(bcm, 0x080F, 0x8078); 1255 bcm43xx_phy_write(bcm, 0x080F, 0x8078);
1249 } 1256 }
@@ -1257,7 +1264,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1257 */ 1264 */
1258 bcm43xx_nrssi_hw_update(bcm, 0xFFFF); 1265 bcm43xx_nrssi_hw_update(bcm, 0xFFFF);
1259 bcm43xx_calc_nrssi_threshold(bcm); 1266 bcm43xx_calc_nrssi_threshold(bcm);
1260 } else if (phy->connected) { 1267 } else if (phy->connected || phy->rev >= 2) {
1261 if (radio->nrssi[0] == -1000) { 1268 if (radio->nrssi[0] == -1000) {
1262 assert(radio->nrssi[1] == -1000); 1269 assert(radio->nrssi[1] == -1000);
1263 bcm43xx_calc_nrssi_slope(bcm); 1270 bcm43xx_calc_nrssi_slope(bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index ee1e7a2afc08..4025dd0089d2 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -458,7 +458,7 @@ static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm)
458 bcm43xx_phy_write(bcm, 0x005A, 0x0480); 458 bcm43xx_phy_write(bcm, 0x005A, 0x0480);
459 bcm43xx_phy_write(bcm, 0x0059, 0x0810); 459 bcm43xx_phy_write(bcm, 0x0059, 0x0810);
460 bcm43xx_phy_write(bcm, 0x0058, 0x000D); 460 bcm43xx_phy_write(bcm, 0x0058, 0x000D);
461 if (phy->rev == 0) { 461 if (phy->analog == 0) {
462 bcm43xx_phy_write(bcm, 0x0003, 0x0122); 462 bcm43xx_phy_write(bcm, 0x0003, 0x0122);
463 } else { 463 } else {
464 bcm43xx_phy_write(bcm, 0x000A, 464 bcm43xx_phy_write(bcm, 0x000A,
@@ -570,9 +570,9 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
570 nrssi0 = (s16)bcm43xx_phy_read(bcm, 0x0027); 570 nrssi0 = (s16)bcm43xx_phy_read(bcm, 0x0027);
571 bcm43xx_radio_write16(bcm, 0x007A, 571 bcm43xx_radio_write16(bcm, 0x007A,
572 bcm43xx_radio_read16(bcm, 0x007A) & 0x007F); 572 bcm43xx_radio_read16(bcm, 0x007A) & 0x007F);
573 if (phy->rev >= 2) { 573 if (phy->analog >= 2) {
574 bcm43xx_write16(bcm, 0x03E6, 0x0040); 574 bcm43xx_write16(bcm, 0x03E6, 0x0040);
575 } else if (phy->rev == 0) { 575 } else if (phy->analog == 0) {
576 bcm43xx_write16(bcm, 0x03E6, 0x0122); 576 bcm43xx_write16(bcm, 0x03E6, 0x0122);
577 } else { 577 } else {
578 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT, 578 bcm43xx_write16(bcm, BCM43xx_MMIO_CHANNEL_EXT,
@@ -596,7 +596,7 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
596 bcm43xx_phy_write(bcm, 0x0015, backup[5]); 596 bcm43xx_phy_write(bcm, 0x0015, backup[5]);
597 bcm43xx_phy_write(bcm, 0x002A, backup[6]); 597 bcm43xx_phy_write(bcm, 0x002A, backup[6]);
598 bcm43xx_synth_pu_workaround(bcm, radio->channel); 598 bcm43xx_synth_pu_workaround(bcm, radio->channel);
599 if (phy->rev != 0) 599 if (phy->analog != 0)
600 bcm43xx_write16(bcm, 0x03F4, backup[13]); 600 bcm43xx_write16(bcm, 0x03F4, backup[13]);
601 601
602 bcm43xx_phy_write(bcm, 0x0020, backup[7]); 602 bcm43xx_phy_write(bcm, 0x0020, backup[7]);
@@ -692,7 +692,7 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
692 692
693 bcm43xx_radio_write16(bcm, 0x007A, 693 bcm43xx_radio_write16(bcm, 0x007A,
694 bcm43xx_radio_read16(bcm, 0x007A) & 0x007F); 694 bcm43xx_radio_read16(bcm, 0x007A) & 0x007F);
695 if (phy->rev >= 2) { 695 if (phy->analog >= 2) {
696 bcm43xx_phy_write(bcm, 0x0003, 696 bcm43xx_phy_write(bcm, 0x0003,
697 (bcm43xx_phy_read(bcm, 0x0003) 697 (bcm43xx_phy_read(bcm, 0x0003)
698 & 0xFF9F) | 0x0040); 698 & 0xFF9F) | 0x0040);
@@ -1579,7 +1579,7 @@ void bcm43xx_radio_set_tx_iq(struct bcm43xx_private *bcm)
1579 1579
1580 for (i = 0; i < 5; i++) { 1580 for (i = 0; i < 5; i++) {
1581 for (j = 0; j < 5; j++) { 1581 for (j = 0; j < 5; j++) {
1582 if (tmp == (data_high[i] << 4 | data_low[j])) { 1582 if (tmp == (data_high[i] | data_low[j])) {
1583 bcm43xx_phy_write(bcm, 0x0069, (i - j) << 8 | 0x00C0); 1583 bcm43xx_phy_write(bcm, 0x0069, (i - j) << 8 | 0x00C0);
1584 return; 1584 return;
1585 } 1585 }
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 9c64f894b71b..87ee3ee020fe 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -337,6 +337,7 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
337 chip->patch_cr157 = (value >> 13) & 0x1; 337 chip->patch_cr157 = (value >> 13) & 0x1;
338 chip->patch_6m_band_edge = (value >> 21) & 0x1; 338 chip->patch_6m_band_edge = (value >> 21) & 0x1;
339 chip->new_phy_layout = (value >> 31) & 0x1; 339 chip->new_phy_layout = (value >> 31) & 0x1;
340 chip->al2230s_bit = (value >> 7) & 0x1;
340 chip->link_led = ((value >> 4) & 1) ? LED1 : LED2; 341 chip->link_led = ((value >> 4) & 1) ? LED1 : LED2;
341 chip->supports_tx_led = 1; 342 chip->supports_tx_led = 1;
342 if (value & (1 << 24)) { /* LED scenario */ 343 if (value & (1 << 24)) { /* LED scenario */
@@ -591,16 +592,16 @@ int zd_chip_unlock_phy_regs(struct zd_chip *chip)
591 return r; 592 return r;
592} 593}
593 594
594/* CR157 can be optionally patched by the EEPROM */ 595/* CR157 can be optionally patched by the EEPROM for original ZD1211 */
595static int patch_cr157(struct zd_chip *chip) 596static int patch_cr157(struct zd_chip *chip)
596{ 597{
597 int r; 598 int r;
598 u32 value; 599 u16 value;
599 600
600 if (!chip->patch_cr157) 601 if (!chip->patch_cr157)
601 return 0; 602 return 0;
602 603
603 r = zd_ioread32_locked(chip, &value, E2P_PHY_REG); 604 r = zd_ioread16_locked(chip, &value, E2P_PHY_REG);
604 if (r) 605 if (r)
605 return r; 606 return r;
606 607
@@ -790,11 +791,6 @@ static int zd1211b_hw_reset_phy(struct zd_chip *chip)
790 goto out; 791 goto out;
791 792
792 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 793 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
793 if (r)
794 goto unlock;
795
796 r = patch_cr157(chip);
797unlock:
798 t = zd_chip_unlock_phy_regs(chip); 794 t = zd_chip_unlock_phy_regs(chip);
799 if (t && !r) 795 if (t && !r)
800 r = t; 796 r = t;
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index b07569e391ee..e57ed75d9425 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -641,8 +641,8 @@ enum {
641 * also only 11 channels. */ 641 * also only 11 channels. */
642#define E2P_ALLOWED_CHANNEL E2P_DATA(0x18) 642#define E2P_ALLOWED_CHANNEL E2P_DATA(0x18)
643 643
644#define E2P_PHY_REG E2P_DATA(0x1a)
645#define E2P_DEVICE_VER E2P_DATA(0x20) 644#define E2P_DEVICE_VER E2P_DATA(0x20)
645#define E2P_PHY_REG E2P_DATA(0x25)
646#define E2P_36M_CAL_VALUE1 E2P_DATA(0x28) 646#define E2P_36M_CAL_VALUE1 E2P_DATA(0x28)
647#define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a) 647#define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a)
648#define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c) 648#define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c)
@@ -711,7 +711,7 @@ struct zd_chip {
711 u16 link_led; 711 u16 link_led;
712 unsigned int pa_type:4, 712 unsigned int pa_type:4,
713 patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, 713 patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
714 new_phy_layout:1, 714 new_phy_layout:1, al2230s_bit:1,
715 is_zd1211b:1, supports_tx_led:1; 715 is_zd1211b:1, supports_tx_led:1;
716}; 716};
717 717
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
index 25323a13a3db..5235a7827ac5 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
@@ -358,6 +358,12 @@ int zd_rf_init_al2230(struct zd_rf *rf)
358{ 358{
359 struct zd_chip *chip = zd_rf_to_chip(rf); 359 struct zd_chip *chip = zd_rf_to_chip(rf);
360 360
361 if (chip->al2230s_bit) {
362 dev_err(zd_chip_dev(chip), "AL2230S devices are not yet "
363 "supported by this driver.\n");
364 return -ENODEV;
365 }
366
361 rf->switch_radio_off = al2230_switch_radio_off; 367 rf->switch_radio_off = al2230_switch_radio_off;
362 if (chip->is_zd1211b) { 368 if (chip->is_zd1211b) {
363 rf->init_hw = zd1211b_al2230_init_hw; 369 rf->init_hw = zd1211b_al2230_init_hw;
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index aac8a1c5ba08..edaaad2f648b 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -62,6 +62,7 @@ static struct usb_device_id usb_ids[] = {
62 { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B }, 62 { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
63 { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B }, 63 { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B },
64 { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B }, 64 { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B },
65 { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B },
65 /* "Driverless" devices that need ejecting */ 66 /* "Driverless" devices that need ejecting */
66 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, 67 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
67 {} 68 {}
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index 00e937e9240e..e7fbac529935 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -70,11 +70,12 @@ void wake_up_buffer_waiter(void)
70int alloc_event_buffer(void) 70int alloc_event_buffer(void)
71{ 71{
72 int err = -ENOMEM; 72 int err = -ENOMEM;
73 unsigned long flags;
73 74
74 spin_lock(&oprofilefs_lock); 75 spin_lock_irqsave(&oprofilefs_lock, flags);
75 buffer_size = fs_buffer_size; 76 buffer_size = fs_buffer_size;
76 buffer_watershed = fs_buffer_watershed; 77 buffer_watershed = fs_buffer_watershed;
77 spin_unlock(&oprofilefs_lock); 78 spin_unlock_irqrestore(&oprofilefs_lock, flags);
78 79
79 if (buffer_watershed >= buffer_size) 80 if (buffer_watershed >= buffer_size)
80 return -EINVAL; 81 return -EINVAL;
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index 6e67b42ca46d..8543cb26cf34 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -65,6 +65,7 @@ ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t co
65int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count) 65int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, size_t count)
66{ 66{
67 char tmpbuf[TMPBUFSIZE]; 67 char tmpbuf[TMPBUFSIZE];
68 unsigned long flags;
68 69
69 if (!count) 70 if (!count)
70 return 0; 71 return 0;
@@ -77,9 +78,9 @@ int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, siz
77 if (copy_from_user(tmpbuf, buf, count)) 78 if (copy_from_user(tmpbuf, buf, count))
78 return -EFAULT; 79 return -EFAULT;
79 80
80 spin_lock(&oprofilefs_lock); 81 spin_lock_irqsave(&oprofilefs_lock, flags);
81 *val = simple_strtoul(tmpbuf, NULL, 0); 82 *val = simple_strtoul(tmpbuf, NULL, 0);
82 spin_unlock(&oprofilefs_lock); 83 spin_unlock_irqrestore(&oprofilefs_lock, flags);
83 return 0; 84 return 0;
84} 85}
85 86
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
index 9793533276ec..400bb90084cf 100644
--- a/drivers/parport/parport_sunbpp.c
+++ b/drivers/parport/parport_sunbpp.c
@@ -126,7 +126,7 @@ static unsigned char status_sunbpp_to_pc(struct parport *p)
126 if (!(value_tcr & P_TCR_BUSY)) 126 if (!(value_tcr & P_TCR_BUSY))
127 bits |= PARPORT_STATUS_BUSY; 127 bits |= PARPORT_STATUS_BUSY;
128 128
129 dprintk((KERN_DEBUG "tcr 0x%x ir 0x%x\n", regs->p_tcr, regs->p_ir)); 129 dprintk((KERN_DEBUG "tcr 0x%x ir 0x%x\n", value_tcr, value_ir));
130 dprintk((KERN_DEBUG "read status 0x%x\n", bits)); 130 dprintk((KERN_DEBUG "read status 0x%x\n", bits));
131 return bits; 131 return bits;
132} 132}
@@ -147,7 +147,7 @@ static unsigned char control_sunbpp_to_pc(struct parport *p)
147 if (value_or & P_OR_SLCT_IN) 147 if (value_or & P_OR_SLCT_IN)
148 bits |= PARPORT_CONTROL_SELECT; 148 bits |= PARPORT_CONTROL_SELECT;
149 149
150 dprintk((KERN_DEBUG "tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or)); 150 dprintk((KERN_DEBUG "tcr 0x%x or 0x%x\n", value_tcr, value_or));
151 dprintk((KERN_DEBUG "read control 0x%x\n", bits)); 151 dprintk((KERN_DEBUG "read control 0x%x\n", bits));
152 return bits; 152 return bits;
153} 153}
@@ -165,7 +165,8 @@ static unsigned char parport_sunbpp_frob_control(struct parport *p,
165 unsigned char value_tcr = sbus_readb(&regs->p_tcr); 165 unsigned char value_tcr = sbus_readb(&regs->p_tcr);
166 unsigned char value_or = sbus_readb(&regs->p_or); 166 unsigned char value_or = sbus_readb(&regs->p_or);
167 167
168 dprintk((KERN_DEBUG "frob1: tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or)); 168 dprintk((KERN_DEBUG "frob1: tcr 0x%x or 0x%x\n",
169 value_tcr, value_or));
169 if (mask & PARPORT_CONTROL_STROBE) { 170 if (mask & PARPORT_CONTROL_STROBE) {
170 if (val & PARPORT_CONTROL_STROBE) { 171 if (val & PARPORT_CONTROL_STROBE) {
171 value_tcr &= ~P_TCR_DS; 172 value_tcr &= ~P_TCR_DS;
@@ -197,7 +198,8 @@ static unsigned char parport_sunbpp_frob_control(struct parport *p,
197 198
198 sbus_writeb(value_or, &regs->p_or); 199 sbus_writeb(value_or, &regs->p_or);
199 sbus_writeb(value_tcr, &regs->p_tcr); 200 sbus_writeb(value_tcr, &regs->p_tcr);
200 dprintk((KERN_DEBUG "frob2: tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or)); 201 dprintk((KERN_DEBUG "frob2: tcr 0x%x or 0x%x\n",
202 value_tcr, value_or));
201 return parport_sunbpp_read_control(p); 203 return parport_sunbpp_read_control(p);
202} 204}
203 205
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ad33e0159514..435c1958a7b7 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -94,6 +94,7 @@ static void msi_set_mask_bit(unsigned int irq, int flag)
94 int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + 94 int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
95 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; 95 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET;
96 writel(flag, entry->mask_base + offset); 96 writel(flag, entry->mask_base + offset);
97 readl(entry->mask_base + offset);
97 break; 98 break;
98 } 99 }
99 default: 100 default:
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 0be5a0b30725..df383645e366 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -93,7 +93,7 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
93 if (!dev->irq && dev->pin) { 93 if (!dev->irq && dev->pin) {
94 printk(KERN_WARNING 94 printk(KERN_WARNING
95 "%s->Dev[%04x:%04x] has invalid IRQ. Check vendor BIOS\n", 95 "%s->Dev[%04x:%04x] has invalid IRQ. Check vendor BIOS\n",
96 __FUNCTION__, dev->device, dev->vendor); 96 __FUNCTION__, dev->vendor, dev->device);
97 } 97 }
98 if (pcie_port_device_register(dev)) { 98 if (pcie_port_device_register(dev)) {
99 pci_disable_device(dev); 99 pci_disable_device(dev);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index a4a96826d9e0..2fe1d690eb13 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -682,34 +682,7 @@ static void pci_read_irq(struct pci_dev *dev)
682 dev->irq = irq; 682 dev->irq = irq;
683} 683}
684 684
685static void change_legacy_io_resource(struct pci_dev * dev, unsigned index, 685#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
686 unsigned start, unsigned end)
687{
688 unsigned base = start & PCI_BASE_ADDRESS_IO_MASK;
689 unsigned len = (end | ~PCI_BASE_ADDRESS_IO_MASK) - base + 1;
690
691 /*
692 * Some X versions get confused when the BARs reported through
693 * /sys or /proc differ from those seen in config space, thus
694 * try to update the config space values, too.
695 */
696 if (!(pci_resource_flags(dev, index) & IORESOURCE_IO))
697 printk(KERN_WARNING "%s: cannot adjust BAR%u (not I/O)\n",
698 pci_name(dev), index);
699 else if (pci_resource_len(dev, index) != len)
700 printk(KERN_WARNING "%s: cannot adjust BAR%u (size %04X)\n",
701 pci_name(dev), index, (unsigned)pci_resource_len(dev, index));
702 else {
703 printk(KERN_INFO "%s: trying to change BAR%u from %04X to %04X\n",
704 pci_name(dev), index,
705 (unsigned)pci_resource_start(dev, index), base);
706 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + index * 4, base);
707 }
708 pci_resource_start(dev, index) = start;
709 pci_resource_end(dev, index) = end;
710 pci_resource_flags(dev, index) =
711 IORESOURCE_IO | IORESOURCE_PCI_FIXED | PCI_BASE_ADDRESS_SPACE_IO;
712}
713 686
714/** 687/**
715 * pci_setup_device - fill in class and map information of a device 688 * pci_setup_device - fill in class and map information of a device
@@ -762,12 +735,20 @@ static int pci_setup_device(struct pci_dev * dev)
762 u8 progif; 735 u8 progif;
763 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); 736 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif);
764 if ((progif & 1) == 0) { 737 if ((progif & 1) == 0) {
765 change_legacy_io_resource(dev, 0, 0x1F0, 0x1F7); 738 dev->resource[0].start = 0x1F0;
766 change_legacy_io_resource(dev, 1, 0x3F6, 0x3F6); 739 dev->resource[0].end = 0x1F7;
740 dev->resource[0].flags = LEGACY_IO_RESOURCE;
741 dev->resource[1].start = 0x3F6;
742 dev->resource[1].end = 0x3F6;
743 dev->resource[1].flags = LEGACY_IO_RESOURCE;
767 } 744 }
768 if ((progif & 4) == 0) { 745 if ((progif & 4) == 0) {
769 change_legacy_io_resource(dev, 2, 0x170, 0x177); 746 dev->resource[2].start = 0x170;
770 change_legacy_io_resource(dev, 3, 0x376, 0x376); 747 dev->resource[2].end = 0x177;
748 dev->resource[2].flags = LEGACY_IO_RESOURCE;
749 dev->resource[3].start = 0x376;
750 dev->resource[3].end = 0x376;
751 dev->resource[3].flags = LEGACY_IO_RESOURCE;
771 } 752 }
772 } 753 }
773 break; 754 break;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 7f94fc098cd3..65d6f23ead41 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -963,6 +963,13 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_ho
963 * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it 963 * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it
964 * becomes necessary to do this tweak in two steps -- I've chosen the Host 964 * becomes necessary to do this tweak in two steps -- I've chosen the Host
965 * bridge as trigger. 965 * bridge as trigger.
966 *
967 * Note that we used to unhide the SMBus that way on Toshiba laptops
968 * (Satellite A40 and Tecra M2) but then found that the thermal management
969 * was done by SMM code, which could cause unsynchronized concurrent
970 * accesses to the SMBus registers, with potentially bad effects. Thus you
971 * should be very careful when adding new entries: if SMM is accessing the
972 * Intel SMBus, this is a very good reason to leave it hidden.
966 */ 973 */
967static int asus_hides_smbus; 974static int asus_hides_smbus;
968 975
@@ -1040,17 +1047,6 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
1040 case 0x099c: /* HP Compaq nx6110 */ 1047 case 0x099c: /* HP Compaq nx6110 */
1041 asus_hides_smbus = 1; 1048 asus_hides_smbus = 1;
1042 } 1049 }
1043 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) {
1044 if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB)
1045 switch(dev->subsystem_device) {
1046 case 0x0001: /* Toshiba Satellite A40 */
1047 asus_hides_smbus = 1;
1048 }
1049 else if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
1050 switch(dev->subsystem_device) {
1051 case 0x0001: /* Toshiba Tecra M2 */
1052 asus_hides_smbus = 1;
1053 }
1054 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) { 1050 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
1055 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 1051 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
1056 switch(dev->subsystem_device) { 1052 switch(dev->subsystem_device) {
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 551bde5d9430..b693367d38cd 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -372,7 +372,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
372 skt->socket.resource_ops = &pccard_static_ops; 372 skt->socket.resource_ops = &pccard_static_ops;
373 skt->socket.ops = &au1x00_pcmcia_operations; 373 skt->socket.ops = &au1x00_pcmcia_operations;
374 skt->socket.owner = ops->owner; 374 skt->socket.owner = ops->owner;
375 skt->socket.dev.dev = dev; 375 skt->socket.dev.parent = dev;
376 376
377 init_timer(&skt->poll_timer); 377 init_timer(&skt->poll_timer);
378 skt->poll_timer.function = au1x00_pcmcia_poll_event; 378 skt->poll_timer.function = au1x00_pcmcia_poll_event;
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index d77f75129f8a..2df216b00817 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -202,15 +202,14 @@ static struct pccard_operations omap_cf_ops = {
202 * "what chipselect is used". Boards could want more. 202 * "what chipselect is used". Boards could want more.
203 */ 203 */
204 204
205static int __devinit omap_cf_probe(struct device *dev) 205static int __init omap_cf_probe(struct platform_device *pdev)
206{ 206{
207 unsigned seg; 207 unsigned seg;
208 struct omap_cf_socket *cf; 208 struct omap_cf_socket *cf;
209 struct platform_device *pdev = to_platform_device(dev);
210 int irq; 209 int irq;
211 int status; 210 int status;
212 211
213 seg = (int) dev->platform_data; 212 seg = (int) pdev->dev.platform_data;
214 if (seg == 0 || seg > 3) 213 if (seg == 0 || seg > 3)
215 return -ENODEV; 214 return -ENODEV;
216 215
@@ -227,7 +226,7 @@ static int __devinit omap_cf_probe(struct device *dev)
227 cf->timer.data = (unsigned long) cf; 226 cf->timer.data = (unsigned long) cf;
228 227
229 cf->pdev = pdev; 228 cf->pdev = pdev;
230 dev_set_drvdata(dev, cf); 229 platform_set_drvdata(pdev, cf);
231 230
232 /* this primarily just shuts up irq handling noise */ 231 /* this primarily just shuts up irq handling noise */
233 status = request_irq(irq, omap_cf_irq, IRQF_SHARED, 232 status = request_irq(irq, omap_cf_irq, IRQF_SHARED,
@@ -291,7 +290,7 @@ static int __devinit omap_cf_probe(struct device *dev)
291 omap_cf_present() ? "present" : "(not present)"); 290 omap_cf_present() ? "present" : "(not present)");
292 291
293 cf->socket.owner = THIS_MODULE; 292 cf->socket.owner = THIS_MODULE;
294 cf->socket.dev.parent = dev; 293 cf->socket.dev.parent = &pdev->dev;
295 cf->socket.ops = &omap_cf_ops; 294 cf->socket.ops = &omap_cf_ops;
296 cf->socket.resource_ops = &pccard_static_ops; 295 cf->socket.resource_ops = &pccard_static_ops;
297 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP 296 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
@@ -318,9 +317,9 @@ fail0:
318 return status; 317 return status;
319} 318}
320 319
321static int __devexit omap_cf_remove(struct device *dev) 320static int __exit omap_cf_remove(struct platform_device *pdev)
322{ 321{
323 struct omap_cf_socket *cf = dev_get_drvdata(dev); 322 struct omap_cf_socket *cf = platform_get_drvdata(pdev);
324 323
325 cf->active = 0; 324 cf->active = 0;
326 pcmcia_unregister_socket(&cf->socket); 325 pcmcia_unregister_socket(&cf->socket);
@@ -332,26 +331,36 @@ static int __devexit omap_cf_remove(struct device *dev)
332 return 0; 331 return 0;
333} 332}
334 333
335static struct device_driver omap_cf_driver = { 334static int omap_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
336 .name = (char *) driver_name, 335{
337 .bus = &platform_bus_type, 336 return pcmcia_socket_dev_suspend(&pdev->dev, mesg);
338 .probe = omap_cf_probe, 337}
339 .remove = __devexit_p(omap_cf_remove), 338
340 .suspend = pcmcia_socket_dev_suspend, 339static int omap_cf_resume(struct platform_device *pdev)
341 .resume = pcmcia_socket_dev_resume, 340{
341 return pcmcia_socket_dev_resume(&pdev->dev);
342}
343
344static struct platform_driver omap_cf_driver = {
345 .driver = {
346 .name = (char *) driver_name,
347 },
348 .remove = __exit_p(omap_cf_remove),
349 .suspend = omap_cf_suspend,
350 .resume = omap_cf_resume,
342}; 351};
343 352
344static int __init omap_cf_init(void) 353static int __init omap_cf_init(void)
345{ 354{
346 if (cpu_is_omap16xx()) 355 if (cpu_is_omap16xx())
347 return driver_register(&omap_cf_driver); 356 return platform_driver_probe(&omap_cf_driver, omap_cf_probe);
348 return -ENODEV; 357 return -ENODEV;
349} 358}
350 359
351static void __exit omap_cf_exit(void) 360static void __exit omap_cf_exit(void)
352{ 361{
353 if (cpu_is_omap16xx()) 362 if (cpu_is_omap16xx())
354 driver_unregister(&omap_cf_driver); 363 platform_driver_unregister(&omap_cf_driver);
355} 364}
356 365
357module_init(omap_cf_init); 366module_init(omap_cf_init);
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index 2065e74bb63f..a8a95540b1ef 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -22,7 +22,7 @@ static const struct pnp_device_id pnp_dev_table[] = {
22 { "", 0 } 22 { "", 0 }
23}; 23};
24 24
25static void reserve_range(char *pnpid, int start, int end, int port) 25static void reserve_range(const char *pnpid, resource_size_t start, resource_size_t end, int port)
26{ 26{
27 struct resource *res; 27 struct resource *res;
28 char *regionid; 28 char *regionid;
@@ -32,9 +32,9 @@ static void reserve_range(char *pnpid, int start, int end, int port)
32 return; 32 return;
33 snprintf(regionid, 16, "pnp %s", pnpid); 33 snprintf(regionid, 16, "pnp %s", pnpid);
34 if (port) 34 if (port)
35 res = request_region(start,end-start+1,regionid); 35 res = request_region(start, end-start+1, regionid);
36 else 36 else
37 res = request_mem_region(start,end-start+1,regionid); 37 res = request_mem_region(start, end-start+1, regionid);
38 if (res == NULL) 38 if (res == NULL)
39 kfree(regionid); 39 kfree(regionid);
40 else 40 else
@@ -45,12 +45,13 @@ static void reserve_range(char *pnpid, int start, int end, int port)
45 * have double reservations. 45 * have double reservations.
46 */ 46 */
47 printk(KERN_INFO 47 printk(KERN_INFO
48 "pnp: %s: %s range 0x%x-0x%x %s reserved\n", 48 "pnp: %s: %s range 0x%llx-0x%llx %s reserved\n",
49 pnpid, port ? "ioport" : "iomem", start, end, 49 pnpid, port ? "ioport" : "iomem",
50 (unsigned long long)start, (unsigned long long)end,
50 NULL != res ? "has been" : "could not be"); 51 NULL != res ? "has been" : "could not be");
51} 52}
52 53
53static void reserve_resources_of_dev(struct pnp_dev *dev) 54static void reserve_resources_of_dev(const struct pnp_dev *dev)
54{ 55{
55 int i; 56 int i;
56 57
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 85bf795abdcc..7c0d60910077 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -59,6 +59,19 @@ struct cmos_rtc {
59 59
60static const char driver_name[] = "rtc_cmos"; 60static const char driver_name[] = "rtc_cmos";
61 61
62/* The RTC_INTR register may have e.g. RTC_PF set even if RTC_PIE is clear;
63 * always mask it against the irq enable bits in RTC_CONTROL. Bit values
64 * are the same: PF==PIE, AF=AIE, UF=UIE; so RTC_IRQMASK works with both.
65 */
66#define RTC_IRQMASK (RTC_PF | RTC_AF | RTC_UF)
67
68static inline int is_intr(u8 rtc_intr)
69{
70 if (!(rtc_intr & RTC_IRQF))
71 return 0;
72 return rtc_intr & RTC_IRQMASK;
73}
74
62/*----------------------------------------------------------------*/ 75/*----------------------------------------------------------------*/
63 76
64static int cmos_read_time(struct device *dev, struct rtc_time *t) 77static int cmos_read_time(struct device *dev, struct rtc_time *t)
@@ -188,7 +201,8 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
188 rtc_control &= ~RTC_AIE; 201 rtc_control &= ~RTC_AIE;
189 CMOS_WRITE(rtc_control, RTC_CONTROL); 202 CMOS_WRITE(rtc_control, RTC_CONTROL);
190 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 203 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
191 if (rtc_intr) 204 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
205 if (is_intr(rtc_intr))
192 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 206 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
193 207
194 /* update alarm */ 208 /* update alarm */
@@ -207,7 +221,8 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
207 rtc_control |= RTC_AIE; 221 rtc_control |= RTC_AIE;
208 CMOS_WRITE(rtc_control, RTC_CONTROL); 222 CMOS_WRITE(rtc_control, RTC_CONTROL);
209 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 223 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
210 if (rtc_intr) 224 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
225 if (is_intr(rtc_intr))
211 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 226 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
212 } 227 }
213 228
@@ -287,7 +302,8 @@ cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
287 } 302 }
288 CMOS_WRITE(rtc_control, RTC_CONTROL); 303 CMOS_WRITE(rtc_control, RTC_CONTROL);
289 rtc_intr = CMOS_READ(RTC_INTR_FLAGS); 304 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
290 if (rtc_intr) 305 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
306 if (is_intr(rtc_intr))
291 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr); 307 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
292 spin_unlock_irqrestore(&rtc_lock, flags); 308 spin_unlock_irqrestore(&rtc_lock, flags);
293 return 0; 309 return 0;
@@ -353,12 +369,10 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
353 369
354 spin_lock(&rtc_lock); 370 spin_lock(&rtc_lock);
355 irqstat = CMOS_READ(RTC_INTR_FLAGS); 371 irqstat = CMOS_READ(RTC_INTR_FLAGS);
372 irqstat &= (CMOS_READ(RTC_CONTROL) & RTC_IRQMASK) | RTC_IRQF;
356 spin_unlock(&rtc_lock); 373 spin_unlock(&rtc_lock);
357 374
358 if (irqstat) { 375 if (is_intr(irqstat)) {
359 /* NOTE: irqstat may have e.g. RTC_PF set
360 * even when RTC_PIE is clear...
361 */
362 rtc_update_irq(p, 1, irqstat); 376 rtc_update_irq(p, 1, irqstat);
363 return IRQ_HANDLED; 377 return IRQ_HANDLED;
364 } else 378 } else
@@ -525,25 +539,26 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
525{ 539{
526 struct cmos_rtc *cmos = dev_get_drvdata(dev); 540 struct cmos_rtc *cmos = dev_get_drvdata(dev);
527 int do_wake = device_may_wakeup(dev); 541 int do_wake = device_may_wakeup(dev);
528 unsigned char tmp, irqstat; 542 unsigned char tmp;
529 543
530 /* only the alarm might be a wakeup event source */ 544 /* only the alarm might be a wakeup event source */
531 spin_lock_irq(&rtc_lock); 545 spin_lock_irq(&rtc_lock);
532 cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL); 546 cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL);
533 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { 547 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
548 unsigned char irqstat;
549
534 if (do_wake) 550 if (do_wake)
535 tmp &= ~(RTC_PIE|RTC_UIE); 551 tmp &= ~(RTC_PIE|RTC_UIE);
536 else 552 else
537 tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE); 553 tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
538 CMOS_WRITE(tmp, RTC_CONTROL); 554 CMOS_WRITE(tmp, RTC_CONTROL);
539 irqstat = CMOS_READ(RTC_INTR_FLAGS); 555 irqstat = CMOS_READ(RTC_INTR_FLAGS);
540 } else 556 irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF;
541 irqstat = 0; 557 if (is_intr(irqstat))
558 rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat);
559 }
542 spin_unlock_irq(&rtc_lock); 560 spin_unlock_irq(&rtc_lock);
543 561
544 if (irqstat)
545 rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat);
546
547 /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE) 562 /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE)
548 * ... it'd be best if we could do that under rtc_lock. 563 * ... it'd be best if we could do that under rtc_lock.
549 */ 564 */
@@ -573,9 +588,10 @@ static int cmos_resume(struct device *dev)
573 spin_lock_irq(&rtc_lock); 588 spin_lock_irq(&rtc_lock);
574 CMOS_WRITE(tmp, RTC_CONTROL); 589 CMOS_WRITE(tmp, RTC_CONTROL);
575 tmp = CMOS_READ(RTC_INTR_FLAGS); 590 tmp = CMOS_READ(RTC_INTR_FLAGS);
576 spin_unlock_irq(&rtc_lock); 591 tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF;
577 if (tmp) 592 if (is_intr(tmp))
578 rtc_update_irq(&cmos->rtc->class_dev, 1, tmp); 593 rtc_update_irq(&cmos->rtc->class_dev, 1, tmp);
594 spin_unlock_irq(&rtc_lock);
579 } 595 }
580 596
581 pr_debug("%s: resume, ctrl %02x\n", 597 pr_debug("%s: resume, ctrl %02x\n",
@@ -594,7 +610,7 @@ static int cmos_resume(struct device *dev)
594/*----------------------------------------------------------------*/ 610/*----------------------------------------------------------------*/
595 611
596/* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems, 612/* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems,
597 * the device node may alternatively be created as a PNP device. 613 * the device node will always be created as a PNPACPI device.
598 */ 614 */
599 615
600#ifdef CONFIG_PNPACPI 616#ifdef CONFIG_PNPACPI
@@ -673,7 +689,7 @@ module_exit(cmos_exit);
673/*----------------------------------------------------------------*/ 689/*----------------------------------------------------------------*/
674 690
675/* Platform setup should have set up an RTC device, when PNPACPI is 691/* Platform setup should have set up an RTC device, when PNPACPI is
676 * unavailable ... this is the normal case, common even on PCs. 692 * unavailable ... this could happen even on (older) PCs.
677 */ 693 */
678 694
679static int __init cmos_platform_probe(struct platform_device *pdev) 695static int __init cmos_platform_probe(struct platform_device *pdev)
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index ab782bb46ac1..e810e4a44ed4 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -65,7 +65,7 @@ static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
65 * resulting condition code and DIAG return code. */ 65 * resulting condition code and DIAG return code. */
66static inline int dia250(void *iob, int cmd) 66static inline int dia250(void *iob, int cmd)
67{ 67{
68 register unsigned long reg0 asm ("0") = (unsigned long) iob; 68 register unsigned long reg2 asm ("2") = (unsigned long) iob;
69 typedef union { 69 typedef union {
70 struct dasd_diag_init_io init_io; 70 struct dasd_diag_init_io init_io;
71 struct dasd_diag_rw_io rw_io; 71 struct dasd_diag_rw_io rw_io;
@@ -74,15 +74,15 @@ static inline int dia250(void *iob, int cmd)
74 74
75 rc = 3; 75 rc = 3;
76 asm volatile( 76 asm volatile(
77 " diag 0,%2,0x250\n" 77 " diag 2,%2,0x250\n"
78 "0: ipm %0\n" 78 "0: ipm %0\n"
79 " srl %0,28\n" 79 " srl %0,28\n"
80 " or %0,1\n" 80 " or %0,3\n"
81 "1:\n" 81 "1:\n"
82 EX_TABLE(0b,1b) 82 EX_TABLE(0b,1b)
83 : "+d" (rc), "=m" (*(addr_type *) iob) 83 : "+d" (rc), "=m" (*(addr_type *) iob)
84 : "d" (cmd), "d" (reg0), "m" (*(addr_type *) iob) 84 : "d" (cmd), "d" (reg2), "m" (*(addr_type *) iob)
85 : "1", "cc"); 85 : "3", "cc");
86 return rc; 86 return rc;
87} 87}
88 88
diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c
index 6b1caea622ea..aa96e6752592 100644
--- a/drivers/s390/cio/device_status.c
+++ b/drivers/s390/cio/device_status.c
@@ -221,6 +221,14 @@ ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb)
221 221
222 cdev_irb = &cdev->private->irb; 222 cdev_irb = &cdev->private->irb;
223 223
224 /*
225 * If the clear function had been performed, all formerly pending
226 * status at the subchannel has been cleared and we must not pass
227 * intermediate accumulated status to the device driver.
228 */
229 if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC)
230 memset(&cdev->private->irb, 0, sizeof(struct irb));
231
224 /* Copy bits which are valid only for the start function. */ 232 /* Copy bits which are valid only for the start function. */
225 if (irb->scsw.fctl & SCSW_FCTL_START_FUNC) { 233 if (irb->scsw.fctl & SCSW_FCTL_START_FUNC) {
226 /* Copy key. */ 234 /* Copy key. */
@@ -263,7 +271,11 @@ ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb)
263 cdev_irb->scsw.cpa = irb->scsw.cpa; 271 cdev_irb->scsw.cpa = irb->scsw.cpa;
264 /* Accumulate device status, but not the device busy flag. */ 272 /* Accumulate device status, but not the device busy flag. */
265 cdev_irb->scsw.dstat &= ~DEV_STAT_BUSY; 273 cdev_irb->scsw.dstat &= ~DEV_STAT_BUSY;
266 cdev_irb->scsw.dstat |= irb->scsw.dstat; 274 /* dstat is not always valid. */
275 if (irb->scsw.stctl &
276 (SCSW_STCTL_PRIM_STATUS | SCSW_STCTL_SEC_STATUS
277 | SCSW_STCTL_INTER_STATUS | SCSW_STCTL_ALERT_STATUS))
278 cdev_irb->scsw.dstat |= irb->scsw.dstat;
267 /* Accumulate subchannel status. */ 279 /* Accumulate subchannel status. */
268 cdev_irb->scsw.cstat |= irb->scsw.cstat; 280 cdev_irb->scsw.cstat |= irb->scsw.cstat;
269 /* Copy residual count if it is valid. */ 281 /* Copy residual count if it is valid. */
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 181b51772b1b..bf37cdf43fae 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -505,6 +505,9 @@ static int ap_device_remove(struct device *dev)
505 spin_lock_bh(&ap_device_lock); 505 spin_lock_bh(&ap_device_lock);
506 list_del_init(&ap_dev->list); 506 list_del_init(&ap_dev->list);
507 spin_unlock_bh(&ap_device_lock); 507 spin_unlock_bh(&ap_device_lock);
508 spin_lock_bh(&ap_dev->lock);
509 atomic_sub(ap_dev->queue_count, &ap_poll_requests);
510 spin_unlock_bh(&ap_dev->lock);
508 return 0; 511 return 0;
509} 512}
510 513
@@ -757,10 +760,16 @@ static void ap_scan_bus(struct work_struct *unused)
757 (void *)(unsigned long)qid, 760 (void *)(unsigned long)qid,
758 __ap_scan_bus); 761 __ap_scan_bus);
759 rc = ap_query_queue(qid, &queue_depth, &device_type); 762 rc = ap_query_queue(qid, &queue_depth, &device_type);
760 if (dev && rc) { 763 if (dev) {
761 put_device(dev); 764 ap_dev = to_ap_dev(dev);
762 device_unregister(dev); 765 spin_lock_bh(&ap_dev->lock);
763 continue; 766 if (rc || ap_dev->unregistered) {
767 spin_unlock_bh(&ap_dev->lock);
768 put_device(dev);
769 device_unregister(dev);
770 continue;
771 } else
772 spin_unlock_bh(&ap_dev->lock);
764 } 773 }
765 if (dev) { 774 if (dev) {
766 put_device(dev); 775 put_device(dev);
@@ -861,6 +870,7 @@ static int ap_poll_read(struct ap_device *ap_dev, unsigned long *flags)
861 case AP_RESPONSE_NO_PENDING_REPLY: 870 case AP_RESPONSE_NO_PENDING_REPLY:
862 if (status.queue_empty) { 871 if (status.queue_empty) {
863 /* The card shouldn't forget requests but who knows. */ 872 /* The card shouldn't forget requests but who knows. */
873 atomic_sub(ap_dev->queue_count, &ap_poll_requests);
864 ap_dev->queue_count = 0; 874 ap_dev->queue_count = 0;
865 list_splice_init(&ap_dev->pendingq, &ap_dev->requestq); 875 list_splice_init(&ap_dev->pendingq, &ap_dev->requestq);
866 ap_dev->requestq_count += ap_dev->pendingq_count; 876 ap_dev->requestq_count += ap_dev->pendingq_count;
@@ -994,7 +1004,7 @@ void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg)
994 ap_dev->unregistered = 1; 1004 ap_dev->unregistered = 1;
995 } else { 1005 } else {
996 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); 1006 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
997 rc = 0; 1007 rc = -ENODEV;
998 } 1008 }
999 spin_unlock_bh(&ap_dev->lock); 1009 spin_unlock_bh(&ap_dev->lock);
1000 if (rc == -ENODEV) 1010 if (rc == -ENODEV)
@@ -1044,18 +1054,12 @@ static void ap_poll_timeout(unsigned long unused)
1044 */ 1054 */
1045static int __ap_poll_all(struct ap_device *ap_dev, unsigned long *flags) 1055static int __ap_poll_all(struct ap_device *ap_dev, unsigned long *flags)
1046{ 1056{
1047 int rc;
1048
1049 spin_lock(&ap_dev->lock); 1057 spin_lock(&ap_dev->lock);
1050 if (!ap_dev->unregistered) { 1058 if (!ap_dev->unregistered) {
1051 rc = ap_poll_queue(ap_dev, flags); 1059 if (ap_poll_queue(ap_dev, flags))
1052 if (rc)
1053 ap_dev->unregistered = 1; 1060 ap_dev->unregistered = 1;
1054 } else 1061 }
1055 rc = 0;
1056 spin_unlock(&ap_dev->lock); 1062 spin_unlock(&ap_dev->lock);
1057 if (rc)
1058 device_unregister(&ap_dev->device);
1059 return 0; 1063 return 0;
1060} 1064}
1061 1065
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index eec28c142a59..5041c9dfbe3b 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -249,7 +249,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
249#ifdef CONFIG_PCI 249#ifdef CONFIG_PCI
250 struct pci_dev *pdev; 250 struct pci_dev *pdev;
251 struct pcidev_cookie *pcp; 251 struct pcidev_cookie *pcp;
252 pdev = pci_find_slot (((int *) op->oprom_array)[0], 252 pdev = pci_get_bus_and_slot (((int *) op->oprom_array)[0],
253 ((int *) op->oprom_array)[1]); 253 ((int *) op->oprom_array)[1]);
254 254
255 pcp = pdev->sysdata; 255 pcp = pdev->sysdata;
@@ -260,6 +260,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
260 op->oprom_size = sizeof(int); 260 op->oprom_size = sizeof(int);
261 err = copyout(argp, op, bufsize + sizeof(int)); 261 err = copyout(argp, op, bufsize + sizeof(int));
262 } 262 }
263 pci_dev_put(pdev);
263#endif 264#endif
264 } 265 }
265 266
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
index 8bfb67ccdcd4..c3135e2fbd5a 100644
--- a/drivers/sbus/char/vfc_dev.c
+++ b/drivers/sbus/char/vfc_dev.c
@@ -259,11 +259,10 @@ static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
259 if (copy_from_user(&inout, argp, sizeof(inout))) 259 if (copy_from_user(&inout, argp, sizeof(inout)))
260 return -EFAULT; 260 return -EFAULT;
261 261
262 buffer = kmalloc(inout.len, GFP_KERNEL); 262 buffer = kzalloc(inout.len, GFP_KERNEL);
263 if (buffer == NULL) 263 if (buffer == NULL)
264 return -ENOMEM; 264 return -ENOMEM;
265 265
266 memset(buffer,0,inout.len);
267 vfc_lock_device(dev); 266 vfc_lock_device(dev);
268 inout.ret= 267 inout.ret=
269 vfc_i2c_recvbuf(dev,inout.addr & 0xff 268 vfc_i2c_recvbuf(dev,inout.addr & 0xff
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index bf5d63e1beee..656bdb1352d8 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1864,10 +1864,17 @@ static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id)
1864/* This function will handle the request sense scsi command */ 1864/* This function will handle the request sense scsi command */
1865static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id) 1865static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)
1866{ 1866{
1867 char request_buffer[18];
1868
1867 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n"); 1869 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");
1868 1870
1869 /* For now we just zero the request buffer */ 1871 memset(request_buffer, 0, sizeof(request_buffer));
1870 memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen); 1872 request_buffer[0] = 0x70; /* Immediate fixed format */
1873 request_buffer[7] = 10; /* minimum size per SPC: 18 bytes */
1874 /* leave all other fields zero, giving effectively NO_SENSE return */
1875 tw_transfer_internal(tw_dev, request_id, request_buffer,
1876 sizeof(request_buffer));
1877
1871 tw_dev->state[request_id] = TW_S_COMPLETED; 1878 tw_dev->state[request_id] = TW_S_COMPLETED;
1872 tw_state_request_finish(tw_dev, request_id); 1879 tw_state_request_finish(tw_dev, request_id);
1873 1880
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 8c81cec85298..60446b88f721 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3091,6 +3091,7 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
3091 cmdp->u.raw64.direction = 3091 cmdp->u.raw64.direction =
3092 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; 3092 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN;
3093 memcpy(cmdp->u.raw64.cmd,scp->cmnd,16); 3093 memcpy(cmdp->u.raw64.cmd,scp->cmnd,16);
3094 cmdp->u.raw64.sg_ranz = 0;
3094 } else { 3095 } else {
3095 cmdp->u.raw.reserved = 0; 3096 cmdp->u.raw.reserved = 0;
3096 cmdp->u.raw.mdisc_time = 0; 3097 cmdp->u.raw.mdisc_time = 0;
@@ -3107,6 +3108,7 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
3107 cmdp->u.raw.direction = 3108 cmdp->u.raw.direction =
3108 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; 3109 gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN;
3109 memcpy(cmdp->u.raw.cmd,scp->cmnd,12); 3110 memcpy(cmdp->u.raw.cmd,scp->cmnd,12);
3111 cmdp->u.raw.sg_ranz = 0;
3110 } 3112 }
3111 3113
3112 if (scp->use_sg) { 3114 if (scp->use_sg) {
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 9d014e5a81c4..057fd7e0e379 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1817,10 +1817,9 @@ static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev,
1817 struct lpfc_sli *psli = &phba->sli; 1817 struct lpfc_sli *psli = &phba->sli;
1818 struct lpfc_sli_ring *pring; 1818 struct lpfc_sli_ring *pring;
1819 1819
1820 if (state == pci_channel_io_perm_failure) { 1820 if (state == pci_channel_io_perm_failure)
1821 lpfc_pci_remove_one(pdev);
1822 return PCI_ERS_RESULT_DISCONNECT; 1821 return PCI_ERS_RESULT_DISCONNECT;
1823 } 1822
1824 pci_disable_device(pdev); 1823 pci_disable_device(pdev);
1825 /* 1824 /*
1826 * There may be I/Os dropped by the firmware. 1825 * There may be I/Os dropped by the firmware.
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 9b827ceec501..9f10689905a8 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1281,7 +1281,7 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti)
1281 (struct scatterlist *)Cmnd->request_buffer, 1281 (struct scatterlist *)Cmnd->request_buffer,
1282 Cmnd->use_sg, 1282 Cmnd->use_sg,
1283 Cmnd->sc_data_direction); 1283 Cmnd->sc_data_direction);
1284 } else { 1284 } else if (Cmnd->request_bufflen) {
1285 sbus_unmap_single(qpti->sdev, 1285 sbus_unmap_single(qpti->sdev,
1286 (__u32)((unsigned long)Cmnd->SCp.ptr), 1286 (__u32)((unsigned long)Cmnd->SCp.ptr),
1287 Cmnd->request_bufflen, 1287 Cmnd->request_bufflen,
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index b8edcf5b5451..918bb6019540 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -716,7 +716,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
716 */ 716 */
717 if (copy_sense) { 717 if (copy_sense) {
718 if (!SCSI_SENSE_VALID(scmd)) { 718 if (!SCSI_SENSE_VALID(scmd)) {
719 memcpy(scmd->sense_buffer, scmd->request_buffer, 719 memcpy(scmd->sense_buffer, page_address(sgl.page),
720 sizeof(scmd->sense_buffer)); 720 sizeof(scmd->sense_buffer));
721 } 721 }
722 __free_page(sgl.page); 722 __free_page(sgl.page);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index c129a0e8e807..90621c3312bc 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1310,7 +1310,8 @@ static unsigned int check_modem_status(struct uart_8250_port *up)
1310{ 1310{
1311 unsigned int status = serial_in(up, UART_MSR); 1311 unsigned int status = serial_in(up, UART_MSR);
1312 1312
1313 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI) { 1313 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI &&
1314 up->port.info != NULL) {
1314 if (status & UART_MSR_TERI) 1315 if (status & UART_MSR_TERI)
1315 up->port.icount.rng++; 1316 up->port.icount.rng++;
1316 if (status & UART_MSR_DDSR) 1317 if (status & UART_MSR_DDSR)
@@ -1333,8 +1334,9 @@ static inline void
1333serial8250_handle_port(struct uart_8250_port *up) 1334serial8250_handle_port(struct uart_8250_port *up)
1334{ 1335{
1335 unsigned int status; 1336 unsigned int status;
1337 unsigned long flags;
1336 1338
1337 spin_lock(&up->port.lock); 1339 spin_lock_irqsave(&up->port.lock, flags);
1338 1340
1339 status = serial_inp(up, UART_LSR); 1341 status = serial_inp(up, UART_LSR);
1340 1342
@@ -1346,7 +1348,7 @@ serial8250_handle_port(struct uart_8250_port *up)
1346 if (status & UART_LSR_THRE) 1348 if (status & UART_LSR_THRE)
1347 transmit_chars(up); 1349 transmit_chars(up);
1348 1350
1349 spin_unlock(&up->port.lock); 1351 spin_unlock_irqrestore(&up->port.lock, flags);
1350} 1352}
1351 1353
1352/* 1354/*
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 41431d0d5512..246c5572667b 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -164,7 +164,7 @@ static void free_port_memory(struct icom_port *icom_port)
164 } 164 }
165} 165}
166 166
167static int __init get_port_memory(struct icom_port *icom_port) 167static int __devinit get_port_memory(struct icom_port *icom_port)
168{ 168{
169 int index; 169 int index;
170 unsigned long stgAddr; 170 unsigned long stgAddr;
@@ -1380,7 +1380,7 @@ static void icom_port_active(struct icom_port *icom_port, struct icom_adapter *i
1380 0x8024 + 2 - 2 * (icom_port->port - 2); 1380 0x8024 + 2 - 2 * (icom_port->port - 2);
1381 } 1381 }
1382} 1382}
1383static int __init icom_load_ports(struct icom_adapter *icom_adapter) 1383static int __devinit icom_load_ports(struct icom_adapter *icom_adapter)
1384{ 1384{
1385 struct icom_port *icom_port; 1385 struct icom_port *icom_port;
1386 int port_num; 1386 int port_num;
@@ -1473,7 +1473,7 @@ static void icom_remove_adapter(struct icom_adapter *icom_adapter)
1473 } 1473 }
1474 } 1474 }
1475 1475
1476 free_irq(icom_adapter->irq_number, (void *) icom_adapter); 1476 free_irq(icom_adapter->pci_dev->irq, (void *) icom_adapter);
1477 iounmap(icom_adapter->base_addr); 1477 iounmap(icom_adapter->base_addr);
1478 icom_free_adapter(icom_adapter); 1478 icom_free_adapter(icom_adapter);
1479 pci_release_regions(icom_adapter->pci_dev); 1479 pci_release_regions(icom_adapter->pci_dev);
@@ -1539,7 +1539,6 @@ static int __devinit icom_probe(struct pci_dev *dev,
1539 } 1539 }
1540 1540
1541 icom_adapter->base_addr_pci = pci_resource_start(dev, 0); 1541 icom_adapter->base_addr_pci = pci_resource_start(dev, 0);
1542 icom_adapter->irq_number = dev->irq;
1543 icom_adapter->pci_dev = dev; 1542 icom_adapter->pci_dev = dev;
1544 icom_adapter->version = ent->driver_data; 1543 icom_adapter->version = ent->driver_data;
1545 icom_adapter->subsystem_id = ent->subdevice; 1544 icom_adapter->subsystem_id = ent->subdevice;
@@ -1570,7 +1569,7 @@ static int __devinit icom_probe(struct pci_dev *dev,
1570 icom_port = &icom_adapter->port_info[index]; 1569 icom_port = &icom_adapter->port_info[index];
1571 1570
1572 if (icom_port->status == ICOM_PORT_ACTIVE) { 1571 if (icom_port->status == ICOM_PORT_ACTIVE) {
1573 icom_port->uart_port.irq = icom_port->adapter->irq_number; 1572 icom_port->uart_port.irq = icom_port->adapter->pci_dev->irq;
1574 icom_port->uart_port.type = PORT_ICOM; 1573 icom_port->uart_port.type = PORT_ICOM;
1575 icom_port->uart_port.iotype = UPIO_MEM; 1574 icom_port->uart_port.iotype = UPIO_MEM;
1576 icom_port->uart_port.membase = 1575 icom_port->uart_port.membase =
diff --git a/drivers/serial/icom.h b/drivers/serial/icom.h
index 798f1ef23712..e8578d8cd35e 100644
--- a/drivers/serial/icom.h
+++ b/drivers/serial/icom.h
@@ -258,7 +258,6 @@ struct icom_port {
258struct icom_adapter { 258struct icom_adapter {
259 void __iomem * base_addr; 259 void __iomem * base_addr;
260 unsigned long base_addr_pci; 260 unsigned long base_addr_pci;
261 unsigned char irq_number;
262 struct pci_dev *pci_dev; 261 struct pci_dev *pci_dev;
263 struct icom_port port_info[4]; 262 struct icom_port port_info[4];
264 int index; 263 int index;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 2328128728be..6657331eed93 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -189,8 +189,8 @@ static DECLARE_MUTEX(board_lock);
189 * this is exported so that for example a USB or parport based adapter 189 * this is exported so that for example a USB or parport based adapter
190 * driver could add devices (which it would learn about out-of-band). 190 * driver could add devices (which it would learn about out-of-band).
191 */ 191 */
192struct spi_device *__init_or_module 192struct spi_device *spi_new_device(struct spi_master *master,
193spi_new_device(struct spi_master *master, struct spi_board_info *chip) 193 struct spi_board_info *chip)
194{ 194{
195 struct spi_device *proxy; 195 struct spi_device *proxy;
196 struct device *dev = master->cdev.dev; 196 struct device *dev = master->cdev.dev;
@@ -352,8 +352,7 @@ static struct class spi_master_class = {
352 * the master's methods before calling spi_register_master(); and (after errors 352 * the master's methods before calling spi_register_master(); and (after errors
353 * adding the device) calling spi_master_put() to prevent a memory leak. 353 * adding the device) calling spi_master_put() to prevent a memory leak.
354 */ 354 */
355struct spi_master * __init_or_module 355struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
356spi_alloc_master(struct device *dev, unsigned size)
357{ 356{
358 struct spi_master *master; 357 struct spi_master *master;
359 358
@@ -392,8 +391,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
392 * After a successful return, the caller is responsible for calling 391 * After a successful return, the caller is responsible for calling
393 * spi_unregister_master(). 392 * spi_unregister_master().
394 */ 393 */
395int __init_or_module 394int spi_register_master(struct spi_master *master)
396spi_register_master(struct spi_master *master)
397{ 395{
398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1); 396 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
399 struct device *dev = master->cdev.dev; 397 struct device *dev = master->cdev.dev;
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 220abce63e4a..b10211c420ef 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -77,7 +77,7 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
77 77
78 switch (value) { 78 switch (value) {
79 case BITBANG_CS_INACTIVE: 79 case BITBANG_CS_INACTIVE:
80 hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol^1); 80 hw->set_cs(hw->pdata, spi->chip_select, cspol^1);
81 break; 81 break;
82 82
83 case BITBANG_CS_ACTIVE: 83 case BITBANG_CS_ACTIVE:
@@ -98,7 +98,7 @@ static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
98 /* write new configration */ 98 /* write new configration */
99 99
100 writeb(spcon, hw->regs + S3C2410_SPCON); 100 writeb(spcon, hw->regs + S3C2410_SPCON);
101 hw->pdata->set_cs(hw->pdata, spi->chip_select, cspol); 101 hw->set_cs(hw->pdata, spi->chip_select, cspol);
102 102
103 break; 103 break;
104 } 104 }
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 3d72aa5cfc71..3524e3fc08b9 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -70,7 +70,6 @@
70#include <asm/dec/machtype.h> 70#include <asm/dec/machtype.h>
71#include <asm/dec/serial.h> 71#include <asm/dec/serial.h>
72#include <asm/dec/system.h> 72#include <asm/dec/system.h>
73#include <asm/dec/tc.h>
74 73
75#ifdef CONFIG_KGDB 74#ifdef CONFIG_KGDB
76#include <asm/kgdb.h> 75#include <asm/kgdb.h>
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 0e5c646cb4f6..f08ec85a6d64 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -30,7 +30,8 @@
30static const struct usb_device_id usb_quirk_list[] = { 30static const struct usb_device_id usb_quirk_list[] = {
31 /* HP 5300/5370C scanner */ 31 /* HP 5300/5370C scanner */
32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, 32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
33 33 /* Seiko Epson Corp - Perfection 1670 */
34 { USB_DEVICE(0x04b8, 0x011f), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
34 /* Elsa MicroLink 56k (V.250) */ 35 /* Elsa MicroLink 56k (V.250) */
35 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 36 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
36 37
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 8f9a2b615422..b394e63894d2 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -296,6 +296,15 @@ omap_free_request(struct usb_ep *ep, struct usb_request *_req)
296 296
297/*-------------------------------------------------------------------------*/ 297/*-------------------------------------------------------------------------*/
298 298
299/*
300 * dma-coherent memory allocation (for dma-capable endpoints)
301 *
302 * NOTE: the dma_*_coherent() API calls suck. Most implementations are
303 * (a) page-oriented, so small buffers lose big; and (b) asymmetric with
304 * respect to calls with irqs disabled: alloc is safe, free is not.
305 * We currently work around (b), but not (a).
306 */
307
299static void * 308static void *
300omap_alloc_buffer( 309omap_alloc_buffer(
301 struct usb_ep *_ep, 310 struct usb_ep *_ep,
@@ -307,6 +316,9 @@ omap_alloc_buffer(
307 void *retval; 316 void *retval;
308 struct omap_ep *ep; 317 struct omap_ep *ep;
309 318
319 if (!_ep)
320 return NULL;
321
310 ep = container_of(_ep, struct omap_ep, ep); 322 ep = container_of(_ep, struct omap_ep, ep);
311 if (use_dma && ep->has_dma) { 323 if (use_dma && ep->has_dma) {
312 static int warned; 324 static int warned;
@@ -326,6 +338,35 @@ omap_alloc_buffer(
326 return retval; 338 return retval;
327} 339}
328 340
341static DEFINE_SPINLOCK(buflock);
342static LIST_HEAD(buffers);
343
344struct free_record {
345 struct list_head list;
346 struct device *dev;
347 unsigned bytes;
348 dma_addr_t dma;
349};
350
351static void do_free(unsigned long ignored)
352{
353 spin_lock_irq(&buflock);
354 while (!list_empty(&buffers)) {
355 struct free_record *buf;
356
357 buf = list_entry(buffers.next, struct free_record, list);
358 list_del(&buf->list);
359 spin_unlock_irq(&buflock);
360
361 dma_free_coherent(buf->dev, buf->bytes, buf, buf->dma);
362
363 spin_lock_irq(&buflock);
364 }
365 spin_unlock_irq(&buflock);
366}
367
368static DECLARE_TASKLET(deferred_free, do_free, 0);
369
329static void omap_free_buffer( 370static void omap_free_buffer(
330 struct usb_ep *_ep, 371 struct usb_ep *_ep,
331 void *buf, 372 void *buf,
@@ -333,13 +374,29 @@ static void omap_free_buffer(
333 unsigned bytes 374 unsigned bytes
334) 375)
335{ 376{
336 struct omap_ep *ep; 377 if (!_ep) {
378 WARN_ON(1);
379 return;
380 }
337 381
338 ep = container_of(_ep, struct omap_ep, ep); 382 /* free memory into the right allocator */
339 if (use_dma && _ep && ep->has_dma) 383 if (dma != DMA_ADDR_INVALID) {
340 dma_free_coherent(ep->udc->gadget.dev.parent, bytes, buf, dma); 384 struct omap_ep *ep;
341 else 385 struct free_record *rec = buf;
342 kfree (buf); 386 unsigned long flags;
387
388 ep = container_of(_ep, struct omap_ep, ep);
389
390 rec->dev = ep->udc->gadget.dev.parent;
391 rec->bytes = bytes;
392 rec->dma = dma;
393
394 spin_lock_irqsave(&buflock, flags);
395 list_add_tail(&rec->list, &buffers);
396 tasklet_schedule(&deferred_free);
397 spin_unlock_irqrestore(&buflock, flags);
398 } else
399 kfree(buf);
343} 400}
344 401
345/*-------------------------------------------------------------------------*/ 402/*-------------------------------------------------------------------------*/
@@ -1691,12 +1748,38 @@ ep0out_status_stage:
1691 udc->ep0_pending = 0; 1748 udc->ep0_pending = 0;
1692 break; 1749 break;
1693 case USB_REQ_GET_STATUS: 1750 case USB_REQ_GET_STATUS:
1751 /* USB_ENDPOINT_HALT status? */
1752 if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
1753 goto intf_status;
1754
1755 /* ep0 never stalls */
1756 if (!(w_index & 0xf))
1757 goto zero_status;
1758
1759 /* only active endpoints count */
1760 ep = &udc->ep[w_index & 0xf];
1761 if (w_index & USB_DIR_IN)
1762 ep += 16;
1763 if (!ep->desc)
1764 goto do_stall;
1765
1766 /* iso never stalls */
1767 if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC)
1768 goto zero_status;
1769
1770 /* FIXME don't assume non-halted endpoints!! */
1771 ERR("%s status, can't report\n", ep->ep.name);
1772 goto do_stall;
1773
1774intf_status:
1694 /* return interface status. if we were pedantic, 1775 /* return interface status. if we were pedantic,
1695 * we'd detect non-existent interfaces, and stall. 1776 * we'd detect non-existent interfaces, and stall.
1696 */ 1777 */
1697 if (u.r.bRequestType 1778 if (u.r.bRequestType
1698 != (USB_DIR_IN|USB_RECIP_INTERFACE)) 1779 != (USB_DIR_IN|USB_RECIP_INTERFACE))
1699 goto delegate; 1780 goto delegate;
1781
1782zero_status:
1700 /* return two zero bytes */ 1783 /* return two zero bytes */
1701 UDC_EP_NUM_REG = UDC_EP_SEL|UDC_EP_DIR; 1784 UDC_EP_NUM_REG = UDC_EP_SEL|UDC_EP_DIR;
1702 UDC_DATA_REG = 0; 1785 UDC_DATA_REG = 0;
@@ -2068,7 +2151,7 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev)
2068 2151
2069/*-------------------------------------------------------------------------*/ 2152/*-------------------------------------------------------------------------*/
2070 2153
2071static inline int machine_needs_vbus_session(void) 2154static inline int machine_without_vbus_sense(void)
2072{ 2155{
2073 return (machine_is_omap_innovator() 2156 return (machine_is_omap_innovator()
2074 || machine_is_omap_osk() 2157 || machine_is_omap_osk()
@@ -2156,7 +2239,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2156 /* boards that don't have VBUS sensing can't autogate 48MHz; 2239 /* boards that don't have VBUS sensing can't autogate 48MHz;
2157 * can't enter deep sleep while a gadget driver is active. 2240 * can't enter deep sleep while a gadget driver is active.
2158 */ 2241 */
2159 if (machine_needs_vbus_session()) 2242 if (machine_without_vbus_sense())
2160 omap_vbus_session(&udc->gadget, 1); 2243 omap_vbus_session(&udc->gadget, 1);
2161 2244
2162done: 2245done:
@@ -2179,7 +2262,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
2179 if (udc->dc_clk != NULL) 2262 if (udc->dc_clk != NULL)
2180 omap_udc_enable_clock(1); 2263 omap_udc_enable_clock(1);
2181 2264
2182 if (machine_needs_vbus_session()) 2265 if (machine_without_vbus_sense())
2183 omap_vbus_session(&udc->gadget, 0); 2266 omap_vbus_session(&udc->gadget, 0);
2184 2267
2185 if (udc->transceiver) 2268 if (udc->transceiver)
@@ -2822,7 +2905,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
2822 hmc = HMC_1510; 2905 hmc = HMC_1510;
2823 type = "(unknown)"; 2906 type = "(unknown)";
2824 2907
2825 if (machine_is_omap_innovator() || machine_is_sx1()) { 2908 if (machine_without_vbus_sense()) {
2826 /* just set up software VBUS detect, and then 2909 /* just set up software VBUS detect, and then
2827 * later rig it so we always report VBUS. 2910 * later rig it so we always report VBUS.
2828 * FIXME without really sensing VBUS, we can't 2911 * FIXME without really sensing VBUS, we can't
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index a74056488234..c7458f7e56cc 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -669,6 +669,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
669 */ 669 */
670 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 670 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
671 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 671 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
672 mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
672 } 673 }
673 } 674 }
674 675
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 8d24d3dc0a61..1497371583b9 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -145,7 +145,8 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space)
145 return out - buf; 145 return out - buf;
146} 146}
147 147
148static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) 148static int uhci_show_qh(struct uhci_hcd *uhci,
149 struct uhci_qh *qh, char *buf, int len, int space)
149{ 150{
150 char *out = buf; 151 char *out = buf;
151 int i, nurbs; 152 int i, nurbs;
@@ -190,6 +191,9 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space)
190 191
191 if (list_empty(&qh->queue)) { 192 if (list_empty(&qh->queue)) {
192 out += sprintf(out, "%*s queue is empty\n", space, ""); 193 out += sprintf(out, "%*s queue is empty\n", space, "");
194 if (qh == uhci->skel_async_qh)
195 out += uhci_show_td(uhci->term_td, out,
196 len - (out - buf), 0);
193 } else { 197 } else {
194 struct urb_priv *urbp = list_entry(qh->queue.next, 198 struct urb_priv *urbp = list_entry(qh->queue.next,
195 struct urb_priv, node); 199 struct urb_priv, node);
@@ -343,6 +347,7 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
343 struct list_head *tmp, *head; 347 struct list_head *tmp, *head;
344 int nframes, nerrs; 348 int nframes, nerrs;
345 __le32 link; 349 __le32 link;
350 __le32 fsbr_link;
346 351
347 static const char * const qh_names[] = { 352 static const char * const qh_names[] = {
348 "unlink", "iso", "int128", "int64", "int32", "int16", 353 "unlink", "iso", "int128", "int64", "int32", "int16",
@@ -424,21 +429,22 @@ check_link:
424 429
425 out += sprintf(out, "Skeleton QHs\n"); 430 out += sprintf(out, "Skeleton QHs\n");
426 431
432 fsbr_link = 0;
427 for (i = 0; i < UHCI_NUM_SKELQH; ++i) { 433 for (i = 0; i < UHCI_NUM_SKELQH; ++i) {
428 int cnt = 0; 434 int cnt = 0;
429 __le32 fsbr_link = 0;
430 435
431 qh = uhci->skelqh[i]; 436 qh = uhci->skelqh[i];
432 out += sprintf(out, "- skel_%s_qh\n", qh_names[i]); \ 437 out += sprintf(out, "- skel_%s_qh\n", qh_names[i]); \
433 out += uhci_show_qh(qh, out, len - (out - buf), 4); 438 out += uhci_show_qh(uhci, qh, out, len - (out - buf), 4);
434 439
435 /* Last QH is the Terminating QH, it's different */ 440 /* Last QH is the Terminating QH, it's different */
436 if (i == SKEL_TERM) { 441 if (i == SKEL_TERM) {
437 if (qh_element(qh) != LINK_TO_TD(uhci->term_td)) 442 if (qh_element(qh) != LINK_TO_TD(uhci->term_td))
438 out += sprintf(out, " skel_term_qh element is not set to term_td!\n"); 443 out += sprintf(out, " skel_term_qh element is not set to term_td!\n");
439 if (link == LINK_TO_QH(uhci->skel_term_qh)) 444 link = fsbr_link;
440 goto check_qh_link; 445 if (!link)
441 continue; 446 link = LINK_TO_QH(uhci->skel_term_qh);
447 goto check_qh_link;
442 } 448 }
443 449
444 head = &qh->node; 450 head = &qh->node;
@@ -448,7 +454,7 @@ check_link:
448 qh = list_entry(tmp, struct uhci_qh, node); 454 qh = list_entry(tmp, struct uhci_qh, node);
449 tmp = tmp->next; 455 tmp = tmp->next;
450 if (++cnt <= 10) 456 if (++cnt <= 10)
451 out += uhci_show_qh(qh, out, 457 out += uhci_show_qh(uhci, qh, out,
452 len - (out - buf), 4); 458 len - (out - buf), 4);
453 if (!fsbr_link && qh->skel >= SKEL_FSBR) 459 if (!fsbr_link && qh->skel >= SKEL_FSBR)
454 fsbr_link = LINK_TO_QH(qh); 460 fsbr_link = LINK_TO_QH(qh);
@@ -463,8 +469,6 @@ check_link:
463 link = LINK_TO_QH(uhci->skel_async_qh); 469 link = LINK_TO_QH(uhci->skel_async_qh);
464 else if (!uhci->fsbr_is_on) 470 else if (!uhci->fsbr_is_on)
465 ; 471 ;
466 else if (fsbr_link)
467 link = fsbr_link;
468 else 472 else
469 link = LINK_TO_QH(uhci->skel_term_qh); 473 link = LINK_TO_QH(uhci->skel_term_qh);
470check_qh_link: 474check_qh_link:
@@ -573,8 +577,8 @@ static const struct file_operations uhci_debug_operations = {
573static inline void lprintk(char *buf) 577static inline void lprintk(char *buf)
574{} 578{}
575 579
576static inline int uhci_show_qh(struct uhci_qh *qh, char *buf, 580static inline int uhci_show_qh(struct uhci_hcd *uhci,
577 int len, int space) 581 struct uhci_qh *qh, char *buf, int len, int space)
578{ 582{
579 return 0; 583 return 0;
580} 584}
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 44da4334f1d6..d22da26ff167 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -632,7 +632,8 @@ static int uhci_start(struct usb_hcd *hcd)
632 */ 632 */
633 for (i = SKEL_ISO + 1; i < SKEL_ASYNC; ++i) 633 for (i = SKEL_ISO + 1; i < SKEL_ASYNC; ++i)
634 uhci->skelqh[i]->link = LINK_TO_QH(uhci->skel_async_qh); 634 uhci->skelqh[i]->link = LINK_TO_QH(uhci->skel_async_qh);
635 uhci->skel_async_qh->link = uhci->skel_term_qh->link = UHCI_PTR_TERM; 635 uhci->skel_async_qh->link = UHCI_PTR_TERM;
636 uhci->skel_term_qh->link = LINK_TO_QH(uhci->skel_term_qh);
636 637
637 /* This dummy TD is to work around a bug in Intel PIIX controllers */ 638 /* This dummy TD is to work around a bug in Intel PIIX controllers */
638 uhci_fill_td(uhci->term_td, 0, uhci_explen(0) | 639 uhci_fill_td(uhci->term_td, 0, uhci_explen(0) |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index f4ebdb3e488f..19a0cc02b9a2 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -45,43 +45,27 @@ static inline void uhci_clear_next_interrupt(struct uhci_hcd *uhci)
45 */ 45 */
46static void uhci_fsbr_on(struct uhci_hcd *uhci) 46static void uhci_fsbr_on(struct uhci_hcd *uhci)
47{ 47{
48 struct uhci_qh *fsbr_qh, *lqh, *tqh; 48 struct uhci_qh *lqh;
49 49
50 /* The terminating skeleton QH always points back to the first
51 * FSBR QH. Make the last async QH point to the terminating
52 * skeleton QH. */
50 uhci->fsbr_is_on = 1; 53 uhci->fsbr_is_on = 1;
51 lqh = list_entry(uhci->skel_async_qh->node.prev, 54 lqh = list_entry(uhci->skel_async_qh->node.prev,
52 struct uhci_qh, node); 55 struct uhci_qh, node);
53 56 lqh->link = LINK_TO_QH(uhci->skel_term_qh);
54 /* Find the first FSBR QH. Linear search through the list is
55 * acceptable because normally FSBR gets turned on as soon as
56 * one QH needs it. */
57 fsbr_qh = NULL;
58 list_for_each_entry_reverse(tqh, &uhci->skel_async_qh->node, node) {
59 if (tqh->skel < SKEL_FSBR)
60 break;
61 fsbr_qh = tqh;
62 }
63
64 /* No FSBR QH means we must insert the terminating skeleton QH */
65 if (!fsbr_qh) {
66 uhci->skel_term_qh->link = LINK_TO_QH(uhci->skel_term_qh);
67 wmb();
68 lqh->link = uhci->skel_term_qh->link;
69
70 /* Otherwise loop the last QH to the first FSBR QH */
71 } else
72 lqh->link = LINK_TO_QH(fsbr_qh);
73} 57}
74 58
75static void uhci_fsbr_off(struct uhci_hcd *uhci) 59static void uhci_fsbr_off(struct uhci_hcd *uhci)
76{ 60{
77 struct uhci_qh *lqh; 61 struct uhci_qh *lqh;
78 62
63 /* Remove the link from the last async QH to the terminating
64 * skeleton QH. */
79 uhci->fsbr_is_on = 0; 65 uhci->fsbr_is_on = 0;
80 lqh = list_entry(uhci->skel_async_qh->node.prev, 66 lqh = list_entry(uhci->skel_async_qh->node.prev,
81 struct uhci_qh, node); 67 struct uhci_qh, node);
82 68 lqh->link = UHCI_PTR_TERM;
83 /* End the async list normally and unlink the terminating QH */
84 lqh->link = uhci->skel_term_qh->link = UHCI_PTR_TERM;
85} 69}
86 70
87static void uhci_add_fsbr(struct uhci_hcd *uhci, struct urb *urb) 71static void uhci_add_fsbr(struct uhci_hcd *uhci, struct urb *urb)
@@ -464,9 +448,8 @@ static void link_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
464 */ 448 */
465static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) 449static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
466{ 450{
467 struct uhci_qh *pqh, *lqh; 451 struct uhci_qh *pqh;
468 __le32 link_to_new_qh; 452 __le32 link_to_new_qh;
469 __le32 *extra_link = &link_to_new_qh;
470 453
471 /* Find the predecessor QH for our new one and insert it in the list. 454 /* Find the predecessor QH for our new one and insert it in the list.
472 * The list of QHs is expected to be short, so linear search won't 455 * The list of QHs is expected to be short, so linear search won't
@@ -476,31 +459,17 @@ static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
476 break; 459 break;
477 } 460 }
478 list_add(&qh->node, &pqh->node); 461 list_add(&qh->node, &pqh->node);
479 qh->link = pqh->link;
480
481 link_to_new_qh = LINK_TO_QH(qh);
482
483 /* If this is now the first FSBR QH, take special action */
484 if (uhci->fsbr_is_on && pqh->skel < SKEL_FSBR &&
485 qh->skel >= SKEL_FSBR) {
486 lqh = list_entry(uhci->skel_async_qh->node.prev,
487 struct uhci_qh, node);
488
489 /* If the new QH is also the last one, we must unlink
490 * the terminating skeleton QH and make the new QH point
491 * back to itself. */
492 if (qh == lqh) {
493 qh->link = link_to_new_qh;
494 extra_link = &uhci->skel_term_qh->link;
495
496 /* Otherwise the last QH must point to the new QH */
497 } else
498 extra_link = &lqh->link;
499 }
500 462
501 /* Link it into the schedule */ 463 /* Link it into the schedule */
464 qh->link = pqh->link;
502 wmb(); 465 wmb();
503 *extra_link = pqh->link = link_to_new_qh; 466 link_to_new_qh = LINK_TO_QH(qh);
467 pqh->link = link_to_new_qh;
468
469 /* If this is now the first FSBR QH, link the terminating skeleton
470 * QH to it. */
471 if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR)
472 uhci->skel_term_qh->link = link_to_new_qh;
504} 473}
505 474
506/* 475/*
@@ -561,31 +530,16 @@ static void unlink_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
561 */ 530 */
562static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh) 531static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
563{ 532{
564 struct uhci_qh *pqh, *lqh; 533 struct uhci_qh *pqh;
565 __le32 link_to_next_qh = qh->link; 534 __le32 link_to_next_qh = qh->link;
566 535
567 pqh = list_entry(qh->node.prev, struct uhci_qh, node); 536 pqh = list_entry(qh->node.prev, struct uhci_qh, node);
568
569 /* If this is the first FSBQ QH, take special action */
570 if (uhci->fsbr_is_on && pqh->skel < SKEL_FSBR &&
571 qh->skel >= SKEL_FSBR) {
572 lqh = list_entry(uhci->skel_async_qh->node.prev,
573 struct uhci_qh, node);
574
575 /* If this QH is also the last one, we must link in
576 * the terminating skeleton QH. */
577 if (qh == lqh) {
578 link_to_next_qh = LINK_TO_QH(uhci->skel_term_qh);
579 uhci->skel_term_qh->link = link_to_next_qh;
580 wmb();
581 qh->link = link_to_next_qh;
582
583 /* Otherwise the last QH must point to the new first FSBR QH */
584 } else
585 lqh->link = link_to_next_qh;
586 }
587
588 pqh->link = link_to_next_qh; 537 pqh->link = link_to_next_qh;
538
539 /* If this was the old first FSBR QH, link the terminating skeleton
540 * QH to the next (new first FSBR) QH. */
541 if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR)
542 uhci->skel_term_qh->link = link_to_next_qh;
589 mb(); 543 mb();
590} 544}
591 545
@@ -1217,7 +1171,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
1217 1171
1218 if (debug > 1 && errbuf) { 1172 if (debug > 1 && errbuf) {
1219 /* Print the chain for debugging */ 1173 /* Print the chain for debugging */
1220 uhci_show_qh(urbp->qh, errbuf, 1174 uhci_show_qh(uhci, urbp->qh, errbuf,
1221 ERRBUF_LEN, 0); 1175 ERRBUF_LEN, 0);
1222 lprintk(errbuf); 1176 lprintk(errbuf);
1223 } 1177 }
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index d48c024cff59..6d12961cf9f9 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -316,6 +316,7 @@ static int update_eth_regs_async(pegasus_t * pegasus)
316 return ret; 316 return ret;
317} 317}
318 318
319/* Returns 0 on success, error on failure */
319static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd) 320static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd)
320{ 321{
321 int i; 322 int i;
@@ -847,10 +848,16 @@ static void intr_callback(struct urb *urb)
847 * d[0].NO_CARRIER kicks in only with failed TX. 848 * d[0].NO_CARRIER kicks in only with failed TX.
848 * ... so monitoring with MII may be safest. 849 * ... so monitoring with MII may be safest.
849 */ 850 */
850 if (d[0] & NO_CARRIER) 851 if (pegasus->features & TRUST_LINK_STATUS) {
851 netif_carrier_off(net); 852 if (d[5] & LINK_STATUS)
852 else 853 netif_carrier_on(net);
853 netif_carrier_on(net); 854 else
855 netif_carrier_off(net);
856 } else {
857 /* Never set carrier _on_ based on ! NO_CARRIER */
858 if (d[0] & NO_CARRIER)
859 netif_carrier_off(net);
860 }
854 861
855 /* bytes 3-4 == rx_lostpkt, reg 2E/2F */ 862 /* bytes 3-4 == rx_lostpkt, reg 2E/2F */
856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; 863 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
@@ -950,7 +957,7 @@ static void set_carrier(struct net_device *net)
950 pegasus_t *pegasus = netdev_priv(net); 957 pegasus_t *pegasus = netdev_priv(net);
951 u16 tmp; 958 u16 tmp;
952 959
953 if (!read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) 960 if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp))
954 return; 961 return;
955 962
956 if (tmp & BMSR_LSTATUS) 963 if (tmp & BMSR_LSTATUS)
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index c7467823cd1c..c7aadb413e8c 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -11,6 +11,7 @@
11 11
12#define PEGASUS_II 0x80000000 12#define PEGASUS_II 0x80000000
13#define HAS_HOME_PNA 0x40000000 13#define HAS_HOME_PNA 0x40000000
14#define TRUST_LINK_STATUS 0x20000000
14 15
15#define PEGASUS_MTU 1536 16#define PEGASUS_MTU 1536
16#define RX_SKBS 4 17#define RX_SKBS 4
@@ -203,7 +204,7 @@ PEGASUS_DEV( "AEI USB Fast Ethernet Adapter", VENDOR_AEILAB, 0x1701,
203PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100, 204PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100,
204 DEFAULT_GPIO_RESET | PEGASUS_II ) 205 DEFAULT_GPIO_RESET | PEGASUS_II )
205PEGASUS_DEV( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 206PEGASUS_DEV( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121,
206 DEFAULT_GPIO_RESET | PEGASUS_II ) 207 DEFAULT_GPIO_RESET | PEGASUS_II | TRUST_LINK_STATUS )
207PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986, 208PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986,
208 DEFAULT_GPIO_RESET ) 209 DEFAULT_GPIO_RESET )
209PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987, 210PEGASUS_DEV( "Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987,
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 7538c64a5097..39a498362594 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -18,7 +18,6 @@
18 18
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
22 { USB_DEVICE(0x413c, 0x8115) }, /* Dell Wireless HSDPA 5500 */ 21 { USB_DEVICE(0x413c, 0x8115) }, /* Dell Wireless HSDPA 5500 */
23 { }, 22 { },
24}; 23};
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1633a0fd48e8..8ff9d54b21e6 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -879,6 +879,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
879 break; 879 break;
880 case FT232BM: /* FT232BM chip */ 880 case FT232BM: /* FT232BM chip */
881 case FT2232C: /* FT2232C chip */ 881 case FT2232C: /* FT2232C chip */
882 case FT232RL:
882 if (baud <= 3000000) { 883 if (baud <= 3000000) {
883 div_value = ftdi_232bm_baud_to_divisor(baud); 884 div_value = ftdi_232bm_baud_to_divisor(baud);
884 } else { 885 } else {
@@ -1021,9 +1022,12 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1021 /* (It might be a BM because of the iSerialNumber bug, 1022 /* (It might be a BM because of the iSerialNumber bug,
1022 * but it will still work as an AM device.) */ 1023 * but it will still work as an AM device.) */
1023 priv->chip_type = FT8U232AM; 1024 priv->chip_type = FT8U232AM;
1024 } else { 1025 } else if (version < 0x600) {
1025 /* Assume its an FT232BM (or FT245BM) */ 1026 /* Assume its an FT232BM (or FT245BM) */
1026 priv->chip_type = FT232BM; 1027 priv->chip_type = FT232BM;
1028 } else {
1029 /* Assume its an FT232R */
1030 priv->chip_type = FT232RL;
1027 } 1031 }
1028 info("Detected %s", ftdi_chip_name[priv->chip_type]); 1032 info("Detected %s", ftdi_chip_name[priv->chip_type]);
1029} 1033}
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 53baeec8f265..4f8282ad7720 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -20,13 +20,14 @@
20#include <linux/usb/serial.h> 20#include <linux/usb/serial.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22 22
23static int generic_probe(struct usb_interface *interface,
24 const struct usb_device_id *id);
25
26 23
27static int debug; 24static int debug;
28 25
29#ifdef CONFIG_USB_SERIAL_GENERIC 26#ifdef CONFIG_USB_SERIAL_GENERIC
27
28static int generic_probe(struct usb_interface *interface,
29 const struct usb_device_id *id);
30
30static __u16 vendor = 0x05f9; 31static __u16 vendor = 0x05f9;
31static __u16 product = 0xffff; 32static __u16 product = 0xffff;
32 33
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index e13637dfb642..4a9d0d5c7282 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -327,6 +327,13 @@ UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100,
327 US_SC_DEVICE, US_PR_DEVICE, NULL, 327 US_SC_DEVICE, US_PR_DEVICE, NULL,
328 US_FL_FIX_CAPACITY), 328 US_FL_FIX_CAPACITY),
329 329
330/* Reported by Emil Larsson <emil@swip.net> */
331UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0100,
332 "NIKON",
333 "NIKON DSC D80",
334 US_SC_DEVICE, US_PR_DEVICE, NULL,
335 US_FL_FIX_CAPACITY),
336
330/* BENQ DC5330 337/* BENQ DC5330
331 * Reported by Manuel Fombuena <mfombuena@ya.com> and 338 * Reported by Manuel Fombuena <mfombuena@ya.com> and
332 * Frank Copeland <fjc@thingy.apana.org.au> */ 339 * Frank Copeland <fjc@thingy.apana.org.au> */
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index e4f0dd00ae85..8372ace4a0d9 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -139,7 +139,7 @@ config FB_TILEBLITTING
139 This is particularly important to one driver, matroxfb. If 139 This is particularly important to one driver, matroxfb. If
140 unsure, say N. 140 unsure, say N.
141 141
142comment "Frambuffer hardware drivers" 142comment "Frame buffer hardware drivers"
143 depends on FB 143 depends on FB
144 144
145config FB_CIRRUS 145config FB_CIRRUS
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index ada6f7e3a891..767c850f8eb7 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -186,8 +186,7 @@ static int cg3_setcolreg(unsigned regno,
186 * @blank_mode: the blank mode we want. 186 * @blank_mode: the blank mode we want.
187 * @info: frame buffer structure that represents a single frame buffer 187 * @info: frame buffer structure that represents a single frame buffer
188 */ 188 */
189static int 189static int cg3_blank(int blank, struct fb_info *info)
190cg3_blank(int blank, struct fb_info *info)
191{ 190{
192 struct cg3_par *par = (struct cg3_par *) info->par; 191 struct cg3_par *par = (struct cg3_par *) info->par;
193 struct cg3_regs __iomem *regs = par->regs; 192 struct cg3_regs __iomem *regs = par->regs;
@@ -251,8 +250,8 @@ static int cg3_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
251 * Initialisation 250 * Initialisation
252 */ 251 */
253 252
254static void 253static void __devinit cg3_init_fix(struct fb_info *info, int linebytes,
255cg3_init_fix(struct fb_info *info, int linebytes, struct device_node *dp) 254 struct device_node *dp)
256{ 255{
257 strlcpy(info->fix.id, dp->name, sizeof(info->fix.id)); 256 strlcpy(info->fix.id, dp->name, sizeof(info->fix.id));
258 257
@@ -264,8 +263,8 @@ cg3_init_fix(struct fb_info *info, int linebytes, struct device_node *dp)
264 info->fix.accel = FB_ACCEL_SUN_CGTHREE; 263 info->fix.accel = FB_ACCEL_SUN_CGTHREE;
265} 264}
266 265
267static void cg3_rdi_maybe_fixup_var(struct fb_var_screeninfo *var, 266static void __devinit cg3_rdi_maybe_fixup_var(struct fb_var_screeninfo *var,
268 struct device_node *dp) 267 struct device_node *dp)
269{ 268{
270 char *params; 269 char *params;
271 char *p; 270 char *p;
@@ -287,36 +286,36 @@ static void cg3_rdi_maybe_fixup_var(struct fb_var_screeninfo *var,
287 } 286 }
288} 287}
289 288
290static u8 cg3regvals_66hz[] __initdata = { /* 1152 x 900, 66 Hz */ 289static u8 cg3regvals_66hz[] __devinitdata = { /* 1152 x 900, 66 Hz */
291 0x14, 0xbb, 0x15, 0x2b, 0x16, 0x04, 0x17, 0x14, 290 0x14, 0xbb, 0x15, 0x2b, 0x16, 0x04, 0x17, 0x14,
292 0x18, 0xae, 0x19, 0x03, 0x1a, 0xa8, 0x1b, 0x24, 291 0x18, 0xae, 0x19, 0x03, 0x1a, 0xa8, 0x1b, 0x24,
293 0x1c, 0x01, 0x1d, 0x05, 0x1e, 0xff, 0x1f, 0x01, 292 0x1c, 0x01, 0x1d, 0x05, 0x1e, 0xff, 0x1f, 0x01,
294 0x10, 0x20, 0 293 0x10, 0x20, 0
295}; 294};
296 295
297static u8 cg3regvals_76hz[] __initdata = { /* 1152 x 900, 76 Hz */ 296static u8 cg3regvals_76hz[] __devinitdata = { /* 1152 x 900, 76 Hz */
298 0x14, 0xb7, 0x15, 0x27, 0x16, 0x03, 0x17, 0x0f, 297 0x14, 0xb7, 0x15, 0x27, 0x16, 0x03, 0x17, 0x0f,
299 0x18, 0xae, 0x19, 0x03, 0x1a, 0xae, 0x1b, 0x2a, 298 0x18, 0xae, 0x19, 0x03, 0x1a, 0xae, 0x1b, 0x2a,
300 0x1c, 0x01, 0x1d, 0x09, 0x1e, 0xff, 0x1f, 0x01, 299 0x1c, 0x01, 0x1d, 0x09, 0x1e, 0xff, 0x1f, 0x01,
301 0x10, 0x24, 0 300 0x10, 0x24, 0
302}; 301};
303 302
304static u8 cg3regvals_rdi[] __initdata = { /* 640 x 480, cgRDI */ 303static u8 cg3regvals_rdi[] __devinitdata = { /* 640 x 480, cgRDI */
305 0x14, 0x70, 0x15, 0x20, 0x16, 0x08, 0x17, 0x10, 304 0x14, 0x70, 0x15, 0x20, 0x16, 0x08, 0x17, 0x10,
306 0x18, 0x06, 0x19, 0x02, 0x1a, 0x31, 0x1b, 0x51, 305 0x18, 0x06, 0x19, 0x02, 0x1a, 0x31, 0x1b, 0x51,
307 0x1c, 0x06, 0x1d, 0x0c, 0x1e, 0xff, 0x1f, 0x01, 306 0x1c, 0x06, 0x1d, 0x0c, 0x1e, 0xff, 0x1f, 0x01,
308 0x10, 0x22, 0 307 0x10, 0x22, 0
309}; 308};
310 309
311static u8 *cg3_regvals[] __initdata = { 310static u8 *cg3_regvals[] __devinitdata = {
312 cg3regvals_66hz, cg3regvals_76hz, cg3regvals_rdi 311 cg3regvals_66hz, cg3regvals_76hz, cg3regvals_rdi
313}; 312};
314 313
315static u_char cg3_dacvals[] __initdata = { 314static u_char cg3_dacvals[] __devinitdata = {
316 4, 0xff, 5, 0x00, 6, 0x70, 7, 0x00, 0 315 4, 0xff, 5, 0x00, 6, 0x70, 7, 0x00, 0
317}; 316};
318 317
319static void cg3_do_default_mode(struct cg3_par *par) 318static void __devinit cg3_do_default_mode(struct cg3_par *par)
320{ 319{
321 enum cg3_type type; 320 enum cg3_type type;
322 u8 *p; 321 u8 *p;
@@ -433,7 +432,8 @@ static int __devinit cg3_init_one(struct of_device *op)
433 return 0; 432 return 0;
434} 433}
435 434
436static int __devinit cg3_probe(struct of_device *dev, const struct of_device_id *match) 435static int __devinit cg3_probe(struct of_device *dev,
436 const struct of_device_id *match)
437{ 437{
438 struct of_device *op = to_of_device(&dev->dev); 438 struct of_device *op = to_of_device(&dev->dev);
439 439
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 15854aec3180..1d4e8354b561 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -336,14 +336,30 @@ struct ffb_dac {
336 u32 value2; 336 u32 value2;
337}; 337};
338 338
339#define FFB_DAC_UCTRL 0x1001 /* User Control */
340#define FFB_DAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */
341#define FFB_DAC_UCTRL_MANREV_SHIFT 8
342#define FFB_DAC_TGEN 0x6000 /* Timing Generator */
343#define FFB_DAC_TGEN_VIDE 0x00000001 /* Video Enable */
344#define FFB_DAC_DID 0x8000 /* Device Identification */
345#define FFB_DAC_DID_PNUM 0x0ffff000 /* Device Part Number */
346#define FFB_DAC_DID_PNUM_SHIFT 12
347#define FFB_DAC_DID_REV 0xf0000000 /* Device Revision */
348#define FFB_DAC_DID_REV_SHIFT 28
349
350#define FFB_DAC_CUR_CTRL 0x100
351#define FFB_DAC_CUR_CTRL_P0 0x00000001
352#define FFB_DAC_CUR_CTRL_P1 0x00000002
353
339struct ffb_par { 354struct ffb_par {
340 spinlock_t lock; 355 spinlock_t lock;
341 struct ffb_fbc __iomem *fbc; 356 struct ffb_fbc __iomem *fbc;
342 struct ffb_dac __iomem *dac; 357 struct ffb_dac __iomem *dac;
343 358
344 u32 flags; 359 u32 flags;
345#define FFB_FLAG_AFB 0x00000001 360#define FFB_FLAG_AFB 0x00000001 /* AFB m3 or m6 */
346#define FFB_FLAG_BLANKED 0x00000002 361#define FFB_FLAG_BLANKED 0x00000002 /* screen is blanked */
362#define FFB_FLAG_INVCURSOR 0x00000004 /* DAC has inverted cursor logic */
347 363
348 u32 fg_cache __attribute__((aligned (8))); 364 u32 fg_cache __attribute__((aligned (8)));
349 u32 bg_cache; 365 u32 bg_cache;
@@ -354,7 +370,6 @@ struct ffb_par {
354 unsigned long physbase; 370 unsigned long physbase;
355 unsigned long fbsize; 371 unsigned long fbsize;
356 372
357 int dac_rev;
358 int board_type; 373 int board_type;
359}; 374};
360 375
@@ -426,11 +441,12 @@ static void ffb_switch_from_graph(struct ffb_par *par)
426 FFBWait(par); 441 FFBWait(par);
427 442
428 /* Disable cursor. */ 443 /* Disable cursor. */
429 upa_writel(0x100, &dac->type2); 444 upa_writel(FFB_DAC_CUR_CTRL, &dac->type2);
430 if (par->dac_rev <= 2) 445 if (par->flags & FFB_FLAG_INVCURSOR)
431 upa_writel(0, &dac->value2); 446 upa_writel(0, &dac->value2);
432 else 447 else
433 upa_writel(3, &dac->value2); 448 upa_writel((FFB_DAC_CUR_CTRL_P0 |
449 FFB_DAC_CUR_CTRL_P1), &dac->value2);
434 450
435 spin_unlock_irqrestore(&par->lock, flags); 451 spin_unlock_irqrestore(&par->lock, flags);
436} 452}
@@ -664,18 +680,18 @@ ffb_blank(int blank, struct fb_info *info)
664 struct ffb_par *par = (struct ffb_par *) info->par; 680 struct ffb_par *par = (struct ffb_par *) info->par;
665 struct ffb_dac __iomem *dac = par->dac; 681 struct ffb_dac __iomem *dac = par->dac;
666 unsigned long flags; 682 unsigned long flags;
667 u32 tmp; 683 u32 val;
684 int i;
668 685
669 spin_lock_irqsave(&par->lock, flags); 686 spin_lock_irqsave(&par->lock, flags);
670 687
671 FFBWait(par); 688 FFBWait(par);
672 689
690 upa_writel(FFB_DAC_TGEN, &dac->type);
691 val = upa_readl(&dac->value);
673 switch (blank) { 692 switch (blank) {
674 case FB_BLANK_UNBLANK: /* Unblanking */ 693 case FB_BLANK_UNBLANK: /* Unblanking */
675 upa_writel(0x6000, &dac->type); 694 val |= FFB_DAC_TGEN_VIDE;
676 tmp = (upa_readl(&dac->value) | 0x1);
677 upa_writel(0x6000, &dac->type);
678 upa_writel(tmp, &dac->value);
679 par->flags &= ~FFB_FLAG_BLANKED; 695 par->flags &= ~FFB_FLAG_BLANKED;
680 break; 696 break;
681 697
@@ -683,13 +699,16 @@ ffb_blank(int blank, struct fb_info *info)
683 case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */ 699 case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
684 case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */ 700 case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
685 case FB_BLANK_POWERDOWN: /* Poweroff */ 701 case FB_BLANK_POWERDOWN: /* Poweroff */
686 upa_writel(0x6000, &dac->type); 702 val &= ~FFB_DAC_TGEN_VIDE;
687 tmp = (upa_readl(&dac->value) & ~0x1);
688 upa_writel(0x6000, &dac->type);
689 upa_writel(tmp, &dac->value);
690 par->flags |= FFB_FLAG_BLANKED; 703 par->flags |= FFB_FLAG_BLANKED;
691 break; 704 break;
692 } 705 }
706 upa_writel(FFB_DAC_TGEN, &dac->type);
707 upa_writel(val, &dac->value);
708 for (i = 0; i < 10; i++) {
709 upa_writel(FFB_DAC_TGEN, &dac->type);
710 upa_readl(&dac->value);
711 }
693 712
694 spin_unlock_irqrestore(&par->lock, flags); 713 spin_unlock_irqrestore(&par->lock, flags);
695 714
@@ -894,6 +913,7 @@ static int ffb_init_one(struct of_device *op)
894 struct ffb_dac __iomem *dac; 913 struct ffb_dac __iomem *dac;
895 struct all_info *all; 914 struct all_info *all;
896 int err; 915 int err;
916 u32 dac_pnum, dac_rev, dac_mrev;
897 917
898 all = kzalloc(sizeof(*all), GFP_KERNEL); 918 all = kzalloc(sizeof(*all), GFP_KERNEL);
899 if (!all) 919 if (!all)
@@ -948,17 +968,31 @@ static int ffb_init_one(struct of_device *op)
948 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0) 968 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0)
949 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr); 969 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr);
950 970
951 ffb_switch_from_graph(&all->par);
952
953 dac = all->par.dac; 971 dac = all->par.dac;
954 upa_writel(0x8000, &dac->type); 972 upa_writel(FFB_DAC_DID, &dac->type);
955 all->par.dac_rev = upa_readl(&dac->value) >> 0x1c; 973 dac_pnum = upa_readl(&dac->value);
974 dac_rev = (dac_pnum & FFB_DAC_DID_REV) >> FFB_DAC_DID_REV_SHIFT;
975 dac_pnum = (dac_pnum & FFB_DAC_DID_PNUM) >> FFB_DAC_DID_PNUM_SHIFT;
976
977 upa_writel(FFB_DAC_UCTRL, &dac->type);
978 dac_mrev = upa_readl(&dac->value);
979 dac_mrev = (dac_mrev & FFB_DAC_UCTRL_MANREV) >>
980 FFB_DAC_UCTRL_MANREV_SHIFT;
956 981
957 /* Elite3D has different DAC revision numbering, and no DAC revisions 982 /* Elite3D has different DAC revision numbering, and no DAC revisions
958 * have the reversed meaning of cursor enable. 983 * have the reversed meaning of cursor enable. Otherwise, Pacifica 1
984 * ramdacs with manufacturing revision less than 3 have inverted
985 * cursor logic. We identify Pacifica 1 as not Pacifica 2, the
986 * latter having a part number value of 0x236e.
959 */ 987 */
960 if (all->par.flags & FFB_FLAG_AFB) 988 if ((all->par.flags & FFB_FLAG_AFB) || dac_pnum == 0x236e) {
961 all->par.dac_rev = 10; 989 all->par.flags &= ~FFB_FLAG_INVCURSOR;
990 } else {
991 if (dac_mrev < 3)
992 all->par.flags |= FFB_FLAG_INVCURSOR;
993 }
994
995 ffb_switch_from_graph(&all->par);
962 996
963 /* Unblank it just to be sure. When there are multiple 997 /* Unblank it just to be sure. When there are multiple
964 * FFB/AFB cards in the system, or it is not the OBP 998 * FFB/AFB cards in the system, or it is not the OBP
@@ -993,10 +1027,12 @@ static int ffb_init_one(struct of_device *op)
993 1027
994 dev_set_drvdata(&op->dev, all); 1028 dev_set_drvdata(&op->dev, all);
995 1029
996 printk("%s: %s at %016lx, type %d, DAC revision %d\n", 1030 printk("%s: %s at %016lx, type %d, "
1031 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n",
997 dp->full_name, 1032 dp->full_name,
998 ((all->par.flags & FFB_FLAG_AFB) ? "AFB" : "FFB"), 1033 ((all->par.flags & FFB_FLAG_AFB) ? "AFB" : "FFB"),
999 all->par.physbase, all->par.board_type, all->par.dac_rev); 1034 all->par.physbase, all->par.board_type,
1035 dac_pnum, dac_rev, dac_mrev);
1000 1036
1001 return 0; 1037 return 0;
1002} 1038}
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index 8ada4c5c5d70..6a82d39dc498 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -40,7 +40,6 @@
40extern struct file_system_type v9fs_fs_type; 40extern struct file_system_type v9fs_fs_type;
41extern const struct address_space_operations v9fs_addr_operations; 41extern const struct address_space_operations v9fs_addr_operations;
42extern const struct file_operations v9fs_file_operations; 42extern const struct file_operations v9fs_file_operations;
43extern const struct file_operations v9fs_cached_file_operations;
44extern const struct file_operations v9fs_dir_operations; 43extern const struct file_operations v9fs_dir_operations;
45extern struct dentry_operations v9fs_dentry_operations; 44extern struct dentry_operations v9fs_dentry_operations;
46extern struct dentry_operations v9fs_cached_dentry_operations; 45extern struct dentry_operations v9fs_cached_dentry_operations;
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 653dfa5b2531..c7b677253843 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -42,6 +42,8 @@
42#include "v9fs_vfs.h" 42#include "v9fs_vfs.h"
43#include "fid.h" 43#include "fid.h"
44 44
45static const struct file_operations v9fs_cached_file_operations;
46
45/** 47/**
46 * v9fs_file_open - open a file (or directory) 48 * v9fs_file_open - open a file (or directory)
47 * @inode: inode to be opened 49 * @inode: inode to be opened
@@ -245,7 +247,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
245 return total; 247 return total;
246} 248}
247 249
248const struct file_operations v9fs_cached_file_operations = { 250static const struct file_operations v9fs_cached_file_operations = {
249 .llseek = generic_file_llseek, 251 .llseek = generic_file_llseek,
250 .read = do_sync_read, 252 .read = do_sync_read,
251 .aio_read = generic_file_aio_read, 253 .aio_read = generic_file_aio_read,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 124a085d1f2e..b01b0a457932 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -415,7 +415,7 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
415 file_inode = file->d_inode; 415 file_inode = file->d_inode;
416 sb = file_inode->i_sb; 416 sb = file_inode->i_sb;
417 v9ses = v9fs_inode2v9ses(file_inode); 417 v9ses = v9fs_inode2v9ses(file_inode);
418 v9fid = v9fs_fid_lookup(file); 418 v9fid = v9fs_fid_clone(file);
419 if(IS_ERR(v9fid)) 419 if(IS_ERR(v9fid))
420 return PTR_ERR(v9fid); 420 return PTR_ERR(v9fid);
421 421
diff --git a/fs/aio.c b/fs/aio.c
index 0b4ee0a5c83e..e4598d6d49dd 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -136,7 +136,6 @@ static int aio_setup_ring(struct kioctx *ctx)
136 0); 136 0);
137 if (IS_ERR((void *)info->mmap_base)) { 137 if (IS_ERR((void *)info->mmap_base)) {
138 up_write(&ctx->mm->mmap_sem); 138 up_write(&ctx->mm->mmap_sem);
139 printk("mmap err: %ld\n", -info->mmap_base);
140 info->mmap_size = 0; 139 info->mmap_size = 0;
141 aio_free_ring(ctx); 140 aio_free_ring(ctx);
142 return -EAGAIN; 141 return -EAGAIN;
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index b4631046867e..d0e9b3a3905d 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -470,9 +470,6 @@ void autofs4_dentry_release(struct dentry *de)
470 if (inf) { 470 if (inf) {
471 struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb); 471 struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb);
472 472
473 inf->dentry = NULL;
474 inf->inode = NULL;
475
476 if (sbi) { 473 if (sbi) {
477 spin_lock(&sbi->rehash_lock); 474 spin_lock(&sbi->rehash_lock);
478 if (!list_empty(&inf->rehash)) 475 if (!list_empty(&inf->rehash))
@@ -480,6 +477,9 @@ void autofs4_dentry_release(struct dentry *de)
480 spin_unlock(&sbi->rehash_lock); 477 spin_unlock(&sbi->rehash_lock);
481 } 478 }
482 479
480 inf->dentry = NULL;
481 inf->inode = NULL;
482
483 autofs4_free_ino(inf); 483 autofs4_free_ino(inf);
484 } 484 }
485} 485}
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index a2fceba7ef8e..9cc4f0a8aaae 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1704,7 +1704,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1704 DUMP_SEEK(PAGE_SIZE); 1704 DUMP_SEEK(PAGE_SIZE);
1705 } else { 1705 } else {
1706 if (page == ZERO_PAGE(addr)) { 1706 if (page == ZERO_PAGE(addr)) {
1707 DUMP_SEEK(PAGE_SIZE); 1707 if (!dump_seek(file, PAGE_SIZE)) {
1708 page_cache_release(page);
1709 goto end_coredump;
1710 }
1708 } else { 1711 } else {
1709 void *kaddr; 1712 void *kaddr;
1710 flush_cache_page(vma, addr, 1713 flush_cache_page(vma, addr,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 47d6d49d1fb9..f3ddca4a387b 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1480,8 +1480,8 @@ static int elf_fdpic_dump_segments(struct file *file, struct mm_struct *mm,
1480 DUMP_SEEK(file->f_pos + PAGE_SIZE); 1480 DUMP_SEEK(file->f_pos + PAGE_SIZE);
1481 } 1481 }
1482 else if (page == ZERO_PAGE(addr)) { 1482 else if (page == ZERO_PAGE(addr)) {
1483 DUMP_SEEK(file->f_pos + PAGE_SIZE);
1484 page_cache_release(page); 1483 page_cache_release(page);
1484 DUMP_SEEK(file->f_pos + PAGE_SIZE);
1485 } 1485 }
1486 else { 1486 else {
1487 void *kaddr; 1487 void *kaddr;
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 78ced721554d..164a45cdaf5f 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -109,8 +109,6 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
109 /* temporary */ 109 /* temporary */
110 if (major == 0) { 110 if (major == 0) {
111 for (i = ARRAY_SIZE(chrdevs)-1; i > 0; i--) { 111 for (i = ARRAY_SIZE(chrdevs)-1; i > 0; i--) {
112 if (is_lanana_major(i))
113 continue;
114 if (chrdevs[i] == NULL) 112 if (chrdevs[i] == NULL)
115 break; 113 break;
116 } 114 }
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c81c958b3e1d..8b1c5d8bf4ef 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -2553,11 +2553,15 @@ HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
2553HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) 2553HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
2554/* wireless */ 2554/* wireless */
2555HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl) 2555HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
2556HANDLE_IOCTL(SIOCGIWPRIV, do_wireless_ioctl)
2557HANDLE_IOCTL(SIOCGIWSTATS, do_wireless_ioctl)
2556HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl) 2558HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
2557HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl) 2559HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
2558HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl) 2560HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
2559HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl) 2561HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
2562HANDLE_IOCTL(SIOCSIWMLME, do_wireless_ioctl)
2560HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl) 2563HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
2564HANDLE_IOCTL(SIOCSIWSCAN, do_wireless_ioctl)
2561HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl) 2565HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
2562HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl) 2566HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
2563HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl) 2567HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
@@ -2565,6 +2569,11 @@ HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
2565HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl) 2569HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
2566HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl) 2570HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
2567HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl) 2571HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
2572HANDLE_IOCTL(SIOCSIWGENIE, do_wireless_ioctl)
2573HANDLE_IOCTL(SIOCGIWGENIE, do_wireless_ioctl)
2574HANDLE_IOCTL(SIOCSIWENCODEEXT, do_wireless_ioctl)
2575HANDLE_IOCTL(SIOCGIWENCODEEXT, do_wireless_ioctl)
2576HANDLE_IOCTL(SIOCSIWPMKSA, do_wireless_ioctl)
2568HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) 2577HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
2569HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) 2578HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
2570HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) 2579HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
diff --git a/fs/exec.c b/fs/exec.c
index 7e36c6f6f538..3155e915307a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1244,13 +1244,17 @@ EXPORT_SYMBOL(set_binfmt);
1244 * name into corename, which must have space for at least 1244 * name into corename, which must have space for at least
1245 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. 1245 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
1246 */ 1246 */
1247static void format_corename(char *corename, const char *pattern, long signr) 1247static int format_corename(char *corename, const char *pattern, long signr)
1248{ 1248{
1249 const char *pat_ptr = pattern; 1249 const char *pat_ptr = pattern;
1250 char *out_ptr = corename; 1250 char *out_ptr = corename;
1251 char *const out_end = corename + CORENAME_MAX_SIZE; 1251 char *const out_end = corename + CORENAME_MAX_SIZE;
1252 int rc; 1252 int rc;
1253 int pid_in_pattern = 0; 1253 int pid_in_pattern = 0;
1254 int ispipe = 0;
1255
1256 if (*pattern == '|')
1257 ispipe = 1;
1254 1258
1255 /* Repeat as long as we have more pattern to process and more output 1259 /* Repeat as long as we have more pattern to process and more output
1256 space */ 1260 space */
@@ -1341,8 +1345,8 @@ static void format_corename(char *corename, const char *pattern, long signr)
1341 * 1345 *
1342 * If core_pattern does not include a %p (as is the default) 1346 * If core_pattern does not include a %p (as is the default)
1343 * and core_uses_pid is set, then .%pid will be appended to 1347 * and core_uses_pid is set, then .%pid will be appended to
1344 * the filename */ 1348 * the filename. Do not do this for piped commands. */
1345 if (!pid_in_pattern 1349 if (!ispipe && !pid_in_pattern
1346 && (core_uses_pid || atomic_read(&current->mm->mm_users) != 1)) { 1350 && (core_uses_pid || atomic_read(&current->mm->mm_users) != 1)) {
1347 rc = snprintf(out_ptr, out_end - out_ptr, 1351 rc = snprintf(out_ptr, out_end - out_ptr,
1348 ".%d", current->tgid); 1352 ".%d", current->tgid);
@@ -1350,8 +1354,9 @@ static void format_corename(char *corename, const char *pattern, long signr)
1350 goto out; 1354 goto out;
1351 out_ptr += rc; 1355 out_ptr += rc;
1352 } 1356 }
1353 out: 1357out:
1354 *out_ptr = 0; 1358 *out_ptr = 0;
1359 return ispipe;
1355} 1360}
1356 1361
1357static void zap_process(struct task_struct *start) 1362static void zap_process(struct task_struct *start)
@@ -1502,16 +1507,15 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1502 * uses lock_kernel() 1507 * uses lock_kernel()
1503 */ 1508 */
1504 lock_kernel(); 1509 lock_kernel();
1505 format_corename(corename, core_pattern, signr); 1510 ispipe = format_corename(corename, core_pattern, signr);
1506 unlock_kernel(); 1511 unlock_kernel();
1507 if (corename[0] == '|') { 1512 if (ispipe) {
1508 /* SIGPIPE can happen, but it's just never processed */ 1513 /* SIGPIPE can happen, but it's just never processed */
1509 if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { 1514 if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) {
1510 printk(KERN_INFO "Core dump to %s pipe failed\n", 1515 printk(KERN_INFO "Core dump to %s pipe failed\n",
1511 corename); 1516 corename);
1512 goto fail_unlock; 1517 goto fail_unlock;
1513 } 1518 }
1514 ispipe = 1;
1515 } else 1519 } else
1516 file = filp_open(corename, 1520 file = filp_open(corename,
1517 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, 1521 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 8a824f4ce5c6..a5b150f7e8a2 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1148,102 +1148,37 @@ static int do_journal_get_write_access(handle_t *handle,
1148 return ext3_journal_get_write_access(handle, bh); 1148 return ext3_journal_get_write_access(handle, bh);
1149} 1149}
1150 1150
1151/*
1152 * The idea of this helper function is following:
1153 * if prepare_write has allocated some blocks, but not all of them, the
1154 * transaction must include the content of the newly allocated blocks.
1155 * This content is expected to be set to zeroes by block_prepare_write().
1156 * 2006/10/14 SAW
1157 */
1158static int ext3_prepare_failure(struct file *file, struct page *page,
1159 unsigned from, unsigned to)
1160{
1161 struct address_space *mapping;
1162 struct buffer_head *bh, *head, *next;
1163 unsigned block_start, block_end;
1164 unsigned blocksize;
1165 int ret;
1166 handle_t *handle = ext3_journal_current_handle();
1167
1168 mapping = page->mapping;
1169 if (ext3_should_writeback_data(mapping->host)) {
1170 /* optimization: no constraints about data */
1171skip:
1172 return ext3_journal_stop(handle);
1173 }
1174
1175 head = page_buffers(page);
1176 blocksize = head->b_size;
1177 for ( bh = head, block_start = 0;
1178 bh != head || !block_start;
1179 block_start = block_end, bh = next)
1180 {
1181 next = bh->b_this_page;
1182 block_end = block_start + blocksize;
1183 if (block_end <= from)
1184 continue;
1185 if (block_start >= to) {
1186 block_start = to;
1187 break;
1188 }
1189 if (!buffer_mapped(bh))
1190 /* prepare_write failed on this bh */
1191 break;
1192 if (ext3_should_journal_data(mapping->host)) {
1193 ret = do_journal_get_write_access(handle, bh);
1194 if (ret) {
1195 ext3_journal_stop(handle);
1196 return ret;
1197 }
1198 }
1199 /*
1200 * block_start here becomes the first block where the current iteration
1201 * of prepare_write failed.
1202 */
1203 }
1204 if (block_start <= from)
1205 goto skip;
1206
1207 /* commit allocated and zeroed buffers */
1208 return mapping->a_ops->commit_write(file, page, from, block_start);
1209}
1210
1211static int ext3_prepare_write(struct file *file, struct page *page, 1151static int ext3_prepare_write(struct file *file, struct page *page,
1212 unsigned from, unsigned to) 1152 unsigned from, unsigned to)
1213{ 1153{
1214 struct inode *inode = page->mapping->host; 1154 struct inode *inode = page->mapping->host;
1215 int ret, ret2; 1155 int ret, needed_blocks = ext3_writepage_trans_blocks(inode);
1216 int needed_blocks = ext3_writepage_trans_blocks(inode);
1217 handle_t *handle; 1156 handle_t *handle;
1218 int retries = 0; 1157 int retries = 0;
1219 1158
1220retry: 1159retry:
1221 handle = ext3_journal_start(inode, needed_blocks); 1160 handle = ext3_journal_start(inode, needed_blocks);
1222 if (IS_ERR(handle)) 1161 if (IS_ERR(handle)) {
1223 return PTR_ERR(handle); 1162 ret = PTR_ERR(handle);
1163 goto out;
1164 }
1224 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode)) 1165 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode))
1225 ret = nobh_prepare_write(page, from, to, ext3_get_block); 1166 ret = nobh_prepare_write(page, from, to, ext3_get_block);
1226 else 1167 else
1227 ret = block_prepare_write(page, from, to, ext3_get_block); 1168 ret = block_prepare_write(page, from, to, ext3_get_block);
1228 if (ret) 1169 if (ret)
1229 goto failure; 1170 goto prepare_write_failed;
1230 1171
1231 if (ext3_should_journal_data(inode)) { 1172 if (ext3_should_journal_data(inode)) {
1232 ret = walk_page_buffers(handle, page_buffers(page), 1173 ret = walk_page_buffers(handle, page_buffers(page),
1233 from, to, NULL, do_journal_get_write_access); 1174 from, to, NULL, do_journal_get_write_access);
1234 if (ret)
1235 /* fatal error, just put the handle and return */
1236 journal_stop(handle);
1237 } 1175 }
1238 return ret; 1176prepare_write_failed:
1239 1177 if (ret)
1240failure: 1178 ext3_journal_stop(handle);
1241 ret2 = ext3_prepare_failure(file, page, from, to);
1242 if (ret2 < 0)
1243 return ret2;
1244 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1179 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1245 goto retry; 1180 goto retry;
1246 /* retry number exceeded, or other error like -EDQUOT */ 1181out:
1247 return ret; 1182 return ret;
1248} 1183}
1249 1184
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index fbff4b9e122a..810b6d6474bf 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1147,102 +1147,37 @@ static int do_journal_get_write_access(handle_t *handle,
1147 return ext4_journal_get_write_access(handle, bh); 1147 return ext4_journal_get_write_access(handle, bh);
1148} 1148}
1149 1149
1150/*
1151 * The idea of this helper function is following:
1152 * if prepare_write has allocated some blocks, but not all of them, the
1153 * transaction must include the content of the newly allocated blocks.
1154 * This content is expected to be set to zeroes by block_prepare_write().
1155 * 2006/10/14 SAW
1156 */
1157static int ext4_prepare_failure(struct file *file, struct page *page,
1158 unsigned from, unsigned to)
1159{
1160 struct address_space *mapping;
1161 struct buffer_head *bh, *head, *next;
1162 unsigned block_start, block_end;
1163 unsigned blocksize;
1164 int ret;
1165 handle_t *handle = ext4_journal_current_handle();
1166
1167 mapping = page->mapping;
1168 if (ext4_should_writeback_data(mapping->host)) {
1169 /* optimization: no constraints about data */
1170skip:
1171 return ext4_journal_stop(handle);
1172 }
1173
1174 head = page_buffers(page);
1175 blocksize = head->b_size;
1176 for ( bh = head, block_start = 0;
1177 bh != head || !block_start;
1178 block_start = block_end, bh = next)
1179 {
1180 next = bh->b_this_page;
1181 block_end = block_start + blocksize;
1182 if (block_end <= from)
1183 continue;
1184 if (block_start >= to) {
1185 block_start = to;
1186 break;
1187 }
1188 if (!buffer_mapped(bh))
1189 /* prepare_write failed on this bh */
1190 break;
1191 if (ext4_should_journal_data(mapping->host)) {
1192 ret = do_journal_get_write_access(handle, bh);
1193 if (ret) {
1194 ext4_journal_stop(handle);
1195 return ret;
1196 }
1197 }
1198 /*
1199 * block_start here becomes the first block where the current iteration
1200 * of prepare_write failed.
1201 */
1202 }
1203 if (block_start <= from)
1204 goto skip;
1205
1206 /* commit allocated and zeroed buffers */
1207 return mapping->a_ops->commit_write(file, page, from, block_start);
1208}
1209
1210static int ext4_prepare_write(struct file *file, struct page *page, 1150static int ext4_prepare_write(struct file *file, struct page *page,
1211 unsigned from, unsigned to) 1151 unsigned from, unsigned to)
1212{ 1152{
1213 struct inode *inode = page->mapping->host; 1153 struct inode *inode = page->mapping->host;
1214 int ret, ret2; 1154 int ret, needed_blocks = ext4_writepage_trans_blocks(inode);
1215 int needed_blocks = ext4_writepage_trans_blocks(inode);
1216 handle_t *handle; 1155 handle_t *handle;
1217 int retries = 0; 1156 int retries = 0;
1218 1157
1219retry: 1158retry:
1220 handle = ext4_journal_start(inode, needed_blocks); 1159 handle = ext4_journal_start(inode, needed_blocks);
1221 if (IS_ERR(handle)) 1160 if (IS_ERR(handle)) {
1222 return PTR_ERR(handle); 1161 ret = PTR_ERR(handle);
1162 goto out;
1163 }
1223 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 1164 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1224 ret = nobh_prepare_write(page, from, to, ext4_get_block); 1165 ret = nobh_prepare_write(page, from, to, ext4_get_block);
1225 else 1166 else
1226 ret = block_prepare_write(page, from, to, ext4_get_block); 1167 ret = block_prepare_write(page, from, to, ext4_get_block);
1227 if (ret) 1168 if (ret)
1228 goto failure; 1169 goto prepare_write_failed;
1229 1170
1230 if (ext4_should_journal_data(inode)) { 1171 if (ext4_should_journal_data(inode)) {
1231 ret = walk_page_buffers(handle, page_buffers(page), 1172 ret = walk_page_buffers(handle, page_buffers(page),
1232 from, to, NULL, do_journal_get_write_access); 1173 from, to, NULL, do_journal_get_write_access);
1233 if (ret)
1234 /* fatal error, just put the handle and return */
1235 ext4_journal_stop(handle);
1236 } 1174 }
1237 return ret; 1175prepare_write_failed:
1238 1176 if (ret)
1239failure: 1177 ext4_journal_stop(handle);
1240 ret2 = ext4_prepare_failure(file, page, from, to);
1241 if (ret2 < 0)
1242 return ret2;
1243 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 1178 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
1244 goto retry; 1179 goto retry;
1245 /* retry number exceeded, or other error like -EDQUOT */ 1180out:
1246 return ret; 1181 return ret;
1247} 1182}
1248 1183
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 406bf61ed510..8890eba1db52 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -195,7 +195,7 @@ static struct dentry_operations fuse_dentry_operations = {
195 .d_revalidate = fuse_dentry_revalidate, 195 .d_revalidate = fuse_dentry_revalidate,
196}; 196};
197 197
198static int valid_mode(int m) 198int fuse_valid_type(int m)
199{ 199{
200 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || 200 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) ||
201 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); 201 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
@@ -248,7 +248,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
248 fuse_put_request(fc, req); 248 fuse_put_request(fc, req);
249 /* Zero nodeid is same as -ENOENT, but with valid timeout */ 249 /* Zero nodeid is same as -ENOENT, but with valid timeout */
250 if (!err && outarg.nodeid && 250 if (!err && outarg.nodeid &&
251 (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) 251 (invalid_nodeid(outarg.nodeid) ||
252 !fuse_valid_type(outarg.attr.mode)))
252 err = -EIO; 253 err = -EIO;
253 if (!err && outarg.nodeid) { 254 if (!err && outarg.nodeid) {
254 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 255 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index b98b20de7405..68ae87cbafab 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -552,3 +552,8 @@ int fuse_ctl_add_conn(struct fuse_conn *fc);
552 * Remove connection from control filesystem 552 * Remove connection from control filesystem
553 */ 553 */
554void fuse_ctl_remove_conn(struct fuse_conn *fc); 554void fuse_ctl_remove_conn(struct fuse_conn *fc);
555
556/**
557 * Is file type valid?
558 */
559int fuse_valid_type(int m);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 5ab8e50e7808..608db81219a0 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -330,6 +330,8 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
330 case OPT_ROOTMODE: 330 case OPT_ROOTMODE:
331 if (match_octal(&args[0], &value)) 331 if (match_octal(&args[0], &value))
332 return 0; 332 return 0;
333 if (!fuse_valid_type(value))
334 return 0;
333 d->rootmode = value; 335 d->rootmode = value;
334 d->rootmode_present = 1; 336 d->rootmode_present = 1;
335 break; 337 break;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 9baf69773ed1..fd301a910122 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -20,7 +20,6 @@
20#include "hostfs.h" 20#include "hostfs.h"
21#include "kern_util.h" 21#include "kern_util.h"
22#include "kern.h" 22#include "kern.h"
23#include "user_util.h"
24#include "init.h" 23#include "init.h"
25 24
26struct hostfs_inode_info { 25struct hostfs_inode_info {
@@ -939,7 +938,7 @@ static const struct address_space_operations hostfs_link_aops = {
939static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) 938static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
940{ 939{
941 struct inode *root_inode; 940 struct inode *root_inode;
942 char *name, *data = d; 941 char *host_root_path, *req_root = d;
943 int err; 942 int err;
944 943
945 sb->s_blocksize = 1024; 944 sb->s_blocksize = 1024;
@@ -948,16 +947,16 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
948 sb->s_op = &hostfs_sbops; 947 sb->s_op = &hostfs_sbops;
949 948
950 /* NULL is printed as <NULL> by sprintf: avoid that. */ 949 /* NULL is printed as <NULL> by sprintf: avoid that. */
951 if (data == NULL) 950 if (req_root == NULL)
952 data = ""; 951 req_root = "";
953 952
954 err = -ENOMEM; 953 err = -ENOMEM;
955 name = kmalloc(strlen(root_ino) + 1 954 host_root_path = kmalloc(strlen(root_ino) + 1
956 + strlen(data) + 1, GFP_KERNEL); 955 + strlen(req_root) + 1, GFP_KERNEL);
957 if(name == NULL) 956 if(host_root_path == NULL)
958 goto out; 957 goto out;
959 958
960 sprintf(name, "%s/%s", root_ino, data); 959 sprintf(host_root_path, "%s/%s", root_ino, req_root);
961 960
962 root_inode = iget(sb, 0); 961 root_inode = iget(sb, 0);
963 if(root_inode == NULL) 962 if(root_inode == NULL)
@@ -967,10 +966,10 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
967 if(err) 966 if(err)
968 goto out_put; 967 goto out_put;
969 968
970 HOSTFS_I(root_inode)->host_filename = name; 969 HOSTFS_I(root_inode)->host_filename = host_root_path;
971 /* Avoid that in the error path, iput(root_inode) frees again name through 970 /* Avoid that in the error path, iput(root_inode) frees again
972 * hostfs_destroy_inode! */ 971 * host_root_path through hostfs_destroy_inode! */
973 name = NULL; 972 host_root_path = NULL;
974 973
975 err = -ENOMEM; 974 err = -ENOMEM;
976 sb->s_root = d_alloc_root(root_inode); 975 sb->s_root = d_alloc_root(root_inode);
@@ -990,7 +989,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
990 out_put: 989 out_put:
991 iput(root_inode); 990 iput(root_inode);
992 out_free: 991 out_free:
993 kfree(name); 992 kfree(host_root_path);
994 out: 993 out:
995 return(err); 994 return(err);
996} 995}
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 92d8ec859e22..cd3469720cbf 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1684,7 +1684,8 @@ go_ahead:
1684 * ... prune child dentries and writebacks if needed. 1684 * ... prune child dentries and writebacks if needed.
1685 */ 1685 */
1686 if (atomic_read(&old_dentry->d_count) > 1) { 1686 if (atomic_read(&old_dentry->d_count) > 1) {
1687 nfs_wb_all(old_inode); 1687 if (S_ISREG(old_inode->i_mode))
1688 nfs_wb_all(old_inode);
1688 shrink_dcache_parent(old_dentry); 1689 shrink_dcache_parent(old_dentry);
1689 } 1690 }
1690 nfs_inode_return_delegation(old_inode); 1691 nfs_inode_return_delegation(old_inode);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index b1c98ea39b72..2877744cb606 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -432,10 +432,10 @@ static void nfs_direct_commit_result(struct rpc_task *task, void *calldata)
432 if (NFS_PROTO(data->inode)->commit_done(task, data) != 0) 432 if (NFS_PROTO(data->inode)->commit_done(task, data) != 0)
433 return; 433 return;
434 if (unlikely(task->tk_status < 0)) { 434 if (unlikely(task->tk_status < 0)) {
435 dreq->error = task->tk_status; 435 dprintk("NFS: %5u commit failed with error %d.\n",
436 task->tk_pid, task->tk_status);
436 dreq->flags = NFS_ODIRECT_RESCHED_WRITES; 437 dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
437 } 438 } else if (memcmp(&dreq->verf, &data->verf, sizeof(data->verf))) {
438 if (memcmp(&dreq->verf, &data->verf, sizeof(data->verf))) {
439 dprintk("NFS: %5u commit verify failed\n", task->tk_pid); 439 dprintk("NFS: %5u commit verify failed\n", task->tk_pid);
440 dreq->flags = NFS_ODIRECT_RESCHED_WRITES; 440 dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
441 } 441 }
@@ -531,9 +531,12 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
531 531
532 spin_lock(&dreq->lock); 532 spin_lock(&dreq->lock);
533 533
534 if (unlikely(dreq->error != 0))
535 goto out_unlock;
534 if (unlikely(status < 0)) { 536 if (unlikely(status < 0)) {
537 /* An error has occured, so we should not commit */
538 dreq->flags = 0;
535 dreq->error = status; 539 dreq->error = status;
536 goto out_unlock;
537 } 540 }
538 541
539 dreq->count += data->res.count; 542 dreq->count += data->res.count;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 93d046c85f52..44aa9b726573 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -341,8 +341,10 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
341 lock_kernel(); 341 lock_kernel();
342 nfs_begin_data_update(inode); 342 nfs_begin_data_update(inode);
343 /* Write all dirty data */ 343 /* Write all dirty data */
344 filemap_write_and_wait(inode->i_mapping); 344 if (S_ISREG(inode->i_mode)) {
345 nfs_wb_all(inode); 345 filemap_write_and_wait(inode->i_mapping);
346 nfs_wb_all(inode);
347 }
346 /* 348 /*
347 * Return any delegations if we're going to change ACLs 349 * Return any delegations if we're going to change ACLs
348 */ 350 */
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 2867e6b7096f..797558941745 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -38,7 +38,6 @@
38static struct nfs_page * nfs_update_request(struct nfs_open_context*, 38static struct nfs_page * nfs_update_request(struct nfs_open_context*,
39 struct page *, 39 struct page *,
40 unsigned int, unsigned int); 40 unsigned int, unsigned int);
41static void nfs_mark_request_dirty(struct nfs_page *req);
42static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how); 41static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how);
43static const struct rpc_call_ops nfs_write_partial_ops; 42static const struct rpc_call_ops nfs_write_partial_ops;
44static const struct rpc_call_ops nfs_write_full_ops; 43static const struct rpc_call_ops nfs_write_full_ops;
@@ -218,9 +217,11 @@ int nfs_congestion_kb;
218#define NFS_CONGESTION_OFF_THRESH \ 217#define NFS_CONGESTION_OFF_THRESH \
219 (NFS_CONGESTION_ON_THRESH - (NFS_CONGESTION_ON_THRESH >> 2)) 218 (NFS_CONGESTION_ON_THRESH - (NFS_CONGESTION_ON_THRESH >> 2))
220 219
221static void nfs_set_page_writeback(struct page *page) 220static int nfs_set_page_writeback(struct page *page)
222{ 221{
223 if (!test_set_page_writeback(page)) { 222 int ret = test_set_page_writeback(page);
223
224 if (!ret) {
224 struct inode *inode = page->mapping->host; 225 struct inode *inode = page->mapping->host;
225 struct nfs_server *nfss = NFS_SERVER(inode); 226 struct nfs_server *nfss = NFS_SERVER(inode);
226 227
@@ -228,6 +229,7 @@ static void nfs_set_page_writeback(struct page *page)
228 NFS_CONGESTION_ON_THRESH) 229 NFS_CONGESTION_ON_THRESH)
229 set_bdi_congested(&nfss->backing_dev_info, WRITE); 230 set_bdi_congested(&nfss->backing_dev_info, WRITE);
230 } 231 }
232 return ret;
231} 233}
232 234
233static void nfs_end_page_writeback(struct page *page) 235static void nfs_end_page_writeback(struct page *page)
@@ -252,7 +254,8 @@ static void nfs_end_page_writeback(struct page *page)
252static int nfs_page_mark_flush(struct page *page) 254static int nfs_page_mark_flush(struct page *page)
253{ 255{
254 struct nfs_page *req; 256 struct nfs_page *req;
255 spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock; 257 struct nfs_inode *nfsi = NFS_I(page->mapping->host);
258 spinlock_t *req_lock = &nfsi->req_lock;
256 int ret; 259 int ret;
257 260
258 spin_lock(req_lock); 261 spin_lock(req_lock);
@@ -276,11 +279,23 @@ static int nfs_page_mark_flush(struct page *page)
276 return ret; 279 return ret;
277 spin_lock(req_lock); 280 spin_lock(req_lock);
278 } 281 }
279 spin_unlock(req_lock); 282 if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) {
280 if (test_and_set_bit(PG_FLUSHING, &req->wb_flags) == 0) { 283 /* This request is marked for commit */
281 nfs_mark_request_dirty(req); 284 spin_unlock(req_lock);
282 nfs_set_page_writeback(page); 285 nfs_unlock_request(req);
286 return 1;
283 } 287 }
288 if (nfs_set_page_writeback(page) == 0) {
289 nfs_list_remove_request(req);
290 /* add the request to the inode's dirty list. */
291 radix_tree_tag_set(&nfsi->nfs_page_tree,
292 req->wb_index, NFS_PAGE_TAG_DIRTY);
293 nfs_list_add_request(req, &nfsi->dirty);
294 nfsi->ndirty++;
295 spin_unlock(req_lock);
296 __mark_inode_dirty(page->mapping->host, I_DIRTY_PAGES);
297 } else
298 spin_unlock(req_lock);
284 ret = test_bit(PG_NEED_FLUSH, &req->wb_flags); 299 ret = test_bit(PG_NEED_FLUSH, &req->wb_flags);
285 nfs_unlock_request(req); 300 nfs_unlock_request(req);
286 return ret; 301 return ret;
@@ -373,6 +388,8 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
373 } 388 }
374 SetPagePrivate(req->wb_page); 389 SetPagePrivate(req->wb_page);
375 set_page_private(req->wb_page, (unsigned long)req); 390 set_page_private(req->wb_page, (unsigned long)req);
391 if (PageDirty(req->wb_page))
392 set_bit(PG_NEED_FLUSH, &req->wb_flags);
376 nfsi->npages++; 393 nfsi->npages++;
377 atomic_inc(&req->wb_count); 394 atomic_inc(&req->wb_count);
378 return 0; 395 return 0;
@@ -392,6 +409,8 @@ static void nfs_inode_remove_request(struct nfs_page *req)
392 set_page_private(req->wb_page, 0); 409 set_page_private(req->wb_page, 0);
393 ClearPagePrivate(req->wb_page); 410 ClearPagePrivate(req->wb_page);
394 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); 411 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index);
412 if (test_and_clear_bit(PG_NEED_FLUSH, &req->wb_flags))
413 __set_page_dirty_nobuffers(req->wb_page);
395 nfsi->npages--; 414 nfsi->npages--;
396 if (!nfsi->npages) { 415 if (!nfsi->npages) {
397 spin_unlock(&nfsi->req_lock); 416 spin_unlock(&nfsi->req_lock);
@@ -403,28 +422,9 @@ static void nfs_inode_remove_request(struct nfs_page *req)
403 nfs_release_request(req); 422 nfs_release_request(req);
404} 423}
405 424
406/*
407 * Add a request to the inode's dirty list.
408 */
409static void
410nfs_mark_request_dirty(struct nfs_page *req)
411{
412 struct inode *inode = req->wb_context->dentry->d_inode;
413 struct nfs_inode *nfsi = NFS_I(inode);
414
415 spin_lock(&nfsi->req_lock);
416 radix_tree_tag_set(&nfsi->nfs_page_tree,
417 req->wb_index, NFS_PAGE_TAG_DIRTY);
418 nfs_list_add_request(req, &nfsi->dirty);
419 nfsi->ndirty++;
420 spin_unlock(&nfsi->req_lock);
421 __mark_inode_dirty(inode, I_DIRTY_PAGES);
422}
423
424static void 425static void
425nfs_redirty_request(struct nfs_page *req) 426nfs_redirty_request(struct nfs_page *req)
426{ 427{
427 clear_bit(PG_FLUSHING, &req->wb_flags);
428 __set_page_dirty_nobuffers(req->wb_page); 428 __set_page_dirty_nobuffers(req->wb_page);
429} 429}
430 430
@@ -434,7 +434,11 @@ nfs_redirty_request(struct nfs_page *req)
434static inline int 434static inline int
435nfs_dirty_request(struct nfs_page *req) 435nfs_dirty_request(struct nfs_page *req)
436{ 436{
437 return test_bit(PG_FLUSHING, &req->wb_flags) == 0; 437 struct page *page = req->wb_page;
438
439 if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags))
440 return 0;
441 return !PageWriteback(req->wb_page);
438} 442}
439 443
440#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 444#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
@@ -450,10 +454,48 @@ nfs_mark_request_commit(struct nfs_page *req)
450 spin_lock(&nfsi->req_lock); 454 spin_lock(&nfsi->req_lock);
451 nfs_list_add_request(req, &nfsi->commit); 455 nfs_list_add_request(req, &nfsi->commit);
452 nfsi->ncommit++; 456 nfsi->ncommit++;
457 set_bit(PG_NEED_COMMIT, &(req)->wb_flags);
453 spin_unlock(&nfsi->req_lock); 458 spin_unlock(&nfsi->req_lock);
454 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 459 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
455 __mark_inode_dirty(inode, I_DIRTY_DATASYNC); 460 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
456} 461}
462
463static inline
464int nfs_write_need_commit(struct nfs_write_data *data)
465{
466 return data->verf.committed != NFS_FILE_SYNC;
467}
468
469static inline
470int nfs_reschedule_unstable_write(struct nfs_page *req)
471{
472 if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) {
473 nfs_mark_request_commit(req);
474 return 1;
475 }
476 if (test_and_clear_bit(PG_NEED_RESCHED, &req->wb_flags)) {
477 nfs_redirty_request(req);
478 return 1;
479 }
480 return 0;
481}
482#else
483static inline void
484nfs_mark_request_commit(struct nfs_page *req)
485{
486}
487
488static inline
489int nfs_write_need_commit(struct nfs_write_data *data)
490{
491 return 0;
492}
493
494static inline
495int nfs_reschedule_unstable_write(struct nfs_page *req)
496{
497 return 0;
498}
457#endif 499#endif
458 500
459/* 501/*
@@ -500,6 +542,7 @@ static void nfs_cancel_dirty_list(struct list_head *head)
500 while(!list_empty(head)) { 542 while(!list_empty(head)) {
501 req = nfs_list_entry(head->next); 543 req = nfs_list_entry(head->next);
502 nfs_list_remove_request(req); 544 nfs_list_remove_request(req);
545 nfs_end_page_writeback(req->wb_page);
503 nfs_inode_remove_request(req); 546 nfs_inode_remove_request(req);
504 nfs_clear_page_writeback(req); 547 nfs_clear_page_writeback(req);
505 } 548 }
@@ -513,6 +556,7 @@ static void nfs_cancel_commit_list(struct list_head *head)
513 req = nfs_list_entry(head->next); 556 req = nfs_list_entry(head->next);
514 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 557 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
515 nfs_list_remove_request(req); 558 nfs_list_remove_request(req);
559 clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
516 nfs_inode_remove_request(req); 560 nfs_inode_remove_request(req);
517 nfs_unlock_request(req); 561 nfs_unlock_request(req);
518 } 562 }
@@ -739,26 +783,12 @@ int nfs_updatepage(struct file *file, struct page *page,
739 783
740static void nfs_writepage_release(struct nfs_page *req) 784static void nfs_writepage_release(struct nfs_page *req)
741{ 785{
742 nfs_end_page_writeback(req->wb_page);
743
744#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
745 if (!PageError(req->wb_page)) {
746 if (NFS_NEED_RESCHED(req)) {
747 nfs_redirty_request(req);
748 goto out;
749 } else if (NFS_NEED_COMMIT(req)) {
750 nfs_mark_request_commit(req);
751 goto out;
752 }
753 }
754 nfs_inode_remove_request(req);
755 786
756out: 787 if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) {
757 nfs_clear_commit(req); 788 nfs_end_page_writeback(req->wb_page);
758 nfs_clear_reschedule(req); 789 nfs_inode_remove_request(req);
759#else 790 } else
760 nfs_inode_remove_request(req); 791 nfs_end_page_writeback(req->wb_page);
761#endif
762 nfs_clear_page_writeback(req); 792 nfs_clear_page_writeback(req);
763} 793}
764 794
@@ -891,6 +921,7 @@ out_bad:
891 nfs_writedata_release(data); 921 nfs_writedata_release(data);
892 } 922 }
893 nfs_redirty_request(req); 923 nfs_redirty_request(req);
924 nfs_end_page_writeback(req->wb_page);
894 nfs_clear_page_writeback(req); 925 nfs_clear_page_writeback(req);
895 return -ENOMEM; 926 return -ENOMEM;
896} 927}
@@ -936,6 +967,7 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, int how)
936 struct nfs_page *req = nfs_list_entry(head->next); 967 struct nfs_page *req = nfs_list_entry(head->next);
937 nfs_list_remove_request(req); 968 nfs_list_remove_request(req);
938 nfs_redirty_request(req); 969 nfs_redirty_request(req);
970 nfs_end_page_writeback(req->wb_page);
939 nfs_clear_page_writeback(req); 971 nfs_clear_page_writeback(req);
940 } 972 }
941 return -ENOMEM; 973 return -ENOMEM;
@@ -971,6 +1003,7 @@ out_err:
971 req = nfs_list_entry(head->next); 1003 req = nfs_list_entry(head->next);
972 nfs_list_remove_request(req); 1004 nfs_list_remove_request(req);
973 nfs_redirty_request(req); 1005 nfs_redirty_request(req);
1006 nfs_end_page_writeback(req->wb_page);
974 nfs_clear_page_writeback(req); 1007 nfs_clear_page_writeback(req);
975 } 1008 }
976 return error; 1009 return error;
@@ -998,22 +1031,28 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
998 nfs_set_pageerror(page); 1031 nfs_set_pageerror(page);
999 req->wb_context->error = task->tk_status; 1032 req->wb_context->error = task->tk_status;
1000 dprintk(", error = %d\n", task->tk_status); 1033 dprintk(", error = %d\n", task->tk_status);
1001 } else { 1034 goto out;
1002#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1003 if (data->verf.committed < NFS_FILE_SYNC) {
1004 if (!NFS_NEED_COMMIT(req)) {
1005 nfs_defer_commit(req);
1006 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1007 dprintk(" defer commit\n");
1008 } else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) {
1009 nfs_defer_reschedule(req);
1010 dprintk(" server reboot detected\n");
1011 }
1012 } else
1013#endif
1014 dprintk(" OK\n");
1015 } 1035 }
1016 1036
1037 if (nfs_write_need_commit(data)) {
1038 spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock;
1039
1040 spin_lock(req_lock);
1041 if (test_bit(PG_NEED_RESCHED, &req->wb_flags)) {
1042 /* Do nothing we need to resend the writes */
1043 } else if (!test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags)) {
1044 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1045 dprintk(" defer commit\n");
1046 } else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) {
1047 set_bit(PG_NEED_RESCHED, &req->wb_flags);
1048 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
1049 dprintk(" server reboot detected\n");
1050 }
1051 spin_unlock(req_lock);
1052 } else
1053 dprintk(" OK\n");
1054
1055out:
1017 if (atomic_dec_and_test(&req->wb_complete)) 1056 if (atomic_dec_and_test(&req->wb_complete))
1018 nfs_writepage_release(req); 1057 nfs_writepage_release(req);
1019} 1058}
@@ -1054,25 +1093,21 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
1054 if (task->tk_status < 0) { 1093 if (task->tk_status < 0) {
1055 nfs_set_pageerror(page); 1094 nfs_set_pageerror(page);
1056 req->wb_context->error = task->tk_status; 1095 req->wb_context->error = task->tk_status;
1057 nfs_end_page_writeback(page);
1058 nfs_inode_remove_request(req);
1059 dprintk(", error = %d\n", task->tk_status); 1096 dprintk(", error = %d\n", task->tk_status);
1060 goto next; 1097 goto remove_request;
1061 } 1098 }
1062 nfs_end_page_writeback(page);
1063 1099
1064#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 1100 if (nfs_write_need_commit(data)) {
1065 if (data->args.stable != NFS_UNSTABLE || data->verf.committed == NFS_FILE_SYNC) { 1101 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1066 nfs_inode_remove_request(req); 1102 nfs_mark_request_commit(req);
1067 dprintk(" OK\n"); 1103 nfs_end_page_writeback(page);
1104 dprintk(" marked for commit\n");
1068 goto next; 1105 goto next;
1069 } 1106 }
1070 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf)); 1107 dprintk(" OK\n");
1071 nfs_mark_request_commit(req); 1108remove_request:
1072 dprintk(" marked for commit\n"); 1109 nfs_end_page_writeback(page);
1073#else
1074 nfs_inode_remove_request(req); 1110 nfs_inode_remove_request(req);
1075#endif
1076 next: 1111 next:
1077 nfs_clear_page_writeback(req); 1112 nfs_clear_page_writeback(req);
1078 } 1113 }
@@ -1260,6 +1295,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
1260 while (!list_empty(&data->pages)) { 1295 while (!list_empty(&data->pages)) {
1261 req = nfs_list_entry(data->pages.next); 1296 req = nfs_list_entry(data->pages.next);
1262 nfs_list_remove_request(req); 1297 nfs_list_remove_request(req);
1298 clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
1263 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 1299 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1264 1300
1265 dprintk("NFS: commit (%s/%Ld %d@%Ld)", 1301 dprintk("NFS: commit (%s/%Ld %d@%Ld)",
@@ -1495,15 +1531,22 @@ int nfs_wb_page(struct inode *inode, struct page* page)
1495 1531
1496int nfs_set_page_dirty(struct page *page) 1532int nfs_set_page_dirty(struct page *page)
1497{ 1533{
1534 spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock;
1498 struct nfs_page *req; 1535 struct nfs_page *req;
1536 int ret;
1499 1537
1500 req = nfs_page_find_request(page); 1538 spin_lock(req_lock);
1539 req = nfs_page_find_request_locked(page);
1501 if (req != NULL) { 1540 if (req != NULL) {
1502 /* Mark any existing write requests for flushing */ 1541 /* Mark any existing write requests for flushing */
1503 set_bit(PG_NEED_FLUSH, &req->wb_flags); 1542 ret = !test_and_set_bit(PG_NEED_FLUSH, &req->wb_flags);
1543 spin_unlock(req_lock);
1504 nfs_release_request(req); 1544 nfs_release_request(req);
1545 return ret;
1505 } 1546 }
1506 return __set_page_dirty_nobuffers(page); 1547 ret = __set_page_dirty_nobuffers(page);
1548 spin_unlock(req_lock);
1549 return ret;
1507} 1550}
1508 1551
1509 1552
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 6f677988c71d..7e4bb0af24d7 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -859,8 +859,8 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
859#define NFS3_ENTRY_BAGGAGE (2 + 1 + 2 + 1) 859#define NFS3_ENTRY_BAGGAGE (2 + 1 + 2 + 1)
860#define NFS3_ENTRYPLUS_BAGGAGE (1 + 21 + 1 + (NFS3_FHSIZE >> 2)) 860#define NFS3_ENTRYPLUS_BAGGAGE (1 + 21 + 1 + (NFS3_FHSIZE >> 2))
861static int 861static int
862encode_entry(struct readdir_cd *ccd, const char *name, 862encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
863 int namlen, off_t offset, ino_t ino, unsigned int d_type, int plus) 863 loff_t offset, ino_t ino, unsigned int d_type, int plus)
864{ 864{
865 struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres, 865 struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres,
866 common); 866 common);
@@ -880,7 +880,7 @@ encode_entry(struct readdir_cd *ccd, const char *name,
880 *cd->offset1 = htonl(offset64 & 0xffffffff); 880 *cd->offset1 = htonl(offset64 & 0xffffffff);
881 cd->offset1 = NULL; 881 cd->offset1 = NULL;
882 } else { 882 } else {
883 xdr_encode_hyper(cd->offset, (u64) offset); 883 xdr_encode_hyper(cd->offset, offset64);
884 } 884 }
885 } 885 }
886 886
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index 832673b14587..673a53c014a3 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -228,7 +228,7 @@ _posix_to_nfsv4_one(struct posix_acl *pacl, struct nfs4_acl *acl,
228 struct posix_acl_summary pas; 228 struct posix_acl_summary pas;
229 unsigned short deny; 229 unsigned short deny;
230 int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ? 230 int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
231 NFS4_INHERITANCE_FLAGS : 0); 231 NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
232 232
233 BUG_ON(pacl->a_count < 3); 233 BUG_ON(pacl->a_count < 3);
234 summarize_posix_acl(pacl, &pas); 234 summarize_posix_acl(pacl, &pas);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 9e4067999209..af360705e551 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -750,9 +750,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
750 status = nfserr_clid_inuse; 750 status = nfserr_clid_inuse;
751 if (!cmp_creds(&conf->cl_cred, &rqstp->rq_cred) 751 if (!cmp_creds(&conf->cl_cred, &rqstp->rq_cred)
752 || conf->cl_addr != sin->sin_addr.s_addr) { 752 || conf->cl_addr != sin->sin_addr.s_addr) {
753 printk("NFSD: setclientid: string in use by client" 753 dprintk("NFSD: setclientid: string in use by client"
754 "(clientid %08x/%08x)\n", 754 "at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr));
755 conf->cl_clientid.cl_boot, conf->cl_clientid.cl_id);
756 goto out; 755 goto out;
757 } 756 }
758 } 757 }
@@ -3261,7 +3260,6 @@ __nfs4_state_shutdown(void)
3261 unhash_delegation(dp); 3260 unhash_delegation(dp);
3262 } 3261 }
3263 3262
3264 cancel_delayed_work(&laundromat_work);
3265 nfsd4_shutdown_recdir(); 3263 nfsd4_shutdown_recdir();
3266 nfs4_init = 0; 3264 nfs4_init = 0;
3267} 3265}
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 6087c4749fee..c558442a0b44 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -138,8 +138,10 @@ static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm);
138 138
139void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) 139void __dlm_unhash_lockres(struct dlm_lock_resource *lockres)
140{ 140{
141 hlist_del_init(&lockres->hash_node); 141 if (!hlist_unhashed(&lockres->hash_node)) {
142 dlm_lockres_put(lockres); 142 hlist_del_init(&lockres->hash_node);
143 dlm_lockres_put(lockres);
144 }
143} 145}
144 146
145void __dlm_insert_lockres(struct dlm_ctxt *dlm, 147void __dlm_insert_lockres(struct dlm_ctxt *dlm,
@@ -655,6 +657,8 @@ void dlm_unregister_domain(struct dlm_ctxt *dlm)
655 dlm_kick_thread(dlm, NULL); 657 dlm_kick_thread(dlm, NULL);
656 658
657 while (dlm_migrate_all_locks(dlm)) { 659 while (dlm_migrate_all_locks(dlm)) {
660 /* Give dlm_thread time to purge the lockres' */
661 msleep(500);
658 mlog(0, "%s: more migration to do\n", dlm->name); 662 mlog(0, "%s: more migration to do\n", dlm->name);
659 } 663 }
660 dlm_mark_domain_leaving(dlm); 664 dlm_mark_domain_leaving(dlm);
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 9229e04362f6..6edffca99d98 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -2424,6 +2424,57 @@ static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data)
2424 dlm_lockres_put(res); 2424 dlm_lockres_put(res);
2425} 2425}
2426 2426
2427/* Checks whether the lockres can be migrated. Returns 0 if yes, < 0
2428 * if not. If 0, numlocks is set to the number of locks in the lockres.
2429 */
2430static int dlm_is_lockres_migrateable(struct dlm_ctxt *dlm,
2431 struct dlm_lock_resource *res,
2432 int *numlocks)
2433{
2434 int ret;
2435 int i;
2436 int count = 0;
2437 struct list_head *queue, *iter;
2438 struct dlm_lock *lock;
2439
2440 assert_spin_locked(&res->spinlock);
2441
2442 ret = -EINVAL;
2443 if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
2444 mlog(0, "cannot migrate lockres with unknown owner!\n");
2445 goto leave;
2446 }
2447
2448 if (res->owner != dlm->node_num) {
2449 mlog(0, "cannot migrate lockres this node doesn't own!\n");
2450 goto leave;
2451 }
2452
2453 ret = 0;
2454 queue = &res->granted;
2455 for (i = 0; i < 3; i++) {
2456 list_for_each(iter, queue) {
2457 lock = list_entry(iter, struct dlm_lock, list);
2458 ++count;
2459 if (lock->ml.node == dlm->node_num) {
2460 mlog(0, "found a lock owned by this node still "
2461 "on the %s queue! will not migrate this "
2462 "lockres\n", (i == 0 ? "granted" :
2463 (i == 1 ? "converting" :
2464 "blocked")));
2465 ret = -ENOTEMPTY;
2466 goto leave;
2467 }
2468 }
2469 queue++;
2470 }
2471
2472 *numlocks = count;
2473 mlog(0, "migrateable lockres having %d locks\n", *numlocks);
2474
2475leave:
2476 return ret;
2477}
2427 2478
2428/* 2479/*
2429 * DLM_MIGRATE_LOCKRES 2480 * DLM_MIGRATE_LOCKRES
@@ -2437,14 +2488,12 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
2437 struct dlm_master_list_entry *mle = NULL; 2488 struct dlm_master_list_entry *mle = NULL;
2438 struct dlm_master_list_entry *oldmle = NULL; 2489 struct dlm_master_list_entry *oldmle = NULL;
2439 struct dlm_migratable_lockres *mres = NULL; 2490 struct dlm_migratable_lockres *mres = NULL;
2440 int ret = -EINVAL; 2491 int ret = 0;
2441 const char *name; 2492 const char *name;
2442 unsigned int namelen; 2493 unsigned int namelen;
2443 int mle_added = 0; 2494 int mle_added = 0;
2444 struct list_head *queue, *iter; 2495 int numlocks;
2445 int i; 2496 int wake = 0;
2446 struct dlm_lock *lock;
2447 int empty = 1, wake = 0;
2448 2497
2449 if (!dlm_grab(dlm)) 2498 if (!dlm_grab(dlm))
2450 return -EINVAL; 2499 return -EINVAL;
@@ -2458,42 +2507,16 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
2458 * ensure this lockres is a proper candidate for migration 2507 * ensure this lockres is a proper candidate for migration
2459 */ 2508 */
2460 spin_lock(&res->spinlock); 2509 spin_lock(&res->spinlock);
2461 if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { 2510 ret = dlm_is_lockres_migrateable(dlm, res, &numlocks);
2462 mlog(0, "cannot migrate lockres with unknown owner!\n"); 2511 if (ret < 0) {
2463 spin_unlock(&res->spinlock);
2464 goto leave;
2465 }
2466 if (res->owner != dlm->node_num) {
2467 mlog(0, "cannot migrate lockres this node doesn't own!\n");
2468 spin_unlock(&res->spinlock); 2512 spin_unlock(&res->spinlock);
2469 goto leave; 2513 goto leave;
2470 } 2514 }
2471 mlog(0, "checking queues...\n");
2472 queue = &res->granted;
2473 for (i=0; i<3; i++) {
2474 list_for_each(iter, queue) {
2475 lock = list_entry (iter, struct dlm_lock, list);
2476 empty = 0;
2477 if (lock->ml.node == dlm->node_num) {
2478 mlog(0, "found a lock owned by this node "
2479 "still on the %s queue! will not "
2480 "migrate this lockres\n",
2481 i==0 ? "granted" :
2482 (i==1 ? "converting" : "blocked"));
2483 spin_unlock(&res->spinlock);
2484 ret = -ENOTEMPTY;
2485 goto leave;
2486 }
2487 }
2488 queue++;
2489 }
2490 mlog(0, "all locks on this lockres are nonlocal. continuing\n");
2491 spin_unlock(&res->spinlock); 2515 spin_unlock(&res->spinlock);
2492 2516
2493 /* no work to do */ 2517 /* no work to do */
2494 if (empty) { 2518 if (numlocks == 0) {
2495 mlog(0, "no locks were found on this lockres! done!\n"); 2519 mlog(0, "no locks were found on this lockres! done!\n");
2496 ret = 0;
2497 goto leave; 2520 goto leave;
2498 } 2521 }
2499 2522
@@ -2729,6 +2752,7 @@ int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
2729{ 2752{
2730 int ret; 2753 int ret;
2731 int lock_dropped = 0; 2754 int lock_dropped = 0;
2755 int numlocks;
2732 2756
2733 spin_lock(&res->spinlock); 2757 spin_lock(&res->spinlock);
2734 if (res->owner != dlm->node_num) { 2758 if (res->owner != dlm->node_num) {
@@ -2740,6 +2764,13 @@ int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
2740 spin_unlock(&res->spinlock); 2764 spin_unlock(&res->spinlock);
2741 goto leave; 2765 goto leave;
2742 } 2766 }
2767
2768 /* No need to migrate a lockres having no locks */
2769 ret = dlm_is_lockres_migrateable(dlm, res, &numlocks);
2770 if (ret >= 0 && numlocks == 0) {
2771 spin_unlock(&res->spinlock);
2772 goto leave;
2773 }
2743 spin_unlock(&res->spinlock); 2774 spin_unlock(&res->spinlock);
2744 2775
2745 /* Wheee! Migrate lockres here! Will sleep so drop spinlock. */ 2776 /* Wheee! Migrate lockres here! Will sleep so drop spinlock. */
diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
index 6421a8fae1de..2b264c6ba039 100644
--- a/fs/ocfs2/dlm/dlmthread.c
+++ b/fs/ocfs2/dlm/dlmthread.c
@@ -256,20 +256,14 @@ static void dlm_run_purge_list(struct dlm_ctxt *dlm,
256 break; 256 break;
257 } 257 }
258 258
259 mlog(0, "removing lockres %.*s:%p from purgelist\n", 259 dlm_lockres_get(lockres);
260 lockres->lockname.len, lockres->lockname.name, lockres);
261 list_del_init(&lockres->purge);
262 dlm_lockres_put(lockres);
263 dlm->purge_count--;
264 260
265 /* This may drop and reacquire the dlm spinlock if it 261 /* This may drop and reacquire the dlm spinlock if it
266 * has to do migration. */ 262 * has to do migration. */
267 mlog(0, "calling dlm_purge_lockres!\n");
268 dlm_lockres_get(lockres);
269 if (dlm_purge_lockres(dlm, lockres)) 263 if (dlm_purge_lockres(dlm, lockres))
270 BUG(); 264 BUG();
265
271 dlm_lockres_put(lockres); 266 dlm_lockres_put(lockres);
272 mlog(0, "DONE calling dlm_purge_lockres!\n");
273 267
274 /* Avoid adding any scheduling latencies */ 268 /* Avoid adding any scheduling latencies */
275 cond_resched_lock(&dlm->spinlock); 269 cond_resched_lock(&dlm->spinlock);
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index a6b3a8f878f0..bce38e3f06cb 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -8,8 +8,9 @@ proc-y := nommu.o task_nommu.o
8proc-$(CONFIG_MMU) := mmu.o task_mmu.o 8proc-$(CONFIG_MMU) := mmu.o task_mmu.o
9 9
10proc-y += inode.o root.o base.o generic.o array.o \ 10proc-y += inode.o root.o base.o generic.o array.o \
11 proc_tty.o proc_misc.o proc_sysctl.o 11 proc_tty.o proc_misc.o
12 12
13proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o
13proc-$(CONFIG_PROC_KCORE) += kcore.o 14proc-$(CONFIG_PROC_KCORE) += kcore.o
14proc-$(CONFIG_PROC_VMCORE) += vmcore.o 15proc-$(CONFIG_PROC_VMCORE) += vmcore.o
15proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o 16proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index c932aa65e198..f771889183c3 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -11,7 +11,11 @@
11 11
12#include <linux/proc_fs.h> 12#include <linux/proc_fs.h>
13 13
14#ifdef CONFIG_PROC_SYSCTL
14extern int proc_sys_init(void); 15extern int proc_sys_init(void);
16#else
17static inline void proc_sys_init(void) { }
18#endif
15 19
16struct vmalloc_info { 20struct vmalloc_info {
17 unsigned long used; 21 unsigned long used;
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 5834a744c2a9..41f17037f738 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -79,9 +79,7 @@ void __init proc_root_init(void)
79 proc_device_tree_init(); 79 proc_device_tree_init();
80#endif 80#endif
81 proc_bus = proc_mkdir("bus", NULL); 81 proc_bus = proc_mkdir("bus", NULL);
82#ifdef CONFIG_SYSCTL
83 proc_sys_init(); 82 proc_sys_init();
84#endif
85} 83}
86 84
87static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat 85static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index b9b423b22a8b..9475557ab499 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -23,7 +23,7 @@ static void sd_decrement_key(struct cpu_key *key)
23{ 23{
24 key->on_disk_key.k_objectid--; 24 key->on_disk_key.k_objectid--;
25 set_cpu_key_k_type(key, TYPE_ANY); 25 set_cpu_key_k_type(key, TYPE_ANY);
26 set_cpu_key_k_offset(key, (loff_t) (-1)); 26 set_cpu_key_k_offset(key, (loff_t)(~0ULL >> 1));
27} 27}
28 28
29static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize) 29static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index f01389fd162e..c8178b7b9212 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -54,82 +54,48 @@
54static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char 54static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
55 *prefix); 55 *prefix);
56 56
57static struct dentry *create_xa_root(struct super_block *sb) 57/* Returns the dentry referring to the root of the extended attribute
58 * directory tree. If it has already been retrieved, it is used. If it
59 * hasn't been created and the flags indicate creation is allowed, we
60 * attempt to create it. On error, we return a pointer-encoded error.
61 */
62static struct dentry *get_xa_root(struct super_block *sb, int flags)
58{ 63{
59 struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root); 64 struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root);
60 struct dentry *xaroot; 65 struct dentry *xaroot;
61 66
62 /* This needs to be created at mount-time */ 67 /* This needs to be created at mount-time */
63 if (!privroot) 68 if (!privroot)
64 return ERR_PTR(-EOPNOTSUPP); 69 return ERR_PTR(-ENODATA);
65 70
66 xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME)); 71 mutex_lock(&privroot->d_inode->i_mutex);
67 if (IS_ERR(xaroot)) { 72 if (REISERFS_SB(sb)->xattr_root) {
73 xaroot = dget(REISERFS_SB(sb)->xattr_root);
68 goto out; 74 goto out;
69 } else if (!xaroot->d_inode) {
70 int err;
71 mutex_lock(&privroot->d_inode->i_mutex);
72 err =
73 privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot,
74 0700);
75 mutex_unlock(&privroot->d_inode->i_mutex);
76
77 if (err) {
78 dput(xaroot);
79 dput(privroot);
80 return ERR_PTR(err);
81 }
82 REISERFS_SB(sb)->xattr_root = dget(xaroot);
83 } 75 }
84 76
85 out:
86 dput(privroot);
87 return xaroot;
88}
89
90/* This will return a dentry, or error, refering to the xa root directory.
91 * If the xa root doesn't exist yet, the dentry will be returned without
92 * an associated inode. This dentry can be used with ->mkdir to create
93 * the xa directory. */
94static struct dentry *__get_xa_root(struct super_block *s)
95{
96 struct dentry *privroot = dget(REISERFS_SB(s)->priv_root);
97 struct dentry *xaroot = NULL;
98
99 if (IS_ERR(privroot) || !privroot)
100 return privroot;
101
102 xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME)); 77 xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME));
103 if (IS_ERR(xaroot)) { 78 if (IS_ERR(xaroot)) {
104 goto out; 79 goto out;
105 } else if (!xaroot->d_inode) { 80 } else if (!xaroot->d_inode) {
106 dput(xaroot); 81 int err = -ENODATA;
107 xaroot = NULL; 82 if (flags == 0 || flags & XATTR_CREATE)
108 goto out; 83 err = privroot->d_inode->i_op->mkdir(privroot->d_inode,
84 xaroot, 0700);
85 if (err) {
86 dput(xaroot);
87 xaroot = ERR_PTR(err);
88 goto out;
89 }
109 } 90 }
110 91 REISERFS_SB(sb)->xattr_root = dget(xaroot);
111 REISERFS_SB(s)->xattr_root = dget(xaroot);
112 92
113 out: 93 out:
94 mutex_unlock(&privroot->d_inode->i_mutex);
114 dput(privroot); 95 dput(privroot);
115 return xaroot; 96 return xaroot;
116} 97}
117 98
118/* Returns the dentry (or NULL) referring to the root of the extended
119 * attribute directory tree. If it has already been retrieved, it is used.
120 * Otherwise, we attempt to retrieve it from disk. It may also return
121 * a pointer-encoded error.
122 */
123static inline struct dentry *get_xa_root(struct super_block *s)
124{
125 struct dentry *dentry = dget(REISERFS_SB(s)->xattr_root);
126
127 if (!dentry)
128 dentry = __get_xa_root(s);
129
130 return dentry;
131}
132
133/* Opens the directory corresponding to the inode's extended attribute store. 99/* Opens the directory corresponding to the inode's extended attribute store.
134 * If flags allow, the tree to the directory may be created. If creation is 100 * If flags allow, the tree to the directory may be created. If creation is
135 * prohibited, -ENODATA is returned. */ 101 * prohibited, -ENODATA is returned. */
@@ -138,21 +104,11 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
138 struct dentry *xaroot, *xadir; 104 struct dentry *xaroot, *xadir;
139 char namebuf[17]; 105 char namebuf[17];
140 106
141 xaroot = get_xa_root(inode->i_sb); 107 xaroot = get_xa_root(inode->i_sb, flags);
142 if (IS_ERR(xaroot)) { 108 if (IS_ERR(xaroot))
143 return xaroot; 109 return xaroot;
144 } else if (!xaroot) {
145 if (flags == 0 || flags & XATTR_CREATE) {
146 xaroot = create_xa_root(inode->i_sb);
147 if (IS_ERR(xaroot))
148 return xaroot;
149 }
150 if (!xaroot)
151 return ERR_PTR(-ENODATA);
152 }
153 110
154 /* ok, we have xaroot open */ 111 /* ok, we have xaroot open */
155
156 snprintf(namebuf, sizeof(namebuf), "%X.%X", 112 snprintf(namebuf, sizeof(namebuf), "%X.%X",
157 le32_to_cpu(INODE_PKEY(inode)->k_objectid), 113 le32_to_cpu(INODE_PKEY(inode)->k_objectid),
158 inode->i_generation); 114 inode->i_generation);
@@ -821,7 +777,7 @@ int reiserfs_delete_xattrs(struct inode *inode)
821 777
822 /* Leftovers besides . and .. -- that's not good. */ 778 /* Leftovers besides . and .. -- that's not good. */
823 if (dir->d_inode->i_nlink <= 2) { 779 if (dir->d_inode->i_nlink <= 2) {
824 root = get_xa_root(inode->i_sb); 780 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
825 reiserfs_write_lock_xattrs(inode->i_sb); 781 reiserfs_write_lock_xattrs(inode->i_sb);
826 err = vfs_rmdir(root->d_inode, dir); 782 err = vfs_rmdir(root->d_inode, dir);
827 reiserfs_write_unlock_xattrs(inode->i_sb); 783 reiserfs_write_unlock_xattrs(inode->i_sb);
diff --git a/fs/splice.c b/fs/splice.c
index 2fca6ebf4cc2..5428b0ff3b6f 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -576,76 +576,21 @@ static int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
576 if (this_len + offset > PAGE_CACHE_SIZE) 576 if (this_len + offset > PAGE_CACHE_SIZE)
577 this_len = PAGE_CACHE_SIZE - offset; 577 this_len = PAGE_CACHE_SIZE - offset;
578 578
579 /*
580 * Reuse buf page, if SPLICE_F_MOVE is set and we are doing a full
581 * page.
582 */
583 if ((sd->flags & SPLICE_F_MOVE) && this_len == PAGE_CACHE_SIZE) {
584 /*
585 * If steal succeeds, buf->page is now pruned from the
586 * pagecache and we can reuse it. The page will also be
587 * locked on successful return.
588 */
589 if (buf->ops->steal(pipe, buf))
590 goto find_page;
591
592 page = buf->page;
593 if (add_to_page_cache(page, mapping, index, GFP_KERNEL)) {
594 unlock_page(page);
595 goto find_page;
596 }
597
598 page_cache_get(page);
599
600 if (!(buf->flags & PIPE_BUF_FLAG_LRU))
601 lru_cache_add(page);
602 } else {
603find_page: 579find_page:
604 page = find_lock_page(mapping, index); 580 page = find_lock_page(mapping, index);
605 if (!page) { 581 if (!page) {
606 ret = -ENOMEM; 582 ret = -ENOMEM;
607 page = page_cache_alloc_cold(mapping); 583 page = page_cache_alloc_cold(mapping);
608 if (unlikely(!page)) 584 if (unlikely(!page))
609 goto out_ret; 585 goto out_ret;
610
611 /*
612 * This will also lock the page
613 */
614 ret = add_to_page_cache_lru(page, mapping, index,
615 GFP_KERNEL);
616 if (unlikely(ret))
617 goto out;
618 }
619 586
620 /* 587 /*
621 * We get here with the page locked. If the page is also 588 * This will also lock the page
622 * uptodate, we don't need to do more. If it isn't, we
623 * may need to bring it in if we are not going to overwrite
624 * the full page.
625 */ 589 */
626 if (!PageUptodate(page)) { 590 ret = add_to_page_cache_lru(page, mapping, index,
627 if (this_len < PAGE_CACHE_SIZE) { 591 GFP_KERNEL);
628 ret = mapping->a_ops->readpage(file, page); 592 if (unlikely(ret))
629 if (unlikely(ret)) 593 goto out;
630 goto out;
631
632 lock_page(page);
633
634 if (!PageUptodate(page)) {
635 /*
636 * Page got invalidated, repeat.
637 */
638 if (!page->mapping) {
639 unlock_page(page);
640 page_cache_release(page);
641 goto find_page;
642 }
643 ret = -EIO;
644 goto out;
645 }
646 } else
647 SetPageUptodate(page);
648 }
649 } 594 }
650 595
651 ret = mapping->a_ops->prepare_write(file, page, offset, offset+this_len); 596 ret = mapping->a_ops->prepare_write(file, page, offset, offset+this_len);
@@ -682,18 +627,25 @@ find_page:
682 } 627 }
683 628
684 ret = mapping->a_ops->commit_write(file, page, offset, offset+this_len); 629 ret = mapping->a_ops->commit_write(file, page, offset, offset+this_len);
685 if (!ret) { 630 if (ret) {
631 if (ret == AOP_TRUNCATED_PAGE) {
632 page_cache_release(page);
633 goto find_page;
634 }
635 if (ret < 0)
636 goto out;
686 /* 637 /*
687 * Return the number of bytes written and mark page as 638 * Partial write has happened, so 'ret' already initialized by
688 * accessed, we are now done! 639 * number of bytes written, Where is nothing we have to do here.
689 */ 640 */
641 } else
690 ret = this_len; 642 ret = this_len;
691 mark_page_accessed(page); 643 /*
692 balance_dirty_pages_ratelimited(mapping); 644 * Return the number of bytes written and mark page as
693 } else if (ret == AOP_TRUNCATED_PAGE) { 645 * accessed, we are now done!
694 page_cache_release(page); 646 */
695 goto find_page; 647 mark_page_accessed(page);
696 } 648 balance_dirty_pages_ratelimited(mapping);
697out: 649out:
698 page_cache_release(page); 650 page_cache_release(page);
699 unlock_page(page); 651 unlock_page(page);
@@ -706,9 +658,9 @@ out_ret:
706 * key here is the 'actor' worker passed in that actually moves the data 658 * key here is the 'actor' worker passed in that actually moves the data
707 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above. 659 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.
708 */ 660 */
709static ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, 661ssize_t __splice_from_pipe(struct pipe_inode_info *pipe,
710 struct file *out, loff_t *ppos, size_t len, 662 struct file *out, loff_t *ppos, size_t len,
711 unsigned int flags, splice_actor *actor) 663 unsigned int flags, splice_actor *actor)
712{ 664{
713 int ret, do_wakeup, err; 665 int ret, do_wakeup, err;
714 struct splice_desc sd; 666 struct splice_desc sd;
@@ -802,6 +754,7 @@ static ssize_t __splice_from_pipe(struct pipe_inode_info *pipe,
802 754
803 return ret; 755 return ret;
804} 756}
757EXPORT_SYMBOL(__splice_from_pipe);
805 758
806ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, 759ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
807 loff_t *ppos, size_t len, unsigned int flags, 760 loff_t *ppos, size_t len, unsigned int flags,
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 013d7afe7cde..f18b79122fa3 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -601,7 +601,7 @@ static void ufs_set_inode_ops(struct inode *inode)
601 ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); 601 ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
602} 602}
603 603
604static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode) 604static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
605{ 605{
606 struct ufs_inode_info *ufsi = UFS_I(inode); 606 struct ufs_inode_info *ufsi = UFS_I(inode);
607 struct super_block *sb = inode->i_sb; 607 struct super_block *sb = inode->i_sb;
@@ -613,8 +613,10 @@ static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
613 */ 613 */
614 inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode); 614 inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode);
615 inode->i_nlink = fs16_to_cpu(sb, ufs_inode->ui_nlink); 615 inode->i_nlink = fs16_to_cpu(sb, ufs_inode->ui_nlink);
616 if (inode->i_nlink == 0) 616 if (inode->i_nlink == 0) {
617 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); 617 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino);
618 return -1;
619 }
618 620
619 /* 621 /*
620 * Linux now has 32-bit uid and gid, so we can support EFT. 622 * Linux now has 32-bit uid and gid, so we can support EFT.
@@ -643,9 +645,10 @@ static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
643 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 645 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
644 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; 646 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i];
645 } 647 }
648 return 0;
646} 649}
647 650
648static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) 651static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
649{ 652{
650 struct ufs_inode_info *ufsi = UFS_I(inode); 653 struct ufs_inode_info *ufsi = UFS_I(inode);
651 struct super_block *sb = inode->i_sb; 654 struct super_block *sb = inode->i_sb;
@@ -658,8 +661,10 @@ static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
658 */ 661 */
659 inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode); 662 inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode);
660 inode->i_nlink = fs16_to_cpu(sb, ufs2_inode->ui_nlink); 663 inode->i_nlink = fs16_to_cpu(sb, ufs2_inode->ui_nlink);
661 if (inode->i_nlink == 0) 664 if (inode->i_nlink == 0) {
662 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); 665 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino);
666 return -1;
667 }
663 668
664 /* 669 /*
665 * Linux now has 32-bit uid and gid, so we can support EFT. 670 * Linux now has 32-bit uid and gid, so we can support EFT.
@@ -690,6 +695,7 @@ static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
690 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 695 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
691 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; 696 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i];
692 } 697 }
698 return 0;
693} 699}
694 700
695void ufs_read_inode(struct inode * inode) 701void ufs_read_inode(struct inode * inode)
@@ -698,6 +704,7 @@ void ufs_read_inode(struct inode * inode)
698 struct super_block * sb; 704 struct super_block * sb;
699 struct ufs_sb_private_info * uspi; 705 struct ufs_sb_private_info * uspi;
700 struct buffer_head * bh; 706 struct buffer_head * bh;
707 int err;
701 708
702 UFSD("ENTER, ino %lu\n", inode->i_ino); 709 UFSD("ENTER, ino %lu\n", inode->i_ino);
703 710
@@ -720,14 +727,17 @@ void ufs_read_inode(struct inode * inode)
720 if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { 727 if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
721 struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data; 728 struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
722 729
723 ufs2_read_inode(inode, 730 err = ufs2_read_inode(inode,
724 ufs2_inode + ufs_inotofsbo(inode->i_ino)); 731 ufs2_inode + ufs_inotofsbo(inode->i_ino));
725 } else { 732 } else {
726 struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data; 733 struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data;
727 734
728 ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino)); 735 err = ufs1_read_inode(inode,
736 ufs_inode + ufs_inotofsbo(inode->i_ino));
729 } 737 }
730 738
739 if (err)
740 goto bad_inode;
731 inode->i_version++; 741 inode->i_version++;
732 ufsi->i_lastfrag = 742 ufsi->i_lastfrag =
733 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; 743 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
@@ -888,6 +898,8 @@ void ufs_delete_inode (struct inode * inode)
888 loff_t old_i_size; 898 loff_t old_i_size;
889 899
890 truncate_inode_pages(&inode->i_data, 0); 900 truncate_inode_pages(&inode->i_data, 0);
901 if (is_bad_inode(inode))
902 goto no_delete;
891 /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/ 903 /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/
892 lock_kernel(); 904 lock_kernel();
893 mark_inode_dirty(inode); 905 mark_inode_dirty(inode);
@@ -898,4 +910,7 @@ void ufs_delete_inode (struct inode * inode)
898 ufs_warning(inode->i_sb, __FUNCTION__, "ufs_truncate failed\n"); 910 ufs_warning(inode->i_sb, __FUNCTION__, "ufs_truncate failed\n");
899 ufs_free_inode (inode); 911 ufs_free_inode (inode);
900 unlock_kernel(); 912 unlock_kernel();
913 return;
914no_delete:
915 clear_inode(inode); /* We must guarantee clearing of inode... */
901} 916}
diff --git a/include/asm-alpha/compiler.h b/include/asm-alpha/compiler.h
index d2768cc3d7a4..da6bb199839c 100644
--- a/include/asm-alpha/compiler.h
+++ b/include/asm-alpha/compiler.h
@@ -17,9 +17,6 @@
17# define __kernel_extbl(val, shift) __builtin_alpha_extbl(val, shift) 17# define __kernel_extbl(val, shift) __builtin_alpha_extbl(val, shift)
18# define __kernel_extwl(val, shift) __builtin_alpha_extwl(val, shift) 18# define __kernel_extwl(val, shift) __builtin_alpha_extwl(val, shift)
19# define __kernel_cmpbge(a, b) __builtin_alpha_cmpbge(a, b) 19# define __kernel_cmpbge(a, b) __builtin_alpha_cmpbge(a, b)
20# define __kernel_cttz(x) __builtin_ctzl(x)
21# define __kernel_ctlz(x) __builtin_clzl(x)
22# define __kernel_ctpop(x) __builtin_popcountl(x)
23#else 20#else
24# define __kernel_insbl(val, shift) \ 21# define __kernel_insbl(val, shift) \
25 ({ unsigned long __kir; \ 22 ({ unsigned long __kir; \
@@ -49,17 +46,39 @@
49 ({ unsigned long __kir; \ 46 ({ unsigned long __kir; \
50 __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \ 47 __asm__("cmpbge %r2,%1,%0" : "=r"(__kir) : "rI"(b), "rJ"(a)); \
51 __kir; }) 48 __kir; })
49#endif
50
51#ifdef __alpha_cix__
52# if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
53# define __kernel_cttz(x) __builtin_ctzl(x)
54# define __kernel_ctlz(x) __builtin_clzl(x)
55# define __kernel_ctpop(x) __builtin_popcountl(x)
56# else
57# define __kernel_cttz(x) \
58 ({ unsigned long __kir; \
59 __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \
60 __kir; })
61# define __kernel_ctlz(x) \
62 ({ unsigned long __kir; \
63 __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
64 __kir; })
65# define __kernel_ctpop(x) \
66 ({ unsigned long __kir; \
67 __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
68 __kir; })
69# endif
70#else
52# define __kernel_cttz(x) \ 71# define __kernel_cttz(x) \
53 ({ unsigned long __kir; \ 72 ({ unsigned long __kir; \
54 __asm__("cttz %1,%0" : "=r"(__kir) : "r"(x)); \ 73 __asm__(".arch ev67; cttz %1,%0" : "=r"(__kir) : "r"(x)); \
55 __kir; }) 74 __kir; })
56# define __kernel_ctlz(x) \ 75# define __kernel_ctlz(x) \
57 ({ unsigned long __kir; \ 76 ({ unsigned long __kir; \
58 __asm__("ctlz %1,%0" : "=r"(__kir) : "r"(x)); \ 77 __asm__(".arch ev67; ctlz %1,%0" : "=r"(__kir) : "r"(x)); \
59 __kir; }) 78 __kir; })
60# define __kernel_ctpop(x) \ 79# define __kernel_ctpop(x) \
61 ({ unsigned long __kir; \ 80 ({ unsigned long __kir; \
62 __asm__("ctpop %1,%0" : "=r"(__kir) : "r"(x)); \ 81 __asm__(".arch ev67; ctpop %1,%0" : "=r"(__kir) : "r"(x)); \
63 __kir; }) 82 __kir; })
64#endif 83#endif
65 84
@@ -78,16 +97,20 @@
78#else 97#else
79#define __kernel_ldbu(mem) \ 98#define __kernel_ldbu(mem) \
80 ({ unsigned char __kir; \ 99 ({ unsigned char __kir; \
81 __asm__("ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \ 100 __asm__(".arch ev56; \
101 ldbu %0,%1" : "=r"(__kir) : "m"(mem)); \
82 __kir; }) 102 __kir; })
83#define __kernel_ldwu(mem) \ 103#define __kernel_ldwu(mem) \
84 ({ unsigned short __kir; \ 104 ({ unsigned short __kir; \
85 __asm__("ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \ 105 __asm__(".arch ev56; \
106 ldwu %0,%1" : "=r"(__kir) : "m"(mem)); \
86 __kir; }) 107 __kir; })
87#define __kernel_stb(val,mem) \ 108#define __kernel_stb(val,mem) \
88 __asm__("stb %1,%0" : "=m"(mem) : "r"(val)) 109 __asm__(".arch ev56; \
89#define __kernel_stw(val,mem) \ 110 stb %1,%0" : "=m"(mem) : "r"(val))
90 __asm__("stw %1,%0" : "=m"(mem) : "r"(val)) 111#define __kernel_stw(val,mem) \
112 __asm__(".arch ev56; \
113 stw %1,%0" : "=m"(mem) : "r"(val))
91#endif 114#endif
92 115
93#ifdef __KERNEL__ 116#ifdef __KERNEL__
diff --git a/include/asm-alpha/core_mcpcia.h b/include/asm-alpha/core_mcpcia.h
index 980a3c51b18e..525b4f6a7ace 100644
--- a/include/asm-alpha/core_mcpcia.h
+++ b/include/asm-alpha/core_mcpcia.h
@@ -72,6 +72,8 @@
72 * 72 *
73 */ 73 */
74 74
75#define MCPCIA_MAX_HOSES 4
76
75#define MCPCIA_MID(m) ((unsigned long)(m) << 33) 77#define MCPCIA_MID(m) ((unsigned long)(m) << 33)
76 78
77/* Dodge has PCI0 and PCI1 at MID 4 and 5 respectively. 79/* Dodge has PCI0 and PCI1 at MID 4 and 5 respectively.
diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h
index 24bdcc8b63aa..21a86f1a05b3 100644
--- a/include/asm-alpha/io.h
+++ b/include/asm-alpha/io.h
@@ -113,6 +113,7 @@ static inline unsigned long virt_to_bus(void *address)
113 unsigned long bus = phys + __direct_map_base; 113 unsigned long bus = phys + __direct_map_base;
114 return phys <= __direct_map_size ? bus : 0; 114 return phys <= __direct_map_size ? bus : 0;
115} 115}
116#define isa_virt_to_bus virt_to_bus
116 117
117static inline void *bus_to_virt(unsigned long address) 118static inline void *bus_to_virt(unsigned long address)
118{ 119{
diff --git a/include/asm-arm/arch-ixp4xx/io.h b/include/asm-arm/arch-ixp4xx/io.h
index b7b5414d9320..a41ba229c564 100644
--- a/include/asm-arm/arch-ixp4xx/io.h
+++ b/include/asm-arm/arch-ixp4xx/io.h
@@ -238,23 +238,6 @@ __ixp4xx_readsl(const volatile void __iomem *bus_addr, u32 *vaddr, u32 count)
238#define memcpy_fromio(a,c,l) _memcpy_fromio((a),(c),(l)) 238#define memcpy_fromio(a,c,l) _memcpy_fromio((a),(c),(l))
239#define memcpy_toio(c,a,l) _memcpy_toio((c),(a),(l)) 239#define memcpy_toio(c,a,l) _memcpy_toio((c),(a),(l))
240 240
241static inline int
242check_signature(const unsigned char __iomem *bus_addr, const unsigned char *signature,
243 int length)
244{
245 int retval = 0;
246 do {
247 if (readb(bus_addr) != *signature)
248 goto out;
249 bus_addr++;
250 signature++;
251 length--;
252 } while (length);
253 retval = 1;
254out:
255 return retval;
256}
257
258#endif 241#endif
259 242
260#ifndef CONFIG_PCI 243#ifndef CONFIG_PCI
diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index f06d8a43fdee..69134c7518c1 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -3,6 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <asm/memory.h>
6 7
7#define CPU_ARCH_UNKNOWN 0 8#define CPU_ARCH_UNKNOWN 0
8#define CPU_ARCH_ARMv3 1 9#define CPU_ARCH_ARMv3 1
@@ -154,7 +155,7 @@ extern unsigned int user_debug;
154#define vectors_high() (0) 155#define vectors_high() (0)
155#endif 156#endif
156 157
157#if __LINUX_ARM_ARCH__ >= 6 158#if defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ >= 6
158#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \ 159#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
159 : : "r" (0) : "memory") 160 : : "r" (0) : "memory")
160#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ 161#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
@@ -168,22 +169,23 @@ extern unsigned int user_debug;
168#define dmb() __asm__ __volatile__ ("" : : : "memory") 169#define dmb() __asm__ __volatile__ ("" : : : "memory")
169#endif 170#endif
170 171
171#define mb() barrier() 172#ifndef CONFIG_SMP
172#define rmb() barrier() 173#define mb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
173#define wmb() barrier() 174#define rmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
174#define read_barrier_depends() do { } while(0) 175#define wmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
175 176#define smp_mb() barrier()
176#ifdef CONFIG_SMP 177#define smp_rmb() barrier()
177#define smp_mb() dmb() 178#define smp_wmb() barrier()
178#define smp_rmb() dmb()
179#define smp_wmb() dmb()
180#define smp_read_barrier_depends() read_barrier_depends()
181#else 179#else
182#define smp_mb() barrier() 180#define mb() dmb()
183#define smp_rmb() barrier() 181#define rmb() dmb()
184#define smp_wmb() barrier() 182#define wmb() dmb()
185#define smp_read_barrier_depends() read_barrier_depends() 183#define smp_mb() dmb()
186#endif /* CONFIG_SMP */ 184#define smp_rmb() dmb()
185#define smp_wmb() dmb()
186#endif
187#define read_barrier_depends() do { } while(0)
188#define smp_read_barrier_depends() do { } while(0)
187 189
188#define set_mb(var, value) do { var = value; smp_mb(); } while (0) 190#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
189#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t"); 191#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 0991b7bc3f78..c025ab47e4b9 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -372,7 +372,7 @@
372#define __NR_move_pages (__NR_SYSCALL_BASE+344) 372#define __NR_move_pages (__NR_SYSCALL_BASE+344)
373#define __NR_getcpu (__NR_SYSCALL_BASE+345) 373#define __NR_getcpu (__NR_SYSCALL_BASE+345)
374 /* 346 for epoll_pwait */ 374 /* 346 for epoll_pwait */
375#define __NR_sys_kexec_load (__NR_SYSCALL_BASE+347) 375#define __NR_kexec_load (__NR_SYSCALL_BASE+347)
376 376
377/* 377/*
378 * The following SWIs are ARM private. 378 * The following SWIs are ARM private.
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 00c23433b39f..6d7e279b1490 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -180,6 +180,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
180#ifndef __HAVE_ARCH_ENTER_LAZY_MMU_MODE 180#ifndef __HAVE_ARCH_ENTER_LAZY_MMU_MODE
181#define arch_enter_lazy_mmu_mode() do {} while (0) 181#define arch_enter_lazy_mmu_mode() do {} while (0)
182#define arch_leave_lazy_mmu_mode() do {} while (0) 182#define arch_leave_lazy_mmu_mode() do {} while (0)
183#define arch_flush_lazy_mmu_mode() do {} while (0)
183#endif 184#endif
184 185
185/* 186/*
@@ -193,6 +194,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
193#ifndef __HAVE_ARCH_ENTER_LAZY_CPU_MODE 194#ifndef __HAVE_ARCH_ENTER_LAZY_CPU_MODE
194#define arch_enter_lazy_cpu_mode() do {} while (0) 195#define arch_enter_lazy_cpu_mode() do {} while (0)
195#define arch_leave_lazy_cpu_mode() do {} while (0) 196#define arch_leave_lazy_cpu_mode() do {} while (0)
197#define arch_flush_lazy_cpu_mode() do {} while (0)
196#endif 198#endif
197 199
198/* 200/*
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index 3f92b94e0d75..d1b8e4ab6c1a 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -75,6 +75,7 @@
75#define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */ 75#define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */
76#define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */ 76#define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */
77#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */ 77#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
78#define X86_FEATURE_LAPIC_TIMER_BROKEN (3*32+ 14) /* lapic timer broken in C1 */
78 79
79/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 80/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
80#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */ 81#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
index ec3b6803fd36..2ad3f30b1a68 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -275,6 +275,8 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
275#define MSR_K7_FID_VID_CTL 0xC0010041 275#define MSR_K7_FID_VID_CTL 0xC0010041
276#define MSR_K7_FID_VID_STATUS 0xC0010042 276#define MSR_K7_FID_VID_STATUS 0xC0010042
277 277
278#define MSR_K8_ENABLE_C1E 0xC0010055
279
278/* extended feature register */ 280/* extended feature register */
279#define MSR_EFER 0xc0000080 281#define MSR_EFER 0xc0000080
280 282
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
index 46dc34ca887a..e63f1e444fcf 100644
--- a/include/asm-i386/paravirt.h
+++ b/include/asm-i386/paravirt.h
@@ -421,14 +421,17 @@ static inline void pmd_clear(pmd_t *pmdp)
421#define PARAVIRT_LAZY_NONE 0 421#define PARAVIRT_LAZY_NONE 0
422#define PARAVIRT_LAZY_MMU 1 422#define PARAVIRT_LAZY_MMU 1
423#define PARAVIRT_LAZY_CPU 2 423#define PARAVIRT_LAZY_CPU 2
424#define PARAVIRT_LAZY_FLUSH 3
424 425
425#define __HAVE_ARCH_ENTER_LAZY_CPU_MODE 426#define __HAVE_ARCH_ENTER_LAZY_CPU_MODE
426#define arch_enter_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_CPU) 427#define arch_enter_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_CPU)
427#define arch_leave_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE) 428#define arch_leave_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE)
429#define arch_flush_lazy_cpu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_FLUSH)
428 430
429#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE 431#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
430#define arch_enter_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_MMU) 432#define arch_enter_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_MMU)
431#define arch_leave_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE) 433#define arch_leave_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_NONE)
434#define arch_flush_lazy_mmu_mode() paravirt_ops.set_lazy_mode(PARAVIRT_LAZY_FLUSH)
432 435
433/* These all sit in the .parainstructions section to tell us what to patch. */ 436/* These all sit in the .parainstructions section to tell us what to patch. */
434struct paravirt_patch { 437struct paravirt_patch {
diff --git a/include/asm-i386/termbits.h b/include/asm-i386/termbits.h
index 12baf1d6343f..2e6237693814 100644
--- a/include/asm-i386/termbits.h
+++ b/include/asm-i386/termbits.h
@@ -144,7 +144,7 @@ struct ktermios {
144#define B3000000 0010015 144#define B3000000 0010015
145#define B3500000 0010016 145#define B3500000 0010016
146#define B4000000 0010017 146#define B4000000 0010017
147#define CIBAUD 002003600000 /* input baud rate (not used) */ 147#define CIBAUD 002003600000
148#define CMSPAR 010000000000 /* mark or space (stick) parity */ 148#define CMSPAR 010000000000 /* mark or space (stick) parity */
149#define CRTSCTS 020000000000 /* flow control */ 149#define CRTSCTS 020000000000 /* flow control */
150 150
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 5830d36fd8e6..4f4ee1c2db2f 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -210,7 +210,7 @@ struct desc_struct {
210 unsigned int a, b; 210 unsigned int a, b;
211}; 211};
212 212
213#define desc_empty(desc) (!((desc)->a + (desc)->b)) 213#define desc_empty(desc) (!((desc)->a | (desc)->b))
214#define desc_equal(desc1, desc2) (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b)) 214#define desc_equal(desc1, desc2) (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
215 215
216#define GDT_ENTRY_TLS_ENTRIES 3 216#define GDT_ENTRY_TLS_ENTRIES 3
diff --git a/include/asm-ia64/sn/pcibr_provider.h b/include/asm-ia64/sn/pcibr_provider.h
index 17cb6cc3f21a..da205b7cdaac 100644
--- a/include/asm-ia64/sn/pcibr_provider.h
+++ b/include/asm-ia64/sn/pcibr_provider.h
@@ -21,6 +21,7 @@
21#define IS_PCI_BRIDGE_ASIC(asic) (asic == PCIIO_ASIC_TYPE_PIC || \ 21#define IS_PCI_BRIDGE_ASIC(asic) (asic == PCIIO_ASIC_TYPE_PIC || \
22 asic == PCIIO_ASIC_TYPE_TIOCP) 22 asic == PCIIO_ASIC_TYPE_TIOCP)
23#define IS_PIC_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_PIC) 23#define IS_PIC_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_PIC)
24#define IS_TIOCP_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_TIOCP)
24 25
25 26
26/* 27/*
@@ -53,8 +54,8 @@
53 * Bridge PMU Address Transaltion Entry Attibutes 54 * Bridge PMU Address Transaltion Entry Attibutes
54 */ 55 */
55#define PCI32_ATE_V (0x1 << 0) 56#define PCI32_ATE_V (0x1 << 0)
56#define PCI32_ATE_CO (0x1 << 1) 57#define PCI32_ATE_CO (0x1 << 1) /* PIC ASIC ONLY */
57#define PCI32_ATE_PREC (0x1 << 2) 58#define PCI32_ATE_PIO (0x1 << 1) /* TIOCP ASIC ONLY */
58#define PCI32_ATE_MSI (0x1 << 2) 59#define PCI32_ATE_MSI (0x1 << 2)
59#define PCI32_ATE_PREF (0x1 << 3) 60#define PCI32_ATE_PREF (0x1 << 3)
60#define PCI32_ATE_BAR (0x1 << 4) 61#define PCI32_ATE_BAR (0x1 << 4)
diff --git a/include/asm-mips/bug.h b/include/asm-mips/bug.h
index 4d560a533940..7eb63de808bc 100644
--- a/include/asm-mips/bug.h
+++ b/include/asm-mips/bug.h
@@ -18,7 +18,8 @@ do { \
18 18
19#define BUG_ON(condition) \ 19#define BUG_ON(condition) \
20do { \ 20do { \
21 __asm__ __volatile__("tne $0, %0" : : "r" (condition)); \ 21 __asm__ __volatile__("tne $0, %0, %1" \
22 : : "r" (condition), "i" (BRK_BUG)); \
22} while (0) 23} while (0)
23 24
24#define HAVE_ARCH_BUG_ON 25#define HAVE_ARCH_BUG_ON
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h
index 20a81e1548f5..290485ac5407 100644
--- a/include/asm-mips/checksum.h
+++ b/include/asm-mips/checksum.h
@@ -166,7 +166,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr,
166#else 166#else
167 "r" (proto + len), 167 "r" (proto + len),
168#endif 168#endif
169 "r" (sum)); 169 "r" ((__force unsigned long)sum));
170 170
171 return sum; 171 return sum;
172} 172}
diff --git a/include/asm-mips/fpu.h b/include/asm-mips/fpu.h
index 4e12d1f9534f..b414a7d9db43 100644
--- a/include/asm-mips/fpu.h
+++ b/include/asm-mips/fpu.h
@@ -68,8 +68,6 @@ do { \
68 /* We don't care about the c0 hazard here */ \ 68 /* We don't care about the c0 hazard here */ \
69} while (0) 69} while (0)
70 70
71#define __fpu_enabled() (read_c0_status() & ST0_CU1)
72
73#define enable_fpu() \ 71#define enable_fpu() \
74do { \ 72do { \
75 if (cpu_has_fpu) \ 73 if (cpu_has_fpu) \
@@ -102,14 +100,19 @@ static inline void __own_fpu(void)
102 set_thread_flag(TIF_USEDFPU); 100 set_thread_flag(TIF_USEDFPU);
103} 101}
104 102
105static inline void own_fpu(int restore) 103static inline void own_fpu_inatomic(int restore)
106{ 104{
107 preempt_disable();
108 if (cpu_has_fpu && !__is_fpu_owner()) { 105 if (cpu_has_fpu && !__is_fpu_owner()) {
109 __own_fpu(); 106 __own_fpu();
110 if (restore) 107 if (restore)
111 _restore_fp(current); 108 _restore_fp(current);
112 } 109 }
110}
111
112static inline void own_fpu(int restore)
113{
114 preempt_disable();
115 own_fpu_inatomic(restore);
113 preempt_enable(); 116 preempt_enable();
114} 117}
115 118
@@ -162,18 +165,4 @@ static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
162 return tsk->thread.fpu.fpr; 165 return tsk->thread.fpu.fpr;
163} 166}
164 167
165static inline void enable_fp_in_kernel(void)
166{
167 set_thread_flag(TIF_ALLOW_FP_IN_KERNEL);
168 /* make sure CU1 and FPU ownership are consistent */
169 if (!__is_fpu_owner() && __fpu_enabled())
170 __disable_fpu();
171}
172
173static inline void disable_fp_in_kernel(void)
174{
175 BUG_ON(!__is_fpu_owner() && __fpu_enabled());
176 clear_thread_flag(TIF_ALLOW_FP_IN_KERNEL);
177}
178
179#endif /* _ASM_FPU_H */ 168#endif /* _ASM_FPU_H */
diff --git a/include/asm-mips/irqflags.h b/include/asm-mips/irqflags.h
index af3b07dfad4b..e459fa05db83 100644
--- a/include/asm-mips/irqflags.h
+++ b/include/asm-mips/irqflags.h
@@ -13,29 +13,9 @@
13 13
14#ifndef __ASSEMBLY__ 14#ifndef __ASSEMBLY__
15 15
16#include <linux/compiler.h>
16#include <asm/hazards.h> 17#include <asm/hazards.h>
17 18
18/*
19 * CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY does prompt replay of deferred IPIs,
20 * at the cost of branch and call overhead on each local_irq_restore()
21 */
22
23#ifdef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY
24
25extern void smtc_ipi_replay(void);
26
27#define irq_restore_epilog(flags) \
28do { \
29 if (!(flags & 0x0400)) \
30 smtc_ipi_replay(); \
31} while (0)
32
33#else
34
35#define irq_restore_epilog(ignore) do { } while (0)
36
37#endif /* CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY */
38
39__asm__ ( 19__asm__ (
40 " .macro raw_local_irq_enable \n" 20 " .macro raw_local_irq_enable \n"
41 " .set push \n" 21 " .set push \n"
@@ -205,17 +185,28 @@ __asm__ (
205 " .set pop \n" 185 " .set pop \n"
206 " .endm \n"); 186 " .endm \n");
207 187
208#define raw_local_irq_restore(flags) \ 188extern void smtc_ipi_replay(void);
209do { \ 189
210 unsigned long __tmp1; \ 190static inline void raw_local_irq_restore(unsigned long flags)
211 \ 191{
212 __asm__ __volatile__( \ 192 unsigned long __tmp1;
213 "raw_local_irq_restore\t%0" \ 193
214 : "=r" (__tmp1) \ 194#ifdef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY
215 : "0" (flags) \ 195 /*
216 : "memory"); \ 196 * CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY does prompt replay of deferred
217 irq_restore_epilog(flags); \ 197 * IPIs, at the cost of branch and call overhead on each
218} while(0) 198 * local_irq_restore()
199 */
200 if (unlikely(!(flags & 0x0400)))
201 smtc_ipi_replay();
202#endif
203
204 __asm__ __volatile__(
205 "raw_local_irq_restore\t%0"
206 : "=r" (__tmp1)
207 : "0" (flags)
208 : "memory");
209}
219 210
220static inline int raw_irqs_disabled_flags(unsigned long flags) 211static inline int raw_irqs_disabled_flags(unsigned long flags)
221{ 212{
diff --git a/include/asm-mips/marvell.h b/include/asm-mips/marvell.h
index df94955b098a..b6144bafc565 100644
--- a/include/asm-mips/marvell.h
+++ b/include/asm-mips/marvell.h
@@ -54,5 +54,6 @@ struct mv_pci_controller {
54}; 54};
55 55
56extern void ll_mv64340_irq(void); 56extern void ll_mv64340_irq(void);
57extern void mv64340_irq_init(unsigned int base);
57 58
58#endif /* __ASM_MIPS_MARVELL_H */ 59#endif /* __ASM_MIPS_MARVELL_H */
diff --git a/include/asm-mips/sibyte/sb1250_scd.h b/include/asm-mips/sibyte/sb1250_scd.h
index 7ed0bb611e56..b6a7d8f6ced5 100644
--- a/include/asm-mips/sibyte/sb1250_scd.h
+++ b/include/asm-mips/sibyte/sb1250_scd.h
@@ -84,6 +84,7 @@
84#define K_SYS_REVISION_BCM112x_A2 0x21 84#define K_SYS_REVISION_BCM112x_A2 0x21
85#define K_SYS_REVISION_BCM112x_A3 0x22 85#define K_SYS_REVISION_BCM112x_A3 0x22
86#define K_SYS_REVISION_BCM112x_A4 0x23 86#define K_SYS_REVISION_BCM112x_A4 0x23
87#define K_SYS_REVISION_BCM112x_B0 0x30
87 88
88#define K_SYS_REVISION_BCM1480_S0 0x01 89#define K_SYS_REVISION_BCM1480_S0 0x01
89#define K_SYS_REVISION_BCM1480_A1 0x02 90#define K_SYS_REVISION_BCM1480_A1 0x02
diff --git a/include/asm-mips/smtc_ipi.h b/include/asm-mips/smtc_ipi.h
index 360ea6d250c7..a52a4a7a36e0 100644
--- a/include/asm-mips/smtc_ipi.h
+++ b/include/asm-mips/smtc_ipi.h
@@ -65,12 +65,10 @@ static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p)
65 spin_unlock_irqrestore(&q->lock, flags); 65 spin_unlock_irqrestore(&q->lock, flags);
66} 66}
67 67
68static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q) 68static inline struct smtc_ipi *__smtc_ipi_dq(struct smtc_ipi_q *q)
69{ 69{
70 struct smtc_ipi *p; 70 struct smtc_ipi *p;
71 long flags;
72 71
73 spin_lock_irqsave(&q->lock, flags);
74 if (q->head == NULL) 72 if (q->head == NULL)
75 p = NULL; 73 p = NULL;
76 else { 74 else {
@@ -81,7 +79,19 @@ static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
81 if (q->head == NULL) 79 if (q->head == NULL)
82 q->tail = NULL; 80 q->tail = NULL;
83 } 81 }
82
83 return p;
84}
85
86static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
87{
88 unsigned long flags;
89 struct smtc_ipi *p;
90
91 spin_lock_irqsave(&q->lock, flags);
92 p = __smtc_ipi_dq(q);
84 spin_unlock_irqrestore(&q->lock, flags); 93 spin_unlock_irqrestore(&q->lock, flags);
94
85 return p; 95 return p;
86} 96}
87 97
diff --git a/include/asm-mips/thread_info.h b/include/asm-mips/thread_info.h
index 6cf05f4a4e7e..fbcda8204473 100644
--- a/include/asm-mips/thread_info.h
+++ b/include/asm-mips/thread_info.h
@@ -119,7 +119,6 @@ register struct thread_info *__current_thread_info __asm__("$28");
119#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 119#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
120#define TIF_MEMDIE 18 120#define TIF_MEMDIE 18
121#define TIF_FREEZE 19 121#define TIF_FREEZE 19
122#define TIF_ALLOW_FP_IN_KERNEL 20
123#define TIF_SYSCALL_TRACE 31 /* syscall trace active */ 122#define TIF_SYSCALL_TRACE 31 /* syscall trace active */
124 123
125#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 124#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
diff --git a/include/asm-powerpc/immap_qe.h b/include/asm-powerpc/immap_qe.h
index 9fdd0491f6a3..1020b7fc0129 100644
--- a/include/asm-powerpc/immap_qe.h
+++ b/include/asm-powerpc/immap_qe.h
@@ -258,8 +258,9 @@ struct ucc_slow {
258 u8 uccs; /* UCCx status register */ 258 u8 uccs; /* UCCx status register */
259 u8 res3[0x24]; 259 u8 res3[0x24];
260 __be16 utpt; 260 __be16 utpt;
261 u8 res4[0x52];
261 u8 guemr; /* UCC general extended mode register */ 262 u8 guemr; /* UCC general extended mode register */
262 u8 res4[0x200 - 0x091]; 263 u8 res5[0x200 - 0x091];
263} __attribute__ ((packed)); 264} __attribute__ ((packed));
264 265
265/* QE UCC Fast */ 266/* QE UCC Fast */
diff --git a/include/asm-powerpc/systbl.h b/include/asm-powerpc/systbl.h
index 8d853c554631..0b00068313f9 100644
--- a/include/asm-powerpc/systbl.h
+++ b/include/asm-powerpc/systbl.h
@@ -288,7 +288,7 @@ COMPAT_SYS(ppoll)
288SYSCALL_SPU(unshare) 288SYSCALL_SPU(unshare)
289SYSCALL_SPU(splice) 289SYSCALL_SPU(splice)
290SYSCALL_SPU(tee) 290SYSCALL_SPU(tee)
291SYSCALL_SPU(vmsplice) 291COMPAT_SYS_SPU(vmsplice)
292COMPAT_SYS_SPU(openat) 292COMPAT_SYS_SPU(openat)
293SYSCALL_SPU(mkdirat) 293SYSCALL_SPU(mkdirat)
294SYSCALL_SPU(mknodat) 294SYSCALL_SPU(mknodat)
diff --git a/include/asm-s390/checksum.h b/include/asm-s390/checksum.h
index 0a3cd7ec8451..d5a8e7c1477c 100644
--- a/include/asm-s390/checksum.h
+++ b/include/asm-s390/checksum.h
@@ -121,50 +121,21 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
121 unsigned short len, unsigned short proto, 121 unsigned short len, unsigned short proto,
122 __wsum sum) 122 __wsum sum)
123{ 123{
124#ifndef __s390x__ 124 __u32 csum = (__force __u32)sum;
125 asm volatile( 125
126 " alr %0,%1\n" /* sum += saddr */ 126 csum += (__force __u32)saddr;
127 " brc 12,0f\n" 127 if (csum < (__force __u32)saddr)
128 " ahi %0,1\n" /* add carry */ 128 csum++;
129 "0:" 129
130 : "+&d" (sum) : "d" (saddr) : "cc"); 130 csum += (__force __u32)daddr;
131 asm volatile( 131 if (csum < (__force __u32)daddr)
132 " alr %0,%1\n" /* sum += daddr */ 132 csum++;
133 " brc 12,1f\n" 133
134 " ahi %0,1\n" /* add carry */ 134 csum += len + proto;
135 "1:" 135 if (csum < len + proto)
136 : "+&d" (sum) : "d" (daddr) : "cc"); 136 csum++;
137 asm volatile( 137
138 " alr %0,%1\n" /* sum += len + proto */ 138 return (__force __wsum)csum;
139 " brc 12,2f\n"
140 " ahi %0,1\n" /* add carry */
141 "2:"
142 : "+&d" (sum)
143 : "d" (len + proto)
144 : "cc");
145#else /* __s390x__ */
146 asm volatile(
147 " lgfr %0,%0\n"
148 " algr %0,%1\n" /* sum += saddr */
149 " brc 12,0f\n"
150 " aghi %0,1\n" /* add carry */
151 "0: algr %0,%2\n" /* sum += daddr */
152 " brc 12,1f\n"
153 " aghi %0,1\n" /* add carry */
154 "1: algfr %0,%3\n" /* sum += len + proto */
155 " brc 12,2f\n"
156 " aghi %0,1\n" /* add carry */
157 "2: srlg 0,%0,32\n"
158 " alr %0,0\n" /* fold to 32 bits */
159 " brc 12,3f\n"
160 " ahi %0,1\n" /* add carry */
161 "3: llgfr %0,%0"
162 : "+&d" (sum)
163 : "d" (saddr), "d" (daddr),
164 "d" (len + proto)
165 : "cc", "0");
166#endif /* __s390x__ */
167 return sum;
168} 139}
169 140
170/* 141/*
diff --git a/include/asm-sh/hp6xx.h b/include/asm-sh/hp6xx.h
index f35134c159dd..53ca5643d9c7 100644
--- a/include/asm-sh/hp6xx.h
+++ b/include/asm-sh/hp6xx.h
@@ -10,9 +10,9 @@
10 * 10 *
11 */ 11 */
12 12
13#define HP680_BTN_IRQ IRQ0_IRQ 13#define HP680_BTN_IRQ 32 /* IRQ0_IRQ */
14#define HP680_TS_IRQ IRQ3_IRQ 14#define HP680_TS_IRQ 35 /* IRQ3_IRQ */
15#define HP680_HD64461_IRQ IRQ4_IRQ 15#define HP680_HD64461_IRQ 36 /* IRQ4_IRQ */
16 16
17#define DAC_LCD_BRIGHTNESS 0 17#define DAC_LCD_BRIGHTNESS 0
18#define DAC_SPEAKER_VOLUME 1 18#define DAC_SPEAKER_VOLUME 1
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index b1e42e7f998b..4a6a19f4f8a4 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/irqflags.h> 9#include <linux/irqflags.h>
10#include <linux/compiler.h>
10#include <asm/types.h> 11#include <asm/types.h>
11 12
12/* 13/*
diff --git a/include/asm-sparc/a.out.h b/include/asm-sparc/a.out.h
index e4e83eb0161e..9090060a23e6 100644
--- a/include/asm-sparc/a.out.h
+++ b/include/asm-sparc/a.out.h
@@ -80,7 +80,7 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */
80 unsigned long r_address; /* relocation addr */ 80 unsigned long r_address; /* relocation addr */
81 unsigned int r_index:24; /* segment index or symbol index */ 81 unsigned int r_index:24; /* segment index or symbol index */
82 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */ 82 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */
83 int r_pad:2; /* <unused> */ 83 unsigned int r_pad:2; /* <unused> */
84 enum reloc_type r_type:5; /* type of relocation to perform */ 84 enum reloc_type r_type:5; /* type of relocation to perform */
85 long r_addend; /* addend for relocation value */ 85 long r_addend; /* addend for relocation value */
86}; 86};
diff --git a/include/asm-sparc/mostek.h b/include/asm-sparc/mostek.h
index bd92a78f4937..958d0513a6d4 100644
--- a/include/asm-sparc/mostek.h
+++ b/include/asm-sparc/mostek.h
@@ -87,7 +87,7 @@ extern void __iomem *mstk48t02_regs;
87#define MSTK_DOW_MASK 0x07 87#define MSTK_DOW_MASK 0x07
88#define MSTK_DOM_MASK 0x3f 88#define MSTK_DOM_MASK 0x3f
89#define MSTK_MONTH_MASK 0x1f 89#define MSTK_MONTH_MASK 0x1f
90#define MSTK_YEAR_MASK 0xff 90#define MSTK_YEAR_MASK 0xffU
91 91
92/* Binary coded decimal conversion macros. */ 92/* Binary coded decimal conversion macros. */
93#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04)) 93#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
diff --git a/include/asm-sparc64/a.out.h b/include/asm-sparc64/a.out.h
index 35cb5c9e0c92..eb3b8e90b279 100644
--- a/include/asm-sparc64/a.out.h
+++ b/include/asm-sparc64/a.out.h
@@ -86,7 +86,7 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */
86 unsigned int r_address; /* relocation addr */ 86 unsigned int r_address; /* relocation addr */
87 unsigned int r_index:24; /* segment index or symbol index */ 87 unsigned int r_index:24; /* segment index or symbol index */
88 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */ 88 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */
89 int r_pad:2; /* <unused> */ 89 unsigned int r_pad:2; /* <unused> */
90 enum reloc_type r_type:5; /* type of relocation to perform */ 90 enum reloc_type r_type:5; /* type of relocation to perform */
91 int r_addend; /* addend for relocation value */ 91 int r_addend; /* addend for relocation value */
92}; 92};
diff --git a/include/asm-sparc64/mostek.h b/include/asm-sparc64/mostek.h
index 09b5aba6678a..d14dd8988161 100644
--- a/include/asm-sparc64/mostek.h
+++ b/include/asm-sparc64/mostek.h
@@ -89,7 +89,7 @@ extern void __iomem *mstk48t02_regs;
89#define MSTK_DOW_MASK 0x07 89#define MSTK_DOW_MASK 0x07
90#define MSTK_DOM_MASK 0x3f 90#define MSTK_DOM_MASK 0x3f
91#define MSTK_MONTH_MASK 0x1f 91#define MSTK_MONTH_MASK 0x1f
92#define MSTK_YEAR_MASK 0xff 92#define MSTK_YEAR_MASK 0xffU
93 93
94/* Binary coded decimal conversion macros. */ 94/* Binary coded decimal conversion macros. */
95#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04)) 95#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
diff --git a/include/asm-um/common.lds.S b/include/asm-um/common.lds.S
index f0454516dd31..f5de80c31e88 100644
--- a/include/asm-um/common.lds.S
+++ b/include/asm-um/common.lds.S
@@ -15,6 +15,7 @@
15 PROVIDE (_unprotected_end = .); 15 PROVIDE (_unprotected_end = .);
16 16
17 . = ALIGN(4096); 17 . = ALIGN(4096);
18 .note : { *(.note.*) }
18 __start___ex_table = .; 19 __start___ex_table = .;
19 __ex_table : { *(__ex_table) } 20 __ex_table : { *(__ex_table) }
20 __stop___ex_table = .; 21 __stop___ex_table = .;
diff --git a/include/asm-um/delay.h b/include/asm-um/delay.h
index 0985bda66750..c71e32b6741e 100644
--- a/include/asm-um/delay.h
+++ b/include/asm-um/delay.h
@@ -1,9 +1,20 @@
1#ifndef __UM_DELAY_H 1#ifndef __UM_DELAY_H
2#define __UM_DELAY_H 2#define __UM_DELAY_H
3 3
4#include "asm/arch/delay.h"
5#include "asm/archparam.h"
6
7#define MILLION 1000000 4#define MILLION 1000000
8 5
6/* Undefined on purpose */
7extern void __bad_udelay(void);
8
9extern void __udelay(unsigned long usecs);
10extern void __delay(unsigned long loops);
11
12#define udelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \
13 __bad_udelay() : __udelay(n))
14
15/* It appears that ndelay is not used at all for UML, and has never been
16 * implemented. */
17extern void __unimplemented_ndelay(void);
18#define ndelay(n) __unimplemented_ndelay()
19
9#endif 20#endif
diff --git a/include/asm-um/pgtable-2level.h b/include/asm-um/pgtable-2level.h
index 6050e0eb257e..172a75fde512 100644
--- a/include/asm-um/pgtable-2level.h
+++ b/include/asm-um/pgtable-2level.h
@@ -45,12 +45,12 @@ static inline void pgd_mkuptodate(pgd_t pgd) { }
45 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 45 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
46 46
47/* 47/*
48 * Bits 0 through 3 are taken 48 * Bits 0 through 4 are taken
49 */ 49 */
50#define PTE_FILE_MAX_BITS 28 50#define PTE_FILE_MAX_BITS 27
51 51
52#define pte_to_pgoff(pte) (pte_val(pte) >> 4) 52#define pte_to_pgoff(pte) (pte_val(pte) >> 5)
53 53
54#define pgoff_to_pte(off) ((pte_t) { ((off) << 4) + _PAGE_FILE }) 54#define pgoff_to_pte(off) ((pte_t) { ((off) << 5) + _PAGE_FILE })
55 55
56#endif 56#endif
diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
index 2e4b7a5ed1c4..6153ae5df2e8 100644
--- a/include/asm-x86_64/hw_irq.h
+++ b/include/asm-x86_64/hw_irq.h
@@ -38,7 +38,7 @@
38#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR 38#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR
39 39
40/* 40/*
41 * Vectors 0x20-0x2f are used for ISA interrupts. 41 * Vectors 0x30-0x3f are used for ISA interrupts.
42 */ 42 */
43#define IRQ0_VECTOR FIRST_EXTERNAL_VECTOR + 0x10 43#define IRQ0_VECTOR FIRST_EXTERNAL_VECTOR + 0x10
44#define IRQ1_VECTOR IRQ0_VECTOR + 1 44#define IRQ1_VECTOR IRQ0_VECTOR + 1
diff --git a/include/linux/ata.h b/include/linux/ata.h
index c331da2da5f7..6caeb98e29dd 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -40,6 +40,7 @@ enum {
40 ATA_MAX_DEVICES = 2, /* per bus/port */ 40 ATA_MAX_DEVICES = 2, /* per bus/port */
41 ATA_MAX_PRD = 256, /* we could make these 256/256 */ 41 ATA_MAX_PRD = 256, /* we could make these 256/256 */
42 ATA_SECT_SIZE = 512, 42 ATA_SECT_SIZE = 512,
43 ATA_MAX_SECTORS_128 = 128,
43 ATA_MAX_SECTORS = 256, 44 ATA_MAX_SECTORS = 256,
44 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */ 45 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */
45 46
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index aca66984aafd..3b6949b41745 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -15,8 +15,8 @@
15# define __acquire(x) __context__(x,1) 15# define __acquire(x) __context__(x,1)
16# define __release(x) __context__(x,-1) 16# define __release(x) __context__(x,-1)
17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) 17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
18extern void __chk_user_ptr(void __user *); 18extern void __chk_user_ptr(const void __user *);
19extern void __chk_io_ptr(void __iomem *); 19extern void __chk_io_ptr(const void __iomem *);
20#else 20#else
21# define __user 21# define __user
22# define __kernel 22# define __kernel
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 769ddc6df492..c22b0dfcbcd2 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -127,9 +127,13 @@ static inline int cpu_is_offline(int cpu) { return 0; }
127#endif /* CONFIG_HOTPLUG_CPU */ 127#endif /* CONFIG_HOTPLUG_CPU */
128 128
129#ifdef CONFIG_SUSPEND_SMP 129#ifdef CONFIG_SUSPEND_SMP
130extern int suspend_cpu_hotplug;
131
130extern int disable_nonboot_cpus(void); 132extern int disable_nonboot_cpus(void);
131extern void enable_nonboot_cpus(void); 133extern void enable_nonboot_cpus(void);
132#else 134#else
135#define suspend_cpu_hotplug 0
136
133static inline int disable_nonboot_cpus(void) { return 0; } 137static inline int disable_nonboot_cpus(void) { return 0; }
134static inline void enable_nonboot_cpus(void) {} 138static inline void enable_nonboot_cpus(void) {}
135#endif 139#endif
diff --git a/include/linux/device.h b/include/linux/device.h
index caad9bba9652..5cf30e95c8b6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -128,6 +128,7 @@ struct device_driver {
128 128
129 struct module * owner; 129 struct module * owner;
130 const char * mod_name; /* used for built-in modules */ 130 const char * mod_name; /* used for built-in modules */
131 struct module_kobject * mkobj;
131 132
132 int (*probe) (struct device * dev); 133 int (*probe) (struct device * dev);
133 int (*remove) (struct device * dev); 134 int (*remove) (struct device * dev);
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 84cfa8bbdc36..d2a96cbf4f0e 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -31,12 +31,19 @@
31/* 31/*
32 * On x86-64 make the 64bit structure have the same alignment as the 32 * On x86-64 make the 64bit structure have the same alignment as the
33 * 32bit structure. This makes 32bit emulation easier. 33 * 32bit structure. This makes 32bit emulation easier.
34 *
35 * UML/x86_64 needs the same packing as x86_64 - UML + UML_X86 +
36 * 64_BIT adds up to UML/x86_64.
34 */ 37 */
35#ifdef __x86_64__ 38#ifdef __x86_64__
36#define EPOLL_PACKED __attribute__((packed)) 39#define EPOLL_PACKED __attribute__((packed))
37#else 40#else
41#if defined(CONFIG_UML) && defined(CONFIG_UML_X86) && defined(CONFIG_64BIT)
42#define EPOLL_PACKED __attribute__((packed))
43#else
38#define EPOLL_PACKED 44#define EPOLL_PACKED
39#endif 45#endif
46#endif
40 47
41struct epoll_event { 48struct epoll_event {
42 __u32 events; 49 __u32 events;
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 5bdbc744e773..17c29dca8354 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -206,6 +206,7 @@ struct hrtimer_cpu_base {
206struct clock_event_device; 206struct clock_event_device;
207 207
208extern void clock_was_set(void); 208extern void clock_was_set(void);
209extern void hres_timers_resume(void);
209extern void hrtimer_interrupt(struct clock_event_device *dev); 210extern void hrtimer_interrupt(struct clock_event_device *dev);
210 211
211/* 212/*
@@ -236,6 +237,8 @@ static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
236 */ 237 */
237static inline void clock_was_set(void) { } 238static inline void clock_was_set(void) { }
238 239
240static inline void hres_timers_resume(void) { }
241
239/* 242/*
240 * In non high resolution mode the time reference is taken from 243 * In non high resolution mode the time reference is taken from
241 * the base softirq time variable. 244 * the base softirq time variable.
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 34f2676b3c62..d3bbc7188b6a 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -615,6 +615,7 @@ typedef struct ide_drive_s {
615 u8 init_speed; /* transfer rate set at boot */ 615 u8 init_speed; /* transfer rate set at boot */
616 u8 pio_speed; /* unused by core, used by some drivers for fallback from DMA */ 616 u8 pio_speed; /* unused by core, used by some drivers for fallback from DMA */
617 u8 current_speed; /* current transfer rate set */ 617 u8 current_speed; /* current transfer rate set */
618 u8 desired_speed; /* desired transfer rate set */
618 u8 dn; /* now wide spread use */ 619 u8 dn; /* now wide spread use */
619 u8 wcache; /* status of write cache */ 620 u8 wcache; /* status of write cache */
620 u8 acoustic; /* acoustic management */ 621 u8 acoustic; /* acoustic management */
@@ -860,6 +861,8 @@ typedef struct hwgroup_s {
860 int (*expiry)(ide_drive_t *); 861 int (*expiry)(ide_drive_t *);
861 /* ide_system_bus_speed */ 862 /* ide_system_bus_speed */
862 int pio_clock; 863 int pio_clock;
864 int req_gen;
865 int req_gen_timer;
863 866
864 unsigned char cmd_buf[4]; 867 unsigned char cmd_buf[4];
865} ide_hwgroup_t; 868} ide_hwgroup_t;
diff --git a/include/linux/io.h b/include/linux/io.h
index c244a0cc9319..09d351236379 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -33,9 +33,22 @@ int ioremap_page_range(unsigned long addr, unsigned long end,
33/* 33/*
34 * Managed iomap interface 34 * Managed iomap interface
35 */ 35 */
36#ifdef CONFIG_HAS_IOPORT
36void __iomem * devm_ioport_map(struct device *dev, unsigned long port, 37void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
37 unsigned int nr); 38 unsigned int nr);
38void devm_ioport_unmap(struct device *dev, void __iomem *addr); 39void devm_ioport_unmap(struct device *dev, void __iomem *addr);
40#else
41static inline void __iomem *devm_ioport_map(struct device *dev,
42 unsigned long port,
43 unsigned int nr)
44{
45 return NULL;
46}
47
48static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
49{
50}
51#endif
39 52
40void __iomem * devm_ioremap(struct device *dev, unsigned long offset, 53void __iomem * devm_ioremap(struct device *dev, unsigned long offset,
41 unsigned long size); 54 unsigned long size);
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 636094c29b16..6da6772c19ff 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -92,19 +92,16 @@ extern struct ipc_namespace init_ipc_ns;
92 92
93#ifdef CONFIG_SYSVIPC 93#ifdef CONFIG_SYSVIPC
94#define INIT_IPC_NS(ns) .ns = &init_ipc_ns, 94#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
95extern int copy_ipcs(unsigned long flags, struct task_struct *tsk);
95#else 96#else
96#define INIT_IPC_NS(ns) 97#define INIT_IPC_NS(ns)
98static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk)
99{ return 0; }
97#endif 100#endif
98 101
99#ifdef CONFIG_IPC_NS 102#ifdef CONFIG_IPC_NS
100extern void free_ipc_ns(struct kref *kref); 103extern void free_ipc_ns(struct kref *kref);
101extern int copy_ipcs(unsigned long flags, struct task_struct *tsk);
102extern int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns); 104extern int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns);
103#else
104static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk)
105{
106 return 0;
107}
108#endif 105#endif
109 106
110static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) 107static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index f8241130f5ea..713eb5eaa81f 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -177,6 +177,7 @@ struct ipv6_devconf {
177#endif 177#endif
178#endif 178#endif
179 __s32 proxy_ndp; 179 __s32 proxy_ndp;
180 __s32 accept_source_route;
180 void *sysctl; 181 void *sysctl;
181}; 182};
182 183
@@ -205,6 +206,8 @@ enum {
205 DEVCONF_RTR_PROBE_INTERVAL, 206 DEVCONF_RTR_PROBE_INTERVAL,
206 DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN, 207 DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN,
207 DEVCONF_PROXY_NDP, 208 DEVCONF_PROXY_NDP,
209 __DEVCONF_OPTIMISTIC_DAD,
210 DEVCONF_ACCEPT_SOURCE_ROUTE,
208 DEVCONF_MAX 211 DEVCONF_MAX
209}; 212};
210 213
diff --git a/include/linux/kdev_t.h b/include/linux/kdev_t.h
index 4c2c3737e415..2dacab8beccb 100644
--- a/include/linux/kdev_t.h
+++ b/include/linux/kdev_t.h
@@ -87,8 +87,6 @@ static inline unsigned sysv_minor(u32 dev)
87 return dev & 0x3ffff; 87 return dev & 0x3ffff;
88} 88}
89 89
90bool is_lanana_major(unsigned int major);
91
92#else /* __KERNEL__ */ 90#else /* __KERNEL__ */
93 91
94/* 92/*
diff --git a/include/linux/libata.h b/include/linux/libata.h
index e3f32f3189b2..0cfbcb6f08eb 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -311,15 +311,17 @@ enum {
311 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */ 311 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */
312 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */ 312 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */
313 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ 313 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */
314 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */
315 ATA_HORKAGE_DMA_RW_ONLY = (1 << 4), /* ATAPI DMA for RW only */
314}; 316};
315 317
316enum hsm_task_states { 318enum hsm_task_states {
317 HSM_ST_IDLE, /* no command on going */ 319 HSM_ST_IDLE, /* no command on going */
320 HSM_ST_FIRST, /* (waiting the device to)
321 write CDB or first data block */
318 HSM_ST, /* (waiting the device to) transfer data */ 322 HSM_ST, /* (waiting the device to) transfer data */
319 HSM_ST_LAST, /* (waiting the device to) complete command */ 323 HSM_ST_LAST, /* (waiting the device to) complete command */
320 HSM_ST_ERR, /* error */ 324 HSM_ST_ERR, /* error */
321 HSM_ST_FIRST, /* (waiting the device to)
322 write CDB or first data block */
323}; 325};
324 326
325enum ata_completion_errors { 327enum ata_completion_errors {
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 2e555d49c9b7..16b0266b14fd 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -31,7 +31,6 @@
31#define PG_NEED_COMMIT 1 31#define PG_NEED_COMMIT 1
32#define PG_NEED_RESCHED 2 32#define PG_NEED_RESCHED 2
33#define PG_NEED_FLUSH 3 33#define PG_NEED_FLUSH 3
34#define PG_FLUSHING 4
35 34
36struct nfs_inode; 35struct nfs_inode;
37struct nfs_page { 36struct nfs_page {
@@ -50,8 +49,6 @@ struct nfs_page {
50}; 49};
51 50
52#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags)) 51#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
53#define NFS_NEED_COMMIT(req) (test_bit(PG_NEED_COMMIT,&(req)->wb_flags))
54#define NFS_NEED_RESCHED(req) (test_bit(PG_NEED_RESCHED,&(req)->wb_flags))
55 52
56extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx, 53extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
57 struct inode *inode, 54 struct inode *inode,
@@ -122,34 +119,6 @@ nfs_list_remove_request(struct nfs_page *req)
122 req->wb_list_head = NULL; 119 req->wb_list_head = NULL;
123} 120}
124 121
125static inline int
126nfs_defer_commit(struct nfs_page *req)
127{
128 return !test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags);
129}
130
131static inline void
132nfs_clear_commit(struct nfs_page *req)
133{
134 smp_mb__before_clear_bit();
135 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
136 smp_mb__after_clear_bit();
137}
138
139static inline int
140nfs_defer_reschedule(struct nfs_page *req)
141{
142 return !test_and_set_bit(PG_NEED_RESCHED, &req->wb_flags);
143}
144
145static inline void
146nfs_clear_reschedule(struct nfs_page *req)
147{
148 smp_mb__before_clear_bit();
149 clear_bit(PG_NEED_RESCHED, &req->wb_flags);
150 smp_mb__after_clear_bit();
151}
152
153static inline struct nfs_page * 122static inline struct nfs_page *
154nfs_list_entry(struct list_head *head) 123nfs_list_entry(struct list_head *head)
155{ 124{
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 2e19478e9e84..8bcbc54e1b48 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -99,4 +99,8 @@ extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *,
99 loff_t *, size_t, unsigned int, 99 loff_t *, size_t, unsigned int,
100 splice_actor *); 100 splice_actor *);
101 101
102extern ssize_t __splice_from_pipe(struct pipe_inode_info *, struct file *,
103 loff_t *, size_t, unsigned int,
104 splice_actor *);
105
102#endif 106#endif
diff --git a/include/linux/plist.h b/include/linux/plist.h
index b95818a037ad..85de2f055874 100644
--- a/include/linux/plist.h
+++ b/include/linux/plist.h
@@ -97,9 +97,9 @@ struct plist_node {
97#endif 97#endif
98 98
99/** 99/**
100 * #PLIST_HEAD_INIT - static struct plist_head initializer 100 * PLIST_HEAD_INIT - static struct plist_head initializer
101 *
102 * @head: struct plist_head variable name 101 * @head: struct plist_head variable name
102 * @_lock: lock to initialize for this list
103 */ 103 */
104#define PLIST_HEAD_INIT(head, _lock) \ 104#define PLIST_HEAD_INIT(head, _lock) \
105{ \ 105{ \
@@ -109,8 +109,7 @@ struct plist_node {
109} 109}
110 110
111/** 111/**
112 * #PLIST_NODE_INIT - static struct plist_node initializer 112 * PLIST_NODE_INIT - static struct plist_node initializer
113 *
114 * @node: struct plist_node variable name 113 * @node: struct plist_node variable name
115 * @__prio: initial node priority 114 * @__prio: initial node priority
116 */ 115 */
@@ -122,8 +121,8 @@ struct plist_node {
122 121
123/** 122/**
124 * plist_head_init - dynamic struct plist_head initializer 123 * plist_head_init - dynamic struct plist_head initializer
125 *
126 * @head: &struct plist_head pointer 124 * @head: &struct plist_head pointer
125 * @lock: list spinlock, remembered for debugging
127 */ 126 */
128static inline void 127static inline void
129plist_head_init(struct plist_head *head, spinlock_t *lock) 128plist_head_init(struct plist_head *head, spinlock_t *lock)
@@ -137,7 +136,6 @@ plist_head_init(struct plist_head *head, spinlock_t *lock)
137 136
138/** 137/**
139 * plist_node_init - Dynamic struct plist_node initializer 138 * plist_node_init - Dynamic struct plist_node initializer
140 *
141 * @node: &struct plist_node pointer 139 * @node: &struct plist_node pointer
142 * @prio: initial node priority 140 * @prio: initial node priority
143 */ 141 */
@@ -152,49 +150,46 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
152 150
153/** 151/**
154 * plist_for_each - iterate over the plist 152 * plist_for_each - iterate over the plist
155 * 153 * @pos: the type * to use as a loop counter
156 * @pos1: the type * to use as a loop counter. 154 * @head: the head for your list
157 * @head: the head for your list.
158 */ 155 */
159#define plist_for_each(pos, head) \ 156#define plist_for_each(pos, head) \
160 list_for_each_entry(pos, &(head)->node_list, plist.node_list) 157 list_for_each_entry(pos, &(head)->node_list, plist.node_list)
161 158
162/** 159/**
163 * plist_for_each_entry_safe - iterate over a plist of given type safe 160 * plist_for_each_safe - iterate safely over a plist of given type
164 * against removal of list entry 161 * @pos: the type * to use as a loop counter
162 * @n: another type * to use as temporary storage
163 * @head: the head for your list
165 * 164 *
166 * @pos1: the type * to use as a loop counter. 165 * Iterate over a plist of given type, safe against removal of list entry.
167 * @n1: another type * to use as temporary storage
168 * @head: the head for your list.
169 */ 166 */
170#define plist_for_each_safe(pos, n, head) \ 167#define plist_for_each_safe(pos, n, head) \
171 list_for_each_entry_safe(pos, n, &(head)->node_list, plist.node_list) 168 list_for_each_entry_safe(pos, n, &(head)->node_list, plist.node_list)
172 169
173/** 170/**
174 * plist_for_each_entry - iterate over list of given type 171 * plist_for_each_entry - iterate over list of given type
175 * 172 * @pos: the type * to use as a loop counter
176 * @pos: the type * to use as a loop counter. 173 * @head: the head for your list
177 * @head: the head for your list. 174 * @mem: the name of the list_struct within the struct
178 * @member: the name of the list_struct within the struct.
179 */ 175 */
180#define plist_for_each_entry(pos, head, mem) \ 176#define plist_for_each_entry(pos, head, mem) \
181 list_for_each_entry(pos, &(head)->node_list, mem.plist.node_list) 177 list_for_each_entry(pos, &(head)->node_list, mem.plist.node_list)
182 178
183/** 179/**
184 * plist_for_each_entry_safe - iterate over list of given type safe against 180 * plist_for_each_entry_safe - iterate safely over list of given type
185 * removal of list entry 181 * @pos: the type * to use as a loop counter
186 *
187 * @pos: the type * to use as a loop counter.
188 * @n: another type * to use as temporary storage 182 * @n: another type * to use as temporary storage
189 * @head: the head for your list. 183 * @head: the head for your list
190 * @m: the name of the list_struct within the struct. 184 * @m: the name of the list_struct within the struct
185 *
186 * Iterate over list of given type, safe against removal of list entry.
191 */ 187 */
192#define plist_for_each_entry_safe(pos, n, head, m) \ 188#define plist_for_each_entry_safe(pos, n, head, m) \
193 list_for_each_entry_safe(pos, n, &(head)->node_list, m.plist.node_list) 189 list_for_each_entry_safe(pos, n, &(head)->node_list, m.plist.node_list)
194 190
195/** 191/**
196 * plist_head_empty - return !0 if a plist_head is empty 192 * plist_head_empty - return !0 if a plist_head is empty
197 *
198 * @head: &struct plist_head pointer 193 * @head: &struct plist_head pointer
199 */ 194 */
200static inline int plist_head_empty(const struct plist_head *head) 195static inline int plist_head_empty(const struct plist_head *head)
@@ -204,7 +199,6 @@ static inline int plist_head_empty(const struct plist_head *head)
204 199
205/** 200/**
206 * plist_node_empty - return !0 if plist_node is not on a list 201 * plist_node_empty - return !0 if plist_node is not on a list
207 *
208 * @node: &struct plist_node pointer 202 * @node: &struct plist_node pointer
209 */ 203 */
210static inline int plist_node_empty(const struct plist_node *node) 204static inline int plist_node_empty(const struct plist_node *node)
@@ -216,10 +210,9 @@ static inline int plist_node_empty(const struct plist_node *node)
216 210
217/** 211/**
218 * plist_first_entry - get the struct for the first entry 212 * plist_first_entry - get the struct for the first entry
219 * 213 * @head: the &struct plist_head pointer
220 * @ptr: the &struct plist_head pointer. 214 * @type: the type of the struct this is embedded in
221 * @type: the type of the struct this is embedded in. 215 * @member: the name of the list_struct within the struct
222 * @member: the name of the list_struct within the struct.
223 */ 216 */
224#ifdef CONFIG_DEBUG_PI_LIST 217#ifdef CONFIG_DEBUG_PI_LIST
225# define plist_first_entry(head, type, member) \ 218# define plist_first_entry(head, type, member) \
@@ -234,7 +227,6 @@ static inline int plist_node_empty(const struct plist_node *node)
234 227
235/** 228/**
236 * plist_first - return the first node (and thus, highest priority) 229 * plist_first - return the first node (and thus, highest priority)
237 *
238 * @head: the &struct plist_head pointer 230 * @head: the &struct plist_head pointer
239 * 231 *
240 * Assumes the plist is _not_ empty. 232 * Assumes the plist is _not_ empty.
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 8245c282168b..de72c49747c8 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -104,6 +104,7 @@ struct mdk_rdev_s
104 * for reporting to userspace and storing 104 * for reporting to userspace and storing
105 * in superblock. 105 * in superblock.
106 */ 106 */
107 struct work_struct del_work; /* used for delayed sysfs removal */
107}; 108};
108 109
109struct mddev_s 110struct mddev_s
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4ff3940210d8..5992f65b4184 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -188,7 +188,7 @@ enum {
188 * @sk: Socket we are owned by 188 * @sk: Socket we are owned by
189 * @tstamp: Time we arrived 189 * @tstamp: Time we arrived
190 * @dev: Device we arrived on/are leaving by 190 * @dev: Device we arrived on/are leaving by
191 * @input_dev: Device we arrived on 191 * @iif: ifindex of device we arrived on
192 * @h: Transport layer header 192 * @h: Transport layer header
193 * @nh: Network layer header 193 * @nh: Network layer header
194 * @mac: Link layer header 194 * @mac: Link layer header
@@ -235,7 +235,8 @@ struct sk_buff {
235 struct sock *sk; 235 struct sock *sk;
236 struct skb_timeval tstamp; 236 struct skb_timeval tstamp;
237 struct net_device *dev; 237 struct net_device *dev;
238 struct net_device *input_dev; 238 int iif;
239 /* 4 byte hole on 64 bit*/
239 240
240 union { 241 union {
241 struct tcphdr *th; 242 struct tcphdr *th;
@@ -345,9 +346,6 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
345 return __alloc_skb(size, priority, 1, -1); 346 return __alloc_skb(size, priority, 1, -1);
346} 347}
347 348
348extern struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
349 unsigned int size,
350 gfp_t priority);
351extern void kfree_skbmem(struct sk_buff *skb); 349extern void kfree_skbmem(struct sk_buff *skb);
352extern struct sk_buff *skb_clone(struct sk_buff *skb, 350extern struct sk_buff *skb_clone(struct sk_buff *skb,
353 gfp_t priority); 351 gfp_t priority);
@@ -621,6 +619,13 @@ static inline void skb_queue_head_init(struct sk_buff_head *list)
621 list->qlen = 0; 619 list->qlen = 0;
622} 620}
623 621
622static inline void skb_queue_head_init_class(struct sk_buff_head *list,
623 struct lock_class_key *class)
624{
625 skb_queue_head_init(list);
626 lockdep_set_class(&list->lock, class);
627}
628
624/* 629/*
625 * Insert an sk_buff at the start of a list. 630 * Insert an sk_buff at the start of a list.
626 * 631 *
diff --git a/include/linux/sony-laptop.h b/include/linux/sony-laptop.h
new file mode 100644
index 000000000000..e2e036d94e4a
--- /dev/null
+++ b/include/linux/sony-laptop.h
@@ -0,0 +1,34 @@
1#ifndef _SONYLAPTOP_H_
2#define _SONYLAPTOP_H_
3
4#include <linux/types.h>
5
6#ifdef __KERNEL__
7
8/* used only for communication between v4l and sony-laptop */
9
10#define SONY_PIC_COMMAND_GETCAMERA 1 /* obsolete */
11#define SONY_PIC_COMMAND_SETCAMERA 2
12#define SONY_PIC_COMMAND_GETCAMERABRIGHTNESS 3 /* obsolete */
13#define SONY_PIC_COMMAND_SETCAMERABRIGHTNESS 4
14#define SONY_PIC_COMMAND_GETCAMERACONTRAST 5 /* obsolete */
15#define SONY_PIC_COMMAND_SETCAMERACONTRAST 6
16#define SONY_PIC_COMMAND_GETCAMERAHUE 7 /* obsolete */
17#define SONY_PIC_COMMAND_SETCAMERAHUE 8
18#define SONY_PIC_COMMAND_GETCAMERACOLOR 9 /* obsolete */
19#define SONY_PIC_COMMAND_SETCAMERACOLOR 10
20#define SONY_PIC_COMMAND_GETCAMERASHARPNESS 11 /* obsolete */
21#define SONY_PIC_COMMAND_SETCAMERASHARPNESS 12
22#define SONY_PIC_COMMAND_GETCAMERAPICTURE 13 /* obsolete */
23#define SONY_PIC_COMMAND_SETCAMERAPICTURE 14
24#define SONY_PIC_COMMAND_GETCAMERAAGC 15 /* obsolete */
25#define SONY_PIC_COMMAND_SETCAMERAAGC 16
26#define SONY_PIC_COMMAND_GETCAMERADIRECTION 17 /* obsolete */
27#define SONY_PIC_COMMAND_GETCAMERAROMVERSION 18 /* obsolete */
28#define SONY_PIC_COMMAND_GETCAMERAREVISION 19 /* obsolete */
29
30int sony_pic_camera_command(int command, u8 value);
31
32#endif /* __KERNEL__ */
33
34#endif /* _SONYLAPTOP_H_ */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 2c5fb38d9392..9a8970bf99a6 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -580,6 +580,7 @@ enum {
580 NET_IPV6_RTR_PROBE_INTERVAL=21, 580 NET_IPV6_RTR_PROBE_INTERVAL=21,
581 NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN=22, 581 NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN=22,
582 NET_IPV6_PROXY_NDP=23, 582 NET_IPV6_PROXY_NDP=23,
583 NET_IPV6_ACCEPT_SOURCE_ROUTE=25,
583 __NET_IPV6_MAX 584 __NET_IPV6_MAX
584}; 585};
585 586
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 3fced4798255..a46104a28f66 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33 33
34#define TASKSTATS_VERSION 3 34#define TASKSTATS_VERSION 4
35#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 35#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
36 * in linux/sched.h */ 36 * in linux/sched.h */
37 37
@@ -66,7 +66,7 @@ struct taskstats {
66 /* Delay waiting for cpu, while runnable 66 /* Delay waiting for cpu, while runnable
67 * count, delay_total NOT updated atomically 67 * count, delay_total NOT updated atomically
68 */ 68 */
69 __u64 cpu_count; 69 __u64 cpu_count __attribute__((aligned(8)));
70 __u64 cpu_delay_total; 70 __u64 cpu_delay_total;
71 71
72 /* Following four fields atomically updated using task->delays->lock */ 72 /* Following four fields atomically updated using task->delays->lock */
@@ -101,14 +101,17 @@ struct taskstats {
101 101
102 /* Basic Accounting Fields start */ 102 /* Basic Accounting Fields start */
103 char ac_comm[TS_COMM_LEN]; /* Command name */ 103 char ac_comm[TS_COMM_LEN]; /* Command name */
104 __u8 ac_sched; /* Scheduling discipline */ 104 __u8 ac_sched __attribute__((aligned(8)));
105 /* Scheduling discipline */
105 __u8 ac_pad[3]; 106 __u8 ac_pad[3];
106 __u32 ac_uid; /* User ID */ 107 __u32 ac_uid __attribute__((aligned(8)));
108 /* User ID */
107 __u32 ac_gid; /* Group ID */ 109 __u32 ac_gid; /* Group ID */
108 __u32 ac_pid; /* Process ID */ 110 __u32 ac_pid; /* Process ID */
109 __u32 ac_ppid; /* Parent process ID */ 111 __u32 ac_ppid; /* Parent process ID */
110 __u32 ac_btime; /* Begin time [sec since 1970] */ 112 __u32 ac_btime; /* Begin time [sec since 1970] */
111 __u64 ac_etime; /* Elapsed time [usec] */ 113 __u64 ac_etime __attribute__((aligned(8)));
114 /* Elapsed time [usec] */
112 __u64 ac_utime; /* User CPU time [usec] */ 115 __u64 ac_utime; /* User CPU time [usec] */
113 __u64 ac_stime; /* SYstem CPU time [usec] */ 116 __u64 ac_stime; /* SYstem CPU time [usec] */
114 __u64 ac_minflt; /* Minor Page Fault Count */ 117 __u64 ac_minflt; /* Minor Page Fault Count */
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index a4555fe3754c..e10267d402c5 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -70,6 +70,8 @@ static inline int unshare_utsname(unsigned long unshare_flags,
70 70
71static inline int copy_utsname(int flags, struct task_struct *tsk) 71static inline int copy_utsname(int flags, struct task_struct *tsk)
72{ 72{
73 if (flags & CLONE_NEWUTS)
74 return -EINVAL;
73 return 0; 75 return 0;
74} 76}
75static inline void put_uts_ns(struct uts_namespace *ns) 77static inline void put_uts_ns(struct uts_namespace *ns)
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 447c52beb691..48759b2f57d7 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -1,10 +1,10 @@
1/* 1/*
2 * This file define a set of standard wireless extensions 2 * This file define a set of standard wireless extensions
3 * 3 *
4 * Version : 21 14.3.06 4 * Version : 22 16.3.07
5 * 5 *
6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> 6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved. 7 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
8 */ 8 */
9 9
10#ifndef _LINUX_WIRELESS_H 10#ifndef _LINUX_WIRELESS_H
@@ -85,7 +85,7 @@
85 * (there is some stuff that will be added in the future...) 85 * (there is some stuff that will be added in the future...)
86 * I just plan to increment with each new version. 86 * I just plan to increment with each new version.
87 */ 87 */
88#define WIRELESS_EXT 21 88#define WIRELESS_EXT 22
89 89
90/* 90/*
91 * Changes : 91 * Changes :
@@ -221,6 +221,10 @@
221 * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers 221 * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
222 * - Power/Retry relative values no longer * 100000 222 * - Power/Retry relative values no longer * 100000
223 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI 223 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
224 *
225 * V21 to V22
226 * ----------
227 * - Prevent leaking of kernel space in stream on 64 bits.
224 */ 228 */
225 229
226/**************************** CONSTANTS ****************************/ 230/**************************** CONSTANTS ****************************/
@@ -1085,4 +1089,15 @@ struct iw_event
1085#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ 1089#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1086 IW_EV_POINT_OFF) 1090 IW_EV_POINT_OFF)
1087 1091
1092/* Size of the Event prefix when packed in stream */
1093#define IW_EV_LCP_PK_LEN (4)
1094/* Size of the various events when packed in stream */
1095#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
1096#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32))
1097#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
1098#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
1099#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
1100#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
1101#define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4)
1102
1088#endif /* _LINUX_WIRELESS_H */ 1103#endif /* _LINUX_WIRELESS_H */
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 83fe2e3d1e25..50e33b0e9349 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -239,7 +239,8 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits);
239#define SAA7146_HPS_SYNC_PORT_B 0x01 239#define SAA7146_HPS_SYNC_PORT_B 0x01
240 240
241/* some memory sizes */ 241/* some memory sizes */
242#define SAA7146_CLIPPING_MEM (14*PAGE_SIZE) 242/* max. 16 clipping rectangles */
243#define SAA7146_CLIPPING_MEM (16 * 4 * sizeof(u32))
243 244
244/* some defines for the various clipping-modes */ 245/* some defines for the various clipping-modes */
245#define SAA7146_CLIPPING_RECT 0x4 246#define SAA7146_CLIPPING_RECT 0x4
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index bc3c26494c3d..d585ea9fa97d 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -34,6 +34,7 @@ struct fib_rules_ops
34 int family; 34 int family;
35 struct list_head list; 35 struct list_head list;
36 int rule_size; 36 int rule_size;
37 int addr_size;
37 38
38 int (*action)(struct fib_rule *, 39 int (*action)(struct fib_rule *,
39 struct flowi *, int, 40 struct flowi *, int,
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 9eda572a2a65..cf355a3c2ad5 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -58,6 +58,7 @@ struct fib6_node
58 __u16 fn_bit; /* bit key */ 58 __u16 fn_bit; /* bit key */
59 __u16 fn_flags; 59 __u16 fn_flags;
60 __u32 fn_sernum; 60 __u32 fn_sernum;
61 struct rt6_info *rr_ptr;
61}; 62};
62 63
63#ifndef CONFIG_IPV6_SUBTREES 64#ifndef CONFIG_IPV6_SUBTREES
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index 10559e937d27..8a830188354d 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -1,10 +1,10 @@
1/* 1/*
2 * This file define the new driver API for Wireless Extensions 2 * This file define the new driver API for Wireless Extensions
3 * 3 *
4 * Version : 7 18.3.05 4 * Version : 8 16.3.07
5 * 5 *
6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> 6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7 * Copyright (c) 2001-2006 Jean Tourrilhes, All Rights Reserved. 7 * Copyright (c) 2001-2007 Jean Tourrilhes, All Rights Reserved.
8 */ 8 */
9 9
10#ifndef _IW_HANDLER_H 10#ifndef _IW_HANDLER_H
@@ -207,7 +207,7 @@
207 * will be needed... 207 * will be needed...
208 * I just plan to increment with each new version. 208 * I just plan to increment with each new version.
209 */ 209 */
210#define IW_HANDLER_VERSION 7 210#define IW_HANDLER_VERSION 8
211 211
212/* 212/*
213 * Changes : 213 * Changes :
@@ -239,6 +239,10 @@
239 * - Remove (struct iw_point *)->pointer from events and streams 239 * - Remove (struct iw_point *)->pointer from events and streams
240 * - Remove spy_offset from struct iw_handler_def 240 * - Remove spy_offset from struct iw_handler_def
241 * - Add "check" version of event macros for ieee802.11 stack 241 * - Add "check" version of event macros for ieee802.11 stack
242 *
243 * V7 to V8
244 * ----------
245 * - Prevent leaking of kernel space in stream on 64 bits.
242 */ 246 */
243 247
244/**************************** CONSTANTS ****************************/ 248/**************************** CONSTANTS ****************************/
@@ -500,7 +504,11 @@ iwe_stream_add_event(char * stream, /* Stream of events */
500 /* Check if it's possible */ 504 /* Check if it's possible */
501 if(likely((stream + event_len) < ends)) { 505 if(likely((stream + event_len) < ends)) {
502 iwe->len = event_len; 506 iwe->len = event_len;
503 memcpy(stream, (char *) iwe, event_len); 507 /* Beware of alignement issues on 64 bits */
508 memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);
509 memcpy(stream + IW_EV_LCP_LEN,
510 ((char *) iwe) + IW_EV_LCP_LEN,
511 event_len - IW_EV_LCP_LEN);
504 stream += event_len; 512 stream += event_len;
505 } 513 }
506 return stream; 514 return stream;
@@ -521,10 +529,10 @@ iwe_stream_add_point(char * stream, /* Stream of events */
521 /* Check if it's possible */ 529 /* Check if it's possible */
522 if(likely((stream + event_len) < ends)) { 530 if(likely((stream + event_len) < ends)) {
523 iwe->len = event_len; 531 iwe->len = event_len;
524 memcpy(stream, (char *) iwe, IW_EV_LCP_LEN); 532 memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);
525 memcpy(stream + IW_EV_LCP_LEN, 533 memcpy(stream + IW_EV_LCP_LEN,
526 ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF, 534 ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
527 IW_EV_POINT_LEN - IW_EV_LCP_LEN); 535 IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
528 memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length); 536 memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length);
529 stream += event_len; 537 stream += event_len;
530 } 538 }
@@ -574,7 +582,11 @@ iwe_stream_check_add_event(char * stream, /* Stream of events */
574 /* Check if it's possible, set error if not */ 582 /* Check if it's possible, set error if not */
575 if(likely((stream + event_len) < ends)) { 583 if(likely((stream + event_len) < ends)) {
576 iwe->len = event_len; 584 iwe->len = event_len;
577 memcpy(stream, (char *) iwe, event_len); 585 /* Beware of alignement issues on 64 bits */
586 memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);
587 memcpy(stream + IW_EV_LCP_LEN,
588 ((char *) iwe) + IW_EV_LCP_LEN,
589 event_len - IW_EV_LCP_LEN);
578 stream += event_len; 590 stream += event_len;
579 } else 591 } else
580 *perr = -E2BIG; 592 *perr = -E2BIG;
@@ -598,10 +610,10 @@ iwe_stream_check_add_point(char * stream, /* Stream of events */
598 /* Check if it's possible */ 610 /* Check if it's possible */
599 if(likely((stream + event_len) < ends)) { 611 if(likely((stream + event_len) < ends)) {
600 iwe->len = event_len; 612 iwe->len = event_len;
601 memcpy(stream, (char *) iwe, IW_EV_LCP_LEN); 613 memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);
602 memcpy(stream + IW_EV_LCP_LEN, 614 memcpy(stream + IW_EV_LCP_LEN,
603 ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF, 615 ((char *) iwe) + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
604 IW_EV_POINT_LEN - IW_EV_LCP_LEN); 616 IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
605 memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length); 617 memcpy(stream + IW_EV_POINT_LEN, extra, iwe->u.data.length);
606 stream += event_len; 618 stream += event_len;
607 } else 619 } else
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 3725b93c52f3..ad7fe1121412 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -36,7 +36,7 @@ struct neigh_parms
36 struct net_device *dev; 36 struct net_device *dev;
37 struct neigh_parms *next; 37 struct neigh_parms *next;
38 int (*neigh_setup)(struct neighbour *); 38 int (*neigh_setup)(struct neighbour *);
39 void (*neigh_destructor)(struct neighbour *); 39 void (*neigh_cleanup)(struct neighbour *);
40 struct neigh_table *tbl; 40 struct neigh_table *tbl;
41 41
42 void *sysctl_table; 42 void *sysctl_table;
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index b902d24a3256..02647fe3d74b 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -352,10 +352,13 @@ tcf_change_indev(struct tcf_proto *tp, char *indev, struct rtattr *indev_tlv)
352static inline int 352static inline int
353tcf_match_indev(struct sk_buff *skb, char *indev) 353tcf_match_indev(struct sk_buff *skb, char *indev)
354{ 354{
355 struct net_device *dev;
356
355 if (indev[0]) { 357 if (indev[0]) {
356 if (!skb->input_dev) 358 if (!skb->iif)
357 return 0; 359 return 0;
358 if (strcmp(indev, skb->input_dev->name)) 360 dev = __dev_get_by_index(skb->iif);
361 if (!dev || strcmp(indev, dev->name))
359 return 0; 362 return 0;
360 } 363 }
361 364
diff --git a/ipc/util.c b/ipc/util.c
index 08a647965b9e..0b652387d169 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -144,6 +144,13 @@ void free_ipc_ns(struct kref *kref)
144 shm_exit_ns(ns); 144 shm_exit_ns(ns);
145 kfree(ns); 145 kfree(ns);
146} 146}
147#else
148int copy_ipcs(unsigned long flags, struct task_struct *tsk)
149{
150 if (flags & CLONE_NEWIPC)
151 return -EINVAL;
152 return 0;
153}
147#endif 154#endif
148 155
149/** 156/**
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3d4206ada5c9..36e70845cfc3 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -254,6 +254,12 @@ int __cpuinit cpu_up(unsigned int cpu)
254} 254}
255 255
256#ifdef CONFIG_SUSPEND_SMP 256#ifdef CONFIG_SUSPEND_SMP
257/* Needed to prevent the microcode driver from requesting firmware in its CPU
258 * hotplug notifier during the suspend/resume.
259 */
260int suspend_cpu_hotplug;
261EXPORT_SYMBOL(suspend_cpu_hotplug);
262
257static cpumask_t frozen_cpus; 263static cpumask_t frozen_cpus;
258 264
259int disable_nonboot_cpus(void) 265int disable_nonboot_cpus(void)
@@ -261,16 +267,8 @@ int disable_nonboot_cpus(void)
261 int cpu, first_cpu, error = 0; 267 int cpu, first_cpu, error = 0;
262 268
263 mutex_lock(&cpu_add_remove_lock); 269 mutex_lock(&cpu_add_remove_lock);
264 first_cpu = first_cpu(cpu_present_map); 270 suspend_cpu_hotplug = 1;
265 if (!cpu_online(first_cpu)) { 271 first_cpu = first_cpu(cpu_online_map);
266 error = _cpu_up(first_cpu);
267 if (error) {
268 printk(KERN_ERR "Could not bring CPU%d up.\n",
269 first_cpu);
270 goto out;
271 }
272 }
273
274 /* We take down all of the non-boot CPUs in one shot to avoid races 272 /* We take down all of the non-boot CPUs in one shot to avoid races
275 * with the userspace trying to use the CPU hotplug at the same time 273 * with the userspace trying to use the CPU hotplug at the same time
276 */ 274 */
@@ -296,7 +294,7 @@ int disable_nonboot_cpus(void)
296 } else { 294 } else {
297 printk(KERN_ERR "Non-boot CPUs are not disabled\n"); 295 printk(KERN_ERR "Non-boot CPUs are not disabled\n");
298 } 296 }
299out: 297 suspend_cpu_hotplug = 0;
300 mutex_unlock(&cpu_add_remove_lock); 298 mutex_unlock(&cpu_add_remove_lock);
301 return error; 299 return error;
302} 300}
@@ -308,20 +306,22 @@ void enable_nonboot_cpus(void)
308 /* Allow everyone to use the CPU hotplug again */ 306 /* Allow everyone to use the CPU hotplug again */
309 mutex_lock(&cpu_add_remove_lock); 307 mutex_lock(&cpu_add_remove_lock);
310 cpu_hotplug_disabled = 0; 308 cpu_hotplug_disabled = 0;
311 mutex_unlock(&cpu_add_remove_lock);
312 if (cpus_empty(frozen_cpus)) 309 if (cpus_empty(frozen_cpus))
313 return; 310 goto out;
314 311
312 suspend_cpu_hotplug = 1;
315 printk("Enabling non-boot CPUs ...\n"); 313 printk("Enabling non-boot CPUs ...\n");
316 for_each_cpu_mask(cpu, frozen_cpus) { 314 for_each_cpu_mask(cpu, frozen_cpus) {
317 error = cpu_up(cpu); 315 error = _cpu_up(cpu);
318 if (!error) { 316 if (!error) {
319 printk("CPU%d is up\n", cpu); 317 printk("CPU%d is up\n", cpu);
320 continue; 318 continue;
321 } 319 }
322 printk(KERN_WARNING "Error taking CPU%d up: %d\n", 320 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error);
323 cpu, error);
324 } 321 }
325 cpus_clear(frozen_cpus); 322 cpus_clear(frozen_cpus);
323 suspend_cpu_hotplug = 0;
324out:
325 mutex_unlock(&cpu_add_remove_lock);
326} 326}
327#endif 327#endif
diff --git a/kernel/exit.c b/kernel/exit.c
index f132349c0325..b55ed4cc9104 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -790,7 +790,7 @@ static void exit_notify(struct task_struct *tsk)
790 790
791 pgrp = task_pgrp(tsk); 791 pgrp = task_pgrp(tsk);
792 if ((task_pgrp(t) != pgrp) && 792 if ((task_pgrp(t) != pgrp) &&
793 (task_session(t) != task_session(tsk)) && 793 (task_session(t) == task_session(tsk)) &&
794 will_become_orphaned_pgrp(pgrp, tsk) && 794 will_become_orphaned_pgrp(pgrp, tsk) &&
795 has_stopped_jobs(pgrp)) { 795 has_stopped_jobs(pgrp)) {
796 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp); 796 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 6a7938a0d513..b74860aaf5f1 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -459,6 +459,18 @@ void clock_was_set(void)
459} 459}
460 460
461/* 461/*
462 * During resume we might have to reprogram the high resolution timer
463 * interrupt (on the local CPU):
464 */
465void hres_timers_resume(void)
466{
467 WARN_ON_ONCE(num_online_cpus() > 1);
468
469 /* Retrigger the CPU local events: */
470 retrigger_next_event(NULL);
471}
472
473/*
462 * Check, whether the timer is on the callback pending list 474 * Check, whether the timer is on the callback pending list
463 */ 475 */
464static inline int hrtimer_cb_pending(const struct hrtimer *timer) 476static inline int hrtimer_cb_pending(const struct hrtimer *timer)
@@ -814,7 +826,12 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
814 826
815 timer_stats_hrtimer_set_start_info(timer); 827 timer_stats_hrtimer_set_start_info(timer);
816 828
817 enqueue_hrtimer(timer, new_base, base == new_base); 829 /*
830 * Only allow reprogramming if the new base is on this CPU.
831 * (it might still be on another CPU if the timer was pending)
832 */
833 enqueue_hrtimer(timer, new_base,
834 new_base->cpu_base == &__get_cpu_var(hrtimer_bases));
818 835
819 unlock_hrtimer_base(timer, &flags); 836 unlock_hrtimer_base(timer, &flags);
820 837
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index 85a430da0fb6..d8ee241115f5 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -54,7 +54,7 @@ int devm_request_irq(struct device *dev, unsigned int irq,
54 54
55 rc = request_irq(irq, handler, irqflags, devname, dev_id); 55 rc = request_irq(irq, handler, irqflags, devname, dev_id);
56 if (rc) { 56 if (rc) {
57 kfree(dr); 57 devres_free(dr);
58 return rc; 58 return rc;
59 } 59 }
60 60
diff --git a/kernel/module.c b/kernel/module.c
index fbc51de6444e..dcdb32b8b13c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2384,8 +2384,13 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
2384 2384
2385 /* Lookup built-in module entry in /sys/modules */ 2385 /* Lookup built-in module entry in /sys/modules */
2386 mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name); 2386 mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name);
2387 if (mkobj) 2387 if (mkobj) {
2388 mk = container_of(mkobj, struct module_kobject, kobj); 2388 mk = container_of(mkobj, struct module_kobject, kobj);
2389 /* remember our module structure */
2390 drv->mkobj = mk;
2391 /* kset_find_obj took a reference */
2392 kobject_put(mkobj);
2393 }
2389 } 2394 }
2390 2395
2391 if (!mk) 2396 if (!mk)
@@ -2405,17 +2410,22 @@ EXPORT_SYMBOL(module_add_driver);
2405 2410
2406void module_remove_driver(struct device_driver *drv) 2411void module_remove_driver(struct device_driver *drv)
2407{ 2412{
2413 struct module_kobject *mk = NULL;
2408 char *driver_name; 2414 char *driver_name;
2409 2415
2410 if (!drv) 2416 if (!drv)
2411 return; 2417 return;
2412 2418
2413 sysfs_remove_link(&drv->kobj, "module"); 2419 sysfs_remove_link(&drv->kobj, "module");
2414 if (drv->owner && drv->owner->mkobj.drivers_dir) { 2420
2421 if (drv->owner)
2422 mk = &drv->owner->mkobj;
2423 else if (drv->mkobj)
2424 mk = drv->mkobj;
2425 if (mk && mk->drivers_dir) {
2415 driver_name = make_driver_name(drv); 2426 driver_name = make_driver_name(drv);
2416 if (driver_name) { 2427 if (driver_name) {
2417 sysfs_remove_link(drv->owner->mkobj.drivers_dir, 2428 sysfs_remove_link(mk->drivers_dir, driver_name);
2418 driver_name);
2419 kfree(driver_name); 2429 kfree(driver_name);
2420 } 2430 }
2421 } 2431 }
diff --git a/kernel/params.c b/kernel/params.c
index e265b13195b1..1fc4ac746cd8 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -356,6 +356,10 @@ int param_set_copystring(const char *val, struct kernel_param *kp)
356{ 356{
357 struct kparam_string *kps = kp->arg; 357 struct kparam_string *kps = kp->arg;
358 358
359 if (!val) {
360 printk(KERN_ERR "%s: missing param set value\n", kp->name);
361 return -EINVAL;
362 }
359 if (strlen(val)+1 > kps->maxlen) { 363 if (strlen(val)+1 > kps->maxlen) {
360 printk(KERN_ERR "%s: string doesn't fit in %u chars.\n", 364 printk(KERN_ERR "%s: string doesn't fit in %u chars.\n",
361 kp->name, kps->maxlen-1); 365 kp->name, kps->maxlen-1);
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index dee0ff40befd..aec19b063e3f 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -58,7 +58,6 @@ static inline int platform_prepare(void)
58 58
59static void power_down(suspend_disk_method_t mode) 59static void power_down(suspend_disk_method_t mode)
60{ 60{
61 disable_nonboot_cpus();
62 switch(mode) { 61 switch(mode) {
63 case PM_DISK_PLATFORM: 62 case PM_DISK_PLATFORM:
64 if (pm_ops && pm_ops->enter) { 63 if (pm_ops && pm_ops->enter) {
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 7fb834397a0d..175370824f37 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -229,13 +229,13 @@ int swsusp_shrink_memory(void)
229 size += highmem_size; 229 size += highmem_size;
230 for_each_zone (zone) 230 for_each_zone (zone)
231 if (populated_zone(zone)) { 231 if (populated_zone(zone)) {
232 tmp += snapshot_additional_pages(zone);
232 if (is_highmem(zone)) { 233 if (is_highmem(zone)) {
233 highmem_size -= 234 highmem_size -=
234 zone_page_state(zone, NR_FREE_PAGES); 235 zone_page_state(zone, NR_FREE_PAGES);
235 } else { 236 } else {
236 tmp -= zone_page_state(zone, NR_FREE_PAGES); 237 tmp -= zone_page_state(zone, NR_FREE_PAGES);
237 tmp += zone->lowmem_reserve[ZONE_NORMAL]; 238 tmp += zone->lowmem_reserve[ZONE_NORMAL];
238 tmp += snapshot_additional_pages(zone);
239 } 239 }
240 } 240 }
241 241
diff --git a/kernel/power/user.c b/kernel/power/user.c
index bf211fee1222..7cf6713b2325 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -401,10 +401,9 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
401 401
402 case PMOPS_ENTER: 402 case PMOPS_ENTER:
403 if (data->platform_suspend) { 403 if (data->platform_suspend) {
404 disable_nonboot_cpus();
405 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); 404 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
406 error = pm_ops->enter(PM_SUSPEND_DISK); 405 error = pm_ops->enter(PM_SUSPEND_DISK);
407 enable_nonboot_cpus(); 406 error = 0;
408 } 407 }
409 break; 408 break;
410 409
diff --git a/kernel/sched.c b/kernel/sched.c
index a4ca632c477c..b9a683730148 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4687,32 +4687,10 @@ out_unlock:
4687 return retval; 4687 return retval;
4688} 4688}
4689 4689
4690static inline struct task_struct *eldest_child(struct task_struct *p)
4691{
4692 if (list_empty(&p->children))
4693 return NULL;
4694 return list_entry(p->children.next,struct task_struct,sibling);
4695}
4696
4697static inline struct task_struct *older_sibling(struct task_struct *p)
4698{
4699 if (p->sibling.prev==&p->parent->children)
4700 return NULL;
4701 return list_entry(p->sibling.prev,struct task_struct,sibling);
4702}
4703
4704static inline struct task_struct *younger_sibling(struct task_struct *p)
4705{
4706 if (p->sibling.next==&p->parent->children)
4707 return NULL;
4708 return list_entry(p->sibling.next,struct task_struct,sibling);
4709}
4710
4711static const char stat_nam[] = "RSDTtZX"; 4690static const char stat_nam[] = "RSDTtZX";
4712 4691
4713static void show_task(struct task_struct *p) 4692static void show_task(struct task_struct *p)
4714{ 4693{
4715 struct task_struct *relative;
4716 unsigned long free = 0; 4694 unsigned long free = 0;
4717 unsigned state; 4695 unsigned state;
4718 4696
@@ -4738,19 +4716,7 @@ static void show_task(struct task_struct *p)
4738 free = (unsigned long)n - (unsigned long)end_of_stack(p); 4716 free = (unsigned long)n - (unsigned long)end_of_stack(p);
4739 } 4717 }
4740#endif 4718#endif
4741 printk("%5lu %5d %6d ", free, p->pid, p->parent->pid); 4719 printk("%5lu %5d %6d", free, p->pid, p->parent->pid);
4742 if ((relative = eldest_child(p)))
4743 printk("%5d ", relative->pid);
4744 else
4745 printk(" ");
4746 if ((relative = younger_sibling(p)))
4747 printk("%7d", relative->pid);
4748 else
4749 printk(" ");
4750 if ((relative = older_sibling(p)))
4751 printk(" %5d", relative->pid);
4752 else
4753 printk(" ");
4754 if (!p->mm) 4720 if (!p->mm)
4755 printk(" (L-TLB)\n"); 4721 printk(" (L-TLB)\n");
4756 else 4722 else
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 1b255df4fcd0..c904748f2290 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1676,7 +1676,7 @@ static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
1676{ 1676{
1677 int op; 1677 int op;
1678 1678
1679 if (!capable(CAP_SYS_ADMIN)) 1679 if (write && !capable(CAP_SYS_ADMIN))
1680 return -EPERM; 1680 return -EPERM;
1681 1681
1682 op = OP_OR; 1682 op = OP_OR;
diff --git a/kernel/time.c b/kernel/time.c
index c6c80ea5d0ea..2f47888e46c9 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -635,6 +635,7 @@ timeval_to_jiffies(const struct timeval *value)
635 (((u64)usec * USEC_CONVERSION + USEC_ROUND) >> 635 (((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
636 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; 636 (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
637} 637}
638EXPORT_SYMBOL(timeval_to_jiffies);
638 639
639void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) 640void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
640{ 641{
@@ -649,6 +650,7 @@ void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
649 tv_usec /= NSEC_PER_USEC; 650 tv_usec /= NSEC_PER_USEC;
650 value->tv_usec = tv_usec; 651 value->tv_usec = tv_usec;
651} 652}
653EXPORT_SYMBOL(jiffies_to_timeval);
652 654
653/* 655/*
654 * Convert jiffies/jiffies_64 to clock_t and back. 656 * Convert jiffies/jiffies_64 to clock_t and back.
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 67932ea78c17..76212b2a99de 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -274,72 +274,3 @@ void clockevents_notify(unsigned long reason, void *arg)
274} 274}
275EXPORT_SYMBOL_GPL(clockevents_notify); 275EXPORT_SYMBOL_GPL(clockevents_notify);
276 276
277#ifdef CONFIG_SYSFS
278
279/**
280 * clockevents_show_registered - sysfs interface for listing clockevents
281 * @dev: unused
282 * @buf: char buffer to be filled with clock events list
283 *
284 * Provides sysfs interface for listing registered clock event devices
285 */
286static ssize_t clockevents_show_registered(struct sys_device *dev, char *buf)
287{
288 struct list_head *tmp;
289 char *p = buf;
290 int cpu;
291
292 spin_lock(&clockevents_lock);
293
294 list_for_each(tmp, &clockevent_devices) {
295 struct clock_event_device *ce;
296
297 ce = list_entry(tmp, struct clock_event_device, list);
298 p += sprintf(p, "%-20s F:%04x M:%d", ce->name,
299 ce->features, ce->mode);
300 p += sprintf(p, " C:");
301 if (!cpus_equal(ce->cpumask, cpu_possible_map)) {
302 for_each_cpu_mask(cpu, ce->cpumask)
303 p += sprintf(p, " %d", cpu);
304 } else {
305 /*
306 * FIXME: Add the cpu which is handling this sucker
307 */
308 }
309 p += sprintf(p, "\n");
310 }
311
312 spin_unlock(&clockevents_lock);
313
314 return p - buf;
315}
316
317/*
318 * Sysfs setup bits:
319 */
320static SYSDEV_ATTR(registered, 0600,
321 clockevents_show_registered, NULL);
322
323static struct sysdev_class clockevents_sysclass = {
324 set_kset_name("clockevents"),
325};
326
327static struct sys_device clockevents_sys_device = {
328 .id = 0,
329 .cls = &clockevents_sysclass,
330};
331
332static int __init clockevents_sysfs_init(void)
333{
334 int error = sysdev_class_register(&clockevents_sysclass);
335
336 if (!error)
337 error = sysdev_register(&clockevents_sys_device);
338 if (!error)
339 error = sysdev_create_file(
340 &clockevents_sys_device,
341 &attr_registered);
342 return error;
343}
344device_initcall(clockevents_sysfs_init);
345#endif
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
index 3be8da8fed7e..4c256fdb8875 100644
--- a/kernel/time/jiffies.c
+++ b/kernel/time/jiffies.c
@@ -69,4 +69,4 @@ static int __init init_jiffies_clocksource(void)
69 return clocksource_register(&clocksource_jiffies); 69 return clocksource_register(&clocksource_jiffies);
70} 70}
71 71
72module_init(init_jiffies_clocksource); 72core_initcall(init_jiffies_clocksource);
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index eb12509e00bd..cb25649c6f50 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -32,7 +32,7 @@ static u64 tick_length, tick_length_base;
32/* TIME_ERROR prevents overwriting the CMOS clock */ 32/* TIME_ERROR prevents overwriting the CMOS clock */
33static int time_state = TIME_OK; /* clock synchronization status */ 33static int time_state = TIME_OK; /* clock synchronization status */
34int time_status = STA_UNSYNC; /* clock status bits */ 34int time_status = STA_UNSYNC; /* clock status bits */
35static long time_offset; /* time adjustment (ns) */ 35static s64 time_offset; /* time adjustment (ns) */
36static long time_constant = 2; /* pll time constant */ 36static long time_constant = 2; /* pll time constant */
37long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ 37long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */
38long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */ 38long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */
@@ -196,7 +196,7 @@ void __attribute__ ((weak)) notify_arch_cmos_timer(void)
196 */ 196 */
197int do_adjtimex(struct timex *txc) 197int do_adjtimex(struct timex *txc)
198{ 198{
199 long ltemp, mtemp, save_adjust; 199 long mtemp, save_adjust, rem;
200 s64 freq_adj, temp64; 200 s64 freq_adj, temp64;
201 int result; 201 int result;
202 202
@@ -277,14 +277,14 @@ int do_adjtimex(struct timex *txc)
277 time_adjust = txc->offset; 277 time_adjust = txc->offset;
278 } 278 }
279 else if (time_status & STA_PLL) { 279 else if (time_status & STA_PLL) {
280 ltemp = txc->offset * NSEC_PER_USEC; 280 time_offset = txc->offset * NSEC_PER_USEC;
281 281
282 /* 282 /*
283 * Scale the phase adjustment and 283 * Scale the phase adjustment and
284 * clamp to the operating range. 284 * clamp to the operating range.
285 */ 285 */
286 time_offset = min(ltemp, MAXPHASE * NSEC_PER_USEC); 286 time_offset = min(time_offset, (s64)MAXPHASE * NSEC_PER_USEC);
287 time_offset = max(time_offset, -MAXPHASE * NSEC_PER_USEC); 287 time_offset = max(time_offset, (s64)-MAXPHASE * NSEC_PER_USEC);
288 288
289 /* 289 /*
290 * Select whether the frequency is to be controlled 290 * Select whether the frequency is to be controlled
@@ -297,11 +297,11 @@ int do_adjtimex(struct timex *txc)
297 mtemp = xtime.tv_sec - time_reftime; 297 mtemp = xtime.tv_sec - time_reftime;
298 time_reftime = xtime.tv_sec; 298 time_reftime = xtime.tv_sec;
299 299
300 freq_adj = (s64)time_offset * mtemp; 300 freq_adj = time_offset * mtemp;
301 freq_adj = shift_right(freq_adj, time_constant * 2 + 301 freq_adj = shift_right(freq_adj, time_constant * 2 +
302 (SHIFT_PLL + 2) * 2 - SHIFT_NSEC); 302 (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
303 if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) { 303 if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > MAXSEC)) {
304 temp64 = (s64)time_offset << (SHIFT_NSEC - SHIFT_FLL); 304 temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL);
305 if (time_offset < 0) { 305 if (time_offset < 0) {
306 temp64 = -temp64; 306 temp64 = -temp64;
307 do_div(temp64, mtemp); 307 do_div(temp64, mtemp);
@@ -314,8 +314,10 @@ int do_adjtimex(struct timex *txc)
314 freq_adj += time_freq; 314 freq_adj += time_freq;
315 freq_adj = min(freq_adj, (s64)MAXFREQ_NSEC); 315 freq_adj = min(freq_adj, (s64)MAXFREQ_NSEC);
316 time_freq = max(freq_adj, (s64)-MAXFREQ_NSEC); 316 time_freq = max(freq_adj, (s64)-MAXFREQ_NSEC);
317 time_offset = (time_offset / NTP_INTERVAL_FREQ) 317 time_offset = div_long_long_rem_signed(time_offset,
318 << SHIFT_UPDATE; 318 NTP_INTERVAL_FREQ,
319 &rem);
320 time_offset <<= SHIFT_UPDATE;
319 } /* STA_PLL */ 321 } /* STA_PLL */
320 } /* txc->modes & ADJ_OFFSET */ 322 } /* txc->modes & ADJ_OFFSET */
321 if (txc->modes & ADJ_TICK) 323 if (txc->modes & ADJ_TICK)
@@ -328,12 +330,12 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
328 result = TIME_ERROR; 330 result = TIME_ERROR;
329 331
330 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) 332 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT)
331 txc->offset = save_adjust; 333 txc->offset = save_adjust;
332 else 334 else
333 txc->offset = shift_right(time_offset, SHIFT_UPDATE) 335 txc->offset = ((long)shift_right(time_offset, SHIFT_UPDATE)) *
334 * NTP_INTERVAL_FREQ / 1000; 336 NTP_INTERVAL_FREQ / 1000;
335 txc->freq = (time_freq / NSEC_PER_USEC) 337 txc->freq = (time_freq / NSEC_PER_USEC) <<
336 << (SHIFT_USEC - SHIFT_NSEC); 338 (SHIFT_USEC - SHIFT_NSEC);
337 txc->maxerror = time_maxerror; 339 txc->maxerror = time_maxerror;
338 txc->esterror = time_esterror; 340 txc->esterror = time_esterror;
339 txc->status = time_status; 341 txc->status = time_status;
diff --git a/kernel/timer.c b/kernel/timer.c
index 440048acaea1..dd6c2c1c561b 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1016,7 +1016,7 @@ static int timekeeping_resume(struct sys_device *dev)
1016 clockevents_notify(CLOCK_EVT_NOTIFY_RESUME, NULL); 1016 clockevents_notify(CLOCK_EVT_NOTIFY_RESUME, NULL);
1017 1017
1018 /* Resume hrtimers */ 1018 /* Resume hrtimers */
1019 clock_was_set(); 1019 hres_timers_resume();
1020 1020
1021 return 0; 1021 return 0;
1022} 1022}
diff --git a/mm/bounce.c b/mm/bounce.c
index 643efbe82402..ad401fc57440 100644
--- a/mm/bounce.c
+++ b/mm/bounce.c
@@ -204,7 +204,7 @@ static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig,
204 /* 204 /*
205 * is destination page below bounce pfn? 205 * is destination page below bounce pfn?
206 */ 206 */
207 if (page_to_pfn(page) < q->bounce_pfn) 207 if (page_to_pfn(page) <= q->bounce_pfn)
208 continue; 208 continue;
209 209
210 /* 210 /*
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 9dd9fbb75139..cbb335813ec0 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -17,6 +17,29 @@
17#include "filemap.h" 17#include "filemap.h"
18 18
19/* 19/*
20 * We do use our own empty page to avoid interference with other users
21 * of ZERO_PAGE(), such as /dev/zero
22 */
23static struct page *__xip_sparse_page;
24
25static struct page *xip_sparse_page(void)
26{
27 if (!__xip_sparse_page) {
28 unsigned long zeroes = get_zeroed_page(GFP_HIGHUSER);
29 if (zeroes) {
30 static DEFINE_SPINLOCK(xip_alloc_lock);
31 spin_lock(&xip_alloc_lock);
32 if (!__xip_sparse_page)
33 __xip_sparse_page = virt_to_page(zeroes);
34 else
35 free_page(zeroes);
36 spin_unlock(&xip_alloc_lock);
37 }
38 }
39 return __xip_sparse_page;
40}
41
42/*
20 * This is a file read routine for execute in place files, and uses 43 * This is a file read routine for execute in place files, and uses
21 * the mapping->a_ops->get_xip_page() function for the actual low-level 44 * the mapping->a_ops->get_xip_page() function for the actual low-level
22 * stuff. 45 * stuff.
@@ -162,7 +185,7 @@ EXPORT_SYMBOL_GPL(xip_file_sendfile);
162 * xip_write 185 * xip_write
163 * 186 *
164 * This function walks all vmas of the address_space and unmaps the 187 * This function walks all vmas of the address_space and unmaps the
165 * ZERO_PAGE when found at pgoff. Should it go in rmap.c? 188 * __xip_sparse_page when found at pgoff.
166 */ 189 */
167static void 190static void
168__xip_unmap (struct address_space * mapping, 191__xip_unmap (struct address_space * mapping,
@@ -177,13 +200,16 @@ __xip_unmap (struct address_space * mapping,
177 spinlock_t *ptl; 200 spinlock_t *ptl;
178 struct page *page; 201 struct page *page;
179 202
203 page = __xip_sparse_page;
204 if (!page)
205 return;
206
180 spin_lock(&mapping->i_mmap_lock); 207 spin_lock(&mapping->i_mmap_lock);
181 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { 208 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
182 mm = vma->vm_mm; 209 mm = vma->vm_mm;
183 address = vma->vm_start + 210 address = vma->vm_start +
184 ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); 211 ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
185 BUG_ON(address < vma->vm_start || address >= vma->vm_end); 212 BUG_ON(address < vma->vm_start || address >= vma->vm_end);
186 page = ZERO_PAGE(0);
187 pte = page_check_address(page, mm, address, &ptl); 213 pte = page_check_address(page, mm, address, &ptl);
188 if (pte) { 214 if (pte) {
189 /* Nuke the page table entry. */ 215 /* Nuke the page table entry. */
@@ -222,16 +248,14 @@ xip_file_nopage(struct vm_area_struct * area,
222 + area->vm_pgoff; 248 + area->vm_pgoff;
223 249
224 size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 250 size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
225 if (pgoff >= size) { 251 if (pgoff >= size)
226 return NULL; 252 return NOPAGE_SIGBUS;
227 }
228 253
229 page = mapping->a_ops->get_xip_page(mapping, pgoff*(PAGE_SIZE/512), 0); 254 page = mapping->a_ops->get_xip_page(mapping, pgoff*(PAGE_SIZE/512), 0);
230 if (!IS_ERR(page)) { 255 if (!IS_ERR(page))
231 goto out; 256 goto out;
232 }
233 if (PTR_ERR(page) != -ENODATA) 257 if (PTR_ERR(page) != -ENODATA)
234 return NULL; 258 return NOPAGE_SIGBUS;
235 259
236 /* sparse block */ 260 /* sparse block */
237 if ((area->vm_flags & (VM_WRITE | VM_MAYWRITE)) && 261 if ((area->vm_flags & (VM_WRITE | VM_MAYWRITE)) &&
@@ -241,12 +265,14 @@ xip_file_nopage(struct vm_area_struct * area,
241 page = mapping->a_ops->get_xip_page (mapping, 265 page = mapping->a_ops->get_xip_page (mapping,
242 pgoff*(PAGE_SIZE/512), 1); 266 pgoff*(PAGE_SIZE/512), 1);
243 if (IS_ERR(page)) 267 if (IS_ERR(page))
244 return NULL; 268 return NOPAGE_SIGBUS;
245 /* unmap page at pgoff from all other vmas */ 269 /* unmap page at pgoff from all other vmas */
246 __xip_unmap(mapping, pgoff); 270 __xip_unmap(mapping, pgoff);
247 } else { 271 } else {
248 /* not shared and writable, use ZERO_PAGE() */ 272 /* not shared and writable, use xip_sparse_page() */
249 page = ZERO_PAGE(0); 273 page = xip_sparse_page();
274 if (!page)
275 return NOPAGE_OOM;
250 } 276 }
251 277
252out: 278out:
diff --git a/mm/madvise.c b/mm/madvise.c
index 77916e9fc52b..603c5257ed6e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -159,9 +159,10 @@ static long madvise_remove(struct vm_area_struct *vma,
159 unsigned long start, unsigned long end) 159 unsigned long start, unsigned long end)
160{ 160{
161 struct address_space *mapping; 161 struct address_space *mapping;
162 loff_t offset, endoff; 162 loff_t offset, endoff;
163 int error;
163 164
164 *prev = vma; 165 *prev = NULL; /* tell sys_madvise we drop mmap_sem */
165 166
166 if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB)) 167 if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB))
167 return -EINVAL; 168 return -EINVAL;
@@ -180,7 +181,12 @@ static long madvise_remove(struct vm_area_struct *vma,
180 + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); 181 + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
181 endoff = (loff_t)(end - vma->vm_start - 1) 182 endoff = (loff_t)(end - vma->vm_start - 1)
182 + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); 183 + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
183 return vmtruncate_range(mapping->host, offset, endoff); 184
185 /* vmtruncate_range needs to take i_mutex and i_alloc_sem */
186 up_write(&current->mm->mmap_sem);
187 error = vmtruncate_range(mapping->host, offset, endoff);
188 down_write(&current->mm->mmap_sem);
189 return error;
184} 190}
185 191
186static long 192static long
@@ -315,12 +321,15 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
315 if (error) 321 if (error)
316 goto out; 322 goto out;
317 start = tmp; 323 start = tmp;
318 if (start < prev->vm_end) 324 if (prev && start < prev->vm_end)
319 start = prev->vm_end; 325 start = prev->vm_end;
320 error = unmapped_error; 326 error = unmapped_error;
321 if (start >= end) 327 if (start >= end)
322 goto out; 328 goto out;
323 vma = prev->vm_next; 329 if (prev)
330 vma = prev->vm_next;
331 else /* madvise_remove dropped mmap_sem */
332 vma = find_vma(current->mm, start);
324 } 333 }
325out: 334out:
326 up_write(&current->mm->mmap_sem); 335 up_write(&current->mm->mmap_sem);
diff --git a/mm/migrate.c b/mm/migrate.c
index 7a66ca25dc8a..a91ca00abebe 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -297,7 +297,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
297 void **pslot; 297 void **pslot;
298 298
299 if (!mapping) { 299 if (!mapping) {
300 /* Anonymous page */ 300 /* Anonymous page without mapping */
301 if (page_count(page) != 1) 301 if (page_count(page) != 1)
302 return -EAGAIN; 302 return -EAGAIN;
303 return 0; 303 return 0;
@@ -333,6 +333,19 @@ static int migrate_page_move_mapping(struct address_space *mapping,
333 */ 333 */
334 __put_page(page); 334 __put_page(page);
335 335
336 /*
337 * If moved to a different zone then also account
338 * the page for that zone. Other VM counters will be
339 * taken care of when we establish references to the
340 * new page and drop references to the old page.
341 *
342 * Note that anonymous pages are accounted for
343 * via NR_FILE_PAGES and NR_ANON_PAGES if they
344 * are mapped to swap space.
345 */
346 __dec_zone_page_state(page, NR_FILE_PAGES);
347 __inc_zone_page_state(newpage, NR_FILE_PAGES);
348
336 write_unlock_irq(&mapping->tree_lock); 349 write_unlock_irq(&mapping->tree_lock);
337 350
338 return 0; 351 return 0;
diff --git a/mm/nommu.c b/mm/nommu.c
index cbbc13774819..1f60194d9b9b 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -45,6 +45,7 @@ int heap_stack_gap = 0;
45 45
46EXPORT_SYMBOL(mem_map); 46EXPORT_SYMBOL(mem_map);
47EXPORT_SYMBOL(__vm_enough_memory); 47EXPORT_SYMBOL(__vm_enough_memory);
48EXPORT_SYMBOL(num_physpages);
48 49
49/* list of shareable VMAs */ 50/* list of shareable VMAs */
50struct rb_root nommu_vma_tree = RB_ROOT; 51struct rb_root nommu_vma_tree = RB_ROOT;
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 2f3916986abf..3791edfffeeb 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -176,6 +176,8 @@ static inline int constrained_alloc(struct zonelist *zonelist, gfp_t gfp_mask)
176 struct zone **z; 176 struct zone **z;
177 nodemask_t nodes; 177 nodemask_t nodes;
178 int node; 178 int node;
179
180 nodes_clear(nodes);
179 /* node has memory ? */ 181 /* node has memory ? */
180 for_each_online_node(node) 182 for_each_online_node(node)
181 if (NODE_DATA(node)->node_present_pages) 183 if (NODE_DATA(node)->node_present_pages)
@@ -333,7 +335,7 @@ static int oom_kill_task(struct task_struct *p)
333 */ 335 */
334 do_each_thread(g, q) { 336 do_each_thread(g, q) {
335 if (q->mm == mm && q->tgid != p->tgid) 337 if (q->mm == mm && q->tgid != p->tgid)
336 force_sig(SIGKILL, p); 338 force_sig(SIGKILL, q);
337 } while_each_thread(g, q); 339 } while_each_thread(g, q);
338 340
339 return 0; 341 return 0;
diff --git a/mm/rmap.c b/mm/rmap.c
index 22ed3f71a674..b82146e6dfc9 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -498,9 +498,9 @@ int page_mkclean(struct page *page)
498 struct address_space *mapping = page_mapping(page); 498 struct address_space *mapping = page_mapping(page);
499 if (mapping) 499 if (mapping)
500 ret = page_mkclean_file(mapping, page); 500 ret = page_mkclean_file(mapping, page);
501 if (page_test_and_clear_dirty(page))
502 ret = 1;
501 } 503 }
502 if (page_test_and_clear_dirty(page))
503 ret = 1;
504 504
505 return ret; 505 return ret;
506} 506}
diff --git a/mm/shmem.c b/mm/shmem.c
index b8c429a2d271..b2a35ebf071a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -402,26 +402,38 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
402/* 402/*
403 * shmem_free_swp - free some swap entries in a directory 403 * shmem_free_swp - free some swap entries in a directory
404 * 404 *
405 * @dir: pointer to the directory 405 * @dir: pointer to the directory
406 * @edir: pointer after last entry of the directory 406 * @edir: pointer after last entry of the directory
407 * @punch_lock: pointer to spinlock when needed for the holepunch case
407 */ 408 */
408static int shmem_free_swp(swp_entry_t *dir, swp_entry_t *edir) 409static int shmem_free_swp(swp_entry_t *dir, swp_entry_t *edir,
410 spinlock_t *punch_lock)
409{ 411{
412 spinlock_t *punch_unlock = NULL;
410 swp_entry_t *ptr; 413 swp_entry_t *ptr;
411 int freed = 0; 414 int freed = 0;
412 415
413 for (ptr = dir; ptr < edir; ptr++) { 416 for (ptr = dir; ptr < edir; ptr++) {
414 if (ptr->val) { 417 if (ptr->val) {
418 if (unlikely(punch_lock)) {
419 punch_unlock = punch_lock;
420 punch_lock = NULL;
421 spin_lock(punch_unlock);
422 if (!ptr->val)
423 continue;
424 }
415 free_swap_and_cache(*ptr); 425 free_swap_and_cache(*ptr);
416 *ptr = (swp_entry_t){0}; 426 *ptr = (swp_entry_t){0};
417 freed++; 427 freed++;
418 } 428 }
419 } 429 }
430 if (punch_unlock)
431 spin_unlock(punch_unlock);
420 return freed; 432 return freed;
421} 433}
422 434
423static int shmem_map_and_free_swp(struct page *subdir, 435static int shmem_map_and_free_swp(struct page *subdir, int offset,
424 int offset, int limit, struct page ***dir) 436 int limit, struct page ***dir, spinlock_t *punch_lock)
425{ 437{
426 swp_entry_t *ptr; 438 swp_entry_t *ptr;
427 int freed = 0; 439 int freed = 0;
@@ -431,7 +443,8 @@ static int shmem_map_and_free_swp(struct page *subdir,
431 int size = limit - offset; 443 int size = limit - offset;
432 if (size > LATENCY_LIMIT) 444 if (size > LATENCY_LIMIT)
433 size = LATENCY_LIMIT; 445 size = LATENCY_LIMIT;
434 freed += shmem_free_swp(ptr+offset, ptr+offset+size); 446 freed += shmem_free_swp(ptr+offset, ptr+offset+size,
447 punch_lock);
435 if (need_resched()) { 448 if (need_resched()) {
436 shmem_swp_unmap(ptr); 449 shmem_swp_unmap(ptr);
437 if (*dir) { 450 if (*dir) {
@@ -481,7 +494,10 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
481 long nr_swaps_freed = 0; 494 long nr_swaps_freed = 0;
482 int offset; 495 int offset;
483 int freed; 496 int freed;
484 int punch_hole = 0; 497 int punch_hole;
498 spinlock_t *needs_lock;
499 spinlock_t *punch_lock;
500 unsigned long upper_limit;
485 501
486 inode->i_ctime = inode->i_mtime = CURRENT_TIME; 502 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
487 idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 503 idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
@@ -492,11 +508,20 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
492 info->flags |= SHMEM_TRUNCATE; 508 info->flags |= SHMEM_TRUNCATE;
493 if (likely(end == (loff_t) -1)) { 509 if (likely(end == (loff_t) -1)) {
494 limit = info->next_index; 510 limit = info->next_index;
511 upper_limit = SHMEM_MAX_INDEX;
495 info->next_index = idx; 512 info->next_index = idx;
513 needs_lock = NULL;
514 punch_hole = 0;
496 } else { 515 } else {
497 limit = (end + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 516 if (end + 1 >= inode->i_size) { /* we may free a little more */
498 if (limit > info->next_index) 517 limit = (inode->i_size + PAGE_CACHE_SIZE - 1) >>
499 limit = info->next_index; 518 PAGE_CACHE_SHIFT;
519 upper_limit = SHMEM_MAX_INDEX;
520 } else {
521 limit = (end + 1) >> PAGE_CACHE_SHIFT;
522 upper_limit = limit;
523 }
524 needs_lock = &info->lock;
500 punch_hole = 1; 525 punch_hole = 1;
501 } 526 }
502 527
@@ -513,17 +538,30 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
513 size = limit; 538 size = limit;
514 if (size > SHMEM_NR_DIRECT) 539 if (size > SHMEM_NR_DIRECT)
515 size = SHMEM_NR_DIRECT; 540 size = SHMEM_NR_DIRECT;
516 nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size); 541 nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size, needs_lock);
517 } 542 }
518 543
519 /* 544 /*
520 * If there are no indirect blocks or we are punching a hole 545 * If there are no indirect blocks or we are punching a hole
521 * below indirect blocks, nothing to be done. 546 * below indirect blocks, nothing to be done.
522 */ 547 */
523 if (!topdir || (punch_hole && (limit <= SHMEM_NR_DIRECT))) 548 if (!topdir || limit <= SHMEM_NR_DIRECT)
524 goto done2; 549 goto done2;
525 550
526 BUG_ON(limit <= SHMEM_NR_DIRECT); 551 /*
552 * The truncation case has already dropped info->lock, and we're safe
553 * because i_size and next_index have already been lowered, preventing
554 * access beyond. But in the punch_hole case, we still need to take
555 * the lock when updating the swap directory, because there might be
556 * racing accesses by shmem_getpage(SGP_CACHE), shmem_unuse_inode or
557 * shmem_writepage. However, whenever we find we can remove a whole
558 * directory page (not at the misaligned start or end of the range),
559 * we first NULLify its pointer in the level above, and then have no
560 * need to take the lock when updating its contents: needs_lock and
561 * punch_lock (either pointing to info->lock or NULL) manage this.
562 */
563
564 upper_limit -= SHMEM_NR_DIRECT;
527 limit -= SHMEM_NR_DIRECT; 565 limit -= SHMEM_NR_DIRECT;
528 idx = (idx > SHMEM_NR_DIRECT)? (idx - SHMEM_NR_DIRECT): 0; 566 idx = (idx > SHMEM_NR_DIRECT)? (idx - SHMEM_NR_DIRECT): 0;
529 offset = idx % ENTRIES_PER_PAGE; 567 offset = idx % ENTRIES_PER_PAGE;
@@ -543,8 +581,14 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
543 if (*dir) { 581 if (*dir) {
544 diroff = ((idx - ENTRIES_PER_PAGEPAGE/2) % 582 diroff = ((idx - ENTRIES_PER_PAGEPAGE/2) %
545 ENTRIES_PER_PAGEPAGE) / ENTRIES_PER_PAGE; 583 ENTRIES_PER_PAGEPAGE) / ENTRIES_PER_PAGE;
546 if (!diroff && !offset) { 584 if (!diroff && !offset && upper_limit >= stage) {
547 *dir = NULL; 585 if (needs_lock) {
586 spin_lock(needs_lock);
587 *dir = NULL;
588 spin_unlock(needs_lock);
589 needs_lock = NULL;
590 } else
591 *dir = NULL;
548 nr_pages_to_free++; 592 nr_pages_to_free++;
549 list_add(&middir->lru, &pages_to_free); 593 list_add(&middir->lru, &pages_to_free);
550 } 594 }
@@ -570,39 +614,55 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
570 } 614 }
571 stage = idx + ENTRIES_PER_PAGEPAGE; 615 stage = idx + ENTRIES_PER_PAGEPAGE;
572 middir = *dir; 616 middir = *dir;
573 *dir = NULL; 617 if (punch_hole)
574 nr_pages_to_free++; 618 needs_lock = &info->lock;
575 list_add(&middir->lru, &pages_to_free); 619 if (upper_limit >= stage) {
620 if (needs_lock) {
621 spin_lock(needs_lock);
622 *dir = NULL;
623 spin_unlock(needs_lock);
624 needs_lock = NULL;
625 } else
626 *dir = NULL;
627 nr_pages_to_free++;
628 list_add(&middir->lru, &pages_to_free);
629 }
576 shmem_dir_unmap(dir); 630 shmem_dir_unmap(dir);
577 cond_resched(); 631 cond_resched();
578 dir = shmem_dir_map(middir); 632 dir = shmem_dir_map(middir);
579 diroff = 0; 633 diroff = 0;
580 } 634 }
635 punch_lock = needs_lock;
581 subdir = dir[diroff]; 636 subdir = dir[diroff];
582 if (subdir && page_private(subdir)) { 637 if (subdir && !offset && upper_limit-idx >= ENTRIES_PER_PAGE) {
638 if (needs_lock) {
639 spin_lock(needs_lock);
640 dir[diroff] = NULL;
641 spin_unlock(needs_lock);
642 punch_lock = NULL;
643 } else
644 dir[diroff] = NULL;
645 nr_pages_to_free++;
646 list_add(&subdir->lru, &pages_to_free);
647 }
648 if (subdir && page_private(subdir) /* has swap entries */) {
583 size = limit - idx; 649 size = limit - idx;
584 if (size > ENTRIES_PER_PAGE) 650 if (size > ENTRIES_PER_PAGE)
585 size = ENTRIES_PER_PAGE; 651 size = ENTRIES_PER_PAGE;
586 freed = shmem_map_and_free_swp(subdir, 652 freed = shmem_map_and_free_swp(subdir,
587 offset, size, &dir); 653 offset, size, &dir, punch_lock);
588 if (!dir) 654 if (!dir)
589 dir = shmem_dir_map(middir); 655 dir = shmem_dir_map(middir);
590 nr_swaps_freed += freed; 656 nr_swaps_freed += freed;
591 if (offset) 657 if (offset || punch_lock) {
592 spin_lock(&info->lock); 658 spin_lock(&info->lock);
593 set_page_private(subdir, page_private(subdir) - freed); 659 set_page_private(subdir,
594 if (offset) 660 page_private(subdir) - freed);
595 spin_unlock(&info->lock); 661 spin_unlock(&info->lock);
596 if (!punch_hole) 662 } else
597 BUG_ON(page_private(subdir) > offset); 663 BUG_ON(page_private(subdir) != freed);
598 }
599 if (offset)
600 offset = 0;
601 else if (subdir && !page_private(subdir)) {
602 dir[diroff] = NULL;
603 nr_pages_to_free++;
604 list_add(&subdir->lru, &pages_to_free);
605 } 664 }
665 offset = 0;
606 } 666 }
607done1: 667done1:
608 shmem_dir_unmap(dir); 668 shmem_dir_unmap(dir);
@@ -614,8 +674,16 @@ done2:
614 * generic_delete_inode did it, before we lowered next_index. 674 * generic_delete_inode did it, before we lowered next_index.
615 * Also, though shmem_getpage checks i_size before adding to 675 * Also, though shmem_getpage checks i_size before adding to
616 * cache, no recheck after: so fix the narrow window there too. 676 * cache, no recheck after: so fix the narrow window there too.
677 *
678 * Recalling truncate_inode_pages_range and unmap_mapping_range
679 * every time for punch_hole (which never got a chance to clear
680 * SHMEM_PAGEIN at the start of vmtruncate_range) is expensive,
681 * yet hardly ever necessary: try to optimize them out later.
617 */ 682 */
618 truncate_inode_pages_range(inode->i_mapping, start, end); 683 truncate_inode_pages_range(inode->i_mapping, start, end);
684 if (punch_hole)
685 unmap_mapping_range(inode->i_mapping, start,
686 end - start, 1);
619 } 687 }
620 688
621 spin_lock(&info->lock); 689 spin_lock(&info->lock);
diff --git a/mm/slab.c b/mm/slab.c
index 57f7aa420064..4cbac24ae2f1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1802,8 +1802,8 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp)
1802 /* Print header */ 1802 /* Print header */
1803 if (lines == 0) { 1803 if (lines == 0) {
1804 printk(KERN_ERR 1804 printk(KERN_ERR
1805 "Slab corruption: start=%p, len=%d\n", 1805 "Slab corruption: %s start=%p, len=%d\n",
1806 realobj, size); 1806 cachep->name, realobj, size);
1807 print_objinfo(cachep, objp, 0); 1807 print_objinfo(cachep, objp, 0);
1808 } 1808 }
1809 /* Hexdump the affected line */ 1809 /* Hexdump the affected line */
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2fc8fe2cb366..b6e0eea1e39e 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -380,6 +380,9 @@ int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
380 } else { 380 } else {
381 vhdr->h_vlan_encapsulated_proto = htons(len); 381 vhdr->h_vlan_encapsulated_proto = htons(len);
382 } 382 }
383
384 skb->protocol = htons(ETH_P_8021Q);
385 skb->nh.raw = skb->data;
383 } 386 }
384 387
385 /* Before delegating work to the lower layer, enter our MAC-address */ 388 /* Before delegating work to the lower layer, enter our MAC-address */
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 113c175f1715..c8b7dc2c3257 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1417,10 +1417,13 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1417 /* 1417 /*
1418 * Size check to see if ddp->deh_len was crap 1418 * Size check to see if ddp->deh_len was crap
1419 * (Otherwise we'll detonate most spectacularly 1419 * (Otherwise we'll detonate most spectacularly
1420 * in the middle of recvmsg()). 1420 * in the middle of atalk_checksum() or recvmsg()).
1421 */ 1421 */
1422 if (skb->len < sizeof(*ddp)) 1422 if (skb->len < sizeof(*ddp) || skb->len < (len_hops & 1023)) {
1423 pr_debug("AppleTalk: dropping corrupted frame (deh_len=%u, "
1424 "skb->len=%u)\n", len_hops & 1023, skb->len);
1423 goto freeit; 1425 goto freeit;
1426 }
1424 1427
1425 /* 1428 /*
1426 * Any checksums. Note we don't do htons() on this == is assumed to be 1429 * Any checksums. Note we don't do htons() on this == is assumed to be
diff --git a/net/atm/clip.c b/net/atm/clip.c
index ebb5d0ce8b6f..8c3825816085 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -261,14 +261,6 @@ static void clip_pop(struct atm_vcc *vcc, struct sk_buff *skb)
261 spin_unlock_irqrestore(&PRIV(dev)->xoff_lock, flags); 261 spin_unlock_irqrestore(&PRIV(dev)->xoff_lock, flags);
262} 262}
263 263
264static void clip_neigh_destroy(struct neighbour *neigh)
265{
266 DPRINTK("clip_neigh_destroy (neigh %p)\n", neigh);
267 if (NEIGH2ENTRY(neigh)->vccs)
268 printk(KERN_CRIT "clip_neigh_destroy: vccs != NULL !!!\n");
269 NEIGH2ENTRY(neigh)->vccs = (void *) NEIGHBOR_DEAD;
270}
271
272static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb) 264static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb)
273{ 265{
274 DPRINTK("clip_neigh_solicit (neigh %p, skb %p)\n", neigh, skb); 266 DPRINTK("clip_neigh_solicit (neigh %p, skb %p)\n", neigh, skb);
@@ -342,7 +334,6 @@ static struct neigh_table clip_tbl = {
342 /* parameters are copied from ARP ... */ 334 /* parameters are copied from ARP ... */
343 .parms = { 335 .parms = {
344 .tbl = &clip_tbl, 336 .tbl = &clip_tbl,
345 .neigh_destructor = clip_neigh_destroy,
346 .base_reachable_time = 30 * HZ, 337 .base_reachable_time = 30 * HZ,
347 .retrans_time = 1 * HZ, 338 .retrans_time = 1 * HZ,
348 .gc_staletime = 60 * HZ, 339 .gc_staletime = 60 * HZ,
diff --git a/net/ax25/Kconfig b/net/ax25/Kconfig
index a8993a041724..43dd86fca4d3 100644
--- a/net/ax25/Kconfig
+++ b/net/ax25/Kconfig
@@ -1,30 +1,27 @@
1# 1#
2# Amateur Radio protocols and AX.25 device configuration 2# Amateur Radio protocols and AX.25 device configuration
3# 3#
4# 19971130 Now in an own category to make correct compilation of the
5# AX.25 stuff easier...
6# Joerg Reuter DL1BKE <jreuter@yaina.de>
7# 19980129 Moved to net/ax25/Config.in, sourcing device drivers.
8 4
9menuconfig HAMRADIO 5menuconfig HAMRADIO
10 depends on NET 6 depends on NET
11 bool "Amateur Radio support" 7 bool "Amateur Radio support"
12 help 8 help
13 If you want to connect your Linux box to an amateur radio, answer Y 9 If you want to connect your Linux box to an amateur radio, answer Y
14 here. You want to read <http://www.tapr.org/tapr/html/pkthome.html> and 10 here. You want to read <http://www.tapr.org/tapr/html/pkthome.html>
15 the AX25-HOWTO, available from <http://www.tldp.org/docs.html#howto>. 11 and more specifically about AX.25 on Linux
12 <http://www.linux-ax25.org/>.
16 13
17 Note that the answer to this question won't directly affect the 14 Note that the answer to this question won't directly affect the
18 kernel: saying N will just cause the configurator to skip all 15 kernel: saying N will just cause the configurator to skip all
19 the questions about amateur radio. 16 the questions about amateur radio.
20 17
21comment "Packet Radio protocols" 18comment "Packet Radio protocols"
22 depends on HAMRADIO && NET 19 depends on HAMRADIO
23 20
24config AX25 21config AX25
25 tristate "Amateur Radio AX.25 Level 2 protocol" 22 tristate "Amateur Radio AX.25 Level 2 protocol"
26 depends on HAMRADIO && NET 23 depends on HAMRADIO
27 ---help--- 24 help
28 This is the protocol used for computer communication over amateur 25 This is the protocol used for computer communication over amateur
29 radio. It is either used by itself for point-to-point links, or to 26 radio. It is either used by itself for point-to-point links, or to
30 carry other protocols such as tcp/ip. To use it, you need a device 27 carry other protocols such as tcp/ip. To use it, you need a device
@@ -52,6 +49,7 @@ config AX25
52 49
53config AX25_DAMA_SLAVE 50config AX25_DAMA_SLAVE
54 bool "AX.25 DAMA Slave support" 51 bool "AX.25 DAMA Slave support"
52 default y
55 depends on AX25 53 depends on AX25
56 help 54 help
57 DAMA is a mechanism to prevent collisions when doing AX.25 55 DAMA is a mechanism to prevent collisions when doing AX.25
@@ -59,23 +57,38 @@ config AX25_DAMA_SLAVE
59 from clients (called "slaves") and redistributes it to other slaves. 57 from clients (called "slaves") and redistributes it to other slaves.
60 If you say Y here, your Linux box will act as a DAMA slave; this is 58 If you say Y here, your Linux box will act as a DAMA slave; this is
61 transparent in that you don't have to do any special DAMA 59 transparent in that you don't have to do any special DAMA
62 configuration. (Linux cannot yet act as a DAMA server.) If unsure, 60 configuration. Linux cannot yet act as a DAMA server. This option
63 say N. 61 only compiles DAMA slave support into the kernel. It still needs to
62 be enabled at runtime. For more about DAMA see
63 <http://www.linux-ax25.org>. If unsure, say Y.
64
65# placeholder until implemented
66config AX25_DAMA_MASTER
67 bool 'AX.25 DAMA Master support'
68 depends on AX25_DAMA_SLAVE && BROKEN
69 help
70 DAMA is a mechanism to prevent collisions when doing AX.25
71 networking. A DAMA server (called "master") accepts incoming traffic
72 from clients (called "slaves") and redistributes it to other slaves.
73 If you say Y here, your Linux box will act as a DAMA master; this is
74 transparent in that you don't have to do any special DAMA
75 configuration. Linux cannot yet act as a DAMA server. This option
76 only compiles DAMA slave support into the kernel. It still needs to
77 be explicitly enabled, so if unsure, say Y.
64 78
65# bool ' AX.25 DAMA Master support' CONFIG_AX25_DAMA_MASTER
66config NETROM 79config NETROM
67 tristate "Amateur Radio NET/ROM protocol" 80 tristate "Amateur Radio NET/ROM protocol"
68 depends on AX25 81 depends on AX25
69 ---help--- 82 help
70 NET/ROM is a network layer protocol on top of AX.25 useful for 83 NET/ROM is a network layer protocol on top of AX.25 useful for
71 routing. 84 routing.
72 85
73 A comprehensive listing of all the software for Linux amateur radio 86 A comprehensive listing of all the software for Linux amateur radio
74 users as well as information about how to configure an AX.25 port is 87 users as well as information about how to configure an AX.25 port is
75 contained in the AX25-HOWTO, available from 88 contained in the Linux Ham Wiki, available from
76 <http://www.tldp.org/docs.html#howto>. You also might want to 89 <http://www.linux-ax25.org>. You also might want to check out the
77 check out the file <file:Documentation/networking/ax25.txt>. More 90 file <file:Documentation/networking/ax25.txt>. More information about
78 information about digital amateur radio in general is on the WWW at 91 digital amateur radio in general is on the WWW at
79 <http://www.tapr.org/tapr/html/pkthome.html>. 92 <http://www.tapr.org/tapr/html/pkthome.html>.
80 93
81 To compile this driver as a module, choose M here: the 94 To compile this driver as a module, choose M here: the
@@ -84,27 +97,25 @@ config NETROM
84config ROSE 97config ROSE
85 tristate "Amateur Radio X.25 PLP (Rose)" 98 tristate "Amateur Radio X.25 PLP (Rose)"
86 depends on AX25 99 depends on AX25
87 ---help--- 100 help
88 The Packet Layer Protocol (PLP) is a way to route packets over X.25 101 The Packet Layer Protocol (PLP) is a way to route packets over X.25
89 connections in general and amateur radio AX.25 connections in 102 connections in general and amateur radio AX.25 connections in
90 particular, essentially an alternative to NET/ROM. 103 particular, essentially an alternative to NET/ROM.
91 104
92 A comprehensive listing of all the software for Linux amateur radio 105 A comprehensive listing of all the software for Linux amateur radio
93 users as well as information about how to configure an AX.25 port is 106 users as well as information about how to configure an AX.25 port is
94 contained in the AX25-HOWTO, available from 107 contained in the Linux Ham Wiki, available from
95 <http://www.tldp.org/docs.html#howto>. You also might want to 108 <http://www.linux-ax25.org>. You also might want to check out the
96 check out the file <file:Documentation/networking/ax25.txt>. More 109 file <file:Documentation/networking/ax25.txt>. More information about
97 information about digital amateur radio in general is on the WWW at 110 digital amateur radio in general is on the WWW at
98 <http://www.tapr.org/tapr/html/pkthome.html>. 111 <http://www.tapr.org/tapr/html/pkthome.html>.
99 112
100 To compile this driver as a module, choose M here: the 113 To compile this driver as a module, choose M here: the
101 module will be called rose. 114 module will be called rose.
102 115
103
104menu "AX.25 network device drivers" 116menu "AX.25 network device drivers"
105 depends on HAMRADIO && NET && AX25!=n 117 depends on HAMRADIO && AX25
106 118
107source "drivers/net/hamradio/Kconfig" 119source "drivers/net/hamradio/Kconfig"
108 120
109endmenu 121endmenu
110
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index ecfe8da1ce6b..d342e89b8bdd 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -679,6 +679,27 @@ static void hidp_close(struct hid_device *hid)
679{ 679{
680} 680}
681 681
682static const struct {
683 __u16 idVendor;
684 __u16 idProduct;
685 unsigned quirks;
686} hidp_blacklist[] = {
687 /* Apple wireless Mighty Mouse */
688 { 0x05ac, 0x030c, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
689
690 { } /* Terminating entry */
691};
692
693static void hidp_setup_quirks(struct hid_device *hid)
694{
695 unsigned int n;
696
697 for (n = 0; hidp_blacklist[n].idVendor; n++)
698 if (hidp_blacklist[n].idVendor == le16_to_cpu(hid->vendor) &&
699 hidp_blacklist[n].idProduct == le16_to_cpu(hid->product))
700 hid->quirks = hidp_blacklist[n].quirks;
701}
702
682static inline void hidp_setup_hid(struct hidp_session *session, struct hidp_connadd_req *req) 703static inline void hidp_setup_hid(struct hidp_session *session, struct hidp_connadd_req *req)
683{ 704{
684 struct hid_device *hid = session->hid; 705 struct hid_device *hid = session->hid;
@@ -708,6 +729,8 @@ static inline void hidp_setup_hid(struct hidp_session *session, struct hidp_conn
708 729
709 hid->hidinput_input_event = hidp_hidinput_event; 730 hid->hidinput_input_event = hidp_hidinput_event;
710 731
732 hidp_setup_quirks(hid);
733
711 list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) 734 list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
712 hidp_send_report(session, report); 735 hidp_send_report(session, report);
713 736
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 58d13f2bd121..a285897a2fb4 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -126,7 +126,9 @@ void br_stp_disable_port(struct net_bridge_port *p)
126/* called under bridge lock */ 126/* called under bridge lock */
127void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr) 127void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
128{ 128{
129 unsigned char oldaddr[6]; 129 /* should be aligned on 2 bytes for compare_ether_addr() */
130 unsigned short oldaddr_aligned[ETH_ALEN >> 1];
131 unsigned char *oldaddr = (unsigned char *)oldaddr_aligned;
130 struct net_bridge_port *p; 132 struct net_bridge_port *p;
131 int wasroot; 133 int wasroot;
132 134
@@ -151,11 +153,14 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
151 br_become_root_bridge(br); 153 br_become_root_bridge(br);
152} 154}
153 155
154static const unsigned char br_mac_zero[6]; 156/* should be aligned on 2 bytes for compare_ether_addr() */
157static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1];
155 158
156/* called under bridge lock */ 159/* called under bridge lock */
157void br_stp_recalculate_bridge_id(struct net_bridge *br) 160void br_stp_recalculate_bridge_id(struct net_bridge *br)
158{ 161{
162 const unsigned char *br_mac_zero =
163 (const unsigned char *)br_mac_zero_aligned;
159 const unsigned char *addr = br_mac_zero; 164 const unsigned char *addr = br_mac_zero;
160 struct net_bridge_port *p; 165 struct net_bridge_port *p;
161 166
diff --git a/net/core/dev.c b/net/core/dev.c
index cf71614dae93..4dc93cc4d5b7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -751,13 +751,10 @@ int dev_change_name(struct net_device *dev, char *newname)
751 else 751 else
752 strlcpy(dev->name, newname, IFNAMSIZ); 752 strlcpy(dev->name, newname, IFNAMSIZ);
753 753
754 err = device_rename(&dev->dev, dev->name); 754 device_rename(&dev->dev, dev->name);
755 if (!err) { 755 hlist_del(&dev->name_hlist);
756 hlist_del(&dev->name_hlist); 756 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
757 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); 757 raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev);
758 raw_notifier_call_chain(&netdev_chain,
759 NETDEV_CHANGENAME, dev);
760 }
761 758
762 return err; 759 return err;
763} 760}
@@ -1741,8 +1738,8 @@ static int ing_filter(struct sk_buff *skb)
1741 if (dev->qdisc_ingress) { 1738 if (dev->qdisc_ingress) {
1742 __u32 ttl = (__u32) G_TC_RTTL(skb->tc_verd); 1739 __u32 ttl = (__u32) G_TC_RTTL(skb->tc_verd);
1743 if (MAX_RED_LOOP < ttl++) { 1740 if (MAX_RED_LOOP < ttl++) {
1744 printk(KERN_WARNING "Redir loop detected Dropping packet (%s->%s)\n", 1741 printk(KERN_WARNING "Redir loop detected Dropping packet (%d->%d)\n",
1745 skb->input_dev->name, skb->dev->name); 1742 skb->iif, skb->dev->ifindex);
1746 return TC_ACT_SHOT; 1743 return TC_ACT_SHOT;
1747 } 1744 }
1748 1745
@@ -1750,10 +1747,10 @@ static int ing_filter(struct sk_buff *skb)
1750 1747
1751 skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_INGRESS); 1748 skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_INGRESS);
1752 1749
1753 spin_lock(&dev->ingress_lock); 1750 spin_lock(&dev->queue_lock);
1754 if ((q = dev->qdisc_ingress) != NULL) 1751 if ((q = dev->qdisc_ingress) != NULL)
1755 result = q->enqueue(skb, q); 1752 result = q->enqueue(skb, q);
1756 spin_unlock(&dev->ingress_lock); 1753 spin_unlock(&dev->queue_lock);
1757 1754
1758 } 1755 }
1759 1756
@@ -1775,8 +1772,8 @@ int netif_receive_skb(struct sk_buff *skb)
1775 if (!skb->tstamp.off_sec) 1772 if (!skb->tstamp.off_sec)
1776 net_timestamp(skb); 1773 net_timestamp(skb);
1777 1774
1778 if (!skb->input_dev) 1775 if (!skb->iif)
1779 skb->input_dev = skb->dev; 1776 skb->iif = skb->dev->ifindex;
1780 1777
1781 orig_dev = skb_bond(skb); 1778 orig_dev = skb_bond(skb);
1782 1779
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 3aea4e87d3d7..7174ced75efc 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -143,7 +143,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
143 } 143 }
144 } 144 }
145 145
146 err = -ENETUNREACH; 146 err = -ESRCH;
147out: 147out:
148 rcu_read_unlock(); 148 rcu_read_unlock();
149 149
@@ -152,6 +152,28 @@ out:
152 152
153EXPORT_SYMBOL_GPL(fib_rules_lookup); 153EXPORT_SYMBOL_GPL(fib_rules_lookup);
154 154
155static int validate_rulemsg(struct fib_rule_hdr *frh, struct nlattr **tb,
156 struct fib_rules_ops *ops)
157{
158 int err = -EINVAL;
159
160 if (frh->src_len)
161 if (tb[FRA_SRC] == NULL ||
162 frh->src_len > (ops->addr_size * 8) ||
163 nla_len(tb[FRA_SRC]) != ops->addr_size)
164 goto errout;
165
166 if (frh->dst_len)
167 if (tb[FRA_DST] == NULL ||
168 frh->dst_len > (ops->addr_size * 8) ||
169 nla_len(tb[FRA_DST]) != ops->addr_size)
170 goto errout;
171
172 err = 0;
173errout:
174 return err;
175}
176
155int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 177int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
156{ 178{
157 struct fib_rule_hdr *frh = nlmsg_data(nlh); 179 struct fib_rule_hdr *frh = nlmsg_data(nlh);
@@ -173,6 +195,10 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
173 if (err < 0) 195 if (err < 0)
174 goto errout; 196 goto errout;
175 197
198 err = validate_rulemsg(frh, tb, ops);
199 if (err < 0)
200 goto errout;
201
176 rule = kzalloc(ops->rule_size, GFP_KERNEL); 202 rule = kzalloc(ops->rule_size, GFP_KERNEL);
177 if (rule == NULL) { 203 if (rule == NULL) {
178 err = -ENOMEM; 204 err = -ENOMEM;
@@ -260,6 +286,10 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
260 if (err < 0) 286 if (err < 0)
261 goto errout; 287 goto errout;
262 288
289 err = validate_rulemsg(frh, tb, ops);
290 if (err < 0)
291 goto errout;
292
263 list_for_each_entry(rule, ops->rules_list, list) { 293 list_for_each_entry(rule, ops->rules_list, list) {
264 if (frh->action && (frh->action != rule->action)) 294 if (frh->action && (frh->action != rule->action))
265 continue; 295 continue;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 3183142c6044..841e3f32cab1 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -140,6 +140,8 @@ static int neigh_forced_gc(struct neigh_table *tbl)
140 n->dead = 1; 140 n->dead = 1;
141 shrunk = 1; 141 shrunk = 1;
142 write_unlock(&n->lock); 142 write_unlock(&n->lock);
143 if (n->parms->neigh_cleanup)
144 n->parms->neigh_cleanup(n);
143 neigh_release(n); 145 neigh_release(n);
144 continue; 146 continue;
145 } 147 }
@@ -211,6 +213,8 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
211 NEIGH_PRINTK2("neigh %p is stray.\n", n); 213 NEIGH_PRINTK2("neigh %p is stray.\n", n);
212 } 214 }
213 write_unlock(&n->lock); 215 write_unlock(&n->lock);
216 if (n->parms->neigh_cleanup)
217 n->parms->neigh_cleanup(n);
214 neigh_release(n); 218 neigh_release(n);
215 } 219 }
216 } 220 }
@@ -582,9 +586,6 @@ void neigh_destroy(struct neighbour *neigh)
582 kfree(hh); 586 kfree(hh);
583 } 587 }
584 588
585 if (neigh->parms->neigh_destructor)
586 (neigh->parms->neigh_destructor)(neigh);
587
588 skb_queue_purge(&neigh->arp_queue); 589 skb_queue_purge(&neigh->arp_queue);
589 590
590 dev_put(neigh->dev); 591 dev_put(neigh->dev);
@@ -675,6 +676,8 @@ static void neigh_periodic_timer(unsigned long arg)
675 *np = n->next; 676 *np = n->next;
676 n->dead = 1; 677 n->dead = 1;
677 write_unlock(&n->lock); 678 write_unlock(&n->lock);
679 if (n->parms->neigh_cleanup)
680 n->parms->neigh_cleanup(n);
678 neigh_release(n); 681 neigh_release(n);
679 continue; 682 continue;
680 } 683 }
@@ -1328,6 +1331,8 @@ void neigh_parms_destroy(struct neigh_parms *parms)
1328 kfree(parms); 1331 kfree(parms);
1329} 1332}
1330 1333
1334static struct lock_class_key neigh_table_proxy_queue_class;
1335
1331void neigh_table_init_no_netlink(struct neigh_table *tbl) 1336void neigh_table_init_no_netlink(struct neigh_table *tbl)
1332{ 1337{
1333 unsigned long now = jiffies; 1338 unsigned long now = jiffies;
@@ -1376,7 +1381,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1376 init_timer(&tbl->proxy_timer); 1381 init_timer(&tbl->proxy_timer);
1377 tbl->proxy_timer.data = (unsigned long)tbl; 1382 tbl->proxy_timer.data = (unsigned long)tbl;
1378 tbl->proxy_timer.function = neigh_proxy_process; 1383 tbl->proxy_timer.function = neigh_proxy_process;
1379 skb_queue_head_init(&tbl->proxy_queue); 1384 skb_queue_head_init_class(&tbl->proxy_queue,
1385 &neigh_table_proxy_queue_class);
1380 1386
1381 tbl->last_flush = now; 1387 tbl->last_flush = now;
1382 tbl->last_rand = now + tbl->parms.reachable_time * 20; 1388 tbl->last_rand = now + tbl->parms.reachable_time * 20;
@@ -2088,8 +2094,11 @@ void __neigh_for_each_release(struct neigh_table *tbl,
2088 } else 2094 } else
2089 np = &n->next; 2095 np = &n->next;
2090 write_unlock(&n->lock); 2096 write_unlock(&n->lock);
2091 if (release) 2097 if (release) {
2098 if (n->parms->neigh_cleanup)
2099 n->parms->neigh_cleanup(n);
2092 neigh_release(n); 2100 neigh_release(n);
2101 }
2093 } 2102 }
2094 } 2103 }
2095} 2104}
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index da1019451ccb..4581ece48bb2 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -471,6 +471,13 @@ int __netpoll_rx(struct sk_buff *skb)
471 if (skb->len < len || len < iph->ihl*4) 471 if (skb->len < len || len < iph->ihl*4)
472 goto out; 472 goto out;
473 473
474 /*
475 * Our transport medium may have padded the buffer out.
476 * Now We trim to the true length of the frame.
477 */
478 if (pskb_trim_rcsum(skb, len))
479 goto out;
480
474 if (iph->protocol != IPPROTO_UDP) 481 if (iph->protocol != IPPROTO_UDP)
475 goto out; 482 goto out;
476 483
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 74a9a32b906d..4b01496dc33d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -129,6 +129,7 @@
129#include <linux/ioport.h> 129#include <linux/ioport.h>
130#include <linux/interrupt.h> 130#include <linux/interrupt.h>
131#include <linux/capability.h> 131#include <linux/capability.h>
132#include <linux/freezer.h>
132#include <linux/delay.h> 133#include <linux/delay.h>
133#include <linux/timer.h> 134#include <linux/timer.h>
134#include <linux/list.h> 135#include <linux/list.h>
@@ -3333,6 +3334,8 @@ static int pktgen_thread_worker(void *arg)
3333 t->control &= ~(T_REMDEV); 3334 t->control &= ~(T_REMDEV);
3334 } 3335 }
3335 3336
3337 try_to_freeze();
3338
3336 set_current_state(TASK_INTERRUPTIBLE); 3339 set_current_state(TASK_INTERRUPTIBLE);
3337 } 3340 }
3338 3341
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 6055074c4b81..33ea8eac7fe0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -621,7 +621,8 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
621 if (err < 0) 621 if (err < 0)
622 goto errout; 622 goto errout;
623 623
624 iw += IW_EV_POINT_OFF; 624 /* Payload is at an offset in buffer */
625 iw = iw_buf + IW_EV_POINT_OFF;
625 } 626 }
626#endif /* CONFIG_NET_WIRELESS_RTNETLINK */ 627#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
627 628
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 702fa8f08747..336958fbbcb2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -197,61 +197,6 @@ nodata:
197} 197}
198 198
199/** 199/**
200 * alloc_skb_from_cache - allocate a network buffer
201 * @cp: kmem_cache from which to allocate the data area
202 * (object size must be big enough for @size bytes + skb overheads)
203 * @size: size to allocate
204 * @gfp_mask: allocation mask
205 *
206 * Allocate a new &sk_buff. The returned buffer has no headroom and
207 * tail room of size bytes. The object has a reference count of one.
208 * The return is the buffer. On a failure the return is %NULL.
209 *
210 * Buffers may only be allocated from interrupts using a @gfp_mask of
211 * %GFP_ATOMIC.
212 */
213struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
214 unsigned int size,
215 gfp_t gfp_mask)
216{
217 struct sk_buff *skb;
218 u8 *data;
219
220 /* Get the HEAD */
221 skb = kmem_cache_alloc(skbuff_head_cache,
222 gfp_mask & ~__GFP_DMA);
223 if (!skb)
224 goto out;
225
226 /* Get the DATA. */
227 size = SKB_DATA_ALIGN(size);
228 data = kmem_cache_alloc(cp, gfp_mask);
229 if (!data)
230 goto nodata;
231
232 memset(skb, 0, offsetof(struct sk_buff, truesize));
233 skb->truesize = size + sizeof(struct sk_buff);
234 atomic_set(&skb->users, 1);
235 skb->head = data;
236 skb->data = data;
237 skb->tail = data;
238 skb->end = data + size;
239
240 atomic_set(&(skb_shinfo(skb)->dataref), 1);
241 skb_shinfo(skb)->nr_frags = 0;
242 skb_shinfo(skb)->gso_size = 0;
243 skb_shinfo(skb)->gso_segs = 0;
244 skb_shinfo(skb)->gso_type = 0;
245 skb_shinfo(skb)->frag_list = NULL;
246out:
247 return skb;
248nodata:
249 kmem_cache_free(skbuff_head_cache, skb);
250 skb = NULL;
251 goto out;
252}
253
254/**
255 * __netdev_alloc_skb - allocate an skbuff for rx on a specific device 200 * __netdev_alloc_skb - allocate an skbuff for rx on a specific device
256 * @dev: network device to receive on 201 * @dev: network device to receive on
257 * @length: length to allocate 202 * @length: length to allocate
@@ -496,7 +441,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
496 n->tc_verd = SET_TC_VERD(skb->tc_verd,0); 441 n->tc_verd = SET_TC_VERD(skb->tc_verd,0);
497 n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); 442 n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
498 n->tc_verd = CLR_TC_MUNGED(n->tc_verd); 443 n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
499 C(input_dev); 444 C(iif);
500#endif 445#endif
501 skb_copy_secmark(n, skb); 446 skb_copy_secmark(n, skb);
502#endif 447#endif
diff --git a/net/core/wireless.c b/net/core/wireless.c
index 9936ab11e6e0..b07fe270a508 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -2,7 +2,7 @@
2 * This file implement the Wireless Extensions APIs. 2 * This file implement the Wireless Extensions APIs.
3 * 3 *
4 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> 4 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
5 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved. 5 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
6 * 6 *
7 * (As all part of the Linux kernel, this file is GPL) 7 * (As all part of the Linux kernel, this file is GPL)
8 */ 8 */
@@ -76,6 +76,9 @@
76 * o Change length in ESSID and NICK to strlen() instead of strlen()+1 76 * o Change length in ESSID and NICK to strlen() instead of strlen()+1
77 * o Make standard_ioctl_num and standard_event_num unsigned 77 * o Make standard_ioctl_num and standard_event_num unsigned
78 * o Remove (struct net_device *)->get_wireless_stats() 78 * o Remove (struct net_device *)->get_wireless_stats()
79 *
80 * v10 - 16.3.07 - Jean II
81 * o Prevent leaking of kernel space in stream on 64 bits.
79 */ 82 */
80 83
81/***************************** INCLUDES *****************************/ 84/***************************** INCLUDES *****************************/
@@ -427,6 +430,21 @@ static const int event_type_size[] = {
427 IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ 430 IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */
428}; 431};
429 432
433/* Size (in bytes) of various events, as packed */
434static const int event_type_pk_size[] = {
435 IW_EV_LCP_PK_LEN, /* IW_HEADER_TYPE_NULL */
436 0,
437 IW_EV_CHAR_PK_LEN, /* IW_HEADER_TYPE_CHAR */
438 0,
439 IW_EV_UINT_PK_LEN, /* IW_HEADER_TYPE_UINT */
440 IW_EV_FREQ_PK_LEN, /* IW_HEADER_TYPE_FREQ */
441 IW_EV_ADDR_PK_LEN, /* IW_HEADER_TYPE_ADDR */
442 0,
443 IW_EV_POINT_PK_LEN, /* Without variable payload */
444 IW_EV_PARAM_PK_LEN, /* IW_HEADER_TYPE_PARAM */
445 IW_EV_QUAL_PK_LEN, /* IW_HEADER_TYPE_QUAL */
446};
447
430/************************ COMMON SUBROUTINES ************************/ 448/************************ COMMON SUBROUTINES ************************/
431/* 449/*
432 * Stuff that may be used in various place or doesn't fit in one 450 * Stuff that may be used in various place or doesn't fit in one
@@ -1217,7 +1235,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
1217 memcpy(buffer + IW_EV_POINT_OFF, request, request_len); 1235 memcpy(buffer + IW_EV_POINT_OFF, request, request_len);
1218 /* Use our own copy of wrqu */ 1236 /* Use our own copy of wrqu */
1219 wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF 1237 wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF
1220 + IW_EV_LCP_LEN); 1238 + IW_EV_LCP_PK_LEN);
1221 1239
1222 /* No extra arguments. Trivial to handle */ 1240 /* No extra arguments. Trivial to handle */
1223 ret = handler(dev, &info, wrqu, NULL); 1241 ret = handler(dev, &info, wrqu, NULL);
@@ -1229,8 +1247,8 @@ static int rtnetlink_standard_get(struct net_device * dev,
1229 1247
1230 /* Get a temp copy of wrqu (skip pointer) */ 1248 /* Get a temp copy of wrqu (skip pointer) */
1231 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF, 1249 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
1232 ((char *) request) + IW_EV_LCP_LEN, 1250 ((char *) request) + IW_EV_LCP_PK_LEN,
1233 IW_EV_POINT_LEN - IW_EV_LCP_LEN); 1251 IW_EV_POINT_LEN - IW_EV_LCP_PK_LEN);
1234 1252
1235 /* Calculate space needed by arguments. Always allocate 1253 /* Calculate space needed by arguments. Always allocate
1236 * for max space. Easier, and won't last long... */ 1254 * for max space. Easier, and won't last long... */
@@ -1240,7 +1258,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
1240 (wrqu_point.data.length > descr->max_tokens)) 1258 (wrqu_point.data.length > descr->max_tokens))
1241 extra_size = (wrqu_point.data.length 1259 extra_size = (wrqu_point.data.length
1242 * descr->token_size); 1260 * descr->token_size);
1243 buffer_size = extra_size + IW_EV_POINT_LEN + IW_EV_POINT_OFF; 1261 buffer_size = extra_size + IW_EV_POINT_PK_LEN + IW_EV_POINT_OFF;
1244#ifdef WE_RTNETLINK_DEBUG 1262#ifdef WE_RTNETLINK_DEBUG
1245 printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n", 1263 printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n",
1246 dev->name, extra_size, buffer_size); 1264 dev->name, extra_size, buffer_size);
@@ -1254,15 +1272,15 @@ static int rtnetlink_standard_get(struct net_device * dev,
1254 1272
1255 /* Put wrqu in the right place (just before extra). 1273 /* Put wrqu in the right place (just before extra).
1256 * Leave space for IWE header and dummy pointer... 1274 * Leave space for IWE header and dummy pointer...
1257 * Note that IW_EV_LCP_LEN==4 bytes, so it's still aligned... 1275 * Note that IW_EV_LCP_PK_LEN==4 bytes, so it's still aligned.
1258 */ 1276 */
1259 memcpy(buffer + IW_EV_LCP_LEN + IW_EV_POINT_OFF, 1277 memcpy(buffer + IW_EV_LCP_PK_LEN + IW_EV_POINT_OFF,
1260 ((char *) &wrqu_point) + IW_EV_POINT_OFF, 1278 ((char *) &wrqu_point) + IW_EV_POINT_OFF,
1261 IW_EV_POINT_LEN - IW_EV_LCP_LEN); 1279 IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
1262 wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_LEN); 1280 wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_PK_LEN);
1263 1281
1264 /* Extra comes logically after that. Offset +12 bytes. */ 1282 /* Extra comes logically after that. Offset +12 bytes. */
1265 extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_LEN; 1283 extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_PK_LEN;
1266 1284
1267 /* Call the handler */ 1285 /* Call the handler */
1268 ret = handler(dev, &info, wrqu, extra); 1286 ret = handler(dev, &info, wrqu, extra);
@@ -1270,11 +1288,11 @@ static int rtnetlink_standard_get(struct net_device * dev,
1270 /* Calculate real returned length */ 1288 /* Calculate real returned length */
1271 extra_size = (wrqu->data.length * descr->token_size); 1289 extra_size = (wrqu->data.length * descr->token_size);
1272 /* Re-adjust reply size */ 1290 /* Re-adjust reply size */
1273 request->len = extra_size + IW_EV_POINT_LEN; 1291 request->len = extra_size + IW_EV_POINT_PK_LEN;
1274 1292
1275 /* Put the iwe header where it should, i.e. scrap the 1293 /* Put the iwe header where it should, i.e. scrap the
1276 * dummy pointer. */ 1294 * dummy pointer. */
1277 memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_LEN); 1295 memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_PK_LEN);
1278 1296
1279#ifdef WE_RTNETLINK_DEBUG 1297#ifdef WE_RTNETLINK_DEBUG
1280 printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size); 1298 printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size);
@@ -1331,10 +1349,10 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
1331#endif /* WE_RTNETLINK_DEBUG */ 1349#endif /* WE_RTNETLINK_DEBUG */
1332 1350
1333 /* Extract fixed header from request. This is properly aligned. */ 1351 /* Extract fixed header from request. This is properly aligned. */
1334 wrqu = &request->u; 1352 wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN);
1335 1353
1336 /* Check if wrqu is complete */ 1354 /* Check if wrqu is complete */
1337 hdr_len = event_type_size[descr->header_type]; 1355 hdr_len = event_type_pk_size[descr->header_type];
1338 if(request_len < hdr_len) { 1356 if(request_len < hdr_len) {
1339#ifdef WE_RTNETLINK_DEBUG 1357#ifdef WE_RTNETLINK_DEBUG
1340 printk(KERN_DEBUG 1358 printk(KERN_DEBUG
@@ -1359,7 +1377,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
1359 1377
1360 /* Put wrqu in the right place (skip pointer) */ 1378 /* Put wrqu in the right place (skip pointer) */
1361 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF, 1379 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
1362 wrqu, IW_EV_POINT_LEN - IW_EV_LCP_LEN); 1380 wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
1363 /* Don't forget about the event code... */ 1381 /* Don't forget about the event code... */
1364 wrqu = &wrqu_point; 1382 wrqu = &wrqu_point;
1365 1383
@@ -1483,7 +1501,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
1483 hdr_len = extra_size; 1501 hdr_len = extra_size;
1484 extra_size = 0; 1502 extra_size = 0;
1485 } else { 1503 } else {
1486 hdr_len = IW_EV_POINT_LEN; 1504 hdr_len = IW_EV_POINT_PK_LEN;
1487 } 1505 }
1488 1506
1489 /* Check if wrqu is complete */ 1507 /* Check if wrqu is complete */
@@ -1514,7 +1532,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
1514 memcpy(buffer + IW_EV_POINT_OFF, request, request_len); 1532 memcpy(buffer + IW_EV_POINT_OFF, request, request_len);
1515 /* Use our own copy of wrqu */ 1533 /* Use our own copy of wrqu */
1516 wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF 1534 wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF
1517 + IW_EV_LCP_LEN); 1535 + IW_EV_LCP_PK_LEN);
1518 1536
1519 /* No extra arguments. Trivial to handle */ 1537 /* No extra arguments. Trivial to handle */
1520 ret = handler(dev, &info, wrqu, (char *) wrqu); 1538 ret = handler(dev, &info, wrqu, (char *) wrqu);
@@ -1523,7 +1541,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
1523 char * extra; 1541 char * extra;
1524 1542
1525 /* Buffer for full reply */ 1543 /* Buffer for full reply */
1526 buffer_size = extra_size + IW_EV_POINT_LEN + IW_EV_POINT_OFF; 1544 buffer_size = extra_size + IW_EV_POINT_PK_LEN + IW_EV_POINT_OFF;
1527 1545
1528#ifdef WE_RTNETLINK_DEBUG 1546#ifdef WE_RTNETLINK_DEBUG
1529 printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n", 1547 printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n",
@@ -1538,15 +1556,15 @@ static inline int rtnetlink_private_get(struct net_device * dev,
1538 1556
1539 /* Put wrqu in the right place (just before extra). 1557 /* Put wrqu in the right place (just before extra).
1540 * Leave space for IWE header and dummy pointer... 1558 * Leave space for IWE header and dummy pointer...
1541 * Note that IW_EV_LCP_LEN==4 bytes, so it's still aligned... 1559 * Note that IW_EV_LCP_PK_LEN==4 bytes, so it's still aligned.
1542 */ 1560 */
1543 memcpy(buffer + IW_EV_LCP_LEN + IW_EV_POINT_OFF, 1561 memcpy(buffer + IW_EV_LCP_PK_LEN + IW_EV_POINT_OFF,
1544 ((char *) request) + IW_EV_LCP_LEN, 1562 ((char *) request) + IW_EV_LCP_PK_LEN,
1545 IW_EV_POINT_LEN - IW_EV_LCP_LEN); 1563 IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
1546 wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_LEN); 1564 wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_PK_LEN);
1547 1565
1548 /* Extra comes logically after that. Offset +12 bytes. */ 1566 /* Extra comes logically after that. Offset +12 bytes. */
1549 extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_LEN; 1567 extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_PK_LEN;
1550 1568
1551 /* Call the handler */ 1569 /* Call the handler */
1552 ret = handler(dev, &info, wrqu, extra); 1570 ret = handler(dev, &info, wrqu, extra);
@@ -1556,11 +1574,11 @@ static inline int rtnetlink_private_get(struct net_device * dev,
1556 if (!(descr->get_args & IW_PRIV_SIZE_FIXED)) 1574 if (!(descr->get_args & IW_PRIV_SIZE_FIXED))
1557 extra_size = adjust_priv_size(descr->get_args, wrqu); 1575 extra_size = adjust_priv_size(descr->get_args, wrqu);
1558 /* Re-adjust reply size */ 1576 /* Re-adjust reply size */
1559 request->len = extra_size + IW_EV_POINT_LEN; 1577 request->len = extra_size + IW_EV_POINT_PK_LEN;
1560 1578
1561 /* Put the iwe header where it should, i.e. scrap the 1579 /* Put the iwe header where it should, i.e. scrap the
1562 * dummy pointer. */ 1580 * dummy pointer. */
1563 memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_LEN); 1581 memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_PK_LEN);
1564 1582
1565#ifdef WE_RTNETLINK_DEBUG 1583#ifdef WE_RTNETLINK_DEBUG
1566 printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size); 1584 printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size);
@@ -1641,14 +1659,14 @@ static inline int rtnetlink_private_set(struct net_device * dev,
1641 /* Does it fits in wrqu ? */ 1659 /* Does it fits in wrqu ? */
1642 if((descr->set_args & IW_PRIV_SIZE_FIXED) && 1660 if((descr->set_args & IW_PRIV_SIZE_FIXED) &&
1643 (extra_size <= IFNAMSIZ)) { 1661 (extra_size <= IFNAMSIZ)) {
1644 hdr_len = IW_EV_LCP_LEN + extra_size; 1662 hdr_len = IW_EV_LCP_PK_LEN + extra_size;
1645 extra_size = 0; 1663 extra_size = 0;
1646 } else { 1664 } else {
1647 hdr_len = IW_EV_POINT_LEN; 1665 hdr_len = IW_EV_POINT_PK_LEN;
1648 } 1666 }
1649 1667
1650 /* Extract fixed header from request. This is properly aligned. */ 1668 /* Extract fixed header from request. This is properly aligned. */
1651 wrqu = &request->u; 1669 wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN);
1652 1670
1653 /* Check if wrqu is complete */ 1671 /* Check if wrqu is complete */
1654 if(request_len < hdr_len) { 1672 if(request_len < hdr_len) {
@@ -1675,7 +1693,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
1675 1693
1676 /* Put wrqu in the right place (skip pointer) */ 1694 /* Put wrqu in the right place (skip pointer) */
1677 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF, 1695 memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
1678 wrqu, IW_EV_POINT_LEN - IW_EV_LCP_LEN); 1696 wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
1679 1697
1680 /* Does it fits within bounds ? */ 1698 /* Does it fits within bounds ? */
1681 if(wrqu_point.data.length > (descr->set_args & 1699 if(wrqu_point.data.length > (descr->set_args &
@@ -1738,7 +1756,7 @@ int wireless_rtnetlink_get(struct net_device * dev,
1738 iw_handler handler; 1756 iw_handler handler;
1739 1757
1740 /* Check length */ 1758 /* Check length */
1741 if(len < IW_EV_LCP_LEN) { 1759 if(len < IW_EV_LCP_PK_LEN) {
1742 printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", 1760 printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
1743 dev->name, len); 1761 dev->name, len);
1744 return -EINVAL; 1762 return -EINVAL;
@@ -1822,7 +1840,7 @@ int wireless_rtnetlink_set(struct net_device * dev,
1822 iw_handler handler; 1840 iw_handler handler;
1823 1841
1824 /* Check length */ 1842 /* Check length */
1825 if(len < IW_EV_LCP_LEN) { 1843 if(len < IW_EV_LCP_PK_LEN) {
1826 printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", 1844 printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
1827 dev->name, len); 1845 dev->name, len);
1828 return -EINVAL; 1846 return -EINVAL;
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index a0e7cd183a5d..e33a9edb4036 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -191,7 +191,6 @@ extern void dccp_send_sync(struct sock *sk, const u64 seq,
191 const enum dccp_pkt_type pkt_type); 191 const enum dccp_pkt_type pkt_type);
192 192
193extern void dccp_write_xmit(struct sock *sk, int block); 193extern void dccp_write_xmit(struct sock *sk, int block);
194extern void dccp_write_xmit_timer(unsigned long data);
195extern void dccp_write_space(struct sock *sk); 194extern void dccp_write_space(struct sock *sk);
196 195
197extern void dccp_init_xmit_timers(struct sock *sk); 196extern void dccp_init_xmit_timers(struct sock *sk);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index cf28c53a389a..6607b7b14f34 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -575,7 +575,7 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
575 if (get_user(len, optlen)) 575 if (get_user(len, optlen))
576 return -EFAULT; 576 return -EFAULT;
577 577
578 if (len < sizeof(int)) 578 if (len < (int)sizeof(int))
579 return -EINVAL; 579 return -EINVAL;
580 580
581 dp = dccp_sk(sk); 581 dp = dccp_sk(sk);
@@ -589,9 +589,11 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
589 (__be32 __user *)optval, optlen); 589 (__be32 __user *)optval, optlen);
590 case DCCP_SOCKOPT_SEND_CSCOV: 590 case DCCP_SOCKOPT_SEND_CSCOV:
591 val = dp->dccps_pcslen; 591 val = dp->dccps_pcslen;
592 len = sizeof(val);
592 break; 593 break;
593 case DCCP_SOCKOPT_RECV_CSCOV: 594 case DCCP_SOCKOPT_RECV_CSCOV:
594 val = dp->dccps_pcrlen; 595 val = dp->dccps_pcrlen;
596 len = sizeof(val);
595 break; 597 break;
596 case 128 ... 191: 598 case 128 ... 191:
597 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, 599 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index b038a0a3ad40..0197a41c256a 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -262,7 +262,7 @@ out:
262} 262}
263 263
264/* Transmit-delay timer: used by the CCIDs to delay actual send time */ 264/* Transmit-delay timer: used by the CCIDs to delay actual send time */
265void dccp_write_xmit_timer(unsigned long data) 265static void dccp_write_xmit_timer(unsigned long data)
266{ 266{
267 struct sock *sk = (struct sock *)data; 267 struct sock *sk = (struct sock *)data;
268 struct dccp_sock *dp = dccp_sk(sk); 268 struct dccp_sock *dp = dccp_sk(sk);
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index 3cbfddc98430..82d58a977e6f 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -63,7 +63,7 @@ static struct
63{ 63{
64 int error; 64 int error;
65 u8 scope; 65 u8 scope;
66} dn_fib_props[RTA_MAX+1] = { 66} dn_fib_props[RTN_MAX+1] = {
67 [RTN_UNSPEC] = { .error = 0, .scope = RT_SCOPE_NOWHERE }, 67 [RTN_UNSPEC] = { .error = 0, .scope = RT_SCOPE_NOWHERE },
68 [RTN_UNICAST] = { .error = 0, .scope = RT_SCOPE_UNIVERSE }, 68 [RTN_UNICAST] = { .error = 0, .scope = RT_SCOPE_UNIVERSE },
69 [RTN_LOCAL] = { .error = 0, .scope = RT_SCOPE_HOST }, 69 [RTN_LOCAL] = { .error = 0, .scope = RT_SCOPE_HOST },
@@ -276,6 +276,9 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta
276 struct dn_fib_info *ofi; 276 struct dn_fib_info *ofi;
277 int nhs = 1; 277 int nhs = 1;
278 278
279 if (r->rtm_type > RTN_MAX)
280 goto err_inval;
281
279 if (dn_fib_props[r->rtm_type].scope > r->rtm_scope) 282 if (dn_fib_props[r->rtm_type].scope > r->rtm_scope)
280 goto err_inval; 283 goto err_inval;
281 284
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index b6c98ac93dc8..5e86dd542302 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -109,8 +109,6 @@ errout:
109 109
110static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = { 110static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
111 FRA_GENERIC_POLICY, 111 FRA_GENERIC_POLICY,
112 [FRA_SRC] = { .type = NLA_U16 },
113 [FRA_DST] = { .type = NLA_U16 },
114}; 112};
115 113
116static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 114static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
@@ -133,7 +131,7 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
133 int err = -EINVAL; 131 int err = -EINVAL;
134 struct dn_fib_rule *r = (struct dn_fib_rule *)rule; 132 struct dn_fib_rule *r = (struct dn_fib_rule *)rule;
135 133
136 if (frh->src_len > 16 || frh->dst_len > 16 || frh->tos) 134 if (frh->tos)
137 goto errout; 135 goto errout;
138 136
139 if (rule->table == RT_TABLE_UNSPEC) { 137 if (rule->table == RT_TABLE_UNSPEC) {
@@ -150,10 +148,10 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
150 } 148 }
151 } 149 }
152 150
153 if (tb[FRA_SRC]) 151 if (frh->src_len)
154 r->src = nla_get_le16(tb[FRA_SRC]); 152 r->src = nla_get_le16(tb[FRA_SRC]);
155 153
156 if (tb[FRA_DST]) 154 if (frh->dst_len)
157 r->dst = nla_get_le16(tb[FRA_DST]); 155 r->dst = nla_get_le16(tb[FRA_DST]);
158 156
159 r->src_len = frh->src_len; 157 r->src_len = frh->src_len;
@@ -176,10 +174,10 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
176 if (frh->dst_len && (r->dst_len != frh->dst_len)) 174 if (frh->dst_len && (r->dst_len != frh->dst_len))
177 return 0; 175 return 0;
178 176
179 if (tb[FRA_SRC] && (r->src != nla_get_le16(tb[FRA_SRC]))) 177 if (frh->src_len && (r->src != nla_get_le16(tb[FRA_SRC])))
180 return 0; 178 return 0;
181 179
182 if (tb[FRA_DST] && (r->dst != nla_get_le16(tb[FRA_DST]))) 180 if (frh->dst_len && (r->dst != nla_get_le16(tb[FRA_DST])))
183 return 0; 181 return 0;
184 182
185 return 1; 183 return 1;
@@ -249,6 +247,7 @@ int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
249static struct fib_rules_ops dn_fib_rules_ops = { 247static struct fib_rules_ops dn_fib_rules_ops = {
250 .family = AF_DECnet, 248 .family = AF_DECnet,
251 .rule_size = sizeof(struct dn_fib_rule), 249 .rule_size = sizeof(struct dn_fib_rule),
250 .addr_size = sizeof(u16),
252 .action = dn_fib_rule_action, 251 .action = dn_fib_rule_action,
253 .match = dn_fib_rule_match, 252 .match = dn_fib_rule_match,
254 .configure = dn_fib_rule_configure, 253 .configure = dn_fib_rule_configure,
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 1fba6439fc57..cac06c43f004 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -493,6 +493,11 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
493 cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; 493 cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid;
494 cfg->fc_nlinfo.nlh = nlh; 494 cfg->fc_nlinfo.nlh = nlh;
495 495
496 if (cfg->fc_type > RTN_MAX) {
497 err = -EINVAL;
498 goto errout;
499 }
500
496 nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) { 501 nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) {
497 switch (attr->nla_type) { 502 switch (attr->nla_type) {
498 case RTA_DST: 503 case RTA_DST:
@@ -771,6 +776,8 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
771 .nl_u = { .ip4_u = { .daddr = frn->fl_addr, 776 .nl_u = { .ip4_u = { .daddr = frn->fl_addr,
772 .tos = frn->fl_tos, 777 .tos = frn->fl_tos,
773 .scope = frn->fl_scope } } }; 778 .scope = frn->fl_scope } } };
779
780 frn->err = -ENOENT;
774 if (tb) { 781 if (tb) {
775 local_bh_disable(); 782 local_bh_disable();
776 783
@@ -782,6 +789,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
782 frn->nh_sel = res.nh_sel; 789 frn->nh_sel = res.nh_sel;
783 frn->type = res.type; 790 frn->type = res.type;
784 frn->scope = res.scope; 791 frn->scope = res.scope;
792 fib_res_put(&res);
785 } 793 }
786 local_bh_enable(); 794 local_bh_enable();
787 } 795 }
@@ -796,6 +804,9 @@ static void nl_fib_input(struct sock *sk, int len)
796 struct fib_table *tb; 804 struct fib_table *tb;
797 805
798 skb = skb_dequeue(&sk->sk_receive_queue); 806 skb = skb_dequeue(&sk->sk_receive_queue);
807 if (skb == NULL)
808 return;
809
799 nlh = (struct nlmsghdr *)skb->data; 810 nlh = (struct nlmsghdr *)skb->data;
800 if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len || 811 if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len ||
801 nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn))) { 812 nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn))) {
@@ -808,7 +819,7 @@ static void nl_fib_input(struct sock *sk, int len)
808 819
809 nl_fib_lookup(frn, tb); 820 nl_fib_lookup(frn, tb);
810 821
811 pid = nlh->nlmsg_pid; /*pid of sending process */ 822 pid = NETLINK_CB(skb).pid; /* pid of sending process */
812 NETLINK_CB(skb).pid = 0; /* from kernel */ 823 NETLINK_CB(skb).pid = 0; /* from kernel */
813 NETLINK_CB(skb).dst_group = 0; /* unicast */ 824 NETLINK_CB(skb).dst_group = 0; /* unicast */
814 netlink_unicast(sk, skb, pid, MSG_DONTWAIT); 825 netlink_unicast(sk, skb, pid, MSG_DONTWAIT);
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index b837c33e0404..c660c074c76c 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -171,8 +171,6 @@ static struct fib_table *fib_empty_table(void)
171 171
172static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = { 172static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
173 FRA_GENERIC_POLICY, 173 FRA_GENERIC_POLICY,
174 [FRA_SRC] = { .type = NLA_U32 },
175 [FRA_DST] = { .type = NLA_U32 },
176 [FRA_FLOW] = { .type = NLA_U32 }, 174 [FRA_FLOW] = { .type = NLA_U32 },
177}; 175};
178 176
@@ -183,8 +181,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
183 int err = -EINVAL; 181 int err = -EINVAL;
184 struct fib4_rule *rule4 = (struct fib4_rule *) rule; 182 struct fib4_rule *rule4 = (struct fib4_rule *) rule;
185 183
186 if (frh->src_len > 32 || frh->dst_len > 32 || 184 if (frh->tos & ~IPTOS_TOS_MASK)
187 (frh->tos & ~IPTOS_TOS_MASK))
188 goto errout; 185 goto errout;
189 186
190 if (rule->table == RT_TABLE_UNSPEC) { 187 if (rule->table == RT_TABLE_UNSPEC) {
@@ -201,10 +198,10 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
201 } 198 }
202 } 199 }
203 200
204 if (tb[FRA_SRC]) 201 if (frh->src_len)
205 rule4->src = nla_get_be32(tb[FRA_SRC]); 202 rule4->src = nla_get_be32(tb[FRA_SRC]);
206 203
207 if (tb[FRA_DST]) 204 if (frh->dst_len)
208 rule4->dst = nla_get_be32(tb[FRA_DST]); 205 rule4->dst = nla_get_be32(tb[FRA_DST]);
209 206
210#ifdef CONFIG_NET_CLS_ROUTE 207#ifdef CONFIG_NET_CLS_ROUTE
@@ -242,10 +239,10 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
242 return 0; 239 return 0;
243#endif 240#endif
244 241
245 if (tb[FRA_SRC] && (rule4->src != nla_get_be32(tb[FRA_SRC]))) 242 if (frh->src_len && (rule4->src != nla_get_be32(tb[FRA_SRC])))
246 return 0; 243 return 0;
247 244
248 if (tb[FRA_DST] && (rule4->dst != nla_get_be32(tb[FRA_DST]))) 245 if (frh->dst_len && (rule4->dst != nla_get_be32(tb[FRA_DST])))
249 return 0; 246 return 0;
250 247
251 return 1; 248 return 1;
@@ -309,6 +306,7 @@ static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
309static struct fib_rules_ops fib4_rules_ops = { 306static struct fib_rules_ops fib4_rules_ops = {
310 .family = AF_INET, 307 .family = AF_INET,
311 .rule_size = sizeof(struct fib4_rule), 308 .rule_size = sizeof(struct fib4_rule),
309 .addr_size = sizeof(u32),
312 .action = fib4_rule_action, 310 .action = fib4_rule_action,
313 .match = fib4_rule_match, 311 .match = fib4_rule_match,
314 .configure = fib4_rule_configure, 312 .configure = fib4_rule_configure,
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 2f1fdae6efa6..3dad12ee76c3 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -89,7 +89,7 @@ static const struct
89{ 89{
90 int error; 90 int error;
91 u8 scope; 91 u8 scope;
92} fib_props[RTA_MAX + 1] = { 92} fib_props[RTN_MAX + 1] = {
93 { 93 {
94 .error = 0, 94 .error = 0,
95 .scope = RT_SCOPE_NOWHERE, 95 .scope = RT_SCOPE_NOWHERE,
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ada9b3db507d..214c34732e84 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1123,6 +1123,9 @@ err:
1123 return fa_head; 1123 return fa_head;
1124} 1124}
1125 1125
1126/*
1127 * Caller must hold RTNL.
1128 */
1126static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg) 1129static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1127{ 1130{
1128 struct trie *t = (struct trie *) tb->tb_data; 1131 struct trie *t = (struct trie *) tb->tb_data;
@@ -1540,6 +1543,9 @@ static int trie_leaf_remove(struct trie *t, t_key key)
1540 return 1; 1543 return 1;
1541} 1544}
1542 1545
1546/*
1547 * Caller must hold RTNL.
1548 */
1543static int fn_trie_delete(struct fib_table *tb, struct fib_config *cfg) 1549static int fn_trie_delete(struct fib_table *tb, struct fib_config *cfg)
1544{ 1550{
1545 struct trie *t = (struct trie *) tb->tb_data; 1551 struct trie *t = (struct trie *) tb->tb_data;
@@ -1718,6 +1724,9 @@ up:
1718 return NULL; /* Ready. Root of trie */ 1724 return NULL; /* Ready. Root of trie */
1719} 1725}
1720 1726
1727/*
1728 * Caller must hold RTNL.
1729 */
1721static int fn_trie_flush(struct fib_table *tb) 1730static int fn_trie_flush(struct fib_table *tb)
1722{ 1731{
1723 struct trie *t = (struct trie *) tb->tb_data; 1732 struct trie *t = (struct trie *) tb->tb_data;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 5170f5c75f9d..57b0221f9e24 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -166,13 +166,9 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
166 return 0; 166 return 0;
167 } 167 }
168 168
169 for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) { 169 for (i = 0, ret = 0; i < IFNAMSIZ; i++) {
170 unsigned long odev; 170 ret |= (outdev[i] ^ arpinfo->outiface[i])
171 memcpy(&odev, outdev + i*sizeof(unsigned long), 171 & arpinfo->outiface_mask[i];
172 sizeof(unsigned long));
173 ret |= (odev
174 ^ ((const unsigned long *)arpinfo->outiface)[i])
175 & ((const unsigned long *)arpinfo->outiface_mask)[i];
176 } 172 }
177 173
178 if (FWINV(ret != 0, ARPT_INV_VIA_OUT)) { 174 if (FWINV(ret != 0, ARPT_INV_VIA_OUT)) {
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index e965b333c997..42b08029e867 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -411,12 +411,10 @@ checkentry(const char *tablename,
411 "has invalid config pointer!\n"); 411 "has invalid config pointer!\n");
412 return 0; 412 return 0;
413 } 413 }
414 clusterip_config_entry_get(cipinfo->config);
415 } else { 414 } else {
416 /* Case B: This is a new rule referring to an existing 415 /* Case B: This is a new rule referring to an existing
417 * clusterip config. */ 416 * clusterip config. */
418 cipinfo->config = config; 417 cipinfo->config = config;
419 clusterip_config_entry_get(cipinfo->config);
420 } 418 }
421 } else { 419 } else {
422 /* Case C: This is a completely new clusterip config */ 420 /* Case C: This is a completely new clusterip config */
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index a26404dbe212..9acc018766f2 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -61,6 +61,7 @@
61#include <linux/netfilter_ipv4/ipt_ULOG.h> 61#include <linux/netfilter_ipv4/ipt_ULOG.h>
62#include <net/sock.h> 62#include <net/sock.h>
63#include <linux/bitops.h> 63#include <linux/bitops.h>
64#include <asm/unaligned.h>
64 65
65MODULE_LICENSE("GPL"); 66MODULE_LICENSE("GPL");
66MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); 67MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
@@ -236,9 +237,9 @@ static void ipt_ulog_packet(unsigned int hooknum,
236 237
237 /* copy hook, prefix, timestamp, payload, etc. */ 238 /* copy hook, prefix, timestamp, payload, etc. */
238 pm->data_len = copy_len; 239 pm->data_len = copy_len;
239 pm->timestamp_sec = skb->tstamp.off_sec; 240 put_unaligned(skb->tstamp.off_sec, &pm->timestamp_sec);
240 pm->timestamp_usec = skb->tstamp.off_usec; 241 put_unaligned(skb->tstamp.off_usec, &pm->timestamp_usec);
241 pm->mark = skb->mark; 242 put_unaligned(skb->mark, &pm->mark);
242 pm->hook = hooknum; 243 pm->hook = hooknum;
243 if (prefix != NULL) 244 if (prefix != NULL)
244 strncpy(pm->prefix, prefix, sizeof(pm->prefix)); 245 strncpy(pm->prefix, prefix, sizeof(pm->prefix));
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 5c8caf4a1244..34ae3f13483a 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -77,18 +77,19 @@ void tcp_init_congestion_control(struct sock *sk)
77 struct inet_connection_sock *icsk = inet_csk(sk); 77 struct inet_connection_sock *icsk = inet_csk(sk);
78 struct tcp_congestion_ops *ca; 78 struct tcp_congestion_ops *ca;
79 79
80 if (icsk->icsk_ca_ops != &tcp_init_congestion_ops) 80 /* if no choice made yet assign the current value set as default */
81 return; 81 if (icsk->icsk_ca_ops == &tcp_init_congestion_ops) {
82 rcu_read_lock();
83 list_for_each_entry_rcu(ca, &tcp_cong_list, list) {
84 if (try_module_get(ca->owner)) {
85 icsk->icsk_ca_ops = ca;
86 break;
87 }
82 88
83 rcu_read_lock(); 89 /* fallback to next available */
84 list_for_each_entry_rcu(ca, &tcp_cong_list, list) {
85 if (try_module_get(ca->owner)) {
86 icsk->icsk_ca_ops = ca;
87 break;
88 } 90 }
89 91 rcu_read_unlock();
90 } 92 }
91 rcu_read_unlock();
92 93
93 if (icsk->icsk_ca_ops->init) 94 if (icsk->icsk_ca_ops->init)
94 icsk->icsk_ca_ops->init(sk); 95 icsk->icsk_ca_ops->init(sk);
@@ -236,6 +237,7 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
236 237
237 rcu_read_lock(); 238 rcu_read_lock();
238 ca = tcp_ca_find(name); 239 ca = tcp_ca_find(name);
240
239 /* no change asking for existing value */ 241 /* no change asking for existing value */
240 if (ca == icsk->icsk_ca_ops) 242 if (ca == icsk->icsk_ca_ops)
241 goto out; 243 goto out;
@@ -261,7 +263,8 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
261 else { 263 else {
262 tcp_cleanup_congestion_control(sk); 264 tcp_cleanup_congestion_control(sk);
263 icsk->icsk_ca_ops = ca; 265 icsk->icsk_ca_ops = ca;
264 if (icsk->icsk_ca_ops->init) 266
267 if (sk->sk_state != TCP_CLOSE && icsk->icsk_ca_ops->init)
265 icsk->icsk_ca_ops->init(sk); 268 icsk->icsk_ca_ops->init(sk);
266 } 269 }
267 out: 270 out:
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index dc151139b5af..3c24881f2a65 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -943,7 +943,8 @@ static void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
943 if (tp->packets_out > tp->snd_cwnd_used) 943 if (tp->packets_out > tp->snd_cwnd_used)
944 tp->snd_cwnd_used = tp->packets_out; 944 tp->snd_cwnd_used = tp->packets_out;
945 945
946 if ((s32)(tcp_time_stamp - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto) 946 if (sysctl_tcp_slow_start_after_idle &&
947 (s32)(tcp_time_stamp - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto)
947 tcp_cwnd_application_limited(sk); 948 tcp_cwnd_application_limited(sk);
948 } 949 }
949} 950}
@@ -1607,6 +1608,9 @@ u32 __tcp_select_window(struct sock *sk)
1607 */ 1608 */
1608 if (window <= free_space - mss || window > free_space) 1609 if (window <= free_space - mss || window > free_space)
1609 window = (free_space/mss)*mss; 1610 window = (free_space/mss)*mss;
1611 else if (mss == full_space &&
1612 free_space > window + full_space/2)
1613 window = free_space;
1610 } 1614 }
1611 1615
1612 return window; 1616 return window;
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 89cf59ea7bbe..d419e15d9803 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -42,10 +42,9 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
42 42
43 skb->nh.raw = skb_push(skb, x->props.header_len + hdrlen); 43 skb->nh.raw = skb_push(skb, x->props.header_len + hdrlen);
44 top_iph = skb->nh.iph; 44 top_iph = skb->nh.iph;
45 hdrlen = iph->ihl * 4 - optlen; 45 skb->h.raw += sizeof(*iph) - hdrlen;
46 skb->h.raw += hdrlen;
47 46
48 memmove(top_iph, iph, hdrlen); 47 memmove(top_iph, iph, sizeof(*iph));
49 if (unlikely(optlen)) { 48 if (unlikely(optlen)) {
50 struct ip_beet_phdr *ph; 49 struct ip_beet_phdr *ph;
51 50
@@ -53,8 +52,10 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
53 52
54 ph = (struct ip_beet_phdr *)skb->h.raw; 53 ph = (struct ip_beet_phdr *)skb->h.raw;
55 ph->padlen = 4 - (optlen & 4); 54 ph->padlen = 4 - (optlen & 4);
56 ph->hdrlen = (optlen + ph->padlen + sizeof(*ph)) / 8; 55 ph->hdrlen = optlen / 8;
57 ph->nexthdr = top_iph->protocol; 56 ph->nexthdr = top_iph->protocol;
57 if (ph->padlen)
58 memset(ph + 1, IPOPT_NOP, ph->padlen);
58 59
59 top_iph->protocol = IPPROTO_BEETPH; 60 top_iph->protocol = IPPROTO_BEETPH;
60 top_iph->ihl = sizeof(struct iphdr) / 4; 61 top_iph->ihl = sizeof(struct iphdr) / 4;
@@ -77,29 +78,32 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
77 protocol = iph->protocol; 78 protocol = iph->protocol;
78 79
79 if (unlikely(iph->protocol == IPPROTO_BEETPH)) { 80 if (unlikely(iph->protocol == IPPROTO_BEETPH)) {
80 struct ip_beet_phdr *ph = (struct ip_beet_phdr*)(iph + 1); 81 struct ip_beet_phdr *ph;
81 82
82 if (!pskb_may_pull(skb, sizeof(*ph))) 83 if (!pskb_may_pull(skb, sizeof(*ph)))
83 goto out; 84 goto out;
85 ph = (struct ip_beet_phdr *)(skb->h.ipiph + 1);
84 86
85 phlen = ph->hdrlen * 8; 87 phlen = sizeof(*ph) + ph->padlen;
86 optlen = phlen - ph->padlen - sizeof(*ph); 88 optlen = ph->hdrlen * 8 + (IPV4_BEET_PHMAXLEN - phlen);
87 if (optlen < 0 || optlen & 3 || optlen > 250) 89 if (optlen < 0 || optlen & 3 || optlen > 250)
88 goto out; 90 goto out;
89 91
90 if (!pskb_may_pull(skb, phlen)) 92 if (!pskb_may_pull(skb, phlen + optlen))
91 goto out; 93 goto out;
94 skb->len -= phlen + optlen;
92 95
93 ph_nexthdr = ph->nexthdr; 96 ph_nexthdr = ph->nexthdr;
94 } 97 }
95 98
96 skb_push(skb, sizeof(*iph) - phlen + optlen); 99 skb->nh.raw = skb->data + (phlen - sizeof(*iph));
97 memmove(skb->data, skb->nh.raw, sizeof(*iph)); 100 memmove(skb->nh.raw, iph, sizeof(*iph));
98 skb->nh.raw = skb->data; 101 skb->h.raw = skb->data + (phlen + optlen);
102 skb->data = skb->h.raw;
99 103
100 iph = skb->nh.iph; 104 iph = skb->nh.iph;
101 iph->ihl = (sizeof(*iph) + optlen) / 4; 105 iph->ihl = (sizeof(*iph) + optlen) / 4;
102 iph->tot_len = htons(skb->len); 106 iph->tot_len = htons(skb->len + iph->ihl * 4);
103 iph->daddr = x->sel.daddr.a4; 107 iph->daddr = x->sel.daddr.a4;
104 iph->saddr = x->sel.saddr.a4; 108 iph->saddr = x->sel.saddr.a4;
105 if (ph_nexthdr) 109 if (ph_nexthdr)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1b616992d916..452a82ce4796 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -172,6 +172,7 @@ struct ipv6_devconf ipv6_devconf __read_mostly = {
172#endif 172#endif
173#endif 173#endif
174 .proxy_ndp = 0, 174 .proxy_ndp = 0,
175 .accept_source_route = 0, /* we do not accept RH0 by default. */
175}; 176};
176 177
177static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { 178static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
@@ -203,6 +204,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
203#endif 204#endif
204#endif 205#endif
205 .proxy_ndp = 0, 206 .proxy_ndp = 0,
207 .accept_source_route = 0, /* we do not accept RH0 by default. */
206}; 208};
207 209
208/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */ 210/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
@@ -342,6 +344,9 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
342 } 344 }
343#endif 345#endif
344 346
347 if (netif_running(dev) && netif_carrier_ok(dev))
348 ndev->if_flags |= IF_READY;
349
345 ipv6_mc_init_dev(ndev); 350 ipv6_mc_init_dev(ndev);
346 ndev->tstamp = jiffies; 351 ndev->tstamp = jiffies;
347#ifdef CONFIG_SYSCTL 352#ifdef CONFIG_SYSCTL
@@ -3353,6 +3358,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
3353#endif 3358#endif
3354#endif 3359#endif
3355 array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp; 3360 array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp;
3361 array[DEVCONF_ACCEPT_SOURCE_ROUTE] = cnf->accept_source_route;
3356} 3362}
3357 3363
3358static inline size_t inet6_if_nlmsg_size(void) 3364static inline size_t inet6_if_nlmsg_size(void)
@@ -3881,6 +3887,14 @@ static struct addrconf_sysctl_table
3881 .proc_handler = &proc_dointvec, 3887 .proc_handler = &proc_dointvec,
3882 }, 3888 },
3883 { 3889 {
3890 .ctl_name = NET_IPV6_ACCEPT_SOURCE_ROUTE,
3891 .procname = "accept_source_route",
3892 .data = &ipv6_devconf.accept_source_route,
3893 .maxlen = sizeof(int),
3894 .mode = 0644,
3895 .proc_handler = &proc_dointvec,
3896 },
3897 {
3884 .ctl_name = 0, /* sentinel */ 3898 .ctl_name = 0, /* sentinel */
3885 } 3899 }
3886 }, 3900 },
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 28e0c6568272..fb39604c3d09 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -362,10 +362,27 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
362 struct inet6_skb_parm *opt = IP6CB(skb); 362 struct inet6_skb_parm *opt = IP6CB(skb);
363 struct in6_addr *addr = NULL; 363 struct in6_addr *addr = NULL;
364 struct in6_addr daddr; 364 struct in6_addr daddr;
365 struct inet6_dev *idev;
365 int n, i; 366 int n, i;
366
367 struct ipv6_rt_hdr *hdr; 367 struct ipv6_rt_hdr *hdr;
368 struct rt0_hdr *rthdr; 368 struct rt0_hdr *rthdr;
369 int accept_source_route = ipv6_devconf.accept_source_route;
370
371 if (accept_source_route < 0 ||
372 ((idev = in6_dev_get(skb->dev)) == NULL)) {
373 kfree_skb(skb);
374 return -1;
375 }
376 if (idev->cnf.accept_source_route < 0) {
377 in6_dev_put(idev);
378 kfree_skb(skb);
379 return -1;
380 }
381
382 if (accept_source_route > idev->cnf.accept_source_route)
383 accept_source_route = idev->cnf.accept_source_route;
384
385 in6_dev_put(idev);
369 386
370 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) || 387 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
371 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) { 388 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
@@ -377,6 +394,22 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
377 394
378 hdr = (struct ipv6_rt_hdr *) skb->h.raw; 395 hdr = (struct ipv6_rt_hdr *) skb->h.raw;
379 396
397 switch (hdr->type) {
398#ifdef CONFIG_IPV6_MIP6
399 break;
400#endif
401 case IPV6_SRCRT_TYPE_0:
402 if (accept_source_route > 0)
403 break;
404 kfree_skb(skb);
405 return -1;
406 default:
407 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
408 IPSTATS_MIB_INHDRERRORS);
409 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
410 return -1;
411 }
412
380 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) || 413 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) ||
381 skb->pkt_type != PACKET_HOST) { 414 skb->pkt_type != PACKET_HOST) {
382 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), 415 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
@@ -434,11 +467,6 @@ looped_back:
434 } 467 }
435 break; 468 break;
436#endif 469#endif
437 default:
438 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
439 IPSTATS_MIB_INHDRERRORS);
440 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
441 return -1;
442 } 470 }
443 471
444 /* 472 /*
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 0862809ffcf7..ea3035b4e3e8 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -131,8 +131,6 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
131 131
132static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = { 132static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = {
133 FRA_GENERIC_POLICY, 133 FRA_GENERIC_POLICY,
134 [FRA_SRC] = { .len = sizeof(struct in6_addr) },
135 [FRA_DST] = { .len = sizeof(struct in6_addr) },
136}; 134};
137 135
138static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb, 136static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
@@ -142,9 +140,6 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
142 int err = -EINVAL; 140 int err = -EINVAL;
143 struct fib6_rule *rule6 = (struct fib6_rule *) rule; 141 struct fib6_rule *rule6 = (struct fib6_rule *) rule;
144 142
145 if (frh->src_len > 128 || frh->dst_len > 128)
146 goto errout;
147
148 if (rule->action == FR_ACT_TO_TBL) { 143 if (rule->action == FR_ACT_TO_TBL) {
149 if (rule->table == RT6_TABLE_UNSPEC) 144 if (rule->table == RT6_TABLE_UNSPEC)
150 goto errout; 145 goto errout;
@@ -155,11 +150,11 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
155 } 150 }
156 } 151 }
157 152
158 if (tb[FRA_SRC]) 153 if (frh->src_len)
159 nla_memcpy(&rule6->src.addr, tb[FRA_SRC], 154 nla_memcpy(&rule6->src.addr, tb[FRA_SRC],
160 sizeof(struct in6_addr)); 155 sizeof(struct in6_addr));
161 156
162 if (tb[FRA_DST]) 157 if (frh->dst_len)
163 nla_memcpy(&rule6->dst.addr, tb[FRA_DST], 158 nla_memcpy(&rule6->dst.addr, tb[FRA_DST],
164 sizeof(struct in6_addr)); 159 sizeof(struct in6_addr));
165 160
@@ -186,11 +181,11 @@ static int fib6_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
186 if (frh->tos && (rule6->tclass != frh->tos)) 181 if (frh->tos && (rule6->tclass != frh->tos))
187 return 0; 182 return 0;
188 183
189 if (tb[FRA_SRC] && 184 if (frh->src_len &&
190 nla_memcmp(tb[FRA_SRC], &rule6->src.addr, sizeof(struct in6_addr))) 185 nla_memcmp(tb[FRA_SRC], &rule6->src.addr, sizeof(struct in6_addr)))
191 return 0; 186 return 0;
192 187
193 if (tb[FRA_DST] && 188 if (frh->dst_len &&
194 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr))) 189 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr)))
195 return 0; 190 return 0;
196 191
@@ -240,6 +235,7 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
240static struct fib_rules_ops fib6_rules_ops = { 235static struct fib_rules_ops fib6_rules_ops = {
241 .family = AF_INET6, 236 .family = AF_INET6,
242 .rule_size = sizeof(struct fib6_rule), 237 .rule_size = sizeof(struct fib6_rule),
238 .addr_size = sizeof(struct in6_addr),
243 .action = fib6_rule_action, 239 .action = fib6_rule_action,
244 .match = fib6_rule_match, 240 .match = fib6_rule_match,
245 .configure = fib6_rule_configure, 241 .configure = fib6_rule_configure,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index f4d7be77eb0f..268f476ef3db 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -658,6 +658,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
658 ins = &iter->u.dst.rt6_next; 658 ins = &iter->u.dst.rt6_next;
659 } 659 }
660 660
661 /* Reset round-robin state, if necessary */
662 if (ins == &fn->leaf)
663 fn->rr_ptr = NULL;
664
661 /* 665 /*
662 * insert node 666 * insert node
663 */ 667 */
@@ -1109,6 +1113,10 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1109 rt6_stats.fib_rt_entries--; 1113 rt6_stats.fib_rt_entries--;
1110 rt6_stats.fib_discarded_routes++; 1114 rt6_stats.fib_discarded_routes++;
1111 1115
1116 /* Reset round-robin state, if necessary */
1117 if (fn->rr_ptr == rt)
1118 fn->rr_ptr = NULL;
1119
1112 /* Adjust walkers */ 1120 /* Adjust walkers */
1113 read_lock(&fib6_walker_lock); 1121 read_lock(&fib6_walker_lock);
1114 FOR_WALKERS(w) { 1122 FOR_WALKERS(w) {
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 11bfc7c43182..61e7a6c8141d 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -108,8 +108,10 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
108 108
109 /* pkt_len may be zero if Jumbo payload option is present */ 109 /* pkt_len may be zero if Jumbo payload option is present */
110 if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) { 110 if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {
111 if (pkt_len + sizeof(struct ipv6hdr) > skb->len) 111 if (pkt_len + sizeof(struct ipv6hdr) > skb->len) {
112 goto truncated; 112 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INTRUNCATEDPKTS);
113 goto drop;
114 }
113 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) { 115 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) {
114 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS); 116 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS);
115 goto drop; 117 goto drop;
@@ -128,8 +130,6 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
128 rcu_read_unlock(); 130 rcu_read_unlock();
129 131
130 return NF_HOOK(PF_INET6,NF_IP6_PRE_ROUTING, skb, dev, NULL, ip6_rcv_finish); 132 return NF_HOOK(PF_INET6,NF_IP6_PRE_ROUTING, skb, dev, NULL, ip6_rcv_finish);
131truncated:
132 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INTRUNCATEDPKTS);
133err: 133err:
134 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS); 134 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS);
135drop: 135drop:
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 306d5d83c068..203e069e7fe9 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -687,9 +687,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
687 int err; 687 int err;
688 688
689 /* Rough check on arithmetic overflow, 689 /* Rough check on arithmetic overflow,
690 better check is made in ip6_build_xmit 690 better check is made in ip6_append_data().
691 */ 691 */
692 if (len < 0) 692 if (len > INT_MAX)
693 return -EMSGSIZE; 693 return -EMSGSIZE;
694 694
695 /* Mirror BSD error message compatibility */ 695 /* Mirror BSD error message compatibility */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a6b3117df546..aebb4e2d5ae3 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -311,21 +311,12 @@ static inline void rt6_probe(struct rt6_info *rt)
311static inline int rt6_check_dev(struct rt6_info *rt, int oif) 311static inline int rt6_check_dev(struct rt6_info *rt, int oif)
312{ 312{
313 struct net_device *dev = rt->rt6i_dev; 313 struct net_device *dev = rt->rt6i_dev;
314 int ret = 0; 314 if (!oif || dev->ifindex == oif)
315
316 if (!oif)
317 return 2;
318 if (dev->flags & IFF_LOOPBACK) {
319 if (!WARN_ON(rt->rt6i_idev == NULL) &&
320 rt->rt6i_idev->dev->ifindex == oif)
321 ret = 1;
322 else
323 return 0;
324 }
325 if (dev->ifindex == oif)
326 return 2; 315 return 2;
327 316 if ((dev->flags & IFF_LOOPBACK) &&
328 return ret; 317 rt->rt6i_idev && rt->rt6i_idev->dev->ifindex == oif)
318 return 1;
319 return 0;
329} 320}
330 321
331static inline int rt6_check_neigh(struct rt6_info *rt) 322static inline int rt6_check_neigh(struct rt6_info *rt)
@@ -363,55 +354,76 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
363 return m; 354 return m;
364} 355}
365 356
366static struct rt6_info *rt6_select(struct rt6_info **head, int oif, 357static struct rt6_info *find_match(struct rt6_info *rt, int oif, int strict,
367 int strict) 358 int *mpri, struct rt6_info *match)
368{ 359{
369 struct rt6_info *match = NULL, *last = NULL; 360 int m;
370 struct rt6_info *rt, *rt0 = *head; 361
371 u32 metric; 362 if (rt6_check_expired(rt))
363 goto out;
364
365 m = rt6_score_route(rt, oif, strict);
366 if (m < 0)
367 goto out;
368
369 if (m > *mpri) {
370 if (strict & RT6_LOOKUP_F_REACHABLE)
371 rt6_probe(match);
372 *mpri = m;
373 match = rt;
374 } else if (strict & RT6_LOOKUP_F_REACHABLE) {
375 rt6_probe(rt);
376 }
377
378out:
379 return match;
380}
381
382static struct rt6_info *find_rr_leaf(struct fib6_node *fn,
383 struct rt6_info *rr_head,
384 u32 metric, int oif, int strict)
385{
386 struct rt6_info *rt, *match;
372 int mpri = -1; 387 int mpri = -1;
373 388
374 RT6_TRACE("%s(head=%p(*head=%p), oif=%d)\n", 389 match = NULL;
375 __FUNCTION__, head, head ? *head : NULL, oif); 390 for (rt = rr_head; rt && rt->rt6i_metric == metric;
391 rt = rt->u.dst.rt6_next)
392 match = find_match(rt, oif, strict, &mpri, match);
393 for (rt = fn->leaf; rt && rt != rr_head && rt->rt6i_metric == metric;
394 rt = rt->u.dst.rt6_next)
395 match = find_match(rt, oif, strict, &mpri, match);
376 396
377 for (rt = rt0, metric = rt0->rt6i_metric; 397 return match;
378 rt && rt->rt6i_metric == metric && (!last || rt != rt0); 398}
379 rt = rt->u.dst.rt6_next) {
380 int m;
381 399
382 if (rt6_check_expired(rt)) 400static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict)
383 continue; 401{
402 struct rt6_info *match, *rt0;
384 403
385 last = rt; 404 RT6_TRACE("%s(fn->leaf=%p, oif=%d)\n",
405 __FUNCTION__, fn->leaf, oif);
386 406
387 m = rt6_score_route(rt, oif, strict); 407 rt0 = fn->rr_ptr;
388 if (m < 0) 408 if (!rt0)
389 continue; 409 fn->rr_ptr = rt0 = fn->leaf;
390 410
391 if (m > mpri) { 411 match = find_rr_leaf(fn, rt0, rt0->rt6i_metric, oif, strict);
392 if (strict & RT6_LOOKUP_F_REACHABLE)
393 rt6_probe(match);
394 match = rt;
395 mpri = m;
396 } else if (strict & RT6_LOOKUP_F_REACHABLE) {
397 rt6_probe(rt);
398 }
399 }
400 412
401 if (!match && 413 if (!match &&
402 (strict & RT6_LOOKUP_F_REACHABLE) && 414 (strict & RT6_LOOKUP_F_REACHABLE)) {
403 last && last != rt0) { 415 struct rt6_info *next = rt0->u.dst.rt6_next;
416
404 /* no entries matched; do round-robin */ 417 /* no entries matched; do round-robin */
405 static DEFINE_SPINLOCK(lock); 418 if (!next || next->rt6i_metric != rt0->rt6i_metric)
406 spin_lock(&lock); 419 next = fn->leaf;
407 *head = rt0->u.dst.rt6_next; 420
408 rt0->u.dst.rt6_next = last->u.dst.rt6_next; 421 if (next != rt0)
409 last->u.dst.rt6_next = rt0; 422 fn->rr_ptr = next;
410 spin_unlock(&lock);
411 } 423 }
412 424
413 RT6_TRACE("%s() => %p, score=%d\n", 425 RT6_TRACE("%s() => %p\n",
414 __FUNCTION__, match, mpri); 426 __FUNCTION__, match);
415 427
416 return (match ? match : &ip6_null_entry); 428 return (match ? match : &ip6_null_entry);
417} 429}
@@ -657,7 +669,7 @@ restart_2:
657 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 669 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
658 670
659restart: 671restart:
660 rt = rt6_select(&fn->leaf, fl->iif, strict | reachable); 672 rt = rt6_select(fn, fl->iif, strict | reachable);
661 BACKTRACK(&fl->fl6_src); 673 BACKTRACK(&fl->fl6_src);
662 if (rt == &ip6_null_entry || 674 if (rt == &ip6_null_entry ||
663 rt->rt6i_flags & RTF_CACHE) 675 rt->rt6i_flags & RTF_CACHE)
@@ -752,7 +764,7 @@ restart_2:
752 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 764 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
753 765
754restart: 766restart:
755 rt = rt6_select(&fn->leaf, fl->oif, strict | reachable); 767 rt = rt6_select(fn, fl->oif, strict | reachable);
756 BACKTRACK(&fl->fl6_src); 768 BACKTRACK(&fl->fl6_src);
757 if (rt == &ip6_null_entry || 769 if (rt == &ip6_null_entry ||
758 rt->rt6i_flags & RTF_CACHE) 770 rt->rt6i_flags & RTF_CACHE)
@@ -1754,13 +1766,22 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
1754 * Drop the packet on the floor 1766 * Drop the packet on the floor
1755 */ 1767 */
1756 1768
1757static inline int ip6_pkt_drop(struct sk_buff *skb, int code) 1769static inline int ip6_pkt_drop(struct sk_buff *skb, int code,
1770 int ipstats_mib_noroutes)
1758{ 1771{
1759 int type = ipv6_addr_type(&skb->nh.ipv6h->daddr); 1772 int type;
1760 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED) 1773 switch (ipstats_mib_noroutes) {
1761 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INADDRERRORS); 1774 case IPSTATS_MIB_INNOROUTES:
1762 1775 type = ipv6_addr_type(&skb->nh.ipv6h->daddr);
1763 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_OUTNOROUTES); 1776 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED) {
1777 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INADDRERRORS);
1778 break;
1779 }
1780 /* FALLTHROUGH */
1781 case IPSTATS_MIB_OUTNOROUTES:
1782 IP6_INC_STATS(ip6_dst_idev(skb->dst), ipstats_mib_noroutes);
1783 break;
1784 }
1764 icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev); 1785 icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev);
1765 kfree_skb(skb); 1786 kfree_skb(skb);
1766 return 0; 1787 return 0;
@@ -1768,26 +1789,26 @@ static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
1768 1789
1769static int ip6_pkt_discard(struct sk_buff *skb) 1790static int ip6_pkt_discard(struct sk_buff *skb)
1770{ 1791{
1771 return ip6_pkt_drop(skb, ICMPV6_NOROUTE); 1792 return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES);
1772} 1793}
1773 1794
1774static int ip6_pkt_discard_out(struct sk_buff *skb) 1795static int ip6_pkt_discard_out(struct sk_buff *skb)
1775{ 1796{
1776 skb->dev = skb->dst->dev; 1797 skb->dev = skb->dst->dev;
1777 return ip6_pkt_discard(skb); 1798 return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES);
1778} 1799}
1779 1800
1780#ifdef CONFIG_IPV6_MULTIPLE_TABLES 1801#ifdef CONFIG_IPV6_MULTIPLE_TABLES
1781 1802
1782static int ip6_pkt_prohibit(struct sk_buff *skb) 1803static int ip6_pkt_prohibit(struct sk_buff *skb)
1783{ 1804{
1784 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED); 1805 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES);
1785} 1806}
1786 1807
1787static int ip6_pkt_prohibit_out(struct sk_buff *skb) 1808static int ip6_pkt_prohibit_out(struct sk_buff *skb)
1788{ 1809{
1789 skb->dev = skb->dst->dev; 1810 skb->dev = skb->dst->dev;
1790 return ip6_pkt_prohibit(skb); 1811 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
1791} 1812}
1792 1813
1793static int ip6_pkt_blk_hole(struct sk_buff *skb) 1814static int ip6_pkt_blk_hole(struct sk_buff *skb)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 0ad471909881..f590db57a7c9 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -615,7 +615,7 @@ do_udp_sendmsg:
615 return udp_sendmsg(iocb, sk, msg, len); 615 return udp_sendmsg(iocb, sk, msg, len);
616 616
617 /* Rough check on arithmetic overflow, 617 /* Rough check on arithmetic overflow,
618 better check is made in ip6_build_xmit 618 better check is made in ip6_append_data().
619 */ 619 */
620 if (len > INT_MAX - sizeof(struct udphdr)) 620 if (len > INT_MAX - sizeof(struct udphdr))
621 return -EMSGSIZE; 621 return -EMSGSIZE;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index eabd6838f50a..0eb7d596d470 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -138,7 +138,6 @@ static void irda_disconnect_indication(void *instance, void *sap,
138 sk->sk_shutdown |= SEND_SHUTDOWN; 138 sk->sk_shutdown |= SEND_SHUTDOWN;
139 139
140 sk->sk_state_change(sk); 140 sk->sk_state_change(sk);
141 sock_orphan(sk);
142 release_sock(sk); 141 release_sock(sk);
143 142
144 /* Close our TSAP. 143 /* Close our TSAP.
@@ -1446,7 +1445,7 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1446 */ 1445 */
1447 ret = sock_error(sk); 1446 ret = sock_error(sk);
1448 if (ret) 1447 if (ret)
1449 break; 1448 ;
1450 else if (sk->sk_shutdown & RCV_SHUTDOWN) 1449 else if (sk->sk_shutdown & RCV_SHUTDOWN)
1451 ; 1450 ;
1452 else if (noblock) 1451 else if (noblock)
diff --git a/net/key/af_key.c b/net/key/af_key.c
index a4e7e2db0ff3..345019345f09 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -630,6 +630,35 @@ pfkey_sockaddr_size(sa_family_t family)
630 /* NOTREACHED */ 630 /* NOTREACHED */
631} 631}
632 632
633static inline int pfkey_mode_from_xfrm(int mode)
634{
635 switch(mode) {
636 case XFRM_MODE_TRANSPORT:
637 return IPSEC_MODE_TRANSPORT;
638 case XFRM_MODE_TUNNEL:
639 return IPSEC_MODE_TUNNEL;
640 case XFRM_MODE_BEET:
641 return IPSEC_MODE_BEET;
642 default:
643 return -1;
644 }
645}
646
647static inline int pfkey_mode_to_xfrm(int mode)
648{
649 switch(mode) {
650 case IPSEC_MODE_ANY: /*XXX*/
651 case IPSEC_MODE_TRANSPORT:
652 return XFRM_MODE_TRANSPORT;
653 case IPSEC_MODE_TUNNEL:
654 return XFRM_MODE_TUNNEL;
655 case IPSEC_MODE_BEET:
656 return XFRM_MODE_BEET;
657 default:
658 return -1;
659 }
660}
661
633static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, int hsc) 662static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, int hsc)
634{ 663{
635 struct sk_buff *skb; 664 struct sk_buff *skb;
@@ -651,6 +680,7 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
651 int encrypt_key_size = 0; 680 int encrypt_key_size = 0;
652 int sockaddr_size; 681 int sockaddr_size;
653 struct xfrm_encap_tmpl *natt = NULL; 682 struct xfrm_encap_tmpl *natt = NULL;
683 int mode;
654 684
655 /* address family check */ 685 /* address family check */
656 sockaddr_size = pfkey_sockaddr_size(x->props.family); 686 sockaddr_size = pfkey_sockaddr_size(x->props.family);
@@ -928,7 +958,11 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
928 sa2 = (struct sadb_x_sa2 *) skb_put(skb, sizeof(struct sadb_x_sa2)); 958 sa2 = (struct sadb_x_sa2 *) skb_put(skb, sizeof(struct sadb_x_sa2));
929 sa2->sadb_x_sa2_len = sizeof(struct sadb_x_sa2)/sizeof(uint64_t); 959 sa2->sadb_x_sa2_len = sizeof(struct sadb_x_sa2)/sizeof(uint64_t);
930 sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2; 960 sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2;
931 sa2->sadb_x_sa2_mode = x->props.mode + 1; 961 if ((mode = pfkey_mode_from_xfrm(x->props.mode)) < 0) {
962 kfree_skb(skb);
963 return ERR_PTR(-EINVAL);
964 }
965 sa2->sadb_x_sa2_mode = mode;
932 sa2->sadb_x_sa2_reserved1 = 0; 966 sa2->sadb_x_sa2_reserved1 = 0;
933 sa2->sadb_x_sa2_reserved2 = 0; 967 sa2->sadb_x_sa2_reserved2 = 0;
934 sa2->sadb_x_sa2_sequence = 0; 968 sa2->sadb_x_sa2_sequence = 0;
@@ -1155,9 +1189,12 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
1155 1189
1156 if (ext_hdrs[SADB_X_EXT_SA2-1]) { 1190 if (ext_hdrs[SADB_X_EXT_SA2-1]) {
1157 struct sadb_x_sa2 *sa2 = (void*)ext_hdrs[SADB_X_EXT_SA2-1]; 1191 struct sadb_x_sa2 *sa2 = (void*)ext_hdrs[SADB_X_EXT_SA2-1];
1158 x->props.mode = sa2->sadb_x_sa2_mode; 1192 int mode = pfkey_mode_to_xfrm(sa2->sadb_x_sa2_mode);
1159 if (x->props.mode) 1193 if (mode < 0) {
1160 x->props.mode--; 1194 err = -EINVAL;
1195 goto out;
1196 }
1197 x->props.mode = mode;
1161 x->props.reqid = sa2->sadb_x_sa2_reqid; 1198 x->props.reqid = sa2->sadb_x_sa2_reqid;
1162 } 1199 }
1163 1200
@@ -1218,7 +1255,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
1218 struct sadb_address *saddr, *daddr; 1255 struct sadb_address *saddr, *daddr;
1219 struct sadb_msg *out_hdr; 1256 struct sadb_msg *out_hdr;
1220 struct xfrm_state *x = NULL; 1257 struct xfrm_state *x = NULL;
1221 u8 mode; 1258 int mode;
1222 u32 reqid; 1259 u32 reqid;
1223 u8 proto; 1260 u8 proto;
1224 unsigned short family; 1261 unsigned short family;
@@ -1233,7 +1270,9 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
1233 return -EINVAL; 1270 return -EINVAL;
1234 1271
1235 if ((sa2 = ext_hdrs[SADB_X_EXT_SA2-1]) != NULL) { 1272 if ((sa2 = ext_hdrs[SADB_X_EXT_SA2-1]) != NULL) {
1236 mode = sa2->sadb_x_sa2_mode - 1; 1273 mode = pfkey_mode_to_xfrm(sa2->sadb_x_sa2_mode);
1274 if (mode < 0)
1275 return -EINVAL;
1237 reqid = sa2->sadb_x_sa2_reqid; 1276 reqid = sa2->sadb_x_sa2_reqid;
1238 } else { 1277 } else {
1239 mode = 0; 1278 mode = 0;
@@ -1756,6 +1795,7 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq)
1756#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1795#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1757 struct sockaddr_in6 *sin6; 1796 struct sockaddr_in6 *sin6;
1758#endif 1797#endif
1798 int mode;
1759 1799
1760 if (xp->xfrm_nr >= XFRM_MAX_DEPTH) 1800 if (xp->xfrm_nr >= XFRM_MAX_DEPTH)
1761 return -ELOOP; 1801 return -ELOOP;
@@ -1764,7 +1804,9 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq)
1764 return -EINVAL; 1804 return -EINVAL;
1765 1805
1766 t->id.proto = rq->sadb_x_ipsecrequest_proto; /* XXX check proto */ 1806 t->id.proto = rq->sadb_x_ipsecrequest_proto; /* XXX check proto */
1767 t->mode = rq->sadb_x_ipsecrequest_mode-1; 1807 if ((mode = pfkey_mode_to_xfrm(rq->sadb_x_ipsecrequest_mode)) < 0)
1808 return -EINVAL;
1809 t->mode = mode;
1768 if (rq->sadb_x_ipsecrequest_level == IPSEC_LEVEL_USE) 1810 if (rq->sadb_x_ipsecrequest_level == IPSEC_LEVEL_USE)
1769 t->optional = 1; 1811 t->optional = 1;
1770 else if (rq->sadb_x_ipsecrequest_level == IPSEC_LEVEL_UNIQUE) { 1812 else if (rq->sadb_x_ipsecrequest_level == IPSEC_LEVEL_UNIQUE) {
@@ -1877,7 +1919,7 @@ static struct sk_buff * pfkey_xfrm_policy2msg_prep(struct xfrm_policy *xp)
1877 return skb; 1919 return skb;
1878} 1920}
1879 1921
1880static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, int dir) 1922static int pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, int dir)
1881{ 1923{
1882 struct sadb_msg *hdr; 1924 struct sadb_msg *hdr;
1883 struct sadb_address *addr; 1925 struct sadb_address *addr;
@@ -2014,6 +2056,7 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
2014 struct sadb_x_ipsecrequest *rq; 2056 struct sadb_x_ipsecrequest *rq;
2015 struct xfrm_tmpl *t = xp->xfrm_vec + i; 2057 struct xfrm_tmpl *t = xp->xfrm_vec + i;
2016 int req_size; 2058 int req_size;
2059 int mode;
2017 2060
2018 req_size = sizeof(struct sadb_x_ipsecrequest); 2061 req_size = sizeof(struct sadb_x_ipsecrequest);
2019 if (t->mode == XFRM_MODE_TUNNEL) 2062 if (t->mode == XFRM_MODE_TUNNEL)
@@ -2027,7 +2070,9 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
2027 memset(rq, 0, sizeof(*rq)); 2070 memset(rq, 0, sizeof(*rq));
2028 rq->sadb_x_ipsecrequest_len = req_size; 2071 rq->sadb_x_ipsecrequest_len = req_size;
2029 rq->sadb_x_ipsecrequest_proto = t->id.proto; 2072 rq->sadb_x_ipsecrequest_proto = t->id.proto;
2030 rq->sadb_x_ipsecrequest_mode = t->mode+1; 2073 if ((mode = pfkey_mode_from_xfrm(t->mode)) < 0)
2074 return -EINVAL;
2075 rq->sadb_x_ipsecrequest_mode = mode;
2031 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_REQUIRE; 2076 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_REQUIRE;
2032 if (t->reqid) 2077 if (t->reqid)
2033 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_UNIQUE; 2078 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_UNIQUE;
@@ -2089,6 +2134,8 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
2089 2134
2090 hdr->sadb_msg_len = size / sizeof(uint64_t); 2135 hdr->sadb_msg_len = size / sizeof(uint64_t);
2091 hdr->sadb_msg_reserved = atomic_read(&xp->refcnt); 2136 hdr->sadb_msg_reserved = atomic_read(&xp->refcnt);
2137
2138 return 0;
2092} 2139}
2093 2140
2094static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c) 2141static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c)
@@ -2102,7 +2149,9 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
2102 err = PTR_ERR(out_skb); 2149 err = PTR_ERR(out_skb);
2103 goto out; 2150 goto out;
2104 } 2151 }
2105 pfkey_xfrm_policy2msg(out_skb, xp, dir); 2152 err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
2153 if (err < 0)
2154 return err;
2106 2155
2107 out_hdr = (struct sadb_msg *) out_skb->data; 2156 out_hdr = (struct sadb_msg *) out_skb->data;
2108 out_hdr->sadb_msg_version = PF_KEY_V2; 2157 out_hdr->sadb_msg_version = PF_KEY_V2;
@@ -2327,7 +2376,9 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, struct sadb
2327 err = PTR_ERR(out_skb); 2376 err = PTR_ERR(out_skb);
2328 goto out; 2377 goto out;
2329 } 2378 }
2330 pfkey_xfrm_policy2msg(out_skb, xp, dir); 2379 err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
2380 if (err < 0)
2381 goto out;
2331 2382
2332 out_hdr = (struct sadb_msg *) out_skb->data; 2383 out_hdr = (struct sadb_msg *) out_skb->data;
2333 out_hdr->sadb_msg_version = hdr->sadb_msg_version; 2384 out_hdr->sadb_msg_version = hdr->sadb_msg_version;
@@ -2409,6 +2460,7 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len,
2409{ 2460{
2410 int err; 2461 int err;
2411 struct sadb_x_ipsecrequest *rq2; 2462 struct sadb_x_ipsecrequest *rq2;
2463 int mode;
2412 2464
2413 if (len <= sizeof(struct sadb_x_ipsecrequest) || 2465 if (len <= sizeof(struct sadb_x_ipsecrequest) ||
2414 len < rq1->sadb_x_ipsecrequest_len) 2466 len < rq1->sadb_x_ipsecrequest_len)
@@ -2439,7 +2491,9 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len,
2439 return -EINVAL; 2491 return -EINVAL;
2440 2492
2441 m->proto = rq1->sadb_x_ipsecrequest_proto; 2493 m->proto = rq1->sadb_x_ipsecrequest_proto;
2442 m->mode = rq1->sadb_x_ipsecrequest_mode - 1; 2494 if ((mode = pfkey_mode_to_xfrm(rq1->sadb_x_ipsecrequest_mode)) < 0)
2495 return -EINVAL;
2496 m->mode = mode;
2443 m->reqid = rq1->sadb_x_ipsecrequest_reqid; 2497 m->reqid = rq1->sadb_x_ipsecrequest_reqid;
2444 2498
2445 return ((int)(rq1->sadb_x_ipsecrequest_len + 2499 return ((int)(rq1->sadb_x_ipsecrequest_len +
@@ -2579,12 +2633,15 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
2579 struct pfkey_dump_data *data = ptr; 2633 struct pfkey_dump_data *data = ptr;
2580 struct sk_buff *out_skb; 2634 struct sk_buff *out_skb;
2581 struct sadb_msg *out_hdr; 2635 struct sadb_msg *out_hdr;
2636 int err;
2582 2637
2583 out_skb = pfkey_xfrm_policy2msg_prep(xp); 2638 out_skb = pfkey_xfrm_policy2msg_prep(xp);
2584 if (IS_ERR(out_skb)) 2639 if (IS_ERR(out_skb))
2585 return PTR_ERR(out_skb); 2640 return PTR_ERR(out_skb);
2586 2641
2587 pfkey_xfrm_policy2msg(out_skb, xp, dir); 2642 err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
2643 if (err < 0)
2644 return err;
2588 2645
2589 out_hdr = (struct sadb_msg *) out_skb->data; 2646 out_hdr = (struct sadb_msg *) out_skb->data;
2590 out_hdr->sadb_msg_version = data->hdr->sadb_msg_version; 2647 out_hdr->sadb_msg_version = data->hdr->sadb_msg_version;
@@ -3513,7 +3570,10 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
3513 3570
3514 for (i = 0, mp = m; i < num_bundles; i++, mp++) { 3571 for (i = 0, mp = m; i < num_bundles; i++, mp++) {
3515 /* old ipsecrequest */ 3572 /* old ipsecrequest */
3516 if (set_ipsecrequest(skb, mp->proto, mp->mode + 1, 3573 int mode = pfkey_mode_from_xfrm(mp->mode);
3574 if (mode < 0)
3575 return -EINVAL;
3576 if (set_ipsecrequest(skb, mp->proto, mode,
3517 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), 3577 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
3518 mp->reqid, mp->old_family, 3578 mp->reqid, mp->old_family,
3519 &mp->old_saddr, &mp->old_daddr) < 0) { 3579 &mp->old_saddr, &mp->old_daddr) < 0) {
@@ -3521,7 +3581,7 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
3521 } 3581 }
3522 3582
3523 /* new ipsecrequest */ 3583 /* new ipsecrequest */
3524 if (set_ipsecrequest(skb, mp->proto, mp->mode + 1, 3584 if (set_ipsecrequest(skb, mp->proto, mode,
3525 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), 3585 (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
3526 mp->reqid, mp->new_family, 3586 mp->reqid, mp->new_family,
3527 &mp->new_saddr, &mp->new_daddr) < 0) { 3587 &mp->new_saddr, &mp->new_daddr) < 0) {
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index e73d8f546c6b..c48b0f49f003 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -443,6 +443,7 @@ static int netlink_release(struct socket *sock)
443 return 0; 443 return 0;
444 444
445 netlink_remove(sk); 445 netlink_remove(sk);
446 sock_orphan(sk);
446 nlk = nlk_sk(sk); 447 nlk = nlk_sk(sk);
447 448
448 spin_lock(&nlk->cb_lock); 449 spin_lock(&nlk->cb_lock);
@@ -457,7 +458,6 @@ static int netlink_release(struct socket *sock)
457 /* OK. Socket is unlinked, and, therefore, 458 /* OK. Socket is unlinked, and, therefore,
458 no new packets will arrive */ 459 no new packets will arrive */
459 460
460 sock_orphan(sk);
461 sock->sk = NULL; 461 sock->sk = NULL;
462 wake_up_interruptible_all(&nlk->wait); 462 wake_up_interruptible_all(&nlk->wait);
463 463
@@ -1412,9 +1412,9 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
1412 return -ECONNREFUSED; 1412 return -ECONNREFUSED;
1413 } 1413 }
1414 nlk = nlk_sk(sk); 1414 nlk = nlk_sk(sk);
1415 /* A dump is in progress... */ 1415 /* A dump or destruction is in progress... */
1416 spin_lock(&nlk->cb_lock); 1416 spin_lock(&nlk->cb_lock);
1417 if (nlk->cb) { 1417 if (nlk->cb || sock_flag(sk, SOCK_DEAD)) {
1418 spin_unlock(&nlk->cb_lock); 1418 spin_unlock(&nlk->cb_lock);
1419 netlink_destroy_callback(cb); 1419 netlink_destroy_callback(cb);
1420 sock_put(sk); 1420 sock_put(sk);
diff --git a/net/sched/Makefile b/net/sched/Makefile
index ff2d6e5e282c..020767a204d4 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
17obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o 17obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
18obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o 18obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
19obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o 19obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
20obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o
21obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o 20obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o
22obj-$(CONFIG_NET_SCH_RED) += sch_red.o 21obj-$(CONFIG_NET_SCH_RED) += sch_red.o
23obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o 22obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 68f26cb278f9..3e93683e9ab3 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -198,7 +198,7 @@ bad_mirred:
198 skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at); 198 skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at);
199 199
200 skb2->dev = dev; 200 skb2->dev = dev;
201 skb2->input_dev = skb->dev; 201 skb2->iif = skb->dev->ifindex;
202 dev_queue_xmit(skb2); 202 dev_queue_xmit(skb2);
203 spin_unlock(&m->tcf_lock); 203 spin_unlock(&m->tcf_lock);
204 return m->tcf_action; 204 return m->tcf_action;
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index fad08e521c24..4a91f082a81d 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -81,6 +81,13 @@ static void basic_put(struct tcf_proto *tp, unsigned long f)
81 81
82static int basic_init(struct tcf_proto *tp) 82static int basic_init(struct tcf_proto *tp)
83{ 83{
84 struct basic_head *head;
85
86 head = kzalloc(sizeof(*head), GFP_KERNEL);
87 if (head == NULL)
88 return -ENOBUFS;
89 INIT_LIST_HEAD(&head->flist);
90 tp->root = head;
84 return 0; 91 return 0;
85} 92}
86 93
@@ -102,6 +109,7 @@ static void basic_destroy(struct tcf_proto *tp)
102 list_del(&f->link); 109 list_del(&f->link);
103 basic_delete_filter(tp, f); 110 basic_delete_filter(tp, f);
104 } 111 }
112 kfree(head);
105} 113}
106 114
107static int basic_delete(struct tcf_proto *tp, unsigned long arg) 115static int basic_delete(struct tcf_proto *tp, unsigned long arg)
@@ -176,15 +184,6 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
176 } 184 }
177 185
178 err = -ENOBUFS; 186 err = -ENOBUFS;
179 if (head == NULL) {
180 head = kzalloc(sizeof(*head), GFP_KERNEL);
181 if (head == NULL)
182 goto errout;
183
184 INIT_LIST_HEAD(&head->flist);
185 tp->root = head;
186 }
187
188 f = kzalloc(sizeof(*f), GFP_KERNEL); 187 f = kzalloc(sizeof(*f), GFP_KERNEL);
189 if (f == NULL) 188 if (f == NULL)
190 goto errout; 189 goto errout;
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 040e2d2d281a..7563fdcef4b7 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -245,9 +245,9 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
245 } 245 }
246 246
247 if (tb[TCA_TCINDEX_SHIFT-1]) { 247 if (tb[TCA_TCINDEX_SHIFT-1]) {
248 if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT-1]) < sizeof(u16)) 248 if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT-1]) < sizeof(int))
249 goto errout; 249 goto errout;
250 cp.shift = *(u16 *) RTA_DATA(tb[TCA_TCINDEX_SHIFT-1]); 250 cp.shift = *(int *) RTA_DATA(tb[TCA_TCINDEX_SHIFT-1]);
251 } 251 }
252 252
253 err = -EBUSY; 253 err = -EBUSY;
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 396deb71480f..407c6fb1ba14 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1184,10 +1184,12 @@ hfsc_delete_class(struct Qdisc *sch, unsigned long arg)
1184 1184
1185 sch_tree_lock(sch); 1185 sch_tree_lock(sch);
1186 1186
1187 list_del(&cl->hlist);
1188 list_del(&cl->siblings); 1187 list_del(&cl->siblings);
1189 hfsc_adjust_levels(cl->cl_parent); 1188 hfsc_adjust_levels(cl->cl_parent);
1189
1190 hfsc_purge_queue(sch, cl); 1190 hfsc_purge_queue(sch, cl);
1191 list_del(&cl->hlist);
1192
1191 if (--cl->refcnt == 0) 1193 if (--cl->refcnt == 0)
1192 hfsc_destroy_class(sch, cl); 1194 hfsc_destroy_class(sch, cl);
1193 1195
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 97cbb9aec946..3c3294d01041 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1380,15 +1380,15 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
1380 1380
1381 sch_tree_lock(sch); 1381 sch_tree_lock(sch);
1382 1382
1383 /* delete from hash and active; remainder in destroy_class */
1384 hlist_del_init(&cl->hlist);
1385
1386 if (!cl->level) { 1383 if (!cl->level) {
1387 qlen = cl->un.leaf.q->q.qlen; 1384 qlen = cl->un.leaf.q->q.qlen;
1388 qdisc_reset(cl->un.leaf.q); 1385 qdisc_reset(cl->un.leaf.q);
1389 qdisc_tree_decrease_qlen(cl->un.leaf.q, qlen); 1386 qdisc_tree_decrease_qlen(cl->un.leaf.q, qlen);
1390 } 1387 }
1391 1388
1389 /* delete from hash and active; remainder in destroy_class */
1390 hlist_del_init(&cl->hlist);
1391
1392 if (cl->prio_activity) 1392 if (cl->prio_activity)
1393 htb_deactivate(q, cl); 1393 htb_deactivate(q, cl);
1394 1394
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 536298c2eda2..a1d026f12b0e 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -627,6 +627,12 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
627 retval = -EINVAL; 627 retval = -EINVAL;
628 goto err_bindx_rem; 628 goto err_bindx_rem;
629 } 629 }
630
631 if (!af->addr_valid(sa_addr, sp, NULL)) {
632 retval = -EADDRNOTAVAIL;
633 goto err_bindx_rem;
634 }
635
630 if (sa_addr->v4.sin_port != htons(bp->port)) { 636 if (sa_addr->v4.sin_port != htons(bp->port)) {
631 retval = -EINVAL; 637 retval = -EINVAL;
632 goto err_bindx_rem; 638 goto err_bindx_rem;
@@ -5638,6 +5644,36 @@ void sctp_wait_for_close(struct sock *sk, long timeout)
5638 finish_wait(sk->sk_sleep, &wait); 5644 finish_wait(sk->sk_sleep, &wait);
5639} 5645}
5640 5646
5647static void sctp_sock_rfree_frag(struct sk_buff *skb)
5648{
5649 struct sk_buff *frag;
5650
5651 if (!skb->data_len)
5652 goto done;
5653
5654 /* Don't forget the fragments. */
5655 for (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next)
5656 sctp_sock_rfree_frag(frag);
5657
5658done:
5659 sctp_sock_rfree(skb);
5660}
5661
5662static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk)
5663{
5664 struct sk_buff *frag;
5665
5666 if (!skb->data_len)
5667 goto done;
5668
5669 /* Don't forget the fragments. */
5670 for (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next)
5671 sctp_skb_set_owner_r_frag(frag, sk);
5672
5673done:
5674 sctp_skb_set_owner_r(skb, sk);
5675}
5676
5641/* Populate the fields of the newsk from the oldsk and migrate the assoc 5677/* Populate the fields of the newsk from the oldsk and migrate the assoc
5642 * and its messages to the newsk. 5678 * and its messages to the newsk.
5643 */ 5679 */
@@ -5692,10 +5728,10 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5692 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) { 5728 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) {
5693 event = sctp_skb2event(skb); 5729 event = sctp_skb2event(skb);
5694 if (event->asoc == assoc) { 5730 if (event->asoc == assoc) {
5695 sctp_sock_rfree(skb); 5731 sctp_sock_rfree_frag(skb);
5696 __skb_unlink(skb, &oldsk->sk_receive_queue); 5732 __skb_unlink(skb, &oldsk->sk_receive_queue);
5697 __skb_queue_tail(&newsk->sk_receive_queue, skb); 5733 __skb_queue_tail(&newsk->sk_receive_queue, skb);
5698 sctp_skb_set_owner_r(skb, newsk); 5734 sctp_skb_set_owner_r_frag(skb, newsk);
5699 } 5735 }
5700 } 5736 }
5701 5737
@@ -5723,10 +5759,10 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5723 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) { 5759 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) {
5724 event = sctp_skb2event(skb); 5760 event = sctp_skb2event(skb);
5725 if (event->asoc == assoc) { 5761 if (event->asoc == assoc) {
5726 sctp_sock_rfree(skb); 5762 sctp_sock_rfree_frag(skb);
5727 __skb_unlink(skb, &oldsp->pd_lobby); 5763 __skb_unlink(skb, &oldsp->pd_lobby);
5728 __skb_queue_tail(queue, skb); 5764 __skb_queue_tail(queue, skb);
5729 sctp_skb_set_owner_r(skb, newsk); 5765 sctp_skb_set_owner_r_frag(skb, newsk);
5730 } 5766 }
5731 } 5767 }
5732 5768
@@ -5738,6 +5774,16 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5738 5774
5739 } 5775 }
5740 5776
5777 sctp_skb_for_each(skb, &assoc->ulpq.reasm, tmp) {
5778 sctp_sock_rfree_frag(skb);
5779 sctp_skb_set_owner_r_frag(skb, newsk);
5780 }
5781
5782 sctp_skb_for_each(skb, &assoc->ulpq.lobby, tmp) {
5783 sctp_sock_rfree_frag(skb);
5784 sctp_skb_set_owner_r_frag(skb, newsk);
5785 }
5786
5741 /* Set the type of socket to indicate that it is peeled off from the 5787 /* Set the type of socket to indicate that it is peeled off from the
5742 * original UDP-style socket or created with the accept() call on a 5788 * original UDP-style socket or created with the accept() call on a
5743 * TCP-style socket.. 5789 * TCP-style socket..
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index bfb197e37da3..b29e3e4b72c9 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -190,7 +190,14 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
190 if (!sctp_sk(sk)->pd_mode) { 190 if (!sctp_sk(sk)->pd_mode) {
191 queue = &sk->sk_receive_queue; 191 queue = &sk->sk_receive_queue;
192 } else if (ulpq->pd_mode) { 192 } else if (ulpq->pd_mode) {
193 if (event->msg_flags & MSG_NOTIFICATION) 193 /* If the association is in partial delivery, we
194 * need to finish delivering the partially processed
195 * packet before passing any other data. This is
196 * because we don't truly support stream interleaving.
197 */
198 if ((event->msg_flags & MSG_NOTIFICATION) ||
199 (SCTP_DATA_NOT_FRAG ==
200 (event->msg_flags & SCTP_DATA_FRAG_MASK)))
194 queue = &sctp_sk(sk)->pd_lobby; 201 queue = &sctp_sk(sk)->pd_lobby;
195 else { 202 else {
196 clear_pd = event->msg_flags & MSG_EOR; 203 clear_pd = event->msg_flags & MSG_EOR;
diff --git a/net/socket.c b/net/socket.c
index 9566e57ac7f5..ea8f81abc45c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1381,7 +1381,7 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1381 1381
1382 err = sock_attach_fd(newsock, newfile); 1382 err = sock_attach_fd(newsock, newfile);
1383 if (err < 0) 1383 if (err < 0)
1384 goto out_fd; 1384 goto out_fd_simple;
1385 1385
1386 err = security_socket_accept(sock, newsock); 1386 err = security_socket_accept(sock, newsock);
1387 if (err) 1387 if (err)
@@ -1414,6 +1414,11 @@ out_put:
1414 fput_light(sock->file, fput_needed); 1414 fput_light(sock->file, fput_needed);
1415out: 1415out:
1416 return err; 1416 return err;
1417out_fd_simple:
1418 sock_release(newsock);
1419 put_filp(newfile);
1420 put_unused_fd(newfd);
1421 goto out_put;
1417out_fd: 1422out_fd:
1418 fput(newfile); 1423 fput(newfile);
1419 put_unused_fd(newfd); 1424 put_unused_fd(newfd);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 6d7221fe990a..396cdbe249d1 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1046,6 +1046,8 @@ call_status(struct rpc_task *task)
1046 rpc_delay(task, 3*HZ); 1046 rpc_delay(task, 3*HZ);
1047 case -ETIMEDOUT: 1047 case -ETIMEDOUT:
1048 task->tk_action = call_timeout; 1048 task->tk_action = call_timeout;
1049 if (task->tk_client->cl_discrtry)
1050 xprt_disconnect(task->tk_xprt);
1049 break; 1051 break;
1050 case -ECONNREFUSED: 1052 case -ECONNREFUSED:
1051 case -ENOTCONN: 1053 case -ENOTCONN:
@@ -1169,6 +1171,8 @@ call_decode(struct rpc_task *task)
1169out_retry: 1171out_retry:
1170 req->rq_received = req->rq_private_buf.len = 0; 1172 req->rq_received = req->rq_private_buf.len = 0;
1171 task->tk_status = 0; 1173 task->tk_status = 0;
1174 if (task->tk_client->cl_discrtry)
1175 xprt_disconnect(task->tk_xprt);
1172} 1176}
1173 1177
1174/* 1178/*
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 9bae4090254c..2bd23ea2aa8b 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -383,7 +383,10 @@ void svcauth_unix_purge(void)
383static inline struct ip_map * 383static inline struct ip_map *
384ip_map_cached_get(struct svc_rqst *rqstp) 384ip_map_cached_get(struct svc_rqst *rqstp)
385{ 385{
386 struct ip_map *ipm = rqstp->rq_sock->sk_info_authunix; 386 struct ip_map *ipm;
387 struct svc_sock *svsk = rqstp->rq_sock;
388 spin_lock_bh(&svsk->sk_defer_lock);
389 ipm = svsk->sk_info_authunix;
387 if (ipm != NULL) { 390 if (ipm != NULL) {
388 if (!cache_valid(&ipm->h)) { 391 if (!cache_valid(&ipm->h)) {
389 /* 392 /*
@@ -391,12 +394,14 @@ ip_map_cached_get(struct svc_rqst *rqstp)
391 * remembered, e.g. by a second mount from the 394 * remembered, e.g. by a second mount from the
392 * same IP address. 395 * same IP address.
393 */ 396 */
394 rqstp->rq_sock->sk_info_authunix = NULL; 397 svsk->sk_info_authunix = NULL;
398 spin_unlock_bh(&svsk->sk_defer_lock);
395 cache_put(&ipm->h, &ip_map_cache); 399 cache_put(&ipm->h, &ip_map_cache);
396 return NULL; 400 return NULL;
397 } 401 }
398 cache_get(&ipm->h); 402 cache_get(&ipm->h);
399 } 403 }
404 spin_unlock_bh(&svsk->sk_defer_lock);
400 return ipm; 405 return ipm;
401} 406}
402 407
@@ -405,9 +410,15 @@ ip_map_cached_put(struct svc_rqst *rqstp, struct ip_map *ipm)
405{ 410{
406 struct svc_sock *svsk = rqstp->rq_sock; 411 struct svc_sock *svsk = rqstp->rq_sock;
407 412
408 if (svsk->sk_sock->type == SOCK_STREAM && svsk->sk_info_authunix == NULL) 413 spin_lock_bh(&svsk->sk_defer_lock);
409 svsk->sk_info_authunix = ipm; /* newly cached, keep the reference */ 414 if (svsk->sk_sock->type == SOCK_STREAM &&
410 else 415 svsk->sk_info_authunix == NULL) {
416 /* newly cached, keep the reference */
417 svsk->sk_info_authunix = ipm;
418 ipm = NULL;
419 }
420 spin_unlock_bh(&svsk->sk_defer_lock);
421 if (ipm)
411 cache_put(&ipm->h, &ip_map_cache); 422 cache_put(&ipm->h, &ip_map_cache);
412} 423}
413 424
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index f6e1eb1ea720..2772fee93881 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -452,6 +452,8 @@ union svc_pktinfo_u {
452 struct in_pktinfo pkti; 452 struct in_pktinfo pkti;
453 struct in6_pktinfo pkti6; 453 struct in6_pktinfo pkti6;
454}; 454};
455#define SVC_PKTINFO_SPACE \
456 CMSG_SPACE(sizeof(union svc_pktinfo_u))
455 457
456static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh) 458static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh)
457{ 459{
@@ -491,8 +493,11 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
491 struct svc_sock *svsk = rqstp->rq_sock; 493 struct svc_sock *svsk = rqstp->rq_sock;
492 struct socket *sock = svsk->sk_sock; 494 struct socket *sock = svsk->sk_sock;
493 int slen; 495 int slen;
494 char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))]; 496 union {
495 struct cmsghdr *cmh = (struct cmsghdr *)buffer; 497 struct cmsghdr hdr;
498 long all[SVC_PKTINFO_SPACE / sizeof(long)];
499 } buffer;
500 struct cmsghdr *cmh = &buffer.hdr;
496 int len = 0; 501 int len = 0;
497 int result; 502 int result;
498 int size; 503 int size;
@@ -745,8 +750,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
745 struct svc_sock *svsk = rqstp->rq_sock; 750 struct svc_sock *svsk = rqstp->rq_sock;
746 struct svc_serv *serv = svsk->sk_server; 751 struct svc_serv *serv = svsk->sk_server;
747 struct sk_buff *skb; 752 struct sk_buff *skb;
748 char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))]; 753 union {
749 struct cmsghdr *cmh = (struct cmsghdr *)buffer; 754 struct cmsghdr hdr;
755 long all[SVC_PKTINFO_SPACE / sizeof(long)];
756 } buffer;
757 struct cmsghdr *cmh = &buffer.hdr;
750 int err, len; 758 int err, len;
751 struct msghdr msg = { 759 struct msghdr msg = {
752 .msg_name = svc_addr(rqstp), 760 .msg_name = svc_addr(rqstp),
@@ -779,8 +787,8 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
779 } 787 }
780 788
781 clear_bit(SK_DATA, &svsk->sk_flags); 789 clear_bit(SK_DATA, &svsk->sk_flags);
782 while ((err == kernel_recvmsg(svsk->sk_sock, &msg, NULL, 790 while ((err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
783 0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 || 791 0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 ||
784 (skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) { 792 (skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
785 if (err == -EAGAIN) { 793 if (err == -EAGAIN) {
786 svc_sock_received(svsk); 794 svc_sock_received(svsk);
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index ee6ffa01dfb1..456a14510308 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -735,16 +735,6 @@ void xprt_transmit(struct rpc_task *task)
735 xprt_reset_majortimeo(req); 735 xprt_reset_majortimeo(req);
736 /* Turn off autodisconnect */ 736 /* Turn off autodisconnect */
737 del_singleshot_timer_sync(&xprt->timer); 737 del_singleshot_timer_sync(&xprt->timer);
738 } else {
739 /* If all request bytes have been sent,
740 * then we must be retransmitting this one */
741 if (!req->rq_bytes_sent) {
742 if (task->tk_client->cl_discrtry) {
743 xprt_disconnect(xprt);
744 task->tk_status = -ENOTCONN;
745 return;
746 }
747 }
748 } 738 }
749 } else if (!req->rq_bytes_sent) 739 } else if (!req->rq_bytes_sent)
750 return; 740 return;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 5c5f6dcab974..e3a0bcfa5df1 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1371,7 +1371,8 @@ int xfrm_replay_check(struct xfrm_state *x, __be32 net_seq)
1371 return 0; 1371 return 0;
1372 1372
1373 diff = x->replay.seq - seq; 1373 diff = x->replay.seq - seq;
1374 if (diff >= x->props.replay_window) { 1374 if (diff >= min_t(unsigned int, x->props.replay_window,
1375 sizeof(x->replay.bitmap) * 8)) {
1375 x->stats.replay_window++; 1376 x->stats.replay_window++;
1376 return -EINVAL; 1377 return -EINVAL;
1377 } 1378 }
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e81e2fb3d429..816e3690b60f 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -272,9 +272,8 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a
272} 272}
273 273
274 274
275static inline int xfrm_user_sec_ctx_size(struct xfrm_policy *xp) 275static inline int xfrm_user_sec_ctx_size(struct xfrm_sec_ctx *xfrm_ctx)
276{ 276{
277 struct xfrm_sec_ctx *xfrm_ctx = xp->security;
278 int len = 0; 277 int len = 0;
279 278
280 if (xfrm_ctx) { 279 if (xfrm_ctx) {
@@ -2170,7 +2169,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
2170 2169
2171 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 2170 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
2172 len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire)); 2171 len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire));
2173 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); 2172 len += RTA_SPACE(xfrm_user_sec_ctx_size(x->security));
2174#ifdef CONFIG_XFRM_SUB_POLICY 2173#ifdef CONFIG_XFRM_SUB_POLICY
2175 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); 2174 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2176#endif 2175#endif
@@ -2280,7 +2279,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve
2280 2279
2281 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 2280 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
2282 len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire)); 2281 len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire));
2283 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); 2282 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp->security));
2284#ifdef CONFIG_XFRM_SUB_POLICY 2283#ifdef CONFIG_XFRM_SUB_POLICY
2285 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); 2284 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2286#endif 2285#endif
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 668a11a8b383..6bc7e7cfccf6 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -28,9 +28,11 @@
28 * the dependency on linux/autoconf.h by a dependency on every config 28 * the dependency on linux/autoconf.h by a dependency on every config
29 * option which is mentioned in any of the listed prequisites. 29 * option which is mentioned in any of the listed prequisites.
30 * 30 *
31 * To be exact, split-include populates a tree in include/config/, 31 * kconfig populates a tree in include/config/ with an empty file
32 * e.g. include/config/his/driver.h, which contains the #define/#undef 32 * for each config symbol and when the configuration is updated
33 * for the CONFIG_HIS_DRIVER option. 33 * the files representing changed config options are touched
34 * which then let make pick up the changes and the files that use
35 * the config symbols are rebuilt.
34 * 36 *
35 * So if the user changes his CONFIG_HIS_DRIVER option, only the objects 37 * So if the user changes his CONFIG_HIS_DRIVER option, only the objects
36 * which depend on "include/linux/config/his/driver.h" will be rebuilt, 38 * which depend on "include/linux/config/his/driver.h" will be rebuilt,
@@ -245,6 +247,8 @@ void parse_config_file(char *map, size_t len)
245 continue; 247 continue;
246 248
247 found: 249 found:
250 if (!memcmp(q - 7, "_MODULE", 7))
251 q -= 7;
248 use_config(p+7, q-p-7); 252 use_config(p+7, q-p-7);
249 } 253 }
250} 254}